Repository navigation
[Feat] dsa: Exact multicast top-k merge for DCP decode - #48588
Merged
Merged
Conversation
hnyls2002
requested review from
1am9trash,
BBuf,
DarkSharpness,
Fridge003,
HaiShaw,
HydraQYH,
YAMY1234,
celve,
hubertlu-tw,
kkHuang-amd,
rainj-me and
yuan-luo
as code owners
November 5, 2026 07:35
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
41 of 42 tasks
Collaborator
Author
|
/rerun-test test_dsa_dcp_topk_merge.py |
Contributor
|
🚀 |
wenkaidu
added a commit
to wenkaidu/sglang
that referenced
this pull request
Nov 5, 2026
Resolve ptx.cuh conflict from sgl-project#48588 self-tagged uint64 helpers: keep the CUDA APIs and add matching HIP overloads on the ROCm side. Co-authored-by: Cursor <[email protected]>
3 tasks done
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.
Original authors: @yhyang201, @Oasis-Git
Port of #48414
Under DCP, the Kimi-K3.1 Day-0 branch (#48414) shards the DSA indexer's index-K cache by token: each rank selects a local top-k and the ranks merge them into the global top-k. This PR ports the merge for decode rows: one kernel that exchanges candidates over NVLink multicast and selects the global top-k exactly. It comes with a test and has no caller yet.
Against the raw port, the context-split verify mode (
split) is dropped; the merge is built withDcpTopKMerge.create(group, max_rows, topk, dcp_rank), which returns None where it cannot run and asserts that the group rank is the rank the candidates encode (the constructor andusable()'s buffer check go); it takesdcp_rank/out_slots/multicast_ptrthroughout; its keys tie -0 with +0, as #48501's deterministic local top-k does, so a DCP row selects what one GPU would; and the test calls #48501's candidate top-k withdcp_size/dcp_rank/deterministic=True. Left for the sharded indexer PR:init_dcp_topk_mergeand the rest ofdsa_dcp_sharded.py. Left for target verify under DCP: the split mode.Modifications
dcp_topk_merge.cuh,dcp_topk_merge.py): one CTA per row. Each rank pushes its best 384 candidates to every rank with multimem stores, selects the k-th key among all candidates, and checks a certificate. Where a rank may hold more of the global top-k, the kernel reads that rank's full local top-k and selects again. It writes this rank's keys at or above the k-th key as widened KV slots, -1 after them. Each entry carries an 8-bit epoch tag, so no flag is needed; two parity buffers alternate.DcpTopKMerge(dsa_dcp_sharded.py):createallocates the symmetric buffer and runs the rendezvous. It returns None unless there are 8 ranks (16 with the megakernel), top-k is 2048, the ranks share one NVLink domain, and multicast is available. Calls go on one stream, with the same rows in the same order on every rank.distributed/ptx.cuh): a relaxed 64-bit system-scope load and store, and a 64-bit multimem store.Tests
test_dsa_dcp_topk_merge.py(8 GPUs): every rank's merged slots equal its share of the global top-k on random, tied, single-rank-owns-top-k (fallback), signed-zero and short rows. A CUDA graph replays three alternating inputs until the epoch tag wraps. The signed-zero case fails without the -0 / +0 tie.deterministic=True, so it does not pin the local tie order the merge relies on; the 16-rank path has no test.On 8 B300 GPUs at this head: 5 passed.
CI States
Latest PR Test (Base): ❌ Run #41995804555
Latest PR Test (Extra): ❌ Run #41995804533
Latest PR Test (AMD ROCm 10): ❌ Run #41995804562
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: