Skip to content

[Spec] Stage Inkling MTP draft metadata before verify - #38169

Merged
Qiaolin-Yu merged 5 commits into
sgl-project:mainfrom
paulzhang-tm:codex/stage-draft-metadata-before-verify
Sep 10, 2026
Merged

Qiaolin-Yu merged 5 commits into
sgl-project:mainfrom
paulzhang-tm:codex/stage-draft-metadata-before-verify

Conversation

@paulzhang-tm

@paulzhang-tm paulzhang-tm commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

Inkling MTP draft extension reads shared request/KV and conv-slot mappings after target verification, keeping the scheduler from updating those mappings for the next batch. Stage those reads into draft-owned buffers before verify so the target metadata-completion event can release the scheduler earlier.

Runtime-only mirror, following the staging approach in #35126 and #35289.

Modifications

Exactly five files under python/sglang/srt/:

File Change
layers/attention/base_attn_backend.py Add an opt-in staging capability, disabled by default.
layers/attention/flashattention_backend.py Own the staging capability checks and fill draft-owned metadata using the existing metadata kernel.
layers/attention/linear/inkling_sconv_backend.py Stage attention metadata and conv slots outside draft graphs; retain result-dependent conv metadata inside them. Commit target conv state through prepared slots.
speculative/multi_layer_eagle_draft_extend_cuda_graph_runner.py Stage mapping reads before verify; populate result-dependent inputs afterward. Clear padded request slots on batch reuse.
speculative/multi_layer_eagle_worker_v2.py Stage before verify and select the target fence only when staging and both graph paths succeed.

Preserves #36752: unstaged/eager fallback still uses the final draft runner. Combined draft graphs remain supported. Staging requires compatible top-k-1 attention/conv backends, a target graph marker, and a supported batch bucket. The Inkling wrapper queries the full-attention capability without importing a concrete backend. Standalone FlashAttention keeps its existing in-graph metadata path and final draft fence.

Accuracy Tests

  • Existing public unit tests: 9 passed (test_multi_layer_eagle_shared_read_event.py and test_decode_cuda_graph_shared_read_fence.py).
  • 14 targeted tests passed on GB300 against this public checkout, including those nine unit tests, four GPU integration cases, and a regression test preserving the standalone FlashAttention draft fence. The GPU cases cover stage → prepare → replay after shared mappings change (page sizes 1/16/128, boundary windows, batch reuse and fallback), plus real target conv-state writes after slot reassignment.
  • Ruff 0.15.1 format/lint, isort 7.0.0, Python syntax, and git diff --check passed.

The GPU validation harness is separate from this runtime-only mirror. No test, private-extension, or benchmark files are added.

Speed Tests and Profiling

No end-to-end speed benchmark was run against this upstream checkout. The change moves shared mapping reads before verify; model computation and KV allocation are unchanged.

Checklist

  • Follow upstream formatting and import conventions.
  • Keep the diff limited to the five relevant srt/ files.
  • Preserve upstream's final-draft-runner fallback.

-Robot


CI States

Latest PR Test (Base): 🚫 Run #34536403208
Latest PR Test (Extra): ❌ Run #34536403316
Latest PR Test (AMD ROCm 10): ⏳ Run #34536403290

@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@Qiaolin-Yu Qiaolin-Yu self-assigned this Sep 8, 2026
Resolve shared attention and conv-slot mappings into draft-owned buffers before target verification. Preserve the final-draft-runner fallback introduced in sgl-project#36752.
Keep the missing-runner fallback explicit, assert initialized attention backends, and assert topk=1 after staging eligibility is established.
@paulzhang-tm
paulzhang-tm force-pushed the codex/stage-draft-metadata-before-verify branch from 849d7f8 to 764d63b Compare September 9, 2026 20:12
@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

/rerun-test test/registered/e2e/models/test_mimo_v2.py test/registered/e2e/models/test_mimo_v2_flash.py

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Rebase Required Before Re-run

A major update has landed on main. Your PR is diverged relative to required base commit 3700c4ee26a1.

Re-run was not dispatched. What to do:

  • Rebase your branch onto the latest main and push again
  • Follow issue #21065 for context
  • CI-fix PRs may request the bypass-maintenance label to skip this check

@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

/rerun-test test/registered/e2e/models/test_mimo_v2.py test/registered/e2e/models/test_mimo_v2_flash.py

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/e2e/models/test_mimo_v2.py test/registered/e2e/models/test_mimo_v2_flash.py:

🚀 8-gpu-h200 (2 tests): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_mimo_v2.py
cd test/ && python3 registered/e2e/models/test_mimo_v2_flash.py

@Qiaolin-Yu
Qiaolin-Yu merged commit bb15be6 into sgl-project:main Sep 10, 2026
77 of 180 checks passed
mqhc2020 pushed a commit to mqhc2020/sglang that referenced this pull request Sep 15, 2026
)

Co-authored-by: Qiaolin-Yu <liin1211@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants