Lightning-AI / Lightning-AI/pytorch-lightning
TQDMProgressBar calls tqdm.refresh instead of tqdm.update.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Bug description
As of GH-13962, `TQDMProgressBar` calls [tqdm.refresh instead of tqdm.update](https://github.com/Lightning-AI/pytorch-lightning/blob/b554e9915aa9868bf62ae8feb2df0543272c1b3f/src/lightning/pytorch/callbacks/progress/tqdm_progress.py#L464), explicitly setting `n`:
```
if not bar.disable:
bar.n = value
bar.refresh()
```
However, I believe the proper API is to use [update](https://tqdm.github.io/docs/tqdm/#update) instead.
In particular, this means that things done as part of `update` like [EMAs](https://github.com/tqdm/tqdm/blob/0ed5d7f18fa3153834cbac0aa57e8092b217cc16/tqdm/std.py#L1238) are not updated, which means that using a custom callback to e.g. pass `smoothing` to have instantaneous values doesn't work, or more generally it might break things in subtle ways.
cc @ethanwharris @lantiga @awaelchli
### What version are you seeing the problem on?
master
### Reproduced in studio
_No response_
### How to reproduce the bug
```python
```
### Error messages and logs
```
# Error messages and logs here please
```
### Environment
Current environment
```
#- PyTorch Lightning Version (e.g., 2.5.0):
#- PyTorch Version (e.g., 2.5):
#- Python version (e.g., 3.12):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
```
### More info
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/lightning/pytorch/callbacks/progress/tqdm_progress.py at the linked line and compare the tqdm.refresh and tqdm.update APIs. Check the TQDMProgressBar behavior with a custom smoothing callback; done means the progress update path preserves EMA and instantaneous values as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100