Repository navigation
[DeepSeek-V4.1] DeepSelect cluster top-k for long rows and bf16 index logits - #44051
Merged
Merged
Conversation
… logits DeepSelect cluster kernel (bf16, max_topk 1024): - Rewrite the cluster kernel: contiguous per-CTA slices streamed through a bulk-copy ring, a cluster-wide two-pass radix pivot over pushed histograms, and output placement by DSMEM atomics (unsorted) or a per-CTA bitmap prefix (sorted_index). Rows up to 32K per CTA stay in registers. - Cluster sizes 16/8/4/3/2 picked per row count from an occupancy probe; modules for a call signature are compiled in parallel (new jit utils parallel_compile). - A NaN row without abort now selects index 0 in every slot instead of a 0x3F3F3F3F sentinel; return_value / abort_when_nan_found default to False. DeepSeek-V4.1 indexer: - SGLANG_OPT_DSV41_BF16_INDEX_LOGITS (default off): DeepGEMM fp4 MQA logits in bf16, top-k through DeepSelect, amax8_varlen on bf16 scores (templated on input/output dtype). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
DarkSharpness
requested review from
BBuf,
Fridge003,
HaiShaw,
HydraQYH,
Qiaolin-Yu,
celve,
hebiao064,
ispobock,
merrymercy and
yuan-luo
as code owners
October 13, 2026 12:02
DarkSharpness
force-pushed
the
deepselect-cluster-select
branch
2 times, most recently
from
October 13, 2026 12:07
0060230 to
362978e
Compare
17 of 56 tasks
BBuf
approved these changes
Oct 14, 2026
yuyu5333
pushed a commit
to yuyu5333/sglang-bytedance
that referenced
this pull request
Oct 15, 2026
… logits (sgl-project#44051) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Xiaoyu Zhang <1182563586@qq.com>
12 tasks done
zcnrex
added a commit
to zcnrex/sglang
that referenced
this pull request
Oct 23, 2026
Resolve conflicts with bf16 V4.1 index logits (sgl-project#44051, sgl-project#45880), grouped verify rows (sgl-project#45251), the two-level-only prefill graph (sgl-project#45783) and KV-shard index-K writes (sgl-project#44280): the adapter takes a logits_dtype and maps [batch, next_n] paged queries and schedules to grouped varlen rows on SM100. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zou3519
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Oct 29, 2026
Cherry-picks the python/sglang/kernels/jit/utils part of upstream sgl-project/sglang#44051 (9d68ecc) ahead of the next upstream sync, so callers can import parallel_compile from sglang.kernels.jit.utils.
Merged
2 of 3 tasks
zou3519
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Oct 29, 2026
Cherry-picks the python/sglang/kernels/jit/utils part of upstream sgl-project/sglang#44051 (9d68ecc) ahead of the next upstream sync, so callers can import parallel_compile from sglang.kernels.jit.utils.
ShivanshuPurohit
pushed a commit
to latent-to/sglang
that referenced
this pull request
Nov 1, 2026
…1 (upstream sgl-project#47748 @ b411cc3, production files) SGLANG_ENABLE_DETERMINISTIC_SPARSE_TOPK (default False) keeps DeepSelect on its single-CTA kernel (the cluster kernels merge CTA picks in arrival order, so a row's order and, on bf16 ties, its set vary between runs) and routes the DSv4 sparse top-k entry points in dsv4/topk.py through it or an exact torch selection. Nothing changes unless the variable is set. This covers the bf16 index-logit path the arena takes on SM103 (SGLANG_OPT_DSV41_BF16_INDEX_LOGITS=1 sends the indexer's paged and ragged top-k to DeepSelect since upstream sgl-project#44051), which the arena's own top-k pin (topk_v2 / topk_bf16_small) does not touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CmhYp5Hj8PzMk8jC4Myhjz
Contributor
|
@DarkSharpness we are supporting epic long context with our brand new sparse attention , where top 2048 is very useful ! Let me explain, we will 2048 chunks, with partials scores each chunk corresponding to 64~128 elements, where we can select total 1 billion context efficiently. |
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.
Speeds up DeepSelect top-k for small-batch, long-context decode (the DeepSeek-V4.1 indexer case) and lets the V4.1 index layers run on bf16 scores.
DeepSelect cluster kernel (bf16, topk <= 1024)
sorted_index).enddecides everything else inside the kernel.parallel_compilein the JIT utils).0x3F3F3F3Fsentinel to slot 0;return_valueandabort_when_nan_founddefault to False.DeepSeek-V4.1 indexer
SGLANG_OPT_DSV41_BF16_INDEX_LOGITS(default off): the DeepGEMM fp4 MQA logits are emitted in bf16 (the reference ranks bf16 scores), their top-k goes through DeepSelect, andamax8_varlenreads bf16 scores (now templated on input/output dtype).Kernel latency (B200, cold L2, width 1M, topk 1024, us at
end128K / 1M). Before, the cluster kernel only ran for rows <= 6 at width >= 512K; every other case took one CTA per row.Validation
test_deep_select.py, plus randomized checks of every cluster size againsttorch.topk(ties, constants, -inf, +-0, NaN, ascending/descending rows, raggedend, offsets, int64, page transform, values,sorted_index).🤖 Generated with Claude Code
CI States
Latest PR Test (Base): 🚫 Run #38555200909
Latest PR Test (Extra): ❌ Run #38555200886
Latest PR Test (AMD ROCm 10): ❌ Run #38555200764