[Bugfix (rlhf)] skip model reload during colocate vLLM init on FSDP2 - #9793
Open
ys2025-AI wants to merge 1 commit into
Open
[Bugfix (rlhf)] skip model reload during colocate vLLM init on FSDP2#9793ys2025-AI wants to merge 1 commit into
ys2025-AI wants to merge 1 commit into
Conversation
In the FSDP2 backend, GRPOTrainer.__init__ -> prepare_rollout() runs before accelerator.prepare() fully-shards the model, so self.model is still the full ~70GB. Exiting offload_context then load_model'd the full model back onto a single card and OOM'd at vLLM init. Add a `reload` flag to RolloutTrainerMixin/GRPOTrainer/GKDTrainer offload_context (default True) and pass reload=False from _prepare_vllm at init, so the full model stays on CPU and is sharded+loaded later by train()'s accelerator.prepare(). Runtime rollouts keep reload=True (the model is now sharded, so reloading is cheap). Also add qwen3_5 FSDP2 LoRA SFT/GRPO example scripts and an accelerate fsdp2.json config for Ascend.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Collaborator
|
Sorry for the late review, and thanks for digging into this! Confirmed the issue is real — at prepare_rollout() time the model isn't sharded yet (accelerator.prepare happens later in _prepare_for_training()), so exiting offload_context() loads the full model onto one card. Instead of adding a reload flag, just skip the offload context entirely in _prepare_vllm() when FSDP2 is enabled — the model is still on CPU at that point, so both the offload and the reload are pointless there. That avoids introducing an asymmetric context manager and keeps the logic in one place. |
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
In the FSDP2 backend, GRPOTrainer.init -> prepare_rollout() runs before accelerator.prepare() fully-shards the model, so self.model is still the full ~70GB. Exiting offload_context then load_model'd the full model back onto a single card and OOM'd at vLLM init.
Add a
reloadflag to RolloutTrainerMixin/GRPOTrainer/GKDTrainer offload_context (default True) and pass reload=False from _prepare_vllm at init, so the full model stays on CPU and is sharded+loaded later by train()'s accelerator.prepare(). Runtime rollouts keep reload=True (the model is now sharded, so reloading is cheap).Also add qwen3_5 FSDP2 LoRA SFT/GRPO example scripts and an accelerate fsdp2.json config for Ascend.