Lightning-AI / Lightning-AI/pytorch-lightning
tensorboard step and self.global_step do not correspond under accumulate_grad
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
Assume accumulate_grad=2, log_every_n_steps=50, val_check_interval=8000; tensorboard is the self.log. The self.global_step will add one when model.forward is done, but tensorboard step will add one when loss.step() is done. So my model will valid when tensorboard step = 4000, because this time the self.global_step is 8000.
I think this logic should be unified.
### What version are you seeing the problem on?
v2.4
### How to reproduce the bug
_No response_
### Error messages and logs
```
# Error messages and logs here please
```
### Environment
Current environment
```
#- PyTorch Lightning Version (e.g., 2.4.0):
#- PyTorch Version (e.g., 2.4):
#- 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_
cc @lantiga
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 by tracing how self.global_step and the TensorBoard step are updated around model.forward and loss.step when accumulate_grad is 2. Reproduce the reported mismatch with log_every_n_steps=50 and val_check_interval=8000, then determine the intended shared step semantics. Done means validation and TensorBoard use corresponding steps, with a regression test covering accumulation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100