Lightning-AI / pytorch-lightning

Pretrain, finetune ANY AI model of ANY size on multiple GPUs, TPUs with zero code changes.
https://lightning.ai
Apache License 2.0
28.47k stars 3.39k forks source link

Move progress bar's loop properties to the loops #12901

Closed carmocca closed 1 year ago

carmocca commented 2 years ago

Proposed refactor

Move these:

https://github.com/PyTorchLightning/pytorch-lightning/blob/6490996b3974019a254f2750f5c01e6d38ff6a6e/pytorch_lightning/callbacks/progress/base.py#L80-L173

To their respective loops.

Deprecate the existing progress bar properties.

Have the progress bar use the new properties.

Motivation

These properties can be useful for other components, but since they are defined in the progress bar, it forces users to either copy the implementation or require that the progress bar is available

Pitch

We can also take advantage and rename them to reduce confusion. For example, even though they are suffixed with _idx, they are not indices.


If you enjoy Lightning, check out our other projects! ⚡

cc @justusschock @awaelchli @rohitgr7 @kaushikb11 @carmocca @ananthsub @ninginthecloud

awaelchli commented 2 years ago

It probably makes sense for some of these but how would you represent for example the val_batch_idx directly on the loop? The logic that is implemented there is taking the value from either one or the other loop, so it seems this type of branching will always be necessary in the progress bar.

carmocca commented 2 years ago

Yes. that one would stay, but we could move the self.epoch_loop.batch_progress.current.processed access