pytorch-lightning icon indicating copy to clipboard operation
pytorch-lightning copied to clipboard

TQDMProgressBar calls tqdm.refresh instead of tqdm.update.

Open cf-natali opened this issue 1 month ago • 4 comments

Bug description

As of GH-13962, TQDMProgressBar calls tqdm.refresh instead of tqdm.update, explicitly setting n:

    if not bar.disable:
        bar.n = value
        bar.refresh()

However, I believe the proper API is to use update instead.

In particular, this means that things done as part of update like EMAs 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


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

cf-natali avatar Oct 27 '25 14:10 cf-natali

@cf-natali thanks for raising this issue. I am fine changing back to using update instead of refresh (sine update just calls refresh underneath https://github.com/tqdm/tqdm/blob/0ed5d7f18fa3153834cbac0aa57e8092b217cc16/tqdm/std.py#L1242) as long as we are not introducing the original visual bugs that lead to the change.

SkafteNicki avatar Oct 28 '25 07:10 SkafteNicki

@SkafteNicki could you provide more info about the visual bugs we are trying to avoid? I would like to tackle this issue, and I'd love to have more details.

giacomo-ciro avatar Nov 23 '25 17:11 giacomo-ciro

@giacomo-ciro if I look through the linked PR, which link to issues, which link to PRs...it seems this is the original issue that prompted the change from update to refresh: https://github.com/Lightning-AI/pytorch-lightning/issues/13124 it may be that this issue is not relevant anymore, but it should be checked

SkafteNicki avatar Dec 01 '25 06:12 SkafteNicki

Thank you! I'll start digging.

giacomo-ciro avatar Dec 01 '25 08:12 giacomo-ciro