Repository navigation
[Feat] deepseek_v41: Score SGLang's page8 index-K pool in K2i - #80
Open
ChangLi811 wants to merge 1 commit into
Open
ChangLi811 wants to merge 1 commit into
ChangLi811 wants to merge 1 commit into
Conversation
SGLANG_HIP_DSV41_INDEX_K_PAGE8=1 keeps the ratio-1 index-K pool in aiter's row-group page-8 byte layout (pack_kv_cache) with unchanged page size and shapes, when aiter ships the row-group kernel. Its 8-row pages are K2i's virtual pages (8 x the 64-row page + the sub page), so the page tables, the candidate table and the selection's map back to slots are unchanged; only the bytes of a page differ. The spec refused the setting since K2i read such a pool as page-64. - score_fp4._keys reads a page8 plane as aiter's page-8 walk does: a lane's four key tiles 128 B apart and their scales one dword. The page-64 branch is unchanged. - build_k2i(page8) builds that variant; each layer's plane carries its pool's low_ratio_index_k_page8, which picks the build. Startup precompiles the page8 variant for the ratio-1 index sources when the env is set. - SPEC no longer requires SGLANG_HIP_DSV41_INDEX_K_PAGE8=False; the README's PD note names it among the layout both peers must share, as SGLang's PD handshake does not compare it. test_deepseek_v41_k2i.py runs each case on a page8 plane too (the same keys packed by aiter's pack_kv_cache): FULL logits bit for bit with the page-64 plane's and within k2i.logits.rel of SGLang's and fp64, a REINDEX consumer's top-512 as a set equal to SGLang's topk_within_candidate_blocks_page8, the two-level pipeline against SGLang's, and a graph replay against eager. The README's V4.1 usage note no longer says decode graph capture fails without AITER_BF16_FP8_MOE_BOUND=0: on the current image (aiter 285579b62) SGLang's decode starts and captures its graphs without it. The command keeps the variable, as the serving tests do.
ChangLi811
force-pushed
the
dsv41-index-k-page8
branch
from
October 29, 2026 15:26
6d0bd3b to
1c20400
Compare
This was referenced Oct 29, 2026
ChangLi811
marked this pull request as ready for review
October 29, 2026 15:27
ChangLi811
requested review from
HaiShaw,
alexnails,
kevin-mii and
kkHuang-amd
as code owners
October 29, 2026 15:27
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.
Motivation
SGLANG_HIP_DSV41_INDEX_K_PAGE8=1(sgl-project/sglang#44006) keeps the ratio-1 index-K pool in aiter's row-group page-8 byte layout, which SGLang's own indexer uses for prefill and wide decode. The monokernels require it off, so a server cannot have both; it is a server-wide switch, and on PD both peers must share it.Modifications
score_fp4._keysreads a page8 plane as aiter's page-8 walk does; the page-64 branch is unchanged.build_k2i(page8)builds that variant; each layer's plane carries its pool'slow_ratio_index_k_page8, which picks the build (aiter without the row-group kernel keeps page-64).test_deepseek_v41_k2i.pyruns each case on a page8 plane too (the same keys packed by aiter'spack_kv_cache).AITER_BF16_FP8_MOE_BOUND=0; on the current image (aiter 285579b62) SGLang's decode starts and captures without it. The command keeps the variable, as the serving tests do.Accuracy Tests
K2i kernel tests (24): FULL logits on a page8 plane bit for bit with the page-64 plane's and within
k2i.logits.relof SGLang's and fp64; a REINDEX consumer's top-512 as a set equal to SGLang'stopk_within_candidate_blocks_page8; the two-level pipeline and a graph replay.End to end: DeepSeek-V4.1-Flash, one MI355X node,
rocm/sgl-dev:v0.5.22-rocm10-mi35x-20261025, SGLangaa6e51982(a local merge of #43465, #44730, #44031 and #46036),PAGE8=1with aiter's row-group kernel, TP4 + prefill CP4 + DSpark block 5; GSM8K: sgl-eval, 1319 questions, max tokens 4096; on and off on fresh servers:TP2 + CP2 + FP8 unified: 0.965 on, 0.963 off. With
PAGE8=0the same server scores 0.964 (the page-64 path unchanged).GSM8K above runs 64 threads, so most verify steps are wider than 8 requests and take SGLang's path. With AgentX's c1 recipe (
max-running-requests 2, its 19 environment variables,SGLANG_HIP_DSV41_INDEX_K_PAGE8=1), every verify step runs on the monokernels; on #70 (now inmain) plus this PR, #78 and #79 (DeepSeek-V4.1-Flash-1017 weights, fresh servers):(GSM8K / DSpark accept length. TP4 "off" accept lengths are left out: with the recipe's
--disable-shared-experts-fusion, SGLang's own path accepts less at batch 1–3, which--enforce-shared-experts-fusion, as the README uses, restores.)PD
MoRI PD (enabled by #70) over two MI355X nodes: P = TP4 + prefill CP4 + DSpark without the monokernels, D = TP4 + DSpark;
SGLANG_HIP_DSV41_INDEX_K_PAGE8=1on both peers; P and D started afresh for every row; GSM8K through the PD router.At 8 threads every verify step of the D runs on the monokernels when they are on. Greedy prompts (short, 15k–100k) and 50 long needles pass on every row; no GPU faults on either peer.
Speed Tests and Profiling
c1 TPOT on the FP8 unified server above: 1.17 ms on, 1.78 ms off.
Checklist
pre-commit run --all-filespasses (ruff, isort, codespell).test/cover the change.aa6e51982:pytest test/unitpasses 262, as onmain, including thedeepseek_v41contract, which also passes against SGLang main (c6c753395). The 7 failures and 3 collection errors (GLM-5.3, MiniMax and DeepSeek-V4-Pro tests) are the same onmainand unrelated to this PR. The K2i change is covered bytest_deepseek_v41_k2i.pyon the GPU (above)..github/CODEOWNERSthat names its owner. (No new model.)