verl icon indicating copy to clipboard operation
verl copied to clipboard

[Tracking] Sharded delta weight sync (delta_sharded): roadmap & known issues

Open ChangyiYang opened this issue 4 months ago • 7 comments

Tracking issue for the sharded delta weight sync (delta_sharded checkpoint-engine backend) merged in #6974, and the follow-up roadmap.

Merged

  • #6974 — [ckpt,rollout] feat: sharded delta weight sync over NCCL for disaggregated rollout (merged 2026-07-16, 903d90cc)

    • Each trainer rank byte-diffs its local shard against a pinned-CPU snapshot; only changed (position, value) pairs are gathered to rank 0 and streamed to the rollout side. No rank ever stages a full-model mirror.
    • Shard layout is described declaratively via ShardSpec (DeviceMesh + Placement, verl/workers/engine/spec.py) — shared contract with the nccl-m2n work.
    • Measured steady-state sync vs nccl full broadcast (disaggregated, cross-node, offload=True): 7B 3.8s vs 9.1s (2.4×), 32B 12.5s vs 23.2s (1.9×), 72B 12.0s vs 36.9s (3.1×); 200-step GRPO equivalence run and independent re-measurement in the PR thread.
  • #7144 — ShardSpec generalization: BlockPlacement block descriptors (any Shard(k) / multi-dim cuts) + explicit-place channel for hybrid geometries (merged 2026-07-27, b9873ee9)

  • #7085 — veomni FSDP+EP shard export: fused expert stacks via a dim-0-separable converter (to_hf_chunk + handler-probed hf_slots), HSDP replica dedup (ShardSpec.contributes, covers newer VeOmni's (ep_replicate, ep_fsdp, ep) expert mesh), ep_size=1 degenerate geometry (merged 2026-07-29, ce195c95). Bit-level idempotence verify sweeps green at 30B (EP8 / EP1 / HSDP) and on VeOmni main.

Next steps

  • [x] 1. FSDP + EP: Shard(1) / block-descriptor placement — DONE via #7144 + #7085. Original scope: — generalize derive_placement from the flat-offset Shard(0) fast path to a block descriptor (local_shape, global_offset) (both already provided by compute_local_shape_and_global_offset), with a vectorized local→global index translation and block placement in the dense first sync. Covers veomni-style FSDP+EP (gate_up_proj split on dim0 across EP ranks, local experts fully-sharded on dim1). Discussed in the #6974 review.
  • [x] 2. Megatron trainer support (bf16 rollout) — DONE via #7181 (merged 2026-07-30, 48ca9eed) (comm-stub probe over Megatron-Bridge mappings; TP+EP+ETP incl. hybrid-Mamba; bit-level verify sweeps + 235B 8.2–9.7× vs same-shape NCCL). PP is out of #7181's scope — see item 5. — mcore shard export through the same ShardSpec contract: 1-D TP DeviceMesh + Shard(partition_dim) + a pure-permutation to_hf converter closure; the engine's converter profile (boundary-preserving gather → NaN-sentinel rebuild → to_hf → HF-coordinate delta) already ships in #6974. (superseded working notes: https://github.com/ChangyiYang/verl/pull/2)
  • [ ] 3. Quantized rollout (fp8) — in progress (Megatron bf16+QAT trainer → sglang fp8 rollout, quant-domain delta): trainer-side sharded blockwise fp8 quantization (partial absmax grids + one all_reduce(MAX) per record, bitwise-identical to the rollout-side whole-tensor kernel), then byte-diff in code space — unchanged codes under an unchanged scale ship nothing, and measured per-128×128-block absmax flips are exactly zero across training windows at 7B/30B. Bit-level verify sweeps zero-mismatch with QAT enabled at 7B, 30B-A3B (EP8) and 235B-A22B (PP8×EP8); steady sync vs same-config fp8 NCCL: 7B 3.3–3.7s vs 5.0–5.6s, 235B 62–79s vs 306–310s (4–5×). Both masked-copy loader guards from the known issue below (param-storage interval index; post_load_weights outside the patch) are implemented on this branch. PR to follow.
  • [ ] 4. Composition with P2P / shard-level weight update (nccl-m2n) — reuse the ShardSpec placement to route each shard's delta point-to-point to the rollout ranks that own it, instead of broadcasting the full delta stream to every worker.
  • [ ] 5. Megatron pipeline parallelism (PP/VPP) for the delta export — draft PR open: #7223 by @gxlvera (rides the bridge's global parameter directory; placeholder rows as zero-count lockstep entries; WORLD merge group with contributes dedup; row-keyed union slot tables also fixing an ep_size>1 expert misattribution. 235B TP4×PP8×EP4 verify sweep zero-mismatch, steady 2.1–2.4× vs same-shape NCCL).

Known issue

  • Masked-copy guards in the SGLang delta loader. The in-place sparse apply patches Tensor.copy_ (scoped to the loader's model.load_weights calls) to skip NaN-masked positions. The slime implementation this design references — THUDM/slime#1806 (and its SGLang patch THUDM/slime#1993) — additionally (a) restricts the masked semantics to destinations whose storage belongs to model.named_parameters()/named_buffers() (a data_ptr interval index; non-param writes pass through untouched), and (b) runs post_load_weights / process_weights_after_loading in the unpatched environment so derived tensors (fp8 scales, MoE biases, MLA w_kc/w_vc) are recomputed normally. Neither guard is present in the merged loader. No impact observed in the shipped scope (bf16, standard dense models — the loaders there are pure slice/permute + copy_), but both guards should be ported before widening the scope (quant, models with post-load weight transforms).

  • (怀疑 / suspected) The cupy staging pool used by the delta wire broadcast holds its blocks instead of returning them to CUDA: measured 4.15 GB held after the full seed and ~0.6–0.9 GB after each steady sync (7B TP2 e2e; the engine logs cupy staging pool after ... send: held X GB). The engine now calls free_all_blocks() after every send as a mitigation; a proper review of the staging-buffer lifecycle for the fsdp and veomni paths is still owed.

ChangyiYang avatar Jul 16 '26 05:07 ChangyiYang

FSDP+EP expert placement could be one of Shard(0), Shard(1), [Replicate(), Shard(0)], [Replicate(), Shard(1)]

wuxibin89 avatar Jul 16 '26 05:07 wuxibin89

Perf matrix refresh (2026-07-20): dense 7B→72B, MoE 30B→235B, three engines

All numbers are steady-state timing_s/update_weights (seconds) on H100 nodes, GRPO/gsm8k smoke shapes, delta_sharded from the #7085 stack (block placement + sync-free masked apply) vs nccl from current main (incl. the #7005 staging fix — the older 7B off=T 9.1s / 32B off=T 23.2s nccl figures predate #7005 and are retired).

Dense (FSDP2)

model offload nccl delta speedup notes
7B on 5.5–6.0 3.9–4.9 ~1.3× gen_wait 2.4–2.7s = pageable H2D staging tax on both sides
32B on 17.7–18.1 11.2–11.9 1.55× delta seed 28s one-off
32B off 14.2 6.2 2.3×
72B off 28.5–29.1 12.0–13.0 2.3× 8 nodes, FSDP32, gen TP8; delta seed 41.6s; changed_ratio 2.1–2.6%, payload 8.6–10.9 GB; nccl sender: 23.5s of 24 is assembly/bucketing (83 buckets, 145 GB), wire_wait only 0.5–1.8s

MoE (three engines)

model / engine nccl delta speedup notes
30B-A3B, veomni ep8 ~32 5.8–7.9 4.3× 3-step probe
30B-A3B, veomni ep8, 50-step run median 32.2 median 7.1 4.5× equivalence run (below)
30B-A3B, mcore TP4×EP2 24.6–25.2 17.1–19.7 1.4× both sides dominated by per-expert conversion; the two batching knives tracked here should widen this
235B-A22B, veomni ep8×fsdp8 255.9/246.5/266.1 14.9/11.8/11.4 ≈21× 10 nodes (8 train + 2 rollout, gen TP16), offload on; delta changed_ratio 0.02–0.05%, payload 78–702 MB vs a ~470 GB bf16 full materialization per nccl sync

Training equivalence (30B-A3B, 50 steps each, wandb)

Same-seed GRPO pair, veomni ep8: score mean 0.682 (delta) vs 0.668 (nccl), rising 0.646→0.719 vs 0.639→0.697 — same-shape trajectories, per-step |Δ| ≈ 0.048 ≈ 3/64 of the sample granularity (independent-sampling noise, no drift). pg_loss/ppo_kl/grad_norm deltas are 1e-3–1e-1 absolute (noise around zero). Sync speedup holds for the whole run (median 7.1s vs 32.2s).

Where the win comes from (unchanged conclusion, now measured up to 235B)

The delta path saves the materialization done for the transfer, not the wire time itself: sender-side full-tensor assembly (all-gathers) + bucket packing, per-bucket sync points and HTTP roundtrips (linear in bucket count), receiver-side bucket merges. With offload=on, both paths additionally pay a pageable H2D staging tax visible as gen_wait (2.5s @7B, ~13s @32B). The ratio therefore grows with model size and MoE sparsity: 1.3× (7B dense, offload) → 2.3× (32B/72B dense) → 4.3–4.5× (30B MoE) → ≈21× (235B MoE).

ChangyiYang avatar Jul 20 '26 21:07 ChangyiYang

Update (2026-09-15): #7869 adds two opt-in GPU checks for delta_sharded: a focused CuPy staging-pool lifecycle test using real NCCL transfers, and a Qwen3-0.6B FSDP2 → SGLang GRPO smoke recipe covering training, weight sync, and rollout.

On two L20 GPUs, all 80 staging transfers matched exactly and the sender pool returned to zero after every release. The 10-step GRPO run completed with 10 zero-mismatch weight-verification sweeps. No persistent staging retention was reproduced in these bounded runs. The PR changes tests only; reproduction commands, environment details, and coverage limits are in #7869.

The earlier gather-probe exit-status fix was submitted separately as #7776 (now closed); its validation details remain in that PR.

0z5a avatar Sep 06 '26 21:09 0z5a

Hi @ChangyiYang, is item 4 still open for contribution, or is it already being coordinated offline? I’d like to start with BF16 dense FSDP2 → vLLM TP2, routing each rank only the sparse updates it needs while keeping the existing HF-coordinate format and native loading. I’d leave removal of the trainer rank-0 gather for a follow-up. @ss16118 @dongha-yoon, would this fit your current M2N work, and which interfaces should I build on?

WEIXILIN0307 avatar Oct 03 '26 09:10 WEIXILIN0307

I'd like to take the masked-copy guards from the Known issue section (ported from THUDM/slime#1806 / #1993):

  • (a) restrict the masked semantics to destinations whose storage belongs to model.named_parameters()/named_buffers() (data_ptr interval index; non-param writes pass through untouched)
  • (b) ensure post_load_weights / process_weights_after_loading run in the unpatched environment so derived tensors (fp8 scales, MoE biases, MLA w_kc/w_vc) are recomputed normally

Plan: start with (a) + CPU unit tests for the guard semantics (in-storage mask applies / out-of-storage passthrough), then audit the SGLang call chain for (b) and land it in the same PR. This also unblocks widening the scope to quant per the note. PR to follow shortly — happy to adjust if anyone is already on it.

Virtuoso461 avatar Oct 13 '26 13:10 Virtuoso461

19. Hi @ChangyiYang, is item 4 still open for contribution, or is it already being coordinated offline? I’d like to start with BF16 dense FSDP2 → vLLM TP2, routing each rank only the sparse updates it needs while keeping the existing HF-coordinate format and native loading. I’d leave removal of the trainer rank-0 gather for a follow-up. @ss16118 @dongha-yoon, would this fit your current M2N work, and which interfaces should I build on?

Hi @Pinoeer-kingxi, BF16 dense FSDP2 → vLLM TP2 sounds like a reasonable initial scope. I suggest we first get feedback on the current M2N PRs (#7432, #7552, #8087, #8088) so we can align on the interfaces to reuse for this follow-up. @ChangyiYang, could you help coordinate reviews of these PRs?

cc @kwen2501, @kaixih

dongha-yoon avatar Oct 13 '26 16:10 dongha-yoon

I think we need @wuxibin89 's approval before going forward to implementation.

ChangyiYang avatar Oct 13 '26 16:10 ChangyiYang