fix(train): initialize GaLore through split optimizer hooks - #10143
Open
MrCapricornLiu wants to merge 1 commit into
Open
MrCapricornLiu wants to merge 1 commit into
MrCapricornLiu wants to merge 1 commit into
Conversation
Signed-off-by: Chenghao Liu <chliu@stu.pku.edu.cn>
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.
PR type
PR information
With Transformers 5.3,
--use_galore trueconstructsGaloreOptimizerCallback, but the trainer calls the separate optimizer and scheduler hooks. GaLore only overrides the combined hook, so training silently uses ordinary AdamW without any GaLore parameter groups.Implement the separate hooks and have the combined hook reuse them. Optimizer construction retains the existing parameter groups and projection settings. Scheduler construction uses the trainer-provided step count and
get_warmup_steps, including ratio-based warmup. Per-parameter schedulers now advance on the same training-step scale as their wrapper, rather than a doubled schedule.Experiment results
python -m unittest discover -s tests -p test_galore_schedule.py -v: both tests pass, covering optimizer selection and eight learning-rate scenarios. The original code fails the optimizer-type check and seven schedule scenarios. The schedule tests perform actual forward/backward and GaLore optimizer steps.Validated with PyTorch 2.12.0, Transformers 5.3.0, and Accelerate 1.15.0. Quantized GaLore and distributed training were not tested.