Repository navigation
[Fix] qwen3_5: Define speculative_runtime_hooks on every built megakernel - #43
Merged
YAMY1234 merged 1 commit intoNov 9, 2026
Conversation
SGLang's BuiltMegakernel requires every built object to define speculative_runtime_hooks (None without a factory), and bind_speculative_runtime_hooks reads it unguarded once SGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATION is on (sgl-project/sglang#47201). Qwen35Prefill did not define it, so a PD prefill worker (TP1/PP4) with MTP, --enable-nvidia-megakernel and the runtime switch failed at scheduler init with AttributeError. The DeepSeek-V4.1 draft and Muse Spark built objects missed it too. Add the member to the three classes, a CPU test that binds the prefill object under the switch, and a static contract test over every built class. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 5 tasks
wenscarl
added a commit
to wenscarl/sgl-nvidia-mega
that referenced
this pull request
Nov 9, 2026
Both sides added sgl_nvidia_mega/muse_spark (main via sgl-project#42/sgl-project#43, this branch with the newer kernel half). Resolved the 12 add/add conflicts by keeping this branch's newer components and re-applying main's GB300 (sm_103) changes: the ISAS/GSM8K tolerance in spec.py, draft_gemv.fits() and its check in draft_boundary, and BuiltMuseSpark.speculative_runtime_hooks = None. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
wenscarl
added a commit
to nvrohanv/sgl-nvidia-mega
that referenced
this pull request
Nov 10, 2026
Resolve the conflicts with main (Muse Spark, Kimi K3 and the optional-reads contract): - CODEOWNERS, plugin.py: keep both the GLM-5.3 and the Muse Spark entries. - README: keep both the GLM-5.3 and the Kimi K3 rows, notes and sections. - test_contract.py: combine main's SGLANG_OPTIONAL_READS with the GLM-5.3 DSA-view / draft-check skips (the per-pattern list is renamed to skipped so it no longer shadows optional), and subtract both main's preparation set and the binding file's public functions from the untolerated names. Follow main's API changes in glm5_3: - Define speculative_runtime_hooks = None on the four built objects (GlmMegakernelVerify, FusedDraft, NoDraftStep, ComposedBuiltDraft), as the contract test added in sgl-project#43 requires. - Read ForwardMode.is_target_verify from forward_mode.py (where SGLang now defines it), falling back to forward_batch_info.py. Co-Authored-By: Claude Opus 5.5 <[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
With
SGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATION=1, SGLang'sbind_speculative_runtime_hooks(sgl-project/sglang#47201) readsbuilt.speculative_runtime_hooksfrom the built megakernel.BuiltMegakernelinsglang/kernels/plugin_kernels/nvidia/spec.pyrequires every built object to define this member, set toNonewhen it has no factory.Qwen35Prefilldoes not define it. A PD prefill worker with MTP,--enable-nvidia-megakerneland the runtime switch therefore fails at scheduler init:The DeepSeek-V4.1 draft (
DraftProposal,DraftDecode) andBuiltMuseSparkare missing the member too.Modifications
speculative_runtime_hooks = NonetoQwen35Prefill,deepseek_v41DraftProposal(and soDraftDecode), andBuiltMuseSpark.test/unit/test_qwen3_5_runtime.py: binds aQwen35Prefillunder the runtime switch and checks that the stock hooks come back. Without the fix it fails with the error above.test/unit/test_contract.py: a static check that every built class in the package (each class withplan,forwardandsummary) assignsspeculative_runtime_hooks, so future builders are covered.Accuracy Tests
No kernel or forward code changes: the member is
None, so the binding keeps SGLang's default speculative hooks.Tested against SGLang 858073e4 (includes #47201):
test_qwen3_5_runtime.py,test_contract.pyandtest_plugin.pypass.Speed Tests and Profiling
Not applicable: no change to kernel or forward code.
Checklist
pre-commit run --all-filespasses.test/cover the change..github/CODEOWNERSthat names its owner. (No new model.)🤖 Generated with Claude Code