Lightning-AI / Lightning-AI/pytorch-lightning

TQDMProgressBar calls tqdm.refresh instead of tqdm.update.

Open
#21,320 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug progress bar: tqdm ver: 2.5.x
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.