Repository navigation
[Refactor] [GB300] kimi_k31: Admit Q5 by the draft token count and run the DCP query-gather levers by default - #84
Merged
Conversation
…n the DCP query-gather levers by default Remove the four TP8 env flags. Q5 is admitted when the server runs 5 draft tokens, at any TP and DCP the verify path serves (no TP8/DCP8 tie). The packed projection runs a width with no tactic of its own in the next wider entry's single N tile (the Q5 widths of the GB300 TP8 run), and the KDA verify table gains the measured Q5 Breq 3 four-CTA row. Under DCP the query is gathered early wherever the one-shot top-k merge serves the rows, and multicast straight into the core's query rows wherever the group is one NVLink clique with multicast on every rank; elsewhere it keeps the group all-gather instead of raising. The package now reads only K31MK_DFLASH_RUNTIME. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
After #83 the package read five env variables:
K31MK_DFLASH_RUNTIMEand the four TP8 leversK31MK_VERIFY_Q5,K31MK_KDA_Q5_R3_C4,K31MK_DSA_EARLY_QAGandK31MK_DSA_DIRECT_QAG. The GB300 TP8 midcurve run (round 5: 1P3D, TP8/DCP8, Q5 DFlash, MK target verify, P90 203.53) set all four to 1. On main a TP8/DCP8 Q5 server needs those four envs, and without them the target refuses Q5.This PR removes the four flags. Q5 is admitted by the draft token count, and the DCP query-gather levers run wherever they apply. With no env, the round-5 setup gets the same lever state it ran with. The measured TP16 setup (DCP1, Q8,
--max-running-requests 1) runs the same path as before.After this PR the package reads one env variable:
K31MK_DFLASH_RUNTIME.Modifications
K31MK_VERIFY_Q5(verify_contract.py,verify_spec.py,spec.py)--speculative-num-draft-tokensis 5, like Q8: Breq 1..8, rows 5..40. Thetp == dcp == 8admission check and theK31 Q5 requires TP8/DCP8raise inBuiltK31Verifyare gone: the verify path takes the query width as a parameter (KDA verify serves 2..16 queries, MLA/DSA takeq, the DCP core takes up to 64 rows). Under DCP, Q5 joins Q8. TheQ5 enabled; Breq=..., rows=...log becomesQ%d enabledfor every width.dcp == tpand DCP 8/16 at Q5/Q8, without attention CP or prefill CP (unchanged; the index-K and latent KV are token-strided over the whole TP group). The sampled accept builds blocks 5 and 8 only (sampled.BLOCKS).sm103/k3/gemm/projection.py)tp == 8 and batch in (10, 20, 25, 30, 35)/batch == 15map becomes a rule. A batch wider than 8 rows with no tactic of its own runs the next wider entry for this device and pitch. That entry has a single N tile, andSplitKGemmpredicates the tile's extra rows. The rule reproduces the round-5 tiles exactly (10/15 -> 16, 20 -> 24, 25/30 -> 32, 35 -> 40). Exact entries still win, and the TP8 table still comes before the TP16 table and then the GB300 table. Thetpargument is gone.K31MK_KDA_Q5_R3_C4(sm103/k3/kda/verify.py)(3, 5): (0, 8, 2, 4)is a row ofSM103_TP8_VERIFY. The comment names the measurement: KDA layer 34.278 -> 31.189 us on GB300 TP8.K31MK_DSA_EARLY_QAG(dsa/verify.py)K31MK_DSA_DIRECT_QAG(dsa/verify.py)_CP_MAX_ROWSrows of 128 heads.CpSparseMlaalready bounds the heads (dcp x heads <= 128) and the rows (<= _CP_MAX_ROWS) to the buffer, so the olddcp == 8,heads == 12androws <= 64checks are not needed. Initializing under graph capture still raises: that is a call-order error, not a setup.The engaged log lines lose the env names:
early query gather engaged (...)anddirect query gather engaged (DCP8 ...). The spec name becomesKimi K3.1 packed-MXFP4 decode / TARGET_VERIFY Q5/Q8/Q16.#83 (
f185d9b) is merged (bf98dd9). This PR is based on main5aeb11a, which adds only GLM files on top of it.What changes outside round 5
--max-running-requests 1(measured)(128, 8, 4, 6), KDA(64, 8, 2, 12)), KDA keeps the default schedule, and there is no DCP. The widths built but not run (24/40/48/56 rows) now compile the 32-/64-row tile instead of the 8-row fallback.--max-running-requests> 1GPU validation
Pending. Plan: one TP8/DCP8 Q5 boot on 8 GB300, from SGLang main plus the SGLang fix that lets a draft spec it does not meet decline. Use round 5's D arguments (
--tp 8 --dcp-size 8 --dcp-comm-backend fi_a2a, trtllm DSA, DFLASH with 5 draft tokens, block verification,--enable-linear-replayssm-spec --enable-nvidia-megakernel --cuda-graph-bs-decode 1 2 3 4 5 6 7 8) and noK31MK_*env. After startup, run a short greedy probe at concurrency 1 and 8.The log must show these lines:
NVIDIA megakernel: Q5 enabled; Breq=(1, 2, 3, 4, 5, 6, 7, 8), rows=(5, 10, 15, 20, 25, 30, 35, 40);NVIDIA megakernel: active (Kimi K3.1 packed-MXFP4 decode / TARGET_VERIFY Q5/Q8/Q16: TARGET_VERIFY Breq=(1, ..., 8) Q=5; ... widths [5, 10, ..., 40];... runs the decode graphs of batch sizes [1, 2, 3, 4, 5, 6, 7, 8] (8 of 8);NVIDIA megakernel: early query gather engaged (...)andNVIDIA megakernel: direct query gather engaged (DCP8 FP8 query multicast into the 128-head layout; ...);sparse verify under DCP8 (rank N): CP sparse core + LSE merge Breq=b Q=5, andactive mode=TARGET_VERIFY Breq=b Q=5, for b in 1..8;kimi_k31_dflash2_draft_chain_nvidia does not serve this setup (tp_size 8 is not one of [16]); the draft keeps its own forward.These lines must not appear:
DFLASH rounds run on the NVIDIA megakernel(no runtime is named), anyno %s projection tactic for B..warning at rows 10-35, andthe DCP group ... the query is all-gathered on the group.Tests
bf98dd9and at this head.git greponkimi_k31finds onlyK31MK_DFLASH_RUNTIMEamongK31MK_*/SGLANG_K31_*.test/unit/test_kimi_k31_split_merge.pyadds two classes, which run the real functions from source without the GPU imports:K31VerifyQ5:K31DcpQueryGather:usable;_CP_MAX_ROWS x 128-head buffer.cf6133a(the CI pin) and main42abbd7e2c. On both, the failure set equals origin/main's line for line (26 and 177 lines). The pass count rises by 5, from the new tests: on the pin from 1243 to 1248, on main from 1149 to 1154. Rerun after rebasing onto5aeb11a, against the pin: failure set identical (26 lines), passed 1279 to 1284. On main, the K3.1 DFlash runtime tests fail on origin/main too, because SGLang droppedapply_dflash_verify_logits_adjustments.BuiltK31Verify.__init__. That constructor needs the GPU weight build, so no CPU test reaches it; the round-5 GPU boot runs at TP8 and does not catch it either.pre-commit runpasses on the changed files.🤖 Generated with Claude Code