verl icon indicating copy to clipboard operation
verl copied to clipboard

[RFC] `nccl_parallel` checkpoint engine: aggregate sender NICs for cross-node weight sync

Open savaresejeremy opened this issue 3 months ago • 3 comments

Summary

We propose an additive checkpoint-engine backend, nccl_parallel, that removes the single-sender bottleneck in the nccl engine's cross-node weight sync. Instead of actor rank 0 broadcasting every bucket, all S actor ranks send concurrently, each owning a stripe of the global bucket sequence over its own NCCL group. Receivers join all S groups and consume buckets in ascending global order, so the reassembled stream is identical to the stock engine's.

We have this running in production-scale RL (FSDP2 trainer + disaggregated vLLM rollout) and would like to contribute it. There is already an open request for this capability (#7167), and a measurement posted there on 2026-08-03 shows that the straightforward version is correct but ~19x slower end-to-end, because the ordering needed to make trainer-side broadcasts safe removed the existing export/broadcast overlap. Most of this engine's hardening exists to keep that overlap. This RFC describes the design, the hardening, and a phased contribution plan. The PR is up at #7263: one new engine file, registry/README/config wiring, and two GPU tests.

Motivation: the single-sender funnel

Every trainer-side transport in verl/checkpoint_engine today funnels the full model through one rank's NIC share. Three observations motivate this design.

  1. Upstream's own benchmark shows the ceiling. The package README measures the NCCL backend at ~7 s / 8.25 GB/s for a 30B model on 4x8 H100 with ConnectX-7 400 Gbps InfiniBand. That is roughly 66 Gbps on a 400 Gbps fabric, because one GPU's network share is the source for the whole rollout fleet. (That setup receives weights without the CUDA-IPC hop to vLLM/SGLang, so it is not directly comparable to the end-to-end refit times below; we cite it only for the single-sender ceiling.)

  2. There is an open request for exactly this capability. #7167 ("[ckpt]: NCCL checkpoint engine broadcast optimization") reports that on GH200 nodes with 4 NICs per node (~100 GB/s bisection), the master-only broadcast caps at ~25 GB/s. Adding all trainer GPUs to the broadcast group, with rank 0 remaining the sole source and the others joining as passive participants whose NICs NCCL can use, raised raw broadcast bandwidth to ~90 GB/s and cut Qwen2.5-14B-Instruct weight sync from 1.5 s to 0.62 s (2.4x). The issue proposes an optional mechanism to include the trainer GPUs in the broadcast group.

  3. The obvious version of that mechanism is correct but far slower end-to-end. A controlled reproduction posted on #7167 on 2026-08-03 (2-node 16-GPU H20/RDMA, Qwen3-30B-A3B, rank 0 sole source, other trainer ranks passive) passed correctness with no hang, but measured median 307.73 s per sync against 15.85 s for today's rank-0-only topology (p95 326.12 vs 16.60), about 19x slower, with the in-engine transfer interval itself at 39-56 s vs 6-8 s. Their stated root cause: "the per-bucket ordering needed to avoid conflicting collectives between the FSDP process group and the checkpoint NCCL group also removed the existing export/broadcast overlap." That candidate is being held back for that reason.

The third result is the one to weigh this proposal against. Adding senders is not hard by itself; the hard part is doing it without destroying the export/broadcast overlap. This design handles that by pinning collective enqueue order at phase boundaries rather than serializing execution per bucket. Non-blocking comm streams and per-transfer CUDA events let the trainer's export keep running underneath. The hardening section below spells this out, and the "Relation to issue #7167" section answers that issue's three open questions directly.

Where the speedup comes from, and its ceiling

Striping parallelizes sender egress; every receiver still ingests every byte. The achievable gain is therefore bounded by how much of the transfer was limited by the sending side's NIC bandwidth on the given topology, and nothing else. On topologies like #7167's GH200 setup, where one source reached ~25 of ~100 GB/s, the bound is generous, and NIC participation alone was worth 2.4x. On our 2-node EFA setup the sender's egress is a smaller share of the total cost (the receiver-side CUDA-IPC re-send and vLLM's layerwise apply are untouched by this PR), so the bound is tighter and the measured end-to-end gain is smaller. Cutting the bytes each receiver ingests is a different lever; that is the next step in the phased plan (PR 2), and this PR claims none of it.

Measured on our stack

2-node: 8xB200 FSDP2 trainer to 8xB200 vLLM rollout, Qwen3.5-27B, 55.6 GB bf16, GEN_TP=4, bucket 2048 MB, AWS EFA, S=8 senders, 50.96 GiB on the wire per refit.

End-to-end weight sync inside a real training run (gather + wire + receiver-side CUDA-IPC re-send + vLLM apply), n=20 refits:

engine sync per refit
nccl (stock) 3.01 s ±0.25
nccl_parallel (S=8) 2.51 s ±0.27

A same-window paired re-run of that A/B (two jobs side by side, all seeds pinned, identical workload, n=20 each, mean±std / median / p95): stock 3.005 ±0.346 / 2.911 / 3.533 s, reproducing the baseline above to 0.1%, vs nccl_parallel 2.457 ±0.205 / 2.466 / 2.818 s. The parallel arm's p95 sits below the stock arm's median. Both arms ran code behaviorally identical to this PR at S=8 (the 16-byte bucket rounding described below is a no-op at 2048 MB / 8).

We also validated 4-node topologies (same recipe, 10 refits per arm, single run per topology, phase=8, mean±std / median / p95): 1 trainer node + 3 rollout nodes (S=8) 2.480 ±0.348 / 2.378 / 3.065 s; 2+2 (S=16) 5.548 ±0.654 / 5.436 / 6.559 s; 3+1 (S=24) 2.931 ±0.363 / 2.932 / 3.440 s. All arms completed every refit and trained normally (weight equality itself is what the shipped GPU test checks, see below). Tripling the receiver fleet (8 to 24 GPUs) left sync time unchanged versus the 2-node case. The 2-trainer/2-rollout split is markedly slower at fixed phase; we don't have an explanation for that yet, and the 3-trainer split does not show it. A second pass of the same matrix on the exact submitted tree reproduced the ordering (2.84 / 5.01 / 3.88 s, with the 2+2 split again slowest); the run-to-run spread on the other splits means these single-topology numbers carry meaningful variance. These runs are correctness evidence across S=8/16/24, not tuned benchmarks.

One related implementation detail: the per-group bucket is rounded down to a 16-byte boundary, with a CPU regression test over a range of S. Without the rounding, 2048 MB / 24 senders is an odd number of bytes, and a bucket-sized cut through a large tensor leaves the tensors packed behind it at a dtype-misaligned storage offset; S=8 and S=16 divide 2048 MB evenly and are unaffected. The rounding removes the bucket cut as a source of misalignment, but it is not a general alignment guarantee. Back-to-back packing of a mixed-dtype stream can still land a later tensor at a misaligned offset whatever the bucket size. That behavior predates this engine, is shared with the stock nccl engine, does not arise on the homogeneous-dtype (bf16) export path this backend is validated against, and is better fixed on its own than folded into this PR.

Wire leg in isolation, from a separate 2-node harness that ships a comparable 51.7 GiB tensor inventory with no concurrent gathers and no apply, n=2-3 timed iterations per cell after a warm-up:

engine wire bandwidth
nccl (stock) 39.7-40.1 GiB/s (three sweeps)
nccl_parallel (S=8) 52.7-61.1 GiB/s (1.33-1.52x stock)

The two tables are different instruments and should not be multiplied together. The wire arm is quoted as a range because the parallel cell in the first sweep varied ~12% iteration-to-iteration (0.84-1.05 s) while its stock cell was stable to <1%. A later sweep re-measured the same parallel config at 0.847 s and was itself stable to <0.1%, so the spread is between sweeps, not inherent to the backend.

Two caveats. First, the end-to-end win (1.20x on the n=20 pair in the table, 1.22x on the same-window re-run) is smaller than the wire win (1.33-1.52x) for the reason given above: the receiver-side re-send and apply are untouched and start to dominate once sender egress is no longer the binding constraint. Second, we are not claiming a measured scaling law. We expect the sender fan-out's value to grow with receiver node count, since aggregate receive demand scales with N nodes while the stock engine sources every byte from one rank's NIC share. But NCCL's broadcast is tree/ring-based, and the 4-node runs above are single runs at fixed phase intended as correctness evidence, one of which (2+2) is slower rather than faster. So the fan-out's benefit is measured at 2 nodes and unquantified beyond it. Two nodes is the smallest cross-node configuration where the fan-out can help at all, and it already wins there.

Learning is unaffected: over 100-step GSM8K runs with seeds pinned, the plateau accuracy (steps 61-100) of nccl_parallel is 0.9609 vs stock's 0.9614, and four backends tested agree within 0.0008, against a per-step spread of ~0.03 within each run. Per-step trajectory divergence from stock is about half the divergence caused by changing the random seed (mean |delta| 0.021 engine-vs-stock across 100 paired steps, versus 0.045 for a same-engine seed change), so the engine moves the trajectory materially less than reseeding does. Residual FP/scheduling nondeterminism means that is a consistency check, not a determinism proof. What the shipped GPU test certifies is weight equality of the reassembled stream via upstream's own tests/checkpoint_engine/test_utils.py::check_weights: every expected tensor present, and torch.allclose against the trainer's weights. Asserting byte-exactness instead would mean hardening upstream's check_weights, which changes the pass/fail semantics of the other backends' tests that share it; we can send that as its own small PR if there's interest.

Relation to issue #7167

The 2026-08-03 comment on #7167 asks three questions of any all-trainer-rank design. Answering them for this engine:

  1. Do all trainer ranks enter every checkpoint broadcast while FSDP export collectives are still active? Yes, but as active stripe owners, not passive participants. Each actor rank broadcasts its own stripe of one global bucket sequence on its own NCCL group. The fan-out gives S times the source egress, and it also distributes the sender-side staging work: an owner only copies its own stripe into a transfer buffer, where the stock engine has rank 0 stage every bucket. (Every actor rank iterates the whole weight stream in both engines; that iteration is what drives the collective FSDP gathers, so it is mandatory, not overhead this engine adds.) The #7167 candidate keeps rank 0 as the sole source and adds the other ranks so NCCL can use their NICs. The topology looks similar from outside and behaves differently.
  2. How is collective launch ordering coordinated across the FSDP and checkpoint process groups without losing the export/broadcast pipeline? Bulk-synchronous phase barriers on a dedicated senders' group pin the enqueue order of engine collectives to fixed points in every rank's collective sequence; NCCL's cross-communicator ordering requirement constrains enqueue order, not execution timing. Execution is not serialized: comm streams are non-blocking with respect to the default stream, and completion is tracked with per-transfer CUDA events, so the trainer's export keeps executing underneath. Synchronization granularity is the phase (up to S buckets), not the bucket. The #7167 reproduction enforced ordering by serializing instead, and per its author's analysis that is where the ~19x regression came from.
  3. Did the checkpoint communicator stay persistent across the measurements? Yes. Communicators are persistent across rounds by default; rebuild_group=True is opt-in and is exercised by one case of the shipped correctness test.

On #7107 ("[ckpt]: nccl broadcast bucket size fix"), which changes bucket handling in the sibling nccl engine and is still settling: nccl_parallel carries its own bucketing, so it does not conflict today, but we would rather match than diverge. We are happy to rebase and adopt that PR's partial-bucket metadata behavior once it lands.

Why this is harder than it looks

Naive "everyone broadcasts at once" deadlocks in real training. The engine makes three specific hazards safe:

  1. NCCL cross-communicator ordering. During a sync, the trainer's own weight-stream materialization issues on the order of a thousand per-tensor collectives. Free-running engine broadcasts interleave at a different position in each rank's collective stream, violating NCCL's requirement that ranks issue collectives on shared communicators in a consistent order. The job wedges with every GPU spinning (diagnosed via NCCL_DEBUG_SUBSYS=COLL). The fix is bulk-synchronous phases. Senders coordinate on a dedicated NCCL group; each phase is: entry barrier, the phase's owners broadcast concurrently on distinct groups, each owner waits on its own transfer event, exit barrier. The barriers pin the enqueue order on every rank. They are deliberately not completion-waited, so broadcast kernels still overlap the trainer's export (waiting for entry-barrier completion before broadcasting deadlocks the real integration). Safety comes from that consistent enqueue order plus each rank's local ordering, where its own broadcast follows its entry barrier and precedes its exit, not from an on-device rendezvous.

  2. Blocking per-communicator streams. ray.util.collective creates each communicator's stream as blocking with respect to the default stream, which (a) serializes each sender's next gathers behind its in-flight broadcast and (b) lets receivers' early-posted reads block their apply-path copies. The engine patches ray's stream factory to non-blocking (process-wide, once, fail-closed if a pool already exists) and replaces the lost implicit ordering with per-transfer CUDA events on senders and a bounded phase-boundary device synchronize on receivers.

  3. zmq PUB/SUB slow-joiner. Bucket metadata rides PUB/SUB. Cross-node, a message published before subscriptions propagate is silently dropped, and a receiver that misses its first metadata never posts its NCCL recv; the sender kernel spin-waits and the trainer stalls into a watchdog kill. The fix is a subscription handshake: senders ping until a second NCCL barrier proves every receiver is subscribed, and residual pings are filtered.

Every wait on the engine's normal path is bounded, so failure is loud and job-fatal rather than a silent hang to the NCCL watchdog. The only unbounded waits are three device-wide torch.cuda.synchronize() fallbacks, taken only if ray's per-communicator stream handle is unavailable (an API drift the engine tolerates rather than crashes on, at the cost of losing overlap). Each mechanism is necessary: designs missing any one of them deadlock in real integration even while passing isolated wire benchmarks. The docstrings record the specific alternatives and their failure modes.

Known limitation: the stream-factory patch

Mechanism 2 is the weakest part of this design, so it gets its own section. ray.util.collective offers no way to ask for non-blocking communicator streams, so the engine reaches into ray.util.collective.collective_group.cuda_stream and wraps its cupy handle so the streams it creates are non-blocking. That is a process-wide patch of another library's private surface, and it is fragile against ray upgrades: a rename or a layout change breaks it.

Why we still think it is acceptable:

  • It fails closed, not silently. The patch is applied in the engine constructor, before any collective group exists. If it cannot take effect, either because the module isn't importable (ray layout drift) or because a stream pool already exists in this process (ray caches one per device on first use, and those streams would stay blocking), the constructor raises RuntimeError and the engine refuses to be built. It never runs on blocking streams, which is the configuration that wedges.
  • It does not degrade the backend it sits next to. The stock nccl engine remains correct under non-blocking comm streams: its five waits are device-wide torch.cuda.synchronize() calls, which cover streams of either kind. So a process that constructs nccl_parallel and the stock engine is still fine; the reasoning is recorded in the engine at the point the patch is applied. We have not audited every other backend against non-blocking comm streams. In a normal job exactly one checkpoint-engine backend is selected, so the mixed case is test-only in practice, and if maintainers would rather not take a process-wide patch on trust, gating it behind an opt-in config flag is an easy change (see the exit paths below).
  • A 1-GPU test asserts the patch actually took effect (stream counter, per-group stream lookup, event completion), so a ray upgrade that breaks it fails a test rather than a training run.

Exit paths, in order of preference: (a) upstream a non_blocking option for ray.util.collective's per-communicator streams; if that lands, this patch is deleted outright, and we are willing to do that work. (b) If verl's weight-sync path moves off ray.util.collective, the patch goes away with the dependency. Stream semantics in this subsystem have needed attention before (#7083 added CUDA stream synchronization to the NCCL broadcast wait), so we assume this is a known sharp edge rather than a surprise.

Choosing S and phase

Each receiver joins S engine communicators, on top of vLLM's own kernels on the same GPU. The phase kwarg caps how many striped broadcasts are co-scheduled at once (default S, range 1..S): S broadcasts times NCCL channels each have to be co-resident on the receiver GPU, and when they are not, progress stalls. #7029 already showed receivers are sensitive to this kind of interference: pre-rollout update_weights severely degraded rollout decode throughput on H800. That was one group's worth of sync work; this backend puts more of it on the receivers at once. The engine docstring's practical guidance: if receivers cannot co-schedule the full fan-out, lower phase, or cap NCCL_MAX_NCHANNELS.

The limits of that guidance: what we have validated is 2 nodes at S=8 with the default phase, plus single 4-node runs at S=8/16/24 with phase=8. We do not have data to recommend a phase for a given (S, receiver count, TP, NCCL channel budget), and the 2+2 result above is a reminder that the mapping is not monotone. Establishing that is the kind of thing broader review and soaks on other topologies should settle. The default is the configuration measured at 2 nodes; the knob exists because kernel co-residency on the receiver GPU is a real limit.

Config surface (one existing key changes meaning)

engine_kwargs: {nccl_parallel: {phase: N}} is the only new knob. One existing key is reinterpreted by this backend, and we want to call it out clearly rather than have anyone find it by surprise:

checkpoint_engine.update_weights_bucket_megabytes means the per-bucket size for the stock nccl engine. For nccl_parallel it means the total in-flight transfer budget, divided by the sender count to size each sender's bucket, so receiver device memory stays ~2 x budget (S groups x 2 buffers x budget/S) instead of scaling with S.

Same key, different meaning across backends. Also note the floor: the per-group bucket is floored at 32 MB, so a budget below S x 32 MB is not honored (receiver buffers then total 2 x S x 32 MB, and the engine logs a warning at init_process_group when that happens). The per-group bucket is additionally rounded down to a 16-byte boundary for dtype alignment (details under "Measured on our stack"). We chose the reinterpretation so that switching backends does not multiply a tuned memory budget by S, but if maintainers prefer a distinct key for this backend we can add one.

Relation to existing backends

  • nccl: same topology assumptions (fixed cluster), same all_gather + broadcast structure, same config surface, same rebuild_group escape hatch. nccl_parallel is a drop-in backend swap; with S=1 it degenerates to a single-sender engine. On elasticity we claim no more than the stock engine: what the shipped test exercises is destroy-and-recreate of every group between update rounds at an unchanged topology (rebuild_group=True, 3 rounds); a membership change is untested.
  • kimi_ckpt_engine: the closest prior art, and complementary rather than overlapping. It is inference-side: weights arrive at rollout via P2P/disk, then a rotating-owner broadcast pipelined with H2D moves them within the rollout fleet. It is multi-source over time (one bucket in flight), and its senders never coexist with live trainer collectives. nccl_parallel is trainer-side with S groups running concurrently next to live FSDP all-gathers, which is why the phase/barrier/non-blocking-stream machinery above exists.
  • delta / sharded transports: orthogonal; a future composition could stripe delta payloads across senders.

Why a separate backend rather than a flag on nccl? Mostly to protect the stock engine. Its simplicity is a feature (one communicator per process, five device-wide synchronizes, easy to reason about), and this engine runs under a different correctness regime: a fail-closed process-wide stream patch, S communicators per process, phase barriers whose enqueue order the correctness argument depends on, and a zmq subscription handshake. Folding those behind a flag would put them in the maintenance path of the engine most people use. Registry-backed backend separation is also the established idiom here; it is how kimi_ckpt_engine, mooncake and delta entered the tree. And because S=1 degenerates to a single-sender engine, nothing is lost by making users choose. If maintainers disagree and would rather see this as a mode of nccl, we can restructure it; the mechanisms are self-contained in one file today.

What's in the PR (#7263)

Seven files. The engine and the two test files are new; the rest is wiring and docs:

  • verl/checkpoint_engine/nccl_parallel_checkpoint_engine.py: the engine (registered as nccl_parallel; ctor kwarg phase, configurable via checkpoint_engine.engine_kwargs: {nccl_parallel: {phase: N}}).
  • verl/checkpoint_engine/__init__.py: try/except import block, same shape as the other optional backends.
  • verl/checkpoint_engine/README.md: backend-table row.
  • verl/trainer/config/rollout/rollout.yaml: comments only: backend list, engine_kwargs keying, and the update_weights_bucket_megabytes reinterpretation noted above.
  • verl/workers/config/rollout.py: comment only. The backend list on CheckpointEngineConfig.backend had drifted from rollout.yaml's, so nccl_parallel is added to both.
  • tests/checkpoint_engine/test_parallel_correctness_on_gpu.py: mirrors test_correctness_on_gpu.py; 6 parametrized cases (S=1 degenerate; phase defaulting; non-divisor and small phase < S marker-drain paths; rebuild_group=True), 3 update rounds per case to exercise cross-round zmq/socket state and group teardown/rebuild, plus two CPU-only checks: that an out-of-range phase is rejected rather than clamped, and that the per-group bucket size stays 16-byte aligned (and above the 32 MB floor) for S in {1, 3, 7, 8, 16, 24, 192}.
  • tests/checkpoint_engine/test_parallel_stream_mechanisms_on_gpu.py: a 1-GPU test that verifies the stream-factory patch, per-group comm-stream lookup, and cupy event completion. This is the first thing to run when triaging on a new ray/cupy/torch stack.

No changes to base.py, nccl_checkpoint_engine.py, or any shared engine code. No new dependencies: cupy is imported with the same guarded idiom the stock nccl engine already uses.

Scope and limitations: this PR aggregates sender NIC bandwidth and reduces nothing on the wire; every receiver still ingests every byte. It is validated with FSDP2 + vLLM. The Megatron engine exposes the same get_per_tensor_param seam and the dispatch runs the weight stream on all actor ranks, and the engine's correctness precondition is only that all actor ranks derive an identical bucket sequence, but we have not run Megatron with it and scope this PR's claims to FSDP.

Phased plan

This RFC and PR cover nccl_parallel only. Two follow-ups we have validated internally (sender-side pre-sharding for bytes-on-wire reduction, and its composition with the striping here) will each come as their own RFC/PR if this one lands.

Questions for maintainers

  1. CI: the existing checkpoint-engine GPU tests are skipped with "ci environment is not ready". Is there a GPU lane we should target, or do maintainers run these manually on release branches?
  2. Any appetite for a Megatron validation pass, or is FSDP-scoped fine for landing?
  3. Naming/config: renaming the backend or folding phase under a different config shape is fine by us if there's a house preference; see also the update_weights_bucket_megabytes note above if you'd rather this backend took its own key.
  4. Coordination: #7167 asks for this capability with a different mechanism (passive participants around a single source), and #7107 is changing bucket handling in the sibling engine. Would you rather this land as its own backend and let those proceed independently, or should they be reconciled first? Either way works for us, and we can help review over there.

savaresejeremy avatar Aug 04 '26 19:08 savaresejeremy

@savaresejeremy Thanks for your RFC, NVIDIA nccl team is proposal a new NCCL M2N Reshard CheckpointEngine to accelerate weight refit: https://github.com/verl-project/verl/discussions/7273

wuxibin89 avatar Aug 06 '26 06:08 wuxibin89

Thanks @wuxibin89. We read #7273 and its thread and replied over there: https://github.com/verl-project/verl/discussions/7273#discussioncomment-17926916

savaresejeremy avatar Aug 06 '26 23:08 savaresejeremy

Closing alongside #7263: #7291 shipped the capability this proposed, by a different mechanism. The measurements stay here for anyone who needs the striped-sender comparison.

savaresejeremy avatar Aug 24 '26 21:08 savaresejeremy