Skip to content

perf(server): tick-cooperative speculative decoding to remove the burst head-of-line block #734

Closed

Description

@inureyes

Context

#638 part 2 asked to replace the run-to-completion speculative burst (src/server/batch/speculative_burst.rs, dispatched from execute_prefill) with tick-cooperative slices so a speculative request no longer stalls every concurrent classic decode row for its whole duration (HOL block documented at src/server/model_worker.rs:400-438). PR #733 landed the measurement side (pairing matrix, adaptive-policy de-rate so GB10 declines regressing pairings, and a BurstFinalized.burst_wall_ms observability counter that measures the HOL stall) but deferred the slice itself.

Blocker found (by #733)

MtpGenerator<T> borrows the model through its adapter, so the generator cannot be stashed across scheduler ticks (self-referential borrow); this is exactly why the burst runs to completion today. A resumable design needs a generator step API with stored per-round state (feasible: MtpVerifyOutput owns MLX handles, not model borrows) plus drafter re-seed on resume.

Design sketch (from #638's plan and #733's analysis)

One speculative round (draft K + verify) per scheduler tick, re-entering the tick loop between rounds (round_loop.rs / round_loop_batched.rs are already per-round structured); per-sequence KV slots preserve state across interleaved classic decodes; the cross-tick lookahead pipeline (#632) is already excluded under speculative dispatch (lookahead_params returns None), and any new action type must call discard_lookahead like the Prefill action does; preferred end state is speculative rounds as first-class decide_action outcomes.

Acceptance criteria

  • With one speculative and one classic request active, the classic request's inter-token latency stays bounded (scheduler-level regression test with a mock/small model, plus manual E2E via scripts/bench_serving_concurrency.py --concurrency 2).
  • burst_wall_ms drops to about one round length.
  • Speculative-vs-greedy output parity holds for B=1 and batched.
  • Env gate semantics unchanged.
  • cargo test --features cuda passes.

Refs: deferred from #638 / PR #733.

Activity

  1. added
    type:performance
    area:inference
    priority:medium
    status:ready
    on Jul 10, 2026
  2. inureyes commented on Jul 10, 2026

    @inureyes
    MemberAuthor

    One more scope note from PR #733's review: the interim HOL observability landed as a tracing log line (BurstFinalized with burst_wall_ms / rounds / accepted / hol_waiters), not as BatchObservability counters surfaced through /metrics, and hol_waiters is a finalize-time snapshot rather than max concurrent waiters. When implementing the tick-cooperative slice here, promote these to proper BatchObservability fields (rounds executed, tokens accepted, HOL wait) per the original #638 AC.

  3. added
    status:in-progress
    status:review
    and removed
    status:ready
    status:in-progress
    on Jul 11, 2026
  4. added
    status:done
    and removed
    status:review
    on Jul 11, 2026
  5. added a commit that references this issue on Jul 30, 2026
    fd146ec
  6. self-assigned this
    on Aug 31, 2026
  7. added 2 commits that reference this issue on Oct 27, 2026
    56e7f22
    98e69a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferencepriority:mediumstatus:donetype:performance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions