Repository navigation
[Perf][DCP] Sparse indexer: read the rank-major DCP top-k gather in place - #65178
Merged
LucasWilkinson merged 2 commits intoNov 2, 2026
Merged
Conversation
…lace The DCP sparse-indexer merge all-gathers each rank's packed (score, global id) candidates along dim 1. GroupCoordinator.all_gather then reorders the rank-major gather into [rows, world_size * topk, 2], a full extra copy of the candidates. Gather along dim 0 instead and let the CuTeDSL selector read the rank-major [world_size, rows, topk, 2] buffer in place. Each rank contributes topk candidates and the merge only runs with topk in (512, 1024, 2048), so every 512-thread slice of a row's candidates falls in one rank: each thread key's (rank, candidate) is a compile-time constant plus the thread index, and the selector's compile key and inner loop are unchanged. The selected set is identical. Kernel level on B200 (6710 rows, DCP8, top-2048): the selector takes 839 us on the rank-major input (838 us on the row-major one), vs 1438 us for the reorder copy plus the selector. Signed-off-by: Mickael Seznec <mickael@mistral.ai>
mickaelseznec
marked this pull request as ready for review
November 2, 2026 15:15
GirasoleY
approved these changes
Nov 2, 2026
GirasoleY
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Thanks for the improvements!
|
✅ @mickaelseznec, CI is now available for this PR.
|
Contributor
|
/ci run |
|
✅ Triggered Buildkite CI #99330 for commit |
LucasWilkinson
approved these changes
Nov 2, 2026
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.
Overview
The DCP sparse-indexer top-k merge (
_merge_dcp_topk_global) all-gathers each rank's packed(score, global_id)candidates along dim 1. Since NCCL gathers along dim 0,GroupCoordinator.all_gatherthen reorders the result into[rows, world_size * topk, 2]: a full extra copy of every candidate. This PR gathers along dim 0 and lets the CuTeDSL selector read the rank-major[world_size, rows, topk, 2]buffer in place. The selected set is unchanged.With
Wranks,Rrows andK = topkcandidates per rank:Claims
Validation
tests/v1/attention/test_indexer_dcp_localize.py: 114 passed on B200. The selector test now feeds the rank-major layout and compares it with an fp64 reference over all candidates. The faked-gather merge tests follow the dim-0 gather.Downstream end-to-end benchmark (same container for both runs, 64 generated tokens, 3 iterations):
Decode was unchanged there, but that fork serves decode-sized batches through a separate symmetric-memory exchange. Upstream's decode path goes through this merge too, and is not measured here.
No public-model end-to-end run yet (e.g. DeepSeek-V3.2 or GLM-5.x with DCP).
Details
_merge_dcp_topk_global, which already requirestopk ∈ (512, 1024, 2048). So each rank contributestopkcandidates, a multiple of the 512-thread block, and every 512-wide slice of a row's candidates falls inside one rank. Each thread key's(rank, candidate)is then a compile-time constant plus the thread index: no runtime division. TheCompileKey(topk, num_candidates)and the selector's radix passes are unchanged.stable_topk_from_gathered_candidates_cutedslnow takes only the rank-major layout, asserting its shape.get_warmup_keysskips a pooled top-k (kpool indexers) that isn't a multiple of 512. The merge rejects such a top-k at runtime anyway, so warmup no longer compiles a kernel that can never run.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.