Fix Wuerstchen LoRA scheduler steps for distributed epochs - #14748
Fix Wuerstchen LoRA scheduler steps for distributed epochs#14748wunianze666-netizen wants to merge 2 commits into
Conversation
|
Hi @wunianze666-netizen, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an issue (or gets the |
|
Thanks for the reminder. This PR is one item in the multi-script umbrella tracker #8384, which still has many unchecked entries, so adding |
Part of #8384. This PR addresses one unchecked script and must not close the umbrella tracker.
Coordination and reproduction evidence: #8384 (comment)
This updates only
examples/research_projects/wuerstchen/text_to_image/train_text_to_image_lora_prior.pyto size the learning-rate scheduler using the post-sharding update count and Accelerate's process-scaled scheduler contract.Root cause
The scheduler was created before
accelerator.prepare()from the unsharded dataloader length, while warmup and training steps were multiplied by gradient accumulation instead of the number of processes. In distributed epoch-based training, the optimizer therefore consumed only part of the intended schedule.The change mirrors the established #8312 pattern:
accelerator.num_processes;accelerator.prepare();Focused reproduction
With five pre-sharding batches, two CPU/Gloo processes, gradient accumulation 2, and one epoch:
0.333333;0.000000on both ranks.Additional uneven-sharding arithmetic cases (7 batches / 3 processes and 11 batches / 2 processes) also match the actual process-scaled scheduler call count after the change.
Minimal training command
Validation
ruff checkon the changed scriptruff format --checkon the changed scriptpython -m py_compileon the changed scriptgit diff --check upstream/main...HEADAI assistance and self-review
This contribution was developed with Codex assistance. I read the repository's AI-agent guidance and ran the repository self-review rubric after syncing with current
main.@sayakpaul @geniuspatrick