Skip to content

perf(k3): batched spec-round propose + e2e A/B and round anatomy - #936

Open
xiaguan wants to merge 3 commits into
mainfrom
feat/k3-batched-propose
Open

perf(k3): batched spec-round propose + e2e A/B and round anatomy#936
xiaguan wants to merge 3 commits into
mainfrom
feat/k3-batched-propose

Conversation

@xiaguan

@xiaguan xiaguan commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

What

Two things from the agreed spec-decode perf follow-up (#931):

  1. Batched proposedecode_spec now makes one drafter call per round
    over every active slot instead of one per slot. A sorted split_at_mut
    walk hands propose() the disjoint &mut slot states it always
    supported; drafts un-permute back to batch order for the verify split
    loop. One Markov readback / pipeline drain per round instead of N, and
    the dense draft prolog/epilog rows batch across slots.
  2. The e2e spec-on/off bench and nsys round anatomy that were supposed
    to come first — they did, and they reorder the rest of the plan
    (documented in docs/models/k3/mtp-dspark.md).

Bench headlines (full 896-expert EP16, SPEED-Bench throughput_1k)

Workload spec-on spec-off verdict
c1 low_entropy TPOT 44.1 ms 76.6 ms 1.74× faster
c1 high_entropy TPOT 140.3 ms 77.0 ms 1.82× slower
c4 mixed steady tok/s 35.7 49.1 −27%

nsys on pruned EP4: round p50 64.6 ms = verify 61.4 + propose ~3. The
verify step is not launch-bound (5.5 ms of gaps): it's small-batch
math — small cuBLAS GEMMs 22.3 ms, MLA 15 ms, per-row b1 elementwise
7.5 ms; MegaMoE only 9.6 ms. So the old "verify CUDA graph" idea buys
≤5 ms; packing the verify step's per-row/per-group math across rows is
the next real lever, and propose graphing only matters after that fixes
the geometry it would capture.

Validation

  • c1 sequential serve A/B vs main: byte-identical (active=1 is the
    same GEMM shapes). c8 concurrent forks in the known near-tie noise
    class (geometry change retiles GEMMs; feat(k3): speculative decoding with the RadixArk DSpark drafter #931 certified this class), with
    per-slot acceptance in-band (dev 3.59 vs main 3.45 tokens/round mean,
    no collapse → no anchor/state cross-wiring).
  • dspark_reference_cross_check green (tray09, both propose rounds).
  • spec_verify 6/6 green on the branch build.
  • 41 pegainfer-k3 lib tests, cargo fmt --check clean.

Bench artifacts: ~/bench-results/k3-spec-e2e-20260819/, trace
~/k3-prof/specround.nsys-rep.

🤖 Generated with Claude Code

xiaguan and others added 2 commits August 19, 2026 10:33
decode_spec proposed per slot — one dspark forward, one Markov readback,
and one full pipeline drain per active slot per round. propose() always
took the batch; the caller just never handed it one (disjoint &mut slot
states). A sorted split_at_mut walk over the slot array hands out the
states, and the drafts un-permute back to batch order for the verify
split loop.

Per round this is one draft forward over active*7 rows and a single
device round-trip instead of N; the dense draft prolog/epilog rows now
batch across slots.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: xiaguan <751080330@qq.com>
…wall

SPEED-Bench EP16 A/B (spec wins 1.74x on low-entropy c1, loses 1.8x on
high-entropy c1 and -27% throughput at c4 mixed) plus the nsys round
anatomy: verify 61.4ms vs propose ~3ms, and the verify step is
small-batch math, not launch overhead. Reorders the perf follow-up
accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: xiaguan <751080330@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 939cc69479

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

(chunkwise FlashKDA vs the fused core — near-tie argmaxes flip); the
`spec_verify` gates certify what is exact instead.
`spec_verify` gates certify what is exact instead. E2e on the EP16 fleet
(SPEED-Bench, 2026-08-19): **1.74× on low-entropy c1, 1.8× SLOWER on

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required DCO sign-off

The reviewed commit message has no Signed-off-by: trailer, so the repository's DCO check will reject this commit regardless of the code changes. Recreate or rebase the commit with --signoff before merging.

AGENTS.md reference: AGENTS.md:L182-L182

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

False positive: both commits on this branch carry the Signed-off-by: trailer (git log --format="%(trailers:key=Signed-off-by)" shows it on 582fa30 and 939cc69), and the repository DCO check passed on this PR (13/13 green).

…gaMoE cross-tray stalls

Signed-off-by: xiaguan <751080330@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant