Skip to content

[Bugfix (rlhf)] skip model reload during colocate vLLM init on FSDP2 - #9793

Open
ys2025-AI wants to merge 1 commit into
modelscope:mainfrom
ys2025-AI:fsdp2_npu
Open

[Bugfix (rlhf)] skip model reload during colocate vLLM init on FSDP2#9793
ys2025-AI wants to merge 1 commit into
modelscope:mainfrom
ys2025-AI:fsdp2_npu

Conversation

@ys2025-AI

Copy link
Copy Markdown
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

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 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.

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.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@hjh0119

hjh0119 commented Aug 1, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants