Fix LoRA weight exports to save merged full checkpoints#2182
Open
taivu1998 wants to merge 2 commits intoPrimeIntellect-ai:mainfrom
Open
Fix LoRA weight exports to save merged full checkpoints#2182taivu1998 wants to merge 2 commits intoPrimeIntellect-ai:mainfrom
taivu1998 wants to merge 2 commits intoPrimeIntellect-ai:mainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
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.

Summary
weights/step_<N>stays a standalone checkpointsave_adapter_separately=trueadditive by still writinglora_adapters/alongside the merged full checkpointCloses #1707.
Testing
python3 -m py_compile src/prime_rl/trainer/lora.py src/prime_rl/trainer/weights.py src/prime_rl/trainer/ckpt.py src/prime_rl/configs/trainer.py tests/unit/train/test_lora.py tests/integration/test_sft_lora.pygit diff --check -- src/prime_rl/trainer/lora.py src/prime_rl/trainer/weights.py src/prime_rl/trainer/ckpt.py src/prime_rl/configs/trainer.py docs/checkpointing.md tests/unit/train/test_lora.py tests/integration/test_sft_lora.pyUV_CACHE_DIR=/tmp/uv-cache uv run pytest tests/unit/train/test_lora.py -qNote
Medium Risk
Changes the semantics of LoRA weight exports by merging adapter deltas into the main
weights/step_<N>checkpoint, which could affect downstream consumers if any relied on the previous unmerged format; adds test coverage to reduce regression risk.Overview
Ensures LoRA weight exports always produce a standalone Hugging Face-compatible merged checkpoint at
weights/step_<N>by merging LoRA deltas into the gathered full-model state dict before HF serialization.Makes
ckpt.weights.save_adapter_separatelyadditive (writesweights/step_<N>/lora_adaptersas a sidecar without altering the main checkpoint), removes LoRA-cleanup fromgather_weights_on_master, and adds unit + expanded integration tests (including a new merged-only CI config) to assert both adapter exports and merged full checkpoints are HF-compatible.Reviewed by Cursor Bugbot for commit 6a6ae08. Bugbot is set up for automated code reviews on this repo. Configure here.