Repository navigation
Conversation
…s through step_penalties SGLang #52054 bumped MEGAKERNEL_API_VERSION from 2 to 3: VerifySamplingView replaces additive_penalties / scaling_penalties (and the acc_* properties) with step_penalties, a VerifyPenaltiesView whose apply_verify applies each verify row's own penalties, and SamplingBatchInfo no longer has the acc_* penalty tensors. Every spec here still declared version 2, so --enable-nvidia-megakernel refused every model at argument resolution on SGLang main. - Every spec declares version 3: deepseek_v41, qwen3_5, glm5_3, muse_spark, kimi_k3 and kimi_k31 (the drafts take their target's). kimi_k31/k3 no longer derives its version from the host module. - The penalties consumers read step_penalties, as SGLang's own verify does: the lifted eagle_sample (spec_step) calls step_penalties.apply_verify with the candidates and the tree before any other adjustment; the step-graph gate (spec_step), the fused GLM verify tail (glm5_3/sm107) and the top-k verify sampler (muse_spark) hand back a step with penalties. Each lists step_penalties in SGLANG_READS. - CI pins SGLang 2544c9ac34, which has version 3. Tests: the kimi_k3 contract asserts version 3; test_plugin resolves each registered spec at the installed SGLang's API version (one case per architecture); test_glm5_3_sm107 covers the verify tail and step-graph gates and the lifted eagle_sample's apply_verify call. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 23, 2026
Merged
7 tasks done
weireweire
added a commit
to weireweire/sgl-nvidia-mega
that referenced
this pull request
Nov 24, 2026
The move of every spec to megakernel API version 3, together with the unit tests' SGLang pin, is sgl-project#85. Declaring version 3 for one model here fails the unit tests on the pinned SGLang, which requires version 2.
YAMY1234
approved these changes
Nov 24, 2026
This was referenced Nov 24, 2026
weireweire
added a commit
to SemiAnalysisAI/InferenceX
that referenced
this pull request
Nov 25, 2026
…0-03fde9cc Root cause: nightly-dev-cu13-20261122-e96e9675 includes sgl-project/sglang#52054, which raised MEGAKERNEL_API_VERSION to 3 while its bundled sgl-nvidia-mega plugin still exposes API version 2 (sgl-project/sgl-nvidia-mega#85 is still open). All four agg points enable --enable-nvidia-megakernel and fail at startup on that image, whereas disagg does not enable the megakernel and stays on 20261122. Fix: roll dsv41flash-fp4-gb300-dynamo-sglang-agentic-agg back to nightly-dev-cu13-20261120-03fde9cc (Dynamo 1.8.0.dev20261119, SGLang 0.0.0.dev1+g03fde9cc3) in nvidia-master.yaml, agg-variants.yaml, and the PR perf-changelog.yaml entry, leaving the disagg key on 20261122-e96e9675. Validation: all four agg points previously succeeded on 20261120-03fde9cc in the PR sweep; local changelog, curve, and recipe generation checks pass.
This was referenced Nov 26, 2026
Collaborator
Author
|
Superseded by #81, which carries this change on main. |
3 of 4 tasks
Oasis-Git
pushed a commit
that referenced
this pull request
Nov 30, 2026
…st or KV layout setting (#94) * deepseek_v41: Let slot moe_balanced deal over --ep-num-redundant-experts 384 Root cause: with SGLang's --ep-num-redundant-experts 384 and the trivial placement each EP rank already holds every routed expert in router-id order, but the spec refused the flag and the routed pair took the layer's slot count (768) as the router's expert count. Fix: admit 384 redundant experts; the router's expert count is the slots less the redundant ones; under moe_balanced with that layout the pair takes the rank's storage whole (offset 0) and deals on the EP rank. Validation: served at attention TP8 + MoE TP4 x EP2 on GB300 at one request: step time and weights match SGLang's balanced expert storage once the four FlashInfer tactics of the 384-local-expert MoE shape are pinned. Numerics change (the deal), as slot moe_balanced already is. * deepseek_v41: Turn the batch-1 slots and KV layout on by default Root cause: serving DeepSeek-V4.1 at one request, attention TP8 + MoE TP4 x EP2, at its best needed a hand-written SGLANG_NVIDIA_MEGAKERNEL_SLOTS list (the shipped slots plus eight opt-in ones) and SGLANG_DSV4_KV_LAYOUT=v41_new for slot attn_core_lean. A default start ran none of those. Fix: - Default-on slots: attn_wo_a_fp8, attn_index_weights_bf16, attn_index_q_first, attn_cluster_merge, draft_stage0_first, draft_embed and draft_final_collapse (bitwise; TP8_DEFAULT_SLOTS: a default start takes them at attention TP8 only; at TP4 the group measured slower and changed seeded T=1 outputs, and listed they still run there), and attn_core_lean (numerics change; a default start takes it only on SGLang's v41_new KV layout). runtime.default_takes holds the rule; the attention and draft builds read it, and the startup summary lists a default slot left off as before. draft_embed is left off, not refused, when the draft has its own vocabulary. - serving.py: a resolution step SGLang runs ahead of handle_nvidia_megakernel (register_resolution_hook, registered by plugin.register). With the megakernel on, DeepSeek-V4.1 at --tp 8 --ep-size 2, --max-running-requests 1 and no PD disaggregation, it sets SGLANG_DSV4_KV_LAYOUT=v41_new when the user left it unset and attn_core_lean is requested, and logs it. Any other shape keeps SGLang's V4 layout. - The redundant experts stay the user's choice: on that configuration without --ep-num-redundant-experts the step logs that moe_balanced is idle and that the flag turns it on at about 47 GB more weights per GPU. - SGLANG_NVIDIA_MEGAKERNEL_SLOTS still replaces the list; hop_final_collapse, lm_head_pinned_tactic, draft_lm_head_mxfp8, hop_b_cap16 and hop_b_quad_trigger stay opt-in. - docs/models/deepseek_v41.md: the default and opt-in tables, and the one-request launch without a slot list. Numerics change: attn_core_lean (v41_new KV encodings, its own split and merge order) now runs by default in one-request TP8 serving; it was already a declared numerics change. Validation: unit tests (test_deepseek_v41_serving.py, default-slot rules) on CPU. Served at one request on two GB300 trays: with no slot list and --ep-num-redundant-experts 384 the startup summaries, KV pool and outputs (T=0, seeded T=1, finish reasons) equal the hand-written configuration's and the step time is unchanged within 2 us; without the flag the layout is chosen and moe_balanced logs idle; two requests keep the V4 layout. * deepseek_v41: Declare SGLang megakernel API version 3 Root cause: SGLang main #52054 raised MEGAKERNEL_API_VERSION from 2 to 3 (VerifySamplingView replaces additive_penalties / scaling_penalties with step_penalties). SGLang refuses a spec whose api_version differs, so the DeepSeek-V4.1 spec at version 2 cannot start on SGLang main. Fix: the DeepSeek-V4.1 package reads none of the removed fields, so only the declared version moves; the draft spec follows spec.API_VERSION. Validation: served on GB300 on SGLang main past #52054 with outputs identical to version 2 on the SGLang before it. SGLang before #52054 refuses this spec. * deepseek_v41: Keep megakernel API version 2 in this change The move of every spec to megakernel API version 3, together with the unit tests' SGLang pin, is #85. Declaring version 3 for one model here fails the unit tests on the pinned SGLang, which requires version 2. --------- Co-authored-by: weireweire <[email protected]> Co-authored-by: Yangmin Li <[email protected]>
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
sgl-project/sglang#52054 (
e96e967570, "Apply exact per-row sampling penalties in verify") bumpedMEGAKERNEL_API_VERSIONinpython/sglang/kernels/plugin_kernels/nvidia/spec.pyfrom 2 to 3. In v3,VerifySamplingViewdropsadditive_penalties,scaling_penaltiesand theacc_additive_penalties/acc_scaling_penaltiesproperties. It carriesstep_penaltiesinstead: aVerifyPenaltiesViewwhoseapply_verify(logits, draft_tokens, next_child=None, next_sibling=None)applies each verify row's own penalties in place.SamplingBatchInfolost theacc_*tensors as well.Every spec in this package still declares version 2. On SGLang main,
--enable-nvidia-megakerneltherefore refuses every model at argument resolution, for example on GB300 with kimi_k31:CI did not catch this because it pins SGLang
cf6133a, which is still at v2.Modifications
The megakernel plugin contract changes between
cf6133aand SGLang main2544c9ac34, and how each lands here:e96e967570VerifySamplingView.step_penalties(VerifyPenaltiesView) replaces the additive/scaling penalty tensorsspec_step,glm5_3/sm107,muse_spark(this PR)Stepprefill/draft modes,SupportsPrefillBody,RecurrentCommitIO,SupportsStateSlotReset,SupportsRecurrentCommit,SupportsDecodeTensorEntry,SupportsDFlashRuntime,ENTRIES += draft_step_fold,MegakernelSpec.{tensor_verify_binding_kind, tensor_verify_build, binding, prefill_graph},EAGLE_DRAFT_CAPTURE_CHECK,FLAG_SETS_ENV. The K3.1 draft protocols that #49411 added were removed again in #51676.kimi_k31,qwen3_5,glm5_36321f714ddbinding.pydrops the K3 Day-0 fields (aux_hidden_states,tokens_per_request,verify_scratch_indices,intermediate_conv_window,intermediate_ssm) and changes theMlaPoolView/KdaStepView/MlaStepView/KdaStateViewsignatureskimi_k3(not in this PR)2544c9ac34kimi_k31draft at TP8 (no change needed)Changes in this PR:
deepseek_v41,qwen3_5,glm5_3,muse_sparkandkimi_k3declare 3. The drafts (deepseek_v41/draft.py,qwen3_5/draft,glm5_3/draft.py,kimi_k31/draft/serving.py) take their target's version.kimi_k31/k3/spec.pyused to derive its version from the host (2 if hasattr(_host_spec, "ENTRIES") else 1). It now declares 3, and the host import goes away.step_penalties, the way SGLang's own verify does:spec_step/lifted.pyeagle_samplecallsstep_penalties.apply_verify(logits, candidates, retrieve_next_token, retrieve_next_sibling)where it used to add the repeated per-request tensors. This is the same hunk #52054 applied to SGLang'seagle_sample:candidatesmoves up, andapply_scaling_penaltiesis no longer imported.step_penalties is not Noneto hand a step with penalties back to SGLang:spec_step/runner.py(the step-graph gate);glm5_3/sm107/verify_tail.py(the fused verify tail);muse_spark/components/verify_topk_sample.py. Before this PR it read the staleacc_linear_penaltiesand thepenalizer_orchestrator, which SGLang has removed.step_penalties(andapply_verify(next_child|next_sibling)for the lifted sampler) inSGLANG_READS.SGLANG_COMMITmoves fromcf6133a(v2) to2544c9ac34(SGLang main at the time of writing, v3, includes #52438). There is no version any-of: a v3 spec cannot be tested against a v2 SGLang. [CI] test: Run the CPU unit tests against SGLang main #81 moves CI to unpinned SGLang main. If [CI] test: Run the CPU unit tests against SGLang main #81 lands first, this PR drops itsunit-test.ymlhunk; if this PR lands first, [CI] test: Run the CPU unit tests against SGLang main #81's diff deletes the pin as before.Tests (added to existing files):
test/unit/test_plugin.py: each registered architecture resolves throughfind_specat the installed SGLang'sMEGAKERNEL_API_VERSION. This is one case per architecture, split out oftest_register_registers_every_spec_and_no_hook, so a package left at the old version is named.test/unit/test_kimi_k3_contract.py: asserts version 3; the mismatch check uses versions 2 and 4.test/unit/test_glm5_3_sm107.py:SamplingBatchInfothat hasstep_penalties;eagle_sample, installed into SGLang'seagle_utilsthroughhooks._eagle_sample()atForwardMode.TARGET_VERIFY, callsapply_verifyfirst, with the logits, the[bs, draft_token_num]candidates and the retrieve tree.CPU unit suite, one file per process, on this branch vs
origin/mainon the same SGLang:2544c9ac34(main, new pin)e96e967570(#52054)*
test_every_registered_spec_resolves_at_this_sglangs_api_version[KimiK31ForConditionalGeneration|DFlash2DraftModel]: the local CPU env has nocutlass. The old loop intest_register_registers_every_spec_and_no_hookfailed on the same import, atcf6133atoo.The 26 fixed cases are the version refusals in
test_deepseek_v41_spec(21),test_kimi_k3_contract(2),test_qwen3_5_spec(1) andtest_plugin(1), plus thespec_step/lifted.pycontract read (1).At the new pin, the remaining failures that are not local-env predate this PR. They come from SGLang main drift that this PR does not touch:
kimi_k31/dflash/runtime.pyimports the helpers #52184 removed (fixed by the open DFlash runtime import fix);kimi_k3K3 Day-0 binding views;qwen3_5readsServerArgs.enable_dp_attention;glm5_3/qwen3_5;spec_step/runner.pyreadssrt/utils/common.py: is_cuda.So CI at the new pin, like #81 at main, stays red until those land.
Eight deliberate mutants were each killed by a failure specific to them:
qwen3_5left at 2;kimi_k3left at 2;apply_verify, with the flat drafts, or without the tree;SGLANG_READSname.pre-commit run --files <changed>passes; every changed file was format-clean on base.GPU validation
Pending. One GB300 boot of kimi_k31 with
--enable-nvidia-megakernelon SGLang main, to check that argument resolution and the build pass. The penalties path (frequency_penalty/repetition_penaltyrequests) runs through SGLang'sapply_verifyand is not changed on the kimi_k31 MK path.Checklist
pre-commit run --files <changed>passes.test/cover the change (cases added totest_plugin.py,test_kimi_k3_contract.py,test_glm5_3_sm107.py).2544c9ac34,e96e967570; GPU run pending..github/CODEOWNERSthat names its owner. N/A.🤖 Generated with Claude Code