Conversation
Cerdore
requested review from
BBuf,
DarkSharpness,
Edwardf0t1,
FlamingoPg,
Fridge003,
HaiShaw,
HydraQYH,
Ying1123,
celve,
ch-wan,
fzyzcjy,
hnyls2002,
ispobock,
merrymercy,
yizhang2077 and
yuan-luo
as code owners
August 3, 2026 07:43
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
`mr.device` resolves to `"cuda"` (index=None) on this path, which made
`can_use_custom_all_reduce_v2`/NVLink P2P access checks evaluate against
the default device rather than the rank-local GPU. Pass
`cuda:{mr.gpu_id}` so the symmetric-memory A2A workspace init sees the
correct device.
Co-Authored-By: Claude <noreply@anthropic.com>
36 tasks
Contributor
|
Hi @Cerdore, is this a sglang version of vllm-project/vllm#48897? |
Author
|
Hi @foraxe — yes, it's the SGLang port of GirasoleY's vLLM #48897. |
Contributor
|
Hi @Cerdore, Thanks for confirming. One related point: SGLang #32851 already adopts the faster Output/LSE implementation from vLLM #50009, which improves upon the original vLLM #48897 approach. In our apples-to-apples vLLM benchmark, vLLM #50009 was 17.85% faster than vLLM #48897 at the c32 geometry. If it's useful, we're happy to share our implementation experience or benchmark results. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
SGLang's existing single-node DCP (Decode Context Parallel) attention-reduction backends both route the exchange through NCCL collectives:
ag_rs(default): NCCLall_gather+ Triton correction +reduce_scatter(two collectives per layer).a2a: pack output + fp32 LSE → NCCLall_to_all_single→ local Triton combine (one collective + pack/unpack copies per layer).At high concurrency (conc=64+) with Kimi-K2.5 TP8/DCP8, this NCCL exchange sits on the critical path of every decode step and becomes a measurable bottleneck. The
fi_a2abackend avoids NCCL via a FlashInfer MNNVL kernel, but requires MNNVL fabric memory (GB200 NVL72), unavailable on the common single-node NVLink/NVSwitch clusters.This adds a
symm_a2abackend targeting single-node NVLink/NVSwitch domains (e.g. H20 ×8, A100 ×8, H100 ×8): it allocates a peer-mapped symmetric memory slab via PyTorch_SymmetricMemory, and each rank directly writes its partial output + LSE into peer buffers via P2P, then runs a lightweight CUDA combine kernel locally — no NCCL involved. Eligibility is detected at init viacan_use_custom_all_reduce_v2(runtime check, not a hardware whitelist); validated on H20 ×8.Modifications
dcp_direct_a2a.cu— four CUDA kernels exposed via the torch opdirect_dcp_a2a_lse_reduce, launched in sequence on the compute stream (all CUDA-graph capturable):increment_epoch_kernel— bumps the epoch counter;parity = epoch & 1selects one of two staging slots for lock-free double-buffering (no host sync between graph replays).dispatch_output_lse_kernel— each rank writes its partial attention output + LSE directly into every peer's region of the symmetric slab, using vectorizeduint4P2P stores over NVLink/NVSwitch.signal_kernel— each rank writes its epoch value into every peer's signal slot with release semantics (st_flag_release_u64), marking its data ready.wait_lse_combine_kernel<scalar_t>— each rank spin-waits (acquire + timeout trap) on its local received-signal slots until all peers signal the current epoch, then performs the LSE-weighted softmax reduction over all ranks' received partial outputs.layers/dcp/comm.py—SymmA2AWorkspace: symmetric slab layout, pointer tables, epoch double-buffering, init/destroy. Wired into the DCP merge dispatch as a new backend alongsideag_rs/a2a/fi_a2a.base_runner.py—_pre_initialize_symm_a2a_workspace()pre-allocates the workspace before CUDA graph capture. Also fixes a device-index bug on this path:mr.deviceresolves to"cuda"(index=None), which madecan_use_custom_all_reduce_v2/ NVLink P2P access checks evaluate against the default device rather than the rank-local GPU — passcuda:{mr.gpu_id}.forward_mla.py— MLA decode path routes tosymm_a2awhen selected.server_args.py—--dcp-comm-backend symm_a2aCLI arg + validation (requires CUDA, single-node NVLink, no--enable-two-batch-overlap). Compatible with--dcp-replicate-q-proj.Accuracy Tests
test_dcp_direct_a2a_kernel.py, 2-GPU and 4-GPU, fp16/bf16, with/without CUDA graph) — passed. Validates the numerical correctness of direct dispatch + LSE-weighted combine, including the CUDA-graph replay path.test_dcp_symm_a2a_tp2.pyTP2,test_dcp_symm_a2a.pyTP4, DeepSeek-V2-Lite) — identical token sequences vsag_rs.Speed Tests and Profiling
Kernel micro-benchmark (
bench_dcp_direct_a2a.py)Kimi-K2.5 geometry (64 heads, 16/rank, D=512, BF16), 4×H20, TP4/DCP4. 4 ranks × 4 paths × 6 token counts (1/8/16/32/64/128), 10 warmup + 100 iterations, latency of the slowest rank (μs).
Direct CUDA-graph path is 1.44×–1.89× faster than A2A+Triton CUDA-graph across all token counts; single decode step (tokens=1) drops 27.8 → 14.7 μs (-47%). Direct-path latency scales linearly with tokens (P2P write + local combine), while A2A-graph grows faster (NCCL
all_to_all+ pack/unpack). Note: micro-bench runs on idle GPUs with full NVLink bandwidth; the E2E speedup below is smaller because A2A is only a fraction of the decode step.E2E serving benchmark
Kimi-K2.5 (555GB, MoE, MLA), H20 ×8, TP=8, DCP=8. 6 scenarios × 3 concurrency (8/32/64) × 2 backends = 36 rounds; 4 synthetic (decode-heavy / balanced / prefill-heavy / heavy-load) + 2 real datasets (ShareGPT V3, online prompts).
conc=64 averages across 6 scenarios: throughput +9.0%, ITL p50 -11.0%. Prefill-heavy (ISL=8192) conc=64: TTFT p50 -15.5%. Low concurrency is flat — communication is not the bottleneck there.
Trend matches vLLM PR #48897 (gains scale with concurrency); the SGLang-side ITL improvement is larger, likely because TP8/DCP8 exchanges more data per step than vLLM's TP4/DCP4.
Checklist
Closes #33355.
CI States
Latest PR Test (Base): ❌ Run #30799521351
Latest PR Test (Extra): ❌ Run #30799520968