Skip to content

[Perf] dsv4: Map V4.1 prefill index selections to pool slots in one kernel - #45938

Merged
hnyls2002 merged 1 commit into
mainfrom
lsyin/dsv4-index-page-glue
Oct 23, 2026
Merged

hnyls2002 merged 1 commit into
mainfrom
lsyin/dsv4-index-page-glue

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator
  • After every DeepGEMM prefill top-k, DeepGEMMPrefillData.write_page_indices turned the request-local selections into index-K pool slots with torch: an add, a clamp, an int64 gather, a compare, a where and an int32 copy into the output, each a full pass over the [rows, topk] selection.
  • flat_selection_slots does the same mapping in one Triton kernel that reads each selection once and writes the int32 slot, or -1 for an unselected entry.

Output is bitwise identical to before.

Verification:

  • The kernel's output matches the torch mapping bit for bit for one and many requests per batch and from 300 to 65536 rows, on B300 and GB300.
  • A micro benchmark on V4.1-Flash shapes shows it several times faster than the torch mapping on B300 and GB300.

CI States

Latest PR Test (Base): 🚫 Run #39887362480
Latest PR Test (Extra): ❌ Run #39887362607
Latest PR Test (AMD ROCm 10): ⏳ Run #39887362454

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_dense_prefill_indexer.py test_dsv41_prefill_sparse_indexer.py test_deepseek_v41_flash_gb300_tp2ep2.py

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

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

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

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

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 23, 2026
@hnyls2002
hnyls2002 merged commit c4fa35b into main Oct 23, 2026
202 of 285 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/dsv4-index-page-glue branch October 23, 2026 02:50
chaohu2000 added a commit to flytiger-eco/sglang-for-sail that referenced this pull request Oct 27, 2026
…ernel (sgl-project#45938)

(cherry picked from commit 7507c69a811a1960bb37a49dd48f34994dd2d34c)
Juhyun-Kim-Memphis added a commit to vessl-ai/sglang that referenced this pull request Oct 28, 2026
…he torch prefill indexer (adapted from sgl-project#45794)

Adaptation of upstream sgl-project#45794 (65f19fc) to this branch,
which lacks the later index-plan refactors (sgl-project#45251, sgl-project#45577, sgl-project#45938), so the
upstream patch does not apply as is.

- Under prefill CP the caller passes req_rows=None with rank-local rows; rebuild
  the row-to-request map from req_pool_indices and rows_per_request instead of
  asserting. Without this, prefill CP on SM90 (torch indexer) dies at the first
  prefill.
- Pad the dequantized index K to a multiple of 64 rows when it is BF16 on CUDA
  and lc >= 1024, size query chunks on the padded width, and slice scores back
  to lc before masking and top-k. Here index_k comes from req_to_token slots
  instead of upstream's k_slots. The padding is on the key axis only, so the
  #88 row shard (which splits query rows) and its max-merge are unchanged.
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