verl icon indicating copy to clipboard operation
verl copied to clipboard

Training collapse when training Qwen3-next with megatron-bridge

Open acphile opened this issue 9 months ago • 3 comments

System Info

System Info ----------Python Info---------- Version : 3.12.12 Compiler : GCC 14.3.0 Build : ('main', 'Oct 22 2025 23:25:55') Arch : ('64bit', 'ELF') ------------Pip Info----------- Version : 25.3 vllm : 0.11.0 sglang : not found. ray : 2.53.0 torch : 2.8.0 ----------verl Info----------- Version : 0.7.0.dev Commit Hash : https://github.com/verl-project/verl/commit/f9c855f7cf04d603c9546bc01776c74806a879c1 ----------Platform Info---------- Platform : Linux-6.8.0-1029-aws-x86_64-with-glibc2.35 system : Linux version : https://github.com/verl-project/verl/pull/31 SMP Thu Apr 24 21:16:18 UTC 2025 ----------Environment---------- OMP_NUM_THREADS="1" CUDA Runtime : 12.8 CUDA Compiler : Cuda compilation tools, release 12.6, V12.6.85

Megatron-bridge: use the commit 83a7c1134c562d8c6decd10a1f0a6e6a7a8a3a44 as suggested in https://verl.readthedocs.io/en/latest/advance/ppo_lora.html transformer_engine: 2.11.0

Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [x] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [ ] My own task or dataset (give details below)

Reproduction

python3 -m verl.trainer.main_ppo \            
    --config-path=config \              
    --config-name='ppo_megatron_trainer.yaml' \
    algorithm.adv_estimator=grpo \
    data.train_files=$HOME/data/gsm8k/train.parquet \
    data.val_files=$HOME/data/gsm8k/test.parquet \
    data.train_batch_size=128 \
    data.max_prompt_length=512 \
    data.max_response_length=1024 \ 
    data.filter_overlong_prompts=True \
    data.truncation='error' \
    data.shuffle=True \
    actor_rollout_ref.model.path=Qwen/Qwen3-Next-80B-A3B-Instruct \
    actor_rollout_ref.actor.megatron.use_remove_padding=False \
    actor_rollout_ref.model.use_remove_padding=False \
    actor_rollout_ref.actor.optim.lr=1e-5 \
    actor_rollout_ref.actor.ppo_mini_batch_size=32 \
    actor_rollout_ref.actor.use_dynamic_bsz=False \
    actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
    actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
    actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
    actor_rollout_ref.actor.use_kl_loss=True \
    actor_rollout_ref.actor.kl_loss_coef=0.001 \
    actor_rollout_ref.actor.kl_loss_type=low_var_kl \
    actor_rollout_ref.actor.entropy_coeff=0 \
    actor_rollout_ref.actor.megatron.use_mbridge=True \
    actor_rollout_ref.actor.megatron.vanilla_mbridge=False \
    actor_rollout_ref.actor.megatron.tensor_model_parallel_size=${TP} \
    actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=${PP} \
    actor_rollout_ref.actor.megatron.expert_model_parallel_size=${EP} \
    actor_rollout_ref.actor.megatron.context_parallel_size=${CP} \
    actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=${ETP} \
    actor_rollout_ref.actor.megatron.sequence_parallel=True \
    actor_rollout_ref.actor.megatron.param_offload=True \
    actor_rollout_ref.actor.megatron.optimizer_offload=True \
    actor_rollout_ref.actor.megatron.grad_offload=True \
    +actor_rollout_ref.actor.megatron.override_transformer_config.recompute_method=uniform \
    +actor_rollout_ref.actor.megatron.override_transformer_config.recompute_granularity=full \
    +actor_rollout_ref.actor.megatron.override_transformer_config.recompute_num_layers=1 \
    +actor_rollout_ref.actor.megatron.override_transformer_config.apply_rope_fusion=True \
    actor_rollout_ref.ref.megatron.tensor_model_parallel_size=${TP} \
    actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=${PP} \
    actor_rollout_ref.ref.megatron.expert_model_parallel_size=${EP} \
    actor_rollout_ref.ref.megatron.context_parallel_size=${CP} \
    actor_rollout_ref.ref.megatron.expert_tensor_parallel_size=${ETP} \
    actor_rollout_ref.ref.megatron.sequence_parallel=True \
    actor_rollout_ref.ref.megatron.param_offload=True \
    actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=False \
    actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
    actor_rollout_ref.rollout.name=vllm \
    actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
    actor_rollout_ref.rollout.n=8 \
    actor_rollout_ref.rollout.enforce_eager=True \
    actor_rollout_ref.rollout.free_cache_engine=True \
    actor_rollout_ref.ref.log_prob_use_dynamic_bsz=False \
    algorithm.use_kl_in_reward=False \
    trainer.critic_warmup=0 \
    trainer.logger=['console','tensorboard'] \
    trainer.project_name=$project_name \
    trainer.experiment_name=$experiment_name \
    trainer.n_gpus_per_node=8 \
    trainer.nnodes=2 \
    trainer.save_freq=20 \
    trainer.test_freq=10 \
    trainer.total_epochs=1

However, the validation score drops to 0 at the step 10.

Expected behavior

The training collapse should not happen.

Not sure if it is related to this issue: https://github.com/verl-project/verl/issues/4917

acphile avatar Feb 13 '26 21:02 acphile

hi , may i ask more version information? such as transformers, click, megatron?

qingxial avatar Mar 03 '26 08:03 qingxial

Training collapse with Qwen3-Next (GatedDeltaNet + attention) is a known issue with Megatron-bridge. The model's hybrid architecture (linear attention + standard attention) has compatibility issues with certain Megatron optimizations.

Key observations from your config:

  1. use_remove_padding=False - Good, avoids thd format issues
  2. sequence_parallel=True - May cause issues with GatedDeltaNet layers
  3. recompute_method=uniform - Recompute may not handle GatedDeltaNet correctly

Potential causes:

  1. GatedDeltaNet state management: The linear attention layers have internal state that may not be correctly handled during recomputation or sequence parallel.

  2. Gradient checkpointing: The hybrid model structure may have missing backward hooks.

  3. Expert parallelism + linear attention: EP with GatedDeltaNet routing needs special handling.

Debugging steps:

  1. Try disabling recompute: recompute_granularity=none
  2. Try sequence_parallel=False
  3. Compare with FSDP backend to isolate the issue

If FSDP training works but Megatron doesn't, the issue is in the Megatron-bridge path for GatedDeltaNet. This would need investigation in the model-specific mbridge implementation.

Kirrito-k423 avatar Mar 17 '26 11:03 Kirrito-k423

中文:感谢报告。这个问题看起来仍需要更多信息才能判断是 verl 的 Megatron-Bridge 适配问题、Megatron-Bridge/Transformer Engine 版本问题,还是特定并行/重计算配置导致的训练不稳定。

请补充以下信息:

  1. transformers、click、megatron-core、megatron-bridge 的完整版本或 commit;
  2. TP/PP/EP/CP/ETP 的实际取值、GPU 型号,以及完整训练日志/validation 曲线,特别是 step 0 到 step 10 前后的 actor loss、KL、reward、entropy 和 generated samples;
  3. 是否能用当前 main 分支的官方 Qwen3-Next FSDP2 + vLLM 示例 examples/grpo_trainer/run_qwen3_next_80b_a3b_fsdp.sh 跑通同一数据集;
  4. 如果 FSDP2 路径正常、Megatron-Bridge 路径崩溃,请再提供关闭 recompute 或关闭 sequence parallel 后的对照结果。

English: Thanks for the report. More information is needed before we can tell whether this is a verl Megatron-Bridge integration issue, a Megatron-Bridge / Transformer Engine version issue, or instability from a specific parallelism / recompute configuration.

Could you please share:

  1. exact transformers, click, megatron-core, and megatron-bridge versions or commits;
  2. actual TP/PP/EP/CP/ETP values, GPU type, and full training logs / validation curves around steps 0-10, especially actor loss, KL, reward, entropy, and generated samples;
  3. whether the current main branch official Qwen3-Next FSDP2 + vLLM script examples/grpo_trainer/run_qwen3_next_80b_a3b_fsdp.sh works on the same dataset;
  4. if FSDP2 works but Megatron-Bridge collapses, comparison results after disabling recompute or sequence parallel.

This response was generated by a scheduled Codex GPT5.5 issue processing task.

Kirrito-k423 avatar Aug 05 '26 01:08 Kirrito-k423