Skip to content

[examples] Fix LR scheduler step count when num_train_epochs is set - #14743

Open
adi-IL wants to merge 1 commit into
huggingface:mainfrom
adi-IL:fix/lr-scheduler-num-train-epochs-umbrella
Open

[examples] Fix LR scheduler step count when num_train_epochs is set#14743
adi-IL wants to merge 1 commit into
huggingface:mainfrom
adi-IL:fix/lr-scheduler-num-train-epochs-umbrella

Conversation

@adi-IL

@adi-IL adi-IL commented Sep 9, 2026

Copy link
Copy Markdown

Fixes #8384

Why

Several example training scripts under-count LR scheduler steps when num_train_epochs is used (especially distributed). That leaves the scheduler short of the intended schedule.

Scope

One PR with the same fix across:

  • examples/text_to_image/train_text_to_image_sdxl.py (+ test)
  • examples/text_to_image/train_text_to_image_lora_sdxl.py (+ test)
  • examples/t2i_adapter/train_t2i_adapter_sdxl.py (+ test)
  • examples/textual_inversion/textual_inversion.py
  • examples/kandinsky2_2/text_to_image/train_text_to_image_prior.py

This supersedes #14527, #14528, #14540, #14546, and #14597 so review can happen once.

Verification

  • Ported tip contents from those five PRs onto current main.
  • Existing example tests updated where those PRs already covered them.

Happy to split again if maintainers prefer per-example PRs.

…stently

Same fix across training examples where num_train_epochs under-counted scheduler steps, especially in distributed runs.

Supersedes huggingface#14527 huggingface#14528 huggingface#14540 huggingface#14546 huggingface#14597.
@github-actions

Copy link
Copy Markdown
Contributor

Hi @adi-IL, 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. Fixes #1234) to the PR description so the issue is linked. See the contribution guide for more details. If this PR intentionally does not fix a tracked issue, a maintainer can add the no-issue-needed label to silence this reminder.

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 no-issue-needed label), you can ignore this message — it stays here as a comment, but it no longer applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Community] Help us fix the LR schedulers when num_train_epochs is passed in a distributed training env

1 participant