Skip to content

[Perf] gemma4: Capture single-step frozen-KV drafts - #45771

Merged
alexnails merged 1 commit into
mainfrom
alexnails/gemma4-mtp-single-step-capture-main
Oct 22, 2026
Merged

alexnails merged 1 commit into
mainfrom
alexnails/gemma4-mtp-single-step-capture-main

Conversation

@alexnails

@alexnails alexnails commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

FrozenKVMTPDraftWorker._capture_cuda_graphs returns early when speculative_num_steps <= 1, so a one-step frozen-KV draft never gets a draft graph. That guard is off by one: a one-step draft still runs the assistant seed forward every decode step, and that forward is exactly what the capture covers. With the guard as written, it always runs eagerly.

How it was found

While profiling Gemma 4 E2B frozen-KV MTP with one draft step and two verification tokens, the assistant seed forward showed up as eager work on every decode step, even with full decode graphs enabled. /server_info confirmed it: startup_time.cuda_graph.draft_decode was 0, while the same server with three draft steps reported a nonzero capture time. The cause turned out to be the <= 1 early return.

Modifications

Change the early-return guard from <= 1 to <= 0, so one-step drafts are captured. The zero-step and graphs-disabled cases are still excluded. Nothing else changes; multi-step drafts take the same path as before.

Accuracy Tests

google/gemma-4-E2B-it + google/gemma-4-E2B-it-assistant, one H200, the cookbook E2B MTP command with --speculative-num-steps 1 --speculative-num-draft-tokens 2 (the case this PR changes).

  • Six greedy chat prompts: identical output on all four runs (main ×2, this PR ×2).
  • GSM8K via sgl-eval==0.1.3, 200 examples, greedy (temperature=0, max_tokens=2048, enable_thinking=false): 79.5% on main and 79.5% on this PR, zero errors.

Speed Tests and Profiling

Same H200 and launch as above. bench_serving random dataset, 256 input / 256 output tokens fixed, one discarded warmup pass per concurrency, runs ordered main → PR → PR → main.

main (run 1 / run 2) this PR (run 1 / run 2) Change
draft_decode capture time 0.00 s / 0.00 s 1.64 s / 1.17 s captured
Median TPOT, concurrency 1 5.30 / 5.33 ms 3.53 / 3.54 ms −33%
Median TPOT, concurrency 8 6.10 / 6.13 ms 4.30 / 4.31 ms −30%
Accept length 1.95–1.96 1.95–1.96 unchanged

Checklist

  • Pre-commit checks.
  • Draft graph captured for one-step drafts (draft_decode > 0), not before.
  • Greedy parity and 200-example GSM8K parity.
  • Same-device serving benchmarks, both orders.
  • No new configuration required.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #39748596192
Latest PR Test (Extra): ⚠️ Not enabled -- add run-ci-extra label to opt in.
Latest PR Test (AMD ROCm 10): ❌ Run #39748595946

@alexnails
alexnails force-pushed the alexnails/gemma4-mtp-single-step-capture-main branch from cd8e475 to 9ee3115 Compare October 22, 2026 08:33
@alexnails alexnails added the run-ci CI: run the baseline test suite on this PR label Oct 22, 2026
@alexnails

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@alexnails

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/spec/test_frozen_kv_mtp.py test/registered/core/test_basic_sanity_dspark.py

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (2 tests): ❌ View workflow run

cd test/ && python3 registered/spec/test_frozen_kv_mtp.py
cd test/ && python3 registered/core/test_basic_sanity_dspark.py

@alexnails

Copy link
Copy Markdown
Collaborator Author

test_frozen_kv_mtp.py passed and the other reproduced as an issue I didn't cause, merging

@alexnails
alexnails merged commit c394a90 into main Oct 22, 2026
281 of 315 checks passed
@alexnails
alexnails deleted the alexnails/gemma4-mtp-single-step-capture-main branch October 22, 2026 22:37
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