[train_t2i_adapter_sdxl.py] Fix the LR scheduler when num_train_epochs is passed in a distributed training env - #14540
Open
adi-IL wants to merge 1 commit into
Conversation
…s is passed in a distributed training env
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8384
Follow-up to #14527 and #14528, still one script. This PR updates
examples/t2i_adapter/train_t2i_adapter_sdxl.py.What was wrong
When
--num_train_epochsis used,train_t2i_adapter_sdxl.pybuilt the LR schedule from the unsharded dataloader and ignoredaccelerator.num_processes, resulting in mismatched warmup and total training steps across distributed environments.What changed
Applies the #8312 pattern already established across the DreamBooth, ControlNet, and Text-to-Image trainers:
get_schedulerare scaled byaccelerator.num_processes.math.ceil(len(train_dataloader) / accelerator.num_processes)).accelerator.prepare, a warning is logged if the prepared dataloader length deviates from that expectation.test_t2i_adapter_sdxl_num_train_epochsinexamples/t2i_adapter/test_t2i_adapter.pyto cover the--num_train_epochspath.Coordination
Covered by the ongoing community tracker #8384. cc @sayakpaul @geniuspatrick
Minimal training command using
num_train_epochsTests I ran
All passed (
2 passed in 84.45s).