Skip to content

[train_instruct_pix2pix_sdxl.py] Fix the LR scheduler when num_train_… - #14598

Open
AayushMainali-Github wants to merge 1 commit into
huggingface:mainfrom
AayushMainali-Github:fix/8384-instruct-pix2pix-sdxl-lr-scheduler
Open

[train_instruct_pix2pix_sdxl.py] Fix the LR scheduler when num_train_…#14598
AayushMainali-Github wants to merge 1 commit into
huggingface:mainfrom
AayushMainali-Github:fix/8384-instruct-pix2pix-sdxl-lr-scheduler

Conversation

@AayushMainali-Github

Copy link
Copy Markdown

What does this PR do?

Fixes the learning-rate scheduler setup in examples/instruct_pix2pix/train_instruct_pix2pix_sdxl.py when training is launched with --num_train_epochs in a distributed environment.

This is one script from the checklist in #8384. The scheduler was previously created from the unsharded dataloader length, so num_training_steps did not match the real optimization step count after accelerator.prepare. The change matches the #8312 pattern already applied to train_instruct_pix2pix.py.

Fixes #8384

Minimal training command using --num_train_epochs:

accelerate launch examples/instruct_pix2pix/train_instruct_pix2pix_sdxl.py \
  --pretrained_model_name_or_path hf-internal-testing/tiny-stable-diffusion-xl-pipe \
  --dataset_name hf-internal-testing/instructpix2pix-10-samples \
  --resolution 64 \
  --random_flip \
  --train_batch_size 1 \
  --num_train_epochs 1 \
  --lr_warmup_steps 0 \
  --output_dir /tmp/instruct-pix2pix-sdxl-epochs \
  --seed 0

…epochs is passed in a distributed training env
@github-actions github-actions Bot added examples fixes-issue size/S PR with diff < 50 LOC labels Aug 25, 2026
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