Skip to content

[Fix] megakernel: Restore Kimi K3 DSpark verification views - #51977

Open
leejnau wants to merge 1 commit into
sgl-project:mainfrom
leejnau:fix/kimi-k3-hybrid-verify-contract
Open

leejnau wants to merge 1 commit into
sgl-project:mainfrom
leejnau:fix/kimi-k3-hybrid-verify-contract

Conversation

@leejnau

@leejnau leejnau commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Kimi K3 five-proposal/q6 DSpark with --enable-nvidia-megakernel fails during preparation because the hybrid binding no longer exposes KdaStateView.intermediate_conv_window. The hybrid-view rewrite in #48414 also dropped the per-request verification scratch indices and auxiliary hidden-state output, while TRTLLM MLA keeps its decode/verify metadata in forward_decode_metadata. The plugin still needs this contract; the native buffers and post-accept commit path already exist.

Modifications

  • Restore typed checkpoint, query-count, scratch-index and auxiliary-output fields. Read state through the native layer router and use the TRTLLM decode/verify metadata.
  • Borrow native checkpoint/scratch storage; reuse runner-owned auxiliary storage during capture, allocating only when needed for eager execution. Validate request/token shapes and retain captured tensor owners, rejecting buffer replacement and unsupported ownership/layout modes.
  • Add five native CPU regression tests covering routing, q6 metadata, capture ownership, rejection and ordinary-decode defaults. No plugin kernels, stock acceptance/commit logic, dependency pins or activation defaults change.

Accuracy Tests

B300 CI run 44815092291 passed: five native CPU tests plus four subtests, followed by both matched E2E tests. TP8/q6, stock RadixArk draft execution, DCP off: captured B1/B2, eager B3/B4, return to B1, and a 32,768-token passkey input. GSM8K-200 was stock 151/200, plugin 150/200, with zero request errors; the unchanged 0.005 accuracy-drop and 0.5 shared-prefix logprob bounds passed.

That run tested framework 0da13fa8c67001fc88d7d9ed454cd6a2b2f41b70 with plugin c5d2baead02d801e6a14b7d81239c02198855190. This PR extracts only the runtime repair and tests onto upstream 83df28fc0b5c2f4cecad5ac26f765f127e910139; the verification logic and regression file are unchanged, and newer upstream DSA changes are preserved. Applicable pre-commit and syntax checks pass on the rebased patch. This is not a claim that the new full upstream pair has been GPU-retested. The latest rebase includes upstream #51978's CPU-fixture fixes; the runtime patch and its regression file are byte-for-byte unchanged. On the previous PR head, all five new native binding tests passed in Base CI; its failed shard was the Mamba fixture now corrected upstream. Fresh CI is running on 5badd574f6d60d411045ccf56f0ea5ede8b9386b.

Speed Tests and Profiling

The same run passed the companion's three warmed C1/C4 timing comparisons. This restores a working runtime path, rather than introducing a kernel optimization. The CI infrastructure and matched test fixture remain separate in #51429 and sgl-nvidia-mega #73; neither is included in this diff.


CI States

Latest PR Test (Base): ✅ Run #44859984991
Latest PR Test (Extra): ⊘ Skipped -- add the run-ci-nv-extra label to opt in.
Latest PR Test (AMD ROCm 10): ✅ Run #44859984650

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@leejnau

leejnau commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Nov 21, 2026
@leejnau
leejnau force-pushed the fix/kimi-k3-hybrid-verify-contract branch from cd78ebc to 5badd57 Compare November 21, 2026 03:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant