Add Megatron-Bridge LoRA support for GRPO actor training#1865
Open
taivu1998 wants to merge 1 commit intoTHUDM:mainfrom
Open
Add Megatron-Bridge LoRA support for GRPO actor training#1865taivu1998 wants to merge 1 commit intoTHUDM:mainfrom
taivu1998 wants to merge 1 commit intoTHUDM:mainfrom
Conversation
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
Addresses #1202.
This PR adds a first supported Megatron-Bridge LoRA path for dense GRPO actor training in slime. It introduces LoRA CLI flags, validates the initially supported configuration at startup, applies Megatron-Bridge PEFT LoRA only to the actor model, and exports effective actor weights to SGLang by temporarily merging adapters into the live model during bridge-based HF weight conversion.
Why
Issue #1202 asks for LoRA support for GRPO training and examples. The discussion also calls out known Megatron-Bridge LoRA risk around MoE and checkpointing paths, so this implementation intentionally starts with a narrow, guarded dense-model path rather than silently enabling unsupported combinations.
Changes
--enable-lora,--lora-target-modules,--lora-rank,--lora-alpha, and--lora-dropout.base + adaptereffective actor weights to SGLang, then restore unmerged training weights.Guardrails
The PR rejects combinations that need separate parity work before support:
--debug-train-only.--only-train-params-name-listand--freeze-params-name-list.--disable-weights-backuper.Validation
env UV_CACHE_DIR=/tmp/uv-cache PYTHONPATH=. uv run pytest tests/test_lora_support.py->22 passedpython3 -m py_compile slime/backends/megatron_utils/peft.py slime/backends/megatron_utils/model_provider.py slime/backends/megatron_utils/model.py slime/backends/megatron_utils/update_weight/hf_weight_iterator_bridge.py slime/utils/arguments.py tests/test_lora_support.pygit diff --checkuv run ruff check ...was attempted locally but could not run because this worktree environment does not have aruffexecutable installed.