verl icon indicating copy to clipboard operation
verl copied to clipboard

`c10d::broadcast_` autograd warning and Dynamo recompile limit hit during Megatron PPO training

Open spacegoing opened this issue 1 year ago • 3 comments

System Info

based on official verl 0.6 base image, upgraded deepep version and installed vllm 0.11.0

Information

I see same error reported in https://github.com/volcengine/verl/pull/3763

but I'm training dsv3 model: https://github.com/spacegoing/verl/blob/my_deepep/my_scripts/run_deepseek671b_math_megatron_96gb.sh

Reproduction

When running a large-scale (64-node) PPO training job with Megatron, the training run is unstable and produces critical autograd warnings. This appears to be a torch.compile (Dynamo/Inductor) issue related to switching between training and inference modes in the PPO loop.

With TORCH_LOGS="recompiles,dynamo,autograd" enabled, the logs show that torch._dynamo hits its recompilation limit (config.recompile_limit (8)) for the fused function bias_dropout_add_fused_train.

The log explicitly provides the "smoking gun" for the recompilation:

[rank25]:W1023 12:14:24.846000 591 torch/_dynamo/convert_frame.py:1016] [6/8] torch._dynamo hit config.recompile_limit (8)
[rank25]:W1023 12:14:24.846000 591 torch/_dynamo/convert_frame.py:1016] [6/8]   function: 'bias_dropout_add_fused_train' (/workspace/Megatron-LM/megatron/core/fusions/fused_bias_dropout.py:67)
[rank25]:W1023 12:14:24.846000 591 torch/_dynamo/convert_frame.py:1016] [6/8]   last reason: 6/7: tensor 'x_with_bias[0]' requires_grad mismatch. expected requires_grad=0

This repeated recompilation (due to the PPO loop alternating requires_grad state) eventually causes Dynamo to give up. This, in turn, confuses the autograd engine, leading to the following critical warning during the backward pass, which indicates that gradients are likely not being computed correctly:

[rank492]:W1023 12:06:01.036000 646 torch/autograd/graph.py:829] [8/1] c10d::broadcast_: an autograd kernel was not registered to the Autograd key(s) but we are trying to backprop through it. This may lead to silently incorrect behavior.

A secondary FileNotFoundError from torch/_inductor/codecache.py is also observed, likely due to cache corruption from the constant recompilations.

Environment

  • Framework: verl PPO trainer
  • Model Parallelism: Megatron (ppo_megatron_trainer.yaml)
  • Hardware: 64 nodes (H200)
  • Key Config: NNODES: 64, train_pp: 16, train_tp: 1, EP: 32

Logs

  • (Attached: run_20251023_115600.log)

run_20251023_115600.log

spacegoing avatar Oct 23 '25 10:10 spacegoing

same problem:

/usr/local/lib/python3.10/dist-packages/megatron/core/pipeline_parallel/schedules.py:160: UserWarning: c10d::broadcast_: an autograd kernel was not registered to the Autograd key(s) but we are trying to backprop through it. This may lead to silently incorrect behavior. This behavior is deprecated and will be removed in a future version of PyTorch. If your operator is differentiable, please ensure you have registered an autograd kernel to the correct Autograd key (e.g. DispatchKey::Autograd, DispatchKey::CompositeImplicitAutograd). If your operator is not differentiable, or to squash this warning and use the previous behavior, please register torch::CppFunction::makeFallthrough() to DispatchKey::Autograd. (Triggered internally at /pytorch/torch/csrc/autograd/autograd_not_implemented_fallback.cpp:62.)

wa2lina avatar Oct 27 '25 08:10 wa2lina

Same error, does this affect the training process?

LuoXiaoHeics avatar Oct 30 '25 07:10 LuoXiaoHeics

中文:这个 issue 目前不建议关闭。这里已有 64 节点 Megatron PPO 的日志、脚本链接和两个后续用户复现/询问;同时我没有找到明确修复 #3883 的 merged PR。#3763/#3937 更偏向 qwen3vl Megatron 支持和 vLLM 0.11 镜像问题,不能证明 DeepSeek V3 PPO 下的 bias_dropout_add_fused_train recompilation 和 c10d::broadcast_ autograd warning 已经解决。

从现有证据看,最可疑的路径是 Megatron fused bias-dropout 在 PPO 训练/推理或 actor/ref 阶段切换时触发 requires_grad guard 不一致:当前 actor 配置默认 actor_rollout_ref.actor.use_torch_compile=true,DeepSeek/MCore converter 里也默认启用 bias_dropout_fusion=True。建议先做两个隔离实验:1. 设置 actor_rollout_ref.actor.use_torch_compile=False(ref 默认会跟随该值);2. 如果仍复现,再尝试 +actor_rollout_ref.actor.megatron.override_transformer_config.bias_dropout_fusion=False,确认 Dynamo recompile_limit 和 autograd warning 是否消失。若使用 DeepEP/Megatron/MBridge 的非官方组合,也建议在最新 main 或维护者推荐镜像上复测。

如果这些开关不能规避,请补充 verl commit、PyTorch、Megatron-Core/Megatron-LM、MBridge、DeepEP、vLLM、NCCL/CUDA 版本,最终解析后的 Hydra 配置,以及禁用 use_torch_compile/bias_dropout_fusion 前后的对比日志。这样维护者可以判断这是 verl 配置层需要默认规避,还是 Megatron/PyTorch/NCCL 上游问题。

English: I would keep this issue open. The thread has a 64-node Megatron PPO report with logs and a script link, plus two follow-up users reproducing or asking about the same warning. I did not find a merged PR that clearly fixes #3883. #3763/#3937 are mainly about qwen3vl Megatron support and the vLLM 0.11 image, so they are not enough evidence that the DeepSeek V3 PPO bias_dropout_add_fused_train recompilation and c10d::broadcast_ autograd warning are fixed.

Based on the current evidence, the most suspicious path is Megatron fused bias-dropout being compiled across PPO train/inference or actor/ref mode changes, causing a requires_grad guard mismatch. The current actor config defaults actor_rollout_ref.actor.use_torch_compile=true, and the DeepSeek/MCore converter also defaults bias_dropout_fusion=True. Please try two isolation checks first: 1. set actor_rollout_ref.actor.use_torch_compile=False (the ref path defaults to the same value); 2. if it still reproduces, try +actor_rollout_ref.actor.megatron.override_transformer_config.bias_dropout_fusion=False, then check whether the Dynamo recompile limit and autograd warning disappear. If this is using a non-standard DeepEP/Megatron/MBridge combination, please also retest on latest main or a maintainer-recommended image.

If those switches do not avoid the issue, please share the verl commit, PyTorch, Megatron-Core/Megatron-LM, MBridge, DeepEP, vLLM, NCCL/CUDA versions, the fully resolved Hydra config, and before/after logs with use_torch_compile / bias_dropout_fusion disabled. That should help maintainers decide whether verl should add a config-level workaround or whether this belongs upstream in Megatron/PyTorch/NCCL. This response was generated by a scheduled Codex GPT5.5 issue processing task.

Kirrito-k423 avatar Jul 21 '26 02:07 Kirrito-k423