Repository navigation
[Spec] Anchor GLM-5.2 MTP IndexShare topk on the draft-extend step - #29787
Conversation
GLM-5.2's MTP (NextN) draft reuses the DSA indexer top-k across draft-decode steps (index_share_for_mtp_iteration) instead of recomputing it every step. Today the reused top-k is captured on the first draft-decode step, whose query hidden state is the draft model's own step-0 output. Anchoring on that speculative hidden state is one step too late: the intended IndexShare seed is the last verified token's (target-derived) hidden state produced during draft-extend. This change captures the indexer top-k during draft-extend (gathering the last position per request) and threads that seed through the draft-decode loop, the draft / draft-extend CUDA-graph capture+replay static buffers, EagleDraftInput filter/merge, and the overlap-schedule FutureMap relay so it survives batching. Gated by seed_topk_from_extend (active only when index_share_for_mtp_iteration is on and the model exposes index_topk); no effect on non-DSA / non-MTP paths. Accept-length A/B (GLM-5.2-NVFP4, TP4, EAGLE steps=5/topk=1/draft=6, temp=0, server-side generation_tokens/spec_verify_calls): context-sweep pooled long-ctx (8k-72k) 5.116 -> 5.232 (+0.117, n_sd +2.9), with the gain growing as context grows (ctx_8k +0.105, ctx_32k +0.095, ctx_72k +0.179). Short-context (DSA dense) is within measurement noise.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
#29654 fixed the reuse mechanism itself: previously the carried topk could be lost across per-step forwards, so IndexShare could become effectively a no-op. With #29654, draft step 0 can compute the seed and later draft steps reuse it. #29787 then refines where the seed comes from for GLM-5.2 MTP: capture the indexer topk during draft-extend on the last verified token, then reuse it in the next draft loop, including draft step 0 and later steps. If the draft-extend seed is unavailable, falling back to draft step 0 computation is still valid. |
|
Profiled Setup: The two captures happened to cover a different number of decode cycles (9 draft-decode loops before, 11 after), so counts are normalized per loop (raw shown as
The reused top-k is now seeded entirely from draft-extend: the redundant recompute at draft-decode step 0 is gone (1 → 0 per loop), while Commits profiled: before = |
|
/tag-and-rerun-ci |
buffers.mtp_seed_topk is accessed under an is-not-None guard in execute()/replay(); the white-box mock's SimpleNamespace lacked the attribute, so every test errored with AttributeError. Add None so the guard short-circuits.
|
/rerun-failed-ci |
EagleWorkerV2.draft_forward reads self.seed_topk_from_extend (gated by index_share_for_mtp_iteration and dsa_index_topk). The white-box _EagleDraftWorkerHarness already mocks index_share_for_mtp_iteration but skipped the two new attrs added by the MTP IndexShare-extend PR, so any eagle-draft runner case errored with AttributeError. Mirror the worker's definition so the guard short-circuits.
EAGLEDraftExtendCudaGraphRunner reads self.eagle_worker.seed_topk_from_extend and .dsa_index_topk (eagle_draft_extend_cuda_graph_runner.py). The white-box _EagleDraftExtendV2WorkerHarness skipped both new attrs added by the MTP IndexShare-extend PR, so the runner_fa3_eagle_draft_extend_v2_cuda_graph_runner_fixed_tokens case errored with AttributeError. Mirror EagleWorkerV2's definition (index_share_for_mtp_iteration + dsa_index_topk + seed_topk_from_extend) so the guard short-circuits.
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
…c topk - mtp_topk_indices -> dsa_topk_indices (EagleDraftInput, RelayPayload, FutureMap buf) - reuse_mtp_topk_indices -> reuse_dsa_topk_indices (ForwardBatch flag) - mtp_seed_topk / mtp_seed_topk_capture / mtp_seed_topk_select -> dsa_seed_topk* - seed_topk_from_extend -> seed_dsa_topk_from_extend - _extend_topk_buf -> _get_dsa_extend_topk_buf; locals dsa-prefixed Co-Authored-By: Claude Fable 5 <[email protected]>
…-extend seed Upstream sgl-project#29787 renamed the carry (reuse_dsa_topk_indices / spec_info.dsa_topk_indices) and made begin conditionally keep a draft-extend-seeded carry. mtp_iteration gains keep_carry_seed to wrap the new begin semantics; the NextN draft-extend seed publish stays raw (capture buffer, not the carry lifecycle).
… step (sgl-project#29787)" This reverts commit 16372b4.
…gl-project#29787) Co-authored-by: kpham-sgl <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
Summary
Successor of #29654, move the topk capture to draft extend phase. Discuss with @zRzRzRzRzRzRzR offline and we believe this conceptually aligned with GLM 5.2 behaviour
GLM-5.2's MTP (NextN) draft reuses the DSA indexer top-k across draft-decode steps (
index_share_for_mtp_iteration) rather than recomputing it each step. Currently the reused top-k is captured on the first draft-decode step, whose query hidden state is the draft model's own step-0 output. That anchor is one step too late — the IndexShare seed should come from the last verified token's (target-derived) hidden state produced during draft-extend.This PR captures the indexer top-k during draft-extend (gathering the last position per request) and threads that seed through:
eagle_worker_v2.py,deepseek_nextn.py),EagleDraftInput.filter_batch/merge_batch,FutureMaprelay (so the seed survives batching / async overlap).Gated by
seed_topk_from_extend, which is active only whenindex_share_for_mtp_iterationis on and the model exposesindex_topk. Non-DSA / non-MTP paths are untouched (short-context DSA-dense requests are unaffected).Benchmark — accept length, before vs after
nvidia/GLM-5.2-NVFP4, TP4, EAGLEsteps=5 / topk=1 / draft=6,temp=0greedy, natural EOS,kv-cache-dtype=fp8_e4m3, hierarchical cache on. Metric = server-sidegeneration_tokens_total / spec_verify_calls_totalfrom/metrics. before = currentmain(step-0 anchor, post #29654); after = this PR. 3 replicates/arm, cache flushed per dataset.Notes:
openhands_longctx+0.061; larger as context grows).Test plan
index_share_for_mtp_iterationon, long-context GLM-5.2 run — accept length matches the numbers above; outputs bit-identical tomainattemp=0(only verify-call count moves).--cuda-graph-max-bs-decode), incl. batch grow/shrink (filter/merge) and overlap schedule._DEBUG_ASSERT(SGLANG_IS_IN_CI) passes with the new pool-indexeddsa_topk_indicesbuffer.Draft: seeking review on the approach + the buffer/relay plumbing before finalizing.
CI States
Latest PR Test (Base): ❌ Run #28751939780
Latest PR Test (Extra): ❌ Run #28751939750