Skip to content

[Perf] dsv4: Score the V4.1 index logits in bf16 on SM100 - #45880

Merged
hnyls2002 merged 5 commits into
mainfrom
lsyin/dsv41-prefill-index-weights-bf16
Oct 22, 2026
Merged

hnyls2002 merged 5 commits into
mainfrom
lsyin/dsv41-prefill-index-weights-bf16

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
  • On SM100, the DeepSeek-V4.1 ratio-1/2 index layers now pass bf16 head weights and request bf16 logits from DeepGEMM's fp8_fp4_mqa_logits / fp8_fp4_paged_mqa_logits, so the kernels reduce in bf16. This is the configuration the reference kernels use on SM100: they take bf16 head weights only and emit bf16 logits there. The sparse candidate path already used bf16 weights and logits.
  • The dtype is decided once (index_logits_dtype() / index_weights_dtype() in index_logits.py), resolved on first use so importing the module does not touch CUDA.
  • SGLANG_OPT_DSV41_BF16_INDEX_LOGITS now defaults to unset: unset means bf16 on SM100 and fp32 elsewhere; setting it keeps working as an explicit override (true: bf16 logits, with bf16 head weights on SM100 only; false: the fp32 path everywhere). Recipes that set it to 1 are unaffected except that SM100 now also passes bf16 head weights.

No change on other architectures (SM90 keeps the torch indexer; SM120 keeps fp32 weights and logits), or anywhere the flag is set to false.

Verification: a dispatch check over SM100 / non-SM100 with the flag unset, true and false gives the expected head-weight and logits dtypes on both the flat and paged calls; on SM100 with no env set the branch resolves to bf16 logits and bf16 head weights at runtime; the existing V4.1 indexer unit tests pass.

  • Flat prefill logits tiles are now sized as fp32 logits whatever the logits dtype (flat_index_logits_rows_per_tile), as its docstring intended: with bf16 logits the old formula doubled the rows per tile, so the per-row selection scratch that grows with the tile pushed the scoring peak past the fp32 path's budget. fp32 tiling is unchanged. The SM100 prefill indexer tests now score their reference in the indexer's dtypes and accept block or pick differences only where bf16 scores tie at the selection floor; they pass with bf16 (the SM100 default) and with SGLANG_OPT_DSV41_BF16_INDEX_LOGITS=0.

CI States

Latest PR Test (Base): 🚫 Run #39857158297
Latest PR Test (Extra): ❌ Run #39857158423
Latest PR Test (AMD ROCm 10): 🚫 Run #39857158175

@hnyls2002 hnyls2002 changed the title [Perf] dsv4: Pass bf16 head weights to the V4.1 prefill index logits [Perf] dsv4: Score the V4.1 index logits in bf16 on SM100 Oct 22, 2026
@hnyls2002

hnyls2002 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_dsv41_prefill_sparse_indexer.py test_dense_prefill_indexer.py
(3 tries)

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (2 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_fp4_indexer.py
cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 4-gpu-b200 (3 tests): ❌ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_dsv41_prefill_sparse_indexer.py
cd test/ && python3 registered/kernels/ops/attention/test_dense_prefill_indexer.py
cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 2-gpu-gb300 (2 tests): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_dp2ep2.py
cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_tp2ep2.py

🚀 ubuntu-latest (2 tests): ✅ View workflow run

cd test/ && python3 registered/unit/layers/test_dsv41_candidate_blocks.py
cd test/ && python3 registered/unit/layers/test_dsv4_nonpaged_indexer.py

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (2 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_fp4_indexer.py
cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 4-gpu-b200 (3 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_dsv41_prefill_sparse_indexer.py
cd test/ && python3 registered/kernels/ops/attention/test_dense_prefill_indexer.py
cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 2-gpu-gb300 (2 tests): ❌ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_dp2ep2.py
cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_tp2ep2.py

🚀 ubuntu-latest (2 tests): ✅ View workflow run

cd test/ && python3 registered/unit/layers/test_dsv41_candidate_blocks.py
cd test/ && python3 registered/unit/layers/test_dsv4_nonpaged_indexer.py

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🚀 4-gpu-b200 (2 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_dsv41_prefill_sparse_indexer.py
cd test/ && python3 registered/kernels/ops/attention/test_dense_prefill_indexer.py

@hnyls2002
hnyls2002 merged commit 840a631 into main Oct 22, 2026
84 of 133 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/dsv41-prefill-index-weights-bf16 branch October 22, 2026 21:29
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant