Repository navigation
[Refactor] [GB300] kimi_k31: Settle the seven scoped levers on the GB300 results - #83
Merged
Merged
Conversation
…300 results #80 left seven levers on best_default pending GPU data. With the results in, none of them stays scoped, so kimi_k31/k3/default_scope.py goes too: - K31MK_MLA_VALUE_EARLY_TRIGGER: the sparse verify MlaValue always releases the o-proj at entry. The dense MlaValue keeps its late trigger. - K31MK_AUX_SIDE_STREAM: the DFlash capture layers' aux mixture always runs on the side stream; ClusterAttnRes no longer launches AuxMixture itself. - K31MK_EXPERTS_COOPERATIVE: the routed experts always launch without the cooperative attribute. check_residency still requires a co-resident grid. - SGLANG_K31_DRAFT_MK: the draft chain (with M1b) always builds where the draft spec admits it (TP16, 8-row blocks); max_rows is always 8. The aux and head follow K31MK_DFLASH_RUNTIME alone. - K31MK_OPROJ_NORM_FOLD: the o-proj consumers always fold the final-norm exchange when there are saved blocks. The fold is per token inside the 7-CTA cluster, so the TP16 condition was not a kernel limit and is gone, with the consumer's separate final-norm exchange. - K31MK_MLAQ_AFTER_SCORING: deleted with its reorder path (no gain). - K31MK_INDEX_SPLIT_MIN: the split threshold is the measured crossover, 320000. DCP and an unusable merge still decline; the explicit-env raises are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
GPU check of this PR's head (
All within the same-node boot range (P90 445.74 to 451.80). |
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
#80 cut the package's env flags from 44 to 12 and left seven levers scoped:
best_default(inkimi_k31/k3/default_scope.py) gave the measured value inside the GB300 BEST configuration (TP16, no DCP, 8 draft tokens,--max-running-requests 1) and the older default everywhere else, pending GPU data. The GB300 runs are done. This PR settles all seven, so none of them reads an env variable or depends on the configuration any more, anddefault_scope.pygoes with them.Inside the measured configuration every lever keeps its measured value, so the measured path is unchanged: 1 / 1 / 0 / on / on / off / 320000. Outside it (
--max-running-requests> 1, DCP, TP8) the levers now take that same value. A condition stays only where it is a real kernel, layout or math limit.After this PR the package reads five env variables:
K31MK_DFLASH_RUNTIME, plus the four TP8 leversK31MK_VERIFY_Q5,K31MK_KDA_Q5_R3_C4,K31MK_DSA_EARLY_QAGandK31MK_DSA_DIRECT_QAG. This PR does not touch the TP8 levers.Modifications
K31MK_MLA_VALUE_EARLY_TRIGGER(dsa/verify.py)MlaValuealways releases the o-proj at entry. This holds for DCP1 (sparse_values) and DCP (cp_values). It is bitwise, because the o-proj still waits forMlaValue's grid._padded_valueloses itsearlyargument. The denseMlaValue(mla/prepared.py) keeps its late trigger.K31MK_AUX_SIDE_STREAM(verify_executor.py,attn_res/)bind_aux()takes no arguments.ClusterAttnReslosesaux_launchand its in-kernelAuxMixturelaunch, because nothing else used the main-stream variant.nb == 0) the kernel stores the aux row itself, because there is no mixture to run.K31MK_EXPERTS_COOPERATIVE(moe/experts.py)launch_optionsandcooperative()are deleted). The "B9+ grids are untested" caveat was a tested-range gate, so it is dropped too.check_residencystays: the CTAs wait on one another, so the whole grid must be co-resident. With that check, a non-cooperative grid cannot deadlock.SGLANG_K31_DRAFT_MK(draft/serving.py)max_rowsis always 8. The aux (2b) and the head (2a) followK31MK_DFLASH_RUNTIMEalone. WithK31MK_DFLASH_RUNTIME=0the chain still builds, but it builds no aux and no head, and the target names no runtime, so no sampled accept is built either. At--max-running-requests> 1 the runtime hands back the rounds the head (bs 1) does not serve.tp_sizes={16}and the 8-row block (ROWS) stay where they are. A draft KV pool that is not plain FP8 MLA keeps M1a.K31MK_OPROJ_NORM_FOLD(oproj/)tp == 16condition was not a limit: the fold is per token inside the 7-CTA cluster, and the TP-wide part is only the mailbox poll. It is gone, together withnorm_fold(), thefoldcompile key and the consumer's separate final-norm exchange (norm_post,norm_total, the third barrier).nb == 0, which includes the draft'sOprojConsumer(0)) have no second exchange to fold.K31MK_MLAQ_AFTER_SCORING(dsa/verify.py)_query_after_scoring, the_scoredevent andVerifySelection.run'sscoredargument.K31MK_INDEX_SPLIT_MIN(dsa/split.py,dsa/verify.py)SPLIT_MIN = 320000, the measured crossover. The comment names the measurement: 16-rank merge unit B1 on GB300, +5.8 us/layer at 134K, ~0 at 338K, -13 us/layer at 600K; prepare-early moved the crossover to 320000. The raises for an explicitly set env under DCP or without a merge are gone.kimi_k31/k3/default_scope.pyis deleted, because nothing uses it any more.docs/models/kimi_k31.mddrops theSGLANG_K31_DRAFT_MKmention and the scope paragraph. The engagement log lines of the four former opt-ins are removed.What changes at TP8
At TP8,
best_defaultreturned the older default, so making a lever unconditional changes the TP8 path. No TP8 gate is added. For each lever:MLA_VALUE_EARLY_TRIGGERcp_valuesand TP8 DCP1 usessparse_values. The midcurve R5 (GB300 TP8/DCP8/Q5) ran with it set. Bitwise.AUX_SIDE_STREAMEXPERTS_COOPERATIVEOPROJ_NORM_FOLDOprojConsumer(producer + consumer) at every batch, and the fold is TP-generic. This changes the numerics and has not been measured at TP8. Before this PR TP8 could not fold even with the env set, so R5 did not fold.INDEX_SPLIT_MINDcpTopKMerge.createadmits 8 ranks, and the split-merge kernel is built for 8 or 16 ranks. A TP8 DCP1 step at a context of 320000 or more would arm the 8-rank split on a crossover that was measured with 16 ranks.SGLANG_K31_DRAFT_MKtp_size 8 is not one of [16]), as before.MLAQ_AFTER_SCORINGGPU validation
These are GB300 TP16 runs on the #80 head (
c5754bf, now mega main) from the GPU check of the scoped levers. Each arm ran one boot.MLA_VALUE_EARLY_TRIGGER=1,AUX_SIDE_STREAM=1andEXPERTS_COOPERATIVE=0on top of A0h): greedy 24/24, identical to A0h. The bs1 round is 7.53 ms (A0h 7.65, A1 7.41). All of bs 1-8 run in graphs. (A1 also hadSGLANG_K31_DRAFT_MK=1and scored 14/24 greedy. The mismatch came from the draft MK combined with the simulated real-draft-token, which is a measurement-only setting.)DRAFT_MKoff vs on): accuracy 0.990 / 0.990, invalid 0.005 / 0.005, 72.78 s / 72.66 s, 276.0 / 276.4 tok/s.aa0d80eOPROJ_NORM_FOLD=0MLAQ_AFTER_SCORING=1The boot noise range is P90 447.49-451.80, over the same-node G0/G3 boots. D1h (fold off) is slightly worse on every column but within that noise. The fold stays on where the kernel supports it. D2h shows P90 +1.3 %, but its round median is 0.08 ms slower; both are within the noise, so there is no gain and the lever is deleted.
INDEX_SPLIT_MINoff / on): P50 402.05 / 424.67, P90 248.62 / 281.38. The bucket below 320K moved the most, and this lever does not act on that bucket, so the difference is noise. The per-bs round medians show the same. Both arms handed every round back to the stock round. The result is inconclusive, so the split stays at its measured crossover, 320000.This PR did not run on GPU. It makes the measured values unconditional; inside the measured configuration they are the same as on main. The only kernel binaries that change on the measured path are the o-proj consumer and the fused and draft kernels built on it. Their shared memory loses the unused separate final-norm buffers and one never-armed barrier, and the computation they run is unchanged.
Tests
e9e01feand at this head. Inside the BEST scope the values are identical: 12 values compared, 0 differences. On this head no lever depends on the scope any more, TP8 included. WithK31MK_DFLASH_RUNTIME=0the target names no runtime, the chain builds with M1b andmax_rows8, and it builds no aux and no head. The only env names the package reads areK31MK_DFLASH_RUNTIME,K31MK_DSA_DIRECT_QAG,K31MK_DSA_EARLY_QAG,K31MK_KDA_Q5_R3_C4andK31MK_VERIFY_Q5. Every kimi_k31 module imports.test/unit/test_kimi_k31_split_merge.py:SplitArmingis new. It pins the 320000 crossover and runs_build_split: armed at 320000 for each verify width, with one merge sized for the widest; declined below the crossover, under DCP, and without a usable merge. TheK31DFlashRuntimeNamingtest (theK31MK_DFLASH_RUNTIME=0path) passes with the GPU packages stubbed.cf6133a(CI pin),a034bb5791and mainb40fc17961: the failure sets equal origin/main's on all three. The count changes come from the tests themselves:test_contracthas two fewer parameters becausedefault_scope.py(which hadSGLANG_READS) is deleted, andSplitArmingadds 2 tests and 3 subtests. Onb40fc17961the K3.1 DFlash runtime tests fail on origin/main too, because SGLang main droppeddflash_utils.apply_dflash_verify_logits_adjustments; ona034bb5791they pass (test_kimi_k31_split_merge: 16 passed, 25 subtests).K31MK_DFLASH_RUNTIME=0, the draft without M1b, the head or the aux built underK31MK_DFLASH_RUNTIME=0, the fold disabled, the late MlaValue trigger, and the aux mixture back on the main stream.pre-commit run --all-filespasses.🤖 Generated with Claude Code