[fully_async] First NCCL checkpoint-engine group init hangs (timing race) — reproduces single-turn without tools
System Info
Possibly related to the (now closed) #5321 — but our hang is at the first weight sync before any generation, and reproduces single-turn without tools, so we believe it is a distinct/lower-level problem.
We root-caused this during a profiling effort on recipe/fully_async_policy. In our repro the deadlock is at the first weight sync (before any generation), inside the NCCL checkpoint-engine process-group init, and it reproduces even single-turn without tools — i.e. it is upstream of the multi-turn + tool "metrics frozen" symptom that #5321 described. Sharing the full repro matrix, a localized root cause, and the red herrings we ruled out, in case it saves maintainer time.
- verl: commit
dc845bb(v0.8.0 + ~130 commits)- Note on latest main: we did not re-run the matrix on the newest tree, but there is no need —
origin/mainas ofe52747a(2026-07-07) leaves this code path byte-identical todc845bb.git diff dc845bb..origin/main -- verl/checkpoint_engine/ recipe/fully_async_policy/is empty;nccl_checkpoint_engine.pyandcheckpoint_engine/base.pyare unchanged; none of the 17 commits in that range touchbuild_process_group/init_process_group/init_collective_group. So the race below applies unchanged to currentmain.
- Note on latest main: we did not re-run the matrix on the newest tree, but there is no need —
- Platform: single node, 2× NVIDIA A100-80GB (driver 570.172.08), Linux
- Python: 3.12.3
- ray: 2.55.1
- vllm: 0.10.2
- torch: 2.8.0+cu128 (CUDA 12.8)
- Recipe:
fully_async_policy, NCCL checkpoint-engine backend,partial_rollout=True, 1 train GPU + 1 rollout GPU (the rollout-sideCheckpointEngineWorkeris colocated with the vLLM engine on the same GPU worker).
Information
- [ ] The official example scripts
- [x] My own modified scripts
Tasks
- [x] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
Symptom
The initial weight sync ([ASYNC MAIN] Param sync before fit.. → FullyAsyncTrainer._fit_update_weights → CheckpointEngineManager.update_weights) hangs at build_process_group → init_process_group (verl/checkpoint_engine/nccl_checkpoint_engine.py), i.e. the first NCCL group rendezvous between actor rank 0 (master, train GPU) and rollout rank 1 (rollout GPU). Both GPUs sit at 0% util, no traceback, the process stays alive. Once the first sync succeeds the group is reused (rebuild_group=False), so all subsequent syncs are fine — the hang is strictly a first-sync event.
It is a timing race (Heisenbug), not a deterministic deadlock
Hang probability scales with anything that lengthens the init window:
| model | staleness_threshold |
first-sync outcome |
|---|---|---|
| Qwen2.5-0.5B-Instruct | 1 | pass (2/2) |
| Qwen2.5-0.5B-Instruct | 2 | hang (3/4) * |
| Qwen2.5-0.5B-Instruct | 4 | hang (2/2) |
| Qwen3-1.7B | 1 | hang (3/3) |
Larger model (measured param_sync 0.9s → 4.0s) and larger staleness buffers (max_queue_size 16 → 40 as staleness_threshold grows) both raise the hang rate — consistent with a rendezvous race window that widens with init duration.
* Heisenbug evidence: the two plain runs at 0.5B/th=2 hung, and a run with coarse step-level print() around the update_weights stages also hung; the only pass came from a run with fine-grained print(..., flush=True) placed inside the init_collective_group / collective.barrier rendezvous. The closer/more instrumentation is added at the exact rendezvous, the more likely it passes — a hallmark of a timing race, and the reason we could not line-pin it via logging.
Root cause (localized, not line-pinned)
The race is inside the first ray.util.collective.init_collective_group(world_size, rank, "nccl", ...) / subsequent collective.barrier(...) rendezvous in NCCLCheckpointEngine.init_process_group, between the two ranks. It lives in the Ray collective layer, exercised concurrently because build_process_group dispatches actor-side and rollout-side init_process_group together.
Ruled out (to save maintainer time)
- The
"Using blocking ray.get inside async actor. This blocks the event loop"warning is a red herring — it appears 4× in both passing and hanging runs.CheckpointEngineManager.update_weights(async, awaited on theFullyAsyncTrainerevent loop) does use blockingray.getfor the worker-group dispatches (prepare/init_process_group/ weight transfer /finalize); converting those toawait asyncio.gather(asyncio.wrap_future(ref.future()) ...)is a valid async-hygiene cleanup that matches the idiom already used for the replica methods in the same class — but we verified it does not fix this hang. - Not the sample queue / pause-resume machinery, not the vLLM server, not tool execution, not message-queue capacity — the hang is strictly at the first NCCL init, before any generation request is issued.
Suggested next step for maintainers
Reproduce on a ptrace-capable host and py-spy dump both the actor rank-0 worker and the rollout rank-1 worker while hung. Unlike print(), py-spy is timing-neutral and won't mask the Heisenbug, so it should show which rank is stuck in init_collective_group vs barrier and expose the rendezvous race directly.
Expected behavior
The first checkpoint-engine weight sync (build_process_group → init_process_group → first collective.barrier) should complete deterministically regardless of model size or staleness_threshold, so that fully_async_policy reaches its first generation step instead of hanging with both GPUs at 0% util.
Thanks for the exceptionally detailed root-cause and repro matrix — this saved a lot of ramp-up time.
I've confirmed the cited path is byte-identical on current main: build_process_group (checkpoint_engine/base.py) dispatches both ranks' init_process_group concurrently via a single ray.get(actor_futures + rollout_futures), and NCCLCheckpointEngine.init_process_group (nccl_checkpoint_engine.py) calls collective.init_collective_group(...) then collective.barrier(...). As you found, the first-sync hang is inside ray.util.collective's rendezvous — verl's own dispatch is correct, so it's a timing race in the Ray collective layer, and only the first sync is affected (the group is reused afterward).
I'd like to work on a verl-side mitigation so the first sync is reliable — and, importantly, so a stalled rendezvous can never be a silent infinite hang. I'm weighing two approaches:
- Bounded timeout + retry around the first
init_collective_group/barrier: on timeout, tear down the partial group and retry, raising a clear error after N attempts instead of hanging forever. - Readiness handshake before
init_collective_group, so all ranks (and the master's rendezvous) confirm ready first, closing the race window.
Plan: reproduce locally on 2 GPUs (the Qwen3-1.7B / staleness_threshold=1 config from your matrix), instrument to pin whether the hang is in init_collective_group vs barrier, then implement the approach the evidence supports (likely both — prevention plus a safety net).
Before I open a PR: do maintainers have a preference between the handshake and the timeout+retry, or any context on the ray.util.collective rendezvous that would steer the fix? Happy to align on approach first.
@aryanyadav0402 Thanks for digging into this and for confirming the current-main code path.
I’d be very happy to collaborate on the fix. Since I still have the original 2×A100 environment and the exact reproducer used for the matrix, I can first collect timing-neutral py-spy --native dumps from both ranks while the job is hung, and rerun the focused Qwen3-1.7B / staleness_threshold=1 case to determine whether the stall is in group registration, NCCLUniqueID rendezvous, communicator creation, or the first barrier.
One implementation detail may be worth checking before choosing the mitigation: in Ray 2.55.1, init_collective_group() appears to register the local group, while the NCCL communicator rendezvous is created lazily when the first collective.barrier() enters the all-reduce path. If the stack dumps confirm that, a two-phase verl-side initialization may be a useful option:
- all ranks complete local group registration and report ready;
- the manager then dispatches the first barrier concurrently to all ranks.
I agree that a bounded timeout is also important so this can never remain a silent infinite hang. I’m slightly cautious about immediately retrying inside the same workers, because timing out the caller may not stop an actor method already blocked in NCCL/CuPy, so cleanup and retry semantics would need to be verified carefully.
I’ll post the stack dumps and reduced reproduction results here. After that, I’d be happy either to open a draft PR and collaborate on the same patch, or to review and validate your implementation against the original reproduction matrix—whichever avoids duplicating work and fits your current progress best.
Thanks @chengcuiping — that'd be a great collaboration, and the native dumps will be decisive.
Your Ray 2.55.1 observation likely explains the whole thing: if init_collective_group() only registers the local group and the NCCL communicator rendezvous is created lazily on the first barrier()'s all-reduce, then the concurrent first barrier() is exactly where the cross-rank rendezvous can race — which fits your matrix (hang probability grows with the init window) and why fine-grained instrumentation right there makes it vanish. py-spy --native dumps separating group-registration vs NCCLUniqueID rendezvous vs comm-creation vs barrier would confirm it precisely.
Your two-phase init is the right shape, and I'd like to implement it:
- all ranks complete
init_collective_group(local registration) and report ready to the manager; - once all are ready, the manager dispatches the first
barrierconcurrently.
This closes the race window rather than papering over it.
On the timeout — I agree with your caution: an actor already blocked in an NCCL/CuPy call can't be safely interrupted, so I'd make the bounded timeout fail-fast with a clear, actionable error (never a silent infinite hang) rather than a blind in-place retry. Any true retry would need fresh workers at a higher level — out of scope for a first fix. So: two-phase init as the fix, timeout as a guardrail.
If that works for you: I'll put up a draft PR implementing the two-phase init + fail-fast timeout (I have a local 2-GPU repro going), and it'd be great if you could validate it against your original 2×A100 reproducer and share the native dumps so we pin the phase. Happy to co-author you. Does that split sound good?
Quick update from my side. I set up the repro on 2×H100 NVL and couldn't reproduce the first-sync hang natively (6 clean runs across staleness_threshold=1/4/16). To try to force it, I injected controlled scheduling skew (env-gated time.sleep) at four points in the init path — before init_collective_group, between it and barrier, after the ZMQ connect, and deep between the NCCL UID rendezvous and ncclCommInitRank — on both ranks, with delays up to 120s. In every case the barrier simply waited for the delayed rank and the sync completed (param_sync time tracked the injected delay exactly); no hang.
That suggests the hang isn't caused by coarse init-window timing skew alone: Ray 2.55.1's Rendezvous.meet(timeout_s=180) polling and NCCL's blocking ncclCommInitRank both tolerate rank skew here. On H100 NVL the two ranks also reach init within ~0–5 ms of each other, so the window is very tight — consistent with your point that the A100 box has more jitter.
So I think your py-spy --native dumps from both hung ranks are the key next step, to pin the exact phase (group registration vs UID rendezvous vs comm creation vs first barrier). That'll tell us whether two-phase init is the right fix or whether it's a deeper NCCL/Ray/network issue. Whenever you can share them (plus the reduced Qwen3-1.7B / th=1 run), I'll build the fix around what they show. Thanks!
@aryanyadav0402 Quick update from the A100 side.
I was able to reconstruct and rerun the original historical configuration, including the GPU-utilization sampler. The current results are:
- clean stock
e52747a: 1/1 first-sync pass (4.4008s); - historical
c5d2b6awith the opt-in ptracer shim: 3/3 passes (4.0568s,4.2963s,4.3856s); - the same historical configuration without the shim: 3/3 passes (
3.8624s,4.3642s,4.0363s).
The shim/no-shim resolved configurations were otherwise byte-identical, so the current comparison does not show that the shim masked the issue. However, it also does not invalidate the original hang matrix; the current environment may differ in scheduling state, system load, caches, filesystem latency, or Ray/container lifecycle.
I cannot currently obtain timing-neutral native dumps from an unmodified Ray worker because this container runs with Yama ptrace_scope=1 and without CAP_SYS_PTRACE, and I do not have a path to change that security context. Therefore I cannot presently localize a fresh hang to local registration, NCCL UID rendezvous, communicator creation, or the first barrier.
Given the current evidence, I do not think we should describe two-phase initialization as a confirmed root-cause fix yet. A bounded fail-fast timeout with a clear actionable error still seems independently valuable as a guardrail against a silent infinite hang. I would also keep any two-phase change separable from that timeout so each can be reviewed and validated independently. I still would not recommend an in-place retry without proof that the blocked NCCL/CuPy operation and partial communicator have been terminated safely.
I’m happy to validate a draft patch on the same A100 configuration, but I want to be transparent that I cannot currently provide the decisive unmodified-process native stacks. No production code was changed, and I’m not claiming that the issue is fixed or gone.