[fsdp2] Qwen3-MoE actor backward fails under FSDP2: CheckpointError with gradient checkpointing, native worker crash without it (FSDP1 works)
Summary
Training Qwen3-30B-A3B (Qwen3MoeForCausalLM) with the FSDP2 engine consistently fails in the first update_actor backward. The same config trains fine with FSDP1, and dense Qwen2.5 models (7B/32B/72B) train fine with FSDP2 — the failure is specific to FSDP2 × Qwen3-MoE.
Two failure modes depending on gradient checkpointing:
A. enable_gradient_checkpointing=True (default):
torch.utils.checkpoint.CheckpointError: torch.utils.checkpoint: A different number of
tensors was saved during the original forward and recomputation.
Number of tensors saved during forward: 1730
Number of tensors saved during recomputation: 178.
raised from check_recomputed_tensors_match during actor_rollout_wg.update_actor(batch). Looks like the MoE router taking a different expert-dispatch path during recomputation (data-dependent saved-tensor count).
B. enable_gradient_checkpointing=False (also tried with use_remove_padding=False):
trainer WorkerDict processes on multiple nodes die natively in the first update_actor — ray reports SYSTEM_ERROR: Worker unexpectedly exits with a connection error code 2 (SIGSEGV/hard-kill class, no Python traceback). Forward-only paths (rollout generation, compute_log_prob) complete fine; only the backward dies.
Tried matrix (all fail on FSDP2, first update_actor):
| grad ckpt | remove_padding | result |
|---|---|---|
| on | on | CheckpointError (A) |
| off | on | native worker crash (B) |
| off | off | native worker crash (B) |
Control experiments:
actor.strategy=fsdp(FSDP1), everything else identical → backward/training work.- FSDP2 + dense
Qwen2.5-{7B,32B,72B}-Instruct, identical script → works.
Repro
2 trainer nodes × 8 H100 (FSDP2, fsdp_size=16, param+optimizer offload) + 2 SGLang rollout nodes (TP8), V1 trainer, GSM8K GRPO. The rollout side is irrelevant to the crash — it dies in the actor update — so a colocated FSDP2 setup should repro as well.
python3 -m verl.trainer.main_ppo \
trainer.use_v1=True trainer.v1.trainer_mode=separate_async \
trainer.v1.separate_async.num_warmup_batches=1 trainer.v1.separate_async.parameter_sync_step=1 \
data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet \
data.max_prompt_length=512 data.max_response_length=256 data.train_batch_size=16 \
actor_rollout_ref.rollout.n=4 algorithm.adv_estimator=grpo \
actor_rollout_ref.model.path=Qwen/Qwen3-30B-A3B-Instruct-2507 \
actor_rollout_ref.actor.ppo_mini_batch_size=16 actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
actor_rollout_ref.actor.strategy=fsdp2 actor_rollout_ref.actor.fsdp_config.strategy=fsdp2 \
actor_rollout_ref.actor.fsdp_config.fsdp_size=16 \
actor_rollout_ref.actor.fsdp_config.param_offload=True actor_rollout_ref.actor.fsdp_config.optimizer_offload=True \
actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True \
actor_rollout_ref.actor.use_dynamic_bsz=True \
actor_rollout_ref.rollout.name=sglang actor_rollout_ref.rollout.tensor_model_parallel_size=8 \
actor_rollout_ref.rollout.nnodes=2 actor_rollout_ref.rollout.n_gpus_per_node=8 \
trainer.nnodes=2 trainer.n_gpus_per_node=8 trainer.total_training_steps=6
Flip enable_gradient_checkpointing to switch between failure modes A and B; set actor.strategy=fsdp + actor.fsdp_config.strategy=fsdp to see it pass.
Environment
- verl: main (@ the delta-weight-sync PR #6974 base — the failing paths are untouched upstream code)
- torch 2.9.1+cu128, transformers 4.57.1, flash-attn 2.8.3
- 8×H100-80GB nodes, NCCL 2.27.5
Happy to run diagnostics (e.g. set_checkpoint_debug_enabled) on our cluster if useful.
Hi @ChangyiYang, I traced the current actor/FSDP2 path and would like to help investigate this issue.
I suggest keeping the first patch diagnosis-focused:
- reduce the reported setup to a minimal multi-GPU Qwen3-MoE FSDP2 backward reproducer, covering gradient checkpointing on and off;
- identify the first mismatch between the original forward and checkpoint recomputation, and determine whether it comes from veRL's integration or upstream PyTorch/Transformers MoE behavior;
- once the boundary is confirmed, add a focused regression and fix without changing the working FSDP1 or dense-model paths.
I would not treat disabling checkpointing or falling back to FSDP1 as the fix. If you already have a smaller model/config that preserves the failure, that would also help keep the validation cycle short.
@wuxibin89, does this diagnosis-first scope look appropriate? If so, I can take it on and report the minimal reproducer before preparing the code change.