[DO NOT REVIEW]Enable LoRA training in the NNX path of MaxText (pre-training and native SFT)#4284
Draft
SurbhiJainUSC wants to merge 1 commit into
Draft
[DO NOT REVIEW]Enable LoRA training in the NNX path of MaxText (pre-training and native SFT)#4284SurbhiJainUSC wants to merge 1 commit into
SurbhiJainUSC wants to merge 1 commit into
Conversation
e1faad5 to
1647e8e
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
7bd18eb to
2b1a987
Compare
2b1a987 to
df7a663
Compare
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.
Description
This PR enables LoRA training in the NNX path of MaxText, extending support to both pre-training and native SFT workflows.
Problem solved and implementation details:
gradient_accumulation.pyandtrain_utils.pyto seamlessly track, scale, and update LoRA-specific parameters during training.lora.lora_restore_path.Tests
Pre-Training
Scenario 1: Start a new training with steps=5
Initialize the LoRA adapters from scratch, run 5 steps of training, and save a checkpoint containing both the base weights and the trained adapters in
$BASE_OUTPUT_DIRECTORY/pre-train-$RUN_NAME.Scenario 2: Resume training with steps=10 without restoring LoRA adapters
MaxText detects the step 5 checkpoint saved in Scenario 1, load the model weights + optimizer states from it, and continue training from step 5 to step 10.
Scenario 3: Warm-starting new training by restoring LoRA adapters from Scenario 2
Warm-starting a new training run at Step 0 by restoring trained LoRA adapter weights from a previous checkpoint into a freshly initialized base model.
SFT
Scenario 0: Run SFT Training & save NNX Checkpoint
Scenario 1: Warm-starting LoRA SFT Training from Base (NNX) Checkpoint
Warm-starting a multimodal SFT run at Step 0 by loading pre-trained base weights from a checkpoint and training freshly initialized LoRA adapters on a vision dataset.
Scenario 2: Warm-starting LoRA SFT Training by restoring LoRA adapters from Scenario 1
Warm-starting a multimodal SFT run at Step 0 by loading base weights from a base checkpoint and restoring trained LoRA adapter weights from a previous SFT checkpoint.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.