Repository navigation
[Perf] kimi-k3.1: Faster DCP decode reduce (push-combine, V pre-projection, direct exchange) - #48740
Conversation
- Rename SGLANG_DCP_PUSH_COMBINE to SGLANG_ENABLE_DCP_PUSH_COMBINE and default SGLANG_DCP_PUSH_COMBINE_MAX_ROWS to 1024; the GB300-specific default helper is not on main. - Declare dcp_v_preproject and _dcp_v_weights on the MLA mixin and read them directly instead of through getattr. - Route the absorbed path's gate + o_proj tail through _finish_absorb_output, so the V-preprojected exit and the regular one share it.
…8414's history sgl-project#48414 dropped its unit tests (sgl-project#48464); these two come from the history it was squashed from: the push-combine reduce against the Triton combine, and the direct exchange, byte gather and candidate merge collectives. Co-authored-by: Xiaoyu Zhang <[email protected]>
…s test FlashMLA prefill token packing is not part of this port.
cc716be to
1452226
Compare
BBuf
left a comment
There was a problem hiding this comment.
[BBuf Review Agent] A few things to fix before this can go in.
| local, | ||
| lengths, | ||
| table, | ||
| all_gather=partial(group.all_gather, dim=0), |
There was a problem hiding this comment.
[BBuf Review Agent] The first reference call raises TypeError: dcp_global_topk() got an unexpected keyword argument 'all_gather', so none of the replay comparisons run. Could we use the current API and temporarily clear _CANDIDATE_ALL_GATHER for the eager reference?
| max_push_size=MAX_ROWS * (H // world_size) * pc.SLOT_BYTES_PER_ROW, | ||
| ) | ||
| assert not comm.disabled | ||
| pc.register_comm(comm.obj) |
There was a problem hiding this comment.
[BBuf Review Agent] After _setup() returns, only the non-owning comm.obj is retained; cyclic GC can free the push buffers and counters while later tests still launch through their pointers. Could we retain the CustomAllReduceV2 owner in the fixture and register its cleanup?
- test_dcp_collectives: dcp_global_topk takes no all_gather argument; run the eager reference with _CANDIDATE_ALL_GATHER cleared instead. - test_dcp_push_combine: keep the CustomAllReduceV2 that owns the push buffers alive for the whole module and close it at exit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
[BBuf Review Agent] Could you add before/after numbers with hardware and workload? |
The decode reduce takes the push-combine path under both the a2a and the fi_a2a DCP backends, but the plane was allocated only inside the fi_a2a workspace hook, so under a2a it was never set up and the reduce always fell back to the all-to-all. Give it its own hook, gated on DCP, an a2a or fi_a2a backend, and replicated q projection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/rerun-test test_dcp_push_combine.py test_dcp_collectives.py test_dsa_dcp_topk_merge.py test_dsa_dcp_attention.py test_dcp_lse_combine.py test_kimi_k3_b300.py |
|
🚀 🚀 🚀 🚀 |
|
Accuracy on 2 x GB300 (4 GPUs each), Kimi-K3.1, PR head
Both arms have a 0% error rate. The AIME26 gap is 3 of 240 samples on main, one of them cut off at the 100K token cap, which is within noise. Setup:
What this run does and does not cover:
|
|
Heads-up: since this PR merged, The test drives |
Two conflicts, both against the kimi-k3.1 DCP work that landed on 11-06. sgl-project#48739 widened the absorbed-MLA gather to skip target-verify, where a sharded index-K now keeps its per-rank partials. The gathered-prefill override is a different route and the two cannot both be on: the route is planned only when index-K is replicated. Keep both, ours first, and keep the dcp_gathered local the rest of the method reads. sgl-project#48740 added dcp_push_combine_fits and dcp_push_combine_reduce to the layers.dcp import in forward_mla, next to is_dsa_dcp_gathered_prefill. Take the union.
Original authors: @yhyang201, @BBuf
Stacks on #48721. Until #48721 merges, this PR's diff also contains it; the commits from "Raw port of the DSA DCP decode reduce" on are this PR.
Port of #48414
Under DCP, Kimi-K3.1 decode merges the attention partials of every rank by LSE. #48721 ports that through the existing pack + all-to-all + Triton combine. This PR ports the faster reduce from #48414:
w_vcat 512 rows or more, or whenever the push-combine plane takes the batch.fi_a2a, the 8-rank, 96-head partials are stored straight into peer buffers. It is gated to B300 and 512-1024 rows, and falls back to FlashInfer's exchange otherwise..contiguous(), since the a2a pack reads any strides.Against the raw port (first commit):
SGLANG_DCP_PUSH_COMBINEbecomesSGLANG_ENABLE_DCP_PUSH_COMBINE, following the env-var naming rules.SGLANG_DCP_PUSH_COMBINE_MAX_ROWSdefaults to 1024. The source's GB300-specific default helper is not on main.dcp_v_preprojectand_dcp_v_weightsare declared on the MLA mixin and read directly.o_projtail goes through one helper,_finish_absorb_output, which both the V-preprojected exit and the regular exit use.dcp_push_combineis registered in the attention kernel group.The tests come from the history #48414 was squashed from, because #48414 dropped its unit tests. The token-packing case is removed.
Left for later ports:
dsa_decode_absorb_under_indexer,_flashmla_kv_q), which is not on main._maybe_precompute_flashmla_sched_meta); [Feat] kimi-k3.1: DSA decode context parallelism runtime #48721 lets FlashMLA schedule DCP decode itself.Modifications
kernels/jit/csrc/dsa/dcp_push_combine.cuh,kernels/ops/attention/dcp_push_combine.py: the push + LSE combine kernel and its op.kernels/ops/attention/dcp_kernels.py:DcpDirectAllToAlland its peer-store pack kernel;_gather_candidate_prefix_kernel.layers/dcp/comm.py,layers/dcp/__init__.py:init_dcp_push_combine/dcp_push_combine_fits/dcp_push_combine_reduce; the direct exchange in thefi_a2areduce; the word-sized reorder in_all_gather_dcp_kv_cache.model_executor/runner/base_runner.py: set up the push plane next to the fi_a2a workspace when q projection is replicated.forward_mla.py: V pre-projection and the push-combine reduce in the DCP decode merge.kimi_k3.py: K3.1 MLA layers opt into the V pre-projection; the gatheredw_vcis refreshed on weight reload.dsa_dcp_sharded.py: the prefix candidate gather.environ.py:SGLANG_ENABLE_DCP_PUSH_COMBINE,SGLANG_DCP_PUSH_COMBINE_MAX_ROWS.Tests
test_dcp_push_combine.py(8 GPUs): the push-combine reduce against gathering every rank's partials and running the Triton combine.test_dcp_collectives.py(4 / 8 GPUs): the direct exchange bit for bit through graph replay; its dispatch and fallback on B300; the request-ordered byte gather; the candidate merge's scratch reuse across graph replays.pre-commitand ruff on the touched files. These tests and a Kimi-K3.1 TP8 / DCP8 run are owed.CI States
Latest PR Test (Base): ❌ Run #42299558253
Latest PR Test (Extra): ❌ Run #42299557805
Latest PR Test (AMD ROCm 10): ❌ Run #42299558126
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: