RL icon indicating copy to clipboard operation
RL copied to clipboard

[TRAIN-1] Megatron async GRPO with dis-colocated generation deadlocks at weight sync

Open anwithk opened this issue 6 months ago • 2 comments

Problem

Async GRPO with colocate_generation: false on the Megatron backend hangs permanently at the first weight sync (step 1 to 2). After the first training step completes, the trainer and the async rollout collector each wait on the other. The pipeline stalls with idle GPUs and never recovers. The same step runs fine with colocated generation and on the DTensor backend.

Steps to reproduce

  1. Configure async GRPO with colocate_generation: false using the Megatron backend.
  2. Start training.
  3. Observe the pipeline stall after step 1 with no error output and idle GPUs.

Suggested fix

  • Investigate the weight handoff coordination between MegatronPolicyWorker and VllmAsyncGenerationWorker.
  • Add a timeout and explicit error on weight-sync deadlock so the failure surfaces rather than hanging silently.

anwithk avatar Jun 05 '26 19:06 anwithk

@anwithk

I can't reproduce it on my side. I need more detailed reproduction guide, including recipe, commit, as well as containers.

https://wandb.ai/nvidia/nemorl-vdr-debug/runs/z1oos66a/overview

Image

This run worked well.

By the way, there's no colocate_generation: false only policy.generation.colocated.enabled.

ZhiyuLi-Nvidia avatar Jun 11 '26 01:06 ZhiyuLi-Nvidia

Formal-verification evidence supporting this report — we model-checked the weight-refit rendezvous in TLA+ (TLC), independent confirmation of the hang class and of the suggested fix direction.

What the model shows:

  1. The wedge is real and structural. The two-sided refit rendezvous (refit_policy_generation, grpo.py ~L2719-2825; trainer-side broadcast_weights_*/stream_weights_* futures and inference-side update_weights_* futures) requires both sides to complete; the driver waits on ray.get(futures_train) / ray.get(futures_inference) (~L2797-2808) with no timeout. TLC produces the liveness counterexample: BeginRefit → one side dies → both sides wedge → phase=Refit forever. Matches this issue's "each waits on the other, no error output, idle GPUs, never recovers".

  2. The suggested fix (timeout + explicit error) is verified. Adding a driver-side refit timeout/rescue to the model makes the liveness property hold — all 16,442 distinct states clean, refit always terminates or raises. So "Add a timeout and explicit error on weight-sync deadlock so the failure surfaces rather than hanging silently" is confirmed sufficient in-model.

  3. Adjacent invariant worth preserving during the fix: the driver's update_success = all(results) all-ack gate is load-bearing. A model variant without it produces a 7-step split-brain counterexample — a shard that joins the new communicator epoch early accepts data while a peer is still mid-join. Whatever timeout/retry logic is added should keep the all-ack semantics intact (i.e., timeout → fail the refit loudly, not partial proceed).

Spec details available on request (the model covers weight-version freshness, stale flag, and crash/recover around the refit phase).

rkoivunen-sw avatar Oct 13 '26 16:10 rkoivunen-sw