Skip to content

Add CUDA-graph P2P channels, SIRCL-EP MoE all-to-all, and vLLM b12x EP integration - #404

Open
FujitsuPolycom wants to merge 7 commits into
mainfrom
feat/libsircl-p2p-graph-and-sircl-ep
Open

FujitsuPolycom wants to merge 7 commits into
mainfrom
feat/libsircl-p2p-graph-and-sircl-ep

Conversation

@FujitsuPolycom

Copy link
Copy Markdown
Owner

Summary

Implements, hardware-verifies, and end-to-end benchmarks a 3-stage Expert-Parallelism (EP) & All-to-All (A2A) stack in libsircl and the libsircl vLLM plugin on a 4-Spark ConnectX-7 ring (positions 4–7) targeting DeepSeek-V4.1-Flash-1017:

  1. Stage 2 — CUDA-Graph-Capturable LIBSIRCL_P2P_CHANNELS (spark_transport/libsircl):
    • Device-side atomic per-channel item counters (kernels/sircl_p2p.cu, src/engine.c) so captured P2P channel ops advance item numbers across replays without host intervention.
    • Stream-ordered staging allocations (cuMemAllocAsync/cuMemFreeAsync) on the channel stream joined to the capturing stream by CUDA graph events for unaligned/non-pack sizes, zero-copy for aligned buffers.
  2. Stage 3 — libsircl C/CUDA "SIRCL-EP" Dynamic MoE All-to-All (include/sircl.h, exports.map, kernels/sircl_p2p.cu, src/api.c, src/engine.c, src/kernelpack.c):
    • Exports sirclEpWorkspaceBytes, sirclEpDispatch, and sirclEpCombine directly over libsircl's existing p2p_ctx RDMA arena and unmodified vendored sircl_p2p_proxy.c (byte-identical SHA-256 preserved).
    • GPU-driven dynamic routing, variable-length per-peer payloads (0 RDMA payload bytes on all-local routing even inside frozen CUDA graphs), fused top-k weighted combine reduction, CUDA graph capture with dynamic per-replay routing, and channels.ep receipt telemetry.
  3. Stage 1 + Stage 3 vLLM Plugin Integration (integrations/vllm/libsircl/):
    • Opt-in SIRCL_B12X_EP_MOE=1 (sircl_ep_b12x.py): wires b12x.moe.ep_moe / run_w4a16_moe into vLLM's B12xExperts for both TP+EP (Stage 1) and DP+EP (Stage 3), including DP global-rank coordination fix, DP expanded-workspace fix, and DeepSeek-V4.1 CED layer-20 DP metadata sync hook.
    • Opt-in SIRCL_EP_ALL2ALL=1 (sircl_ep_all2all.py): SirclEpAll2AllManager replacing AgRsAll2AllManager for EP dispatch/combine across all 40/40 MoE layers inside decode CUDA graphs (with automatic eager fallback to AgRs when max_tokens > SIRCL_EP_MAX_TOKENS while pre-warming map/workspace for graph capture).

Hardware Verification & Benchmarks (Ring 4–7: 4× NVIDIA DGX Spark GB10, ConnectX-7)

1. Stage 3 CUDA-Graph Microbenchmark (H=5120, BF16, E=384, K=6, libsircl.so.0.6.0 8005169b...)

  • B=1: 71.07 µs (1.63× faster than fixed P2P)
  • B=64: 298.13 µs (1.14× faster than fixed P2P)
  • B=128: 489.60 µs (1.09× faster than AgRs 536.08 µs, 1.27× faster than fixed P2P 619.87 µs)
  • Bit-exact across dynamic routing replays inside frozen CUDA graphs; 0 RDMA payload bytes transferred on all-local routing.

2. End-to-End DeepSeek-V4.1-Flash-1017 — no_spec Ladder (cudagraph_capture_sizes=[1,2,4,8,16], BF16 W4A16)

Mode cc=1 (tok/s) cc=4 (tok/s) cc=8 (tok/s) cc=16 (tok/s) cc=16 TTFT (ms) Prefill 26.8K (tok/s) Prefill 111.2K (tok/s) 4-Rank libsircl Receipts
A_tp4_w4a16 (baseline TP4) 41.86 99.23 150.95 243.89 1,370.0 3,046.8 4,161.7 healthy=True, captured=1512, ar=6494..6498
B_tp4_ep4 (Stage 1 TP4+EP4) 38.35 85.92 116.55 237.73 1,277.5 3,852.5 (+26.4%) 4,076.3 healthy=True, captured=1512, ar=6340..6341
C_dp4_ep4_agrs (DP4+EP4 AgRs)* 15.51 48.17 85.22 145.12 1,243.1 2,000.4 1,997.2 healthy=True, captured=2880, ag=5280, rs=1760
D_dp4_ep4_sircl_ep (Stage 3b SIRCL-EP) 17.96 (+15.8%) 52.16 (+8.3%) 91.32 (+7.2%) 163.72 (+12.8%) 1,045.0 2,030.5 2,062.7 healthy=True, captured=1440, ep={2581/2580}, 5.12 GB / 996,733 RDMA writes, staged=0, refused=0

*Note: C_dp4_ep4_agrs required CUDA_LAUNCH_BLOCKING=1 to avoid an intermittent async CUBLAS_STATUS_INTERNAL_ERROR in b12x/gemm/bf16_gemv (torch.mm) on CUDA 13.4; D_dp4_ep4_sircl_ep ran fully asynchronous with zero errors across all 4 ranks and 9.1× concurrency scaling (cc=1 → 16) alongside 4× KV-cache capacity.

3. End-to-End DeepSeek-V4.1-Flash-1017 — spec Ladder (DSpark speculative decoding)

Mode cc=1 (tok/s) cc=4 (tok/s) cc=8 (tok/s) cc=16 (tok/s) Prefill 26.8K (tok/s) Prefill 111.2K (tok/s) 4-Rank libsircl Receipts
A_tp4_w4a8 64.36 225.27 324.49 457.05 4,142.1 4,199.2 healthy=True, captured=9076
A_tp4_w4a16 65.53 168.58 246.37 400.76 4,309.5 3,826.4 healthy=True, captured=9076
B_tp4_ep4 (Stage 1) 60.91 181.48 (+7.7%) 288.28 (+17.0%) 379.95 4,026.8 3,960.6 (+3.5%) healthy=True, captured=9076

Test Plan

  • make check inside GB10 CUDA 13.4 container (nvcc sm_120/sm_121): check_entries (all 358 entries across 4 packs), test_fabric (10,057 checks), test_link_plan (15), test_kernelpack_cache (69), test_vendored_sources (5), test_abi (17), test_bootstrap (27), test_lifecycle (23), test_engine_cpu, test_shm_verbs, test_mpi_shim (6), test_check_nccl_tests (12), test_kernel_entries (3), test_build_flags (3), test_source_snapshot (2), test_concurrent_close (8) — all passed.
  • GPU emulation on GB10 (tests/emulation/p2p_channels.py --world 4 --case graph): 32/32 checks passed, 0 failed (10 mutated-payload graph replays bit-exact).
  • GPU emulation on GB10 (tests/emulation/p2p_channels.py --world 4 --case ep): 40/40 checks passed, 0 failed (bf16/fp16/fp32 asymmetric, all-local, and 8 dynamic-routing CUDA graph replays bit-exact).
  • vLLM plugin unit tests (integrations/vllm/libsircl/test_sparkring_libsircl.py) inside container with PyTorch 2.13.0+cu130: 19/19 passed, 0 skipped.
  • pytest spark_transport/libsircl/tests/test_docs_consistency.py spark_transport/libsircl/tests/test_vendored_sources.py -v: 7/7 passed (sircl_p2p_proxy.c and sircl_roce_proxy.c untouched).
  • ruff check on all modified/added Python files: 0 errors.

…d grouped routing

Verified on Ring 4-7 (DeepSeek-V4.1-Flash-1017 TP4+EP4):
- Fused Triton _remap_expert_ids_kernel replacing ~258 eager ATen ops/step
- Text-only dsv4_topk is_padding forwarding to skip padded CUDA-graph slots
- EP grouped MoE routing override avoiding direct-routing slowdown at M=5
- Unit tests covering Triton remap fallback, router padding skip, and grouped routing
Update serving.EXPERT_PARALLEL_LINK, installer/transport unit tests, and the DeepSeek V4.1 EP performance record with the verified R1-leg2 balanced tuning:
- SIRCL_ONESHOT_MAX_BYTES=262144 (256 KiB ceiling, eliminating decode twoshot phases)
- SIRCL_FORWARD_CHUNK_BYTES=65536 and SIRCL_PROGRESS_CPU=9 (GB10 X925 P-core)
- B12X_DYNAMIC_W4A8_SHARE_INPUT=1, VLLM_MOE_SKIP_PADDING=1, OMP_NUM_THREADS=4
- Retains 1 MiB link slot/pieces and 8,192-token prefill batch (+9.0% Coding Peak, +8-15% C=2/C=4 decode, 6.4-6.8 ktok/s prefill, 18.5 GiB KV at 256K)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant