Schedule speculative work under shared latency and capacity budgets
Connect variable verification work, temporary cache reservations, and request fairness to continuous batching without assuming isolated-request speedups survive loaded serving.
On this page
The question for today
What you’ll understand
- Distinguish verification work from committed tokens in scheduler accounting.
- Explain batch, prefill, and lookahead interactions under shared resources.
- Evaluate a dynamic speculation policy against load and latency objectives.
A speculative configuration cuts one isolated request's decode time but worsens loaded-service tail latency. Its larger verification blocks consume shared token and memory budgets, leaving fewer opportunities to admit or advance other requests. Continuous batching changes the tradeoff because request membership and work vary between iterations. A scheduler must account for proposal cost, target verification, temporary KV, and actual committed progress. The right decision can depend on load, context length, deadline, and observed draft agreement rather than one fixed lookahead for every request.
Charge for scheduled computation, not hoped-for output
Iteration-level or continuous batching can remove completed requests and admit or advance others between scheduling boundaries. Orca develops iteration-level scheduling for generative models, while later serving systems combine batching with other memory and execution mechanisms. Speculation adds variable-width work within a request: a long proposed block may consume many target query positions even if the first candidate fails. Define the backend's work unit explicitly. Some accounting includes a pending last token, prefix work, or a bonus prediction differently, so do not infer target input rows from committed token count alone.
Use a measured or supported estimate of verification cost and temporary storage before admitting work. A batch can contain requests with different lookahead lengths and acceptance histories, and padding or graph-shape constraints can waste some of the intended gain. Draft work may run on the same device, another device, or a shared stream, introducing communication and synchronization. Reserving room for every temporary branch can reduce the number of requests that fit. Separate a reduction in sequential target calls from a reduction in total device work or scheduler occupancy.
Balance prefill, decode, and fairness
Long prompts can compete with decode and verification for compute and KV capacity. Chunking prefill or limiting speculative work may reduce an individual iteration's duration and improve opportunities for short requests, but the effect depends on the backend and workload. Measure time to first token, inter-token gaps, completion latency, throughput, and memory at the intended arrival process. A speculative round can emit several tokens at once followed by a longer pause; dividing its time by token count does not describe every user-visible gap. Preserve per-request traces rather than rely only on aggregate tokens per second.
Dynamic policies can reduce lookahead under high load, disable expensive drafts for poorly matched domains, or adapt to recent accepted-prefix statistics. Their correctness still requires the verifier to use actual proposal distributions and valid histories; changing scheduling should not introduce an unproved acceptance shortcut. Their performance must be compared as policies, including estimation and switching overhead. Pinned Transformers 4.56.2's documented assisted interface does not support batched inputs, while a separate serving backend has its own feature matrix. Do not combine those API capabilities into an unsupported universal implementation claim.
Evaluate under a load profile that exposes tradeoffs
Replay or generate a declared arrival and prompt/output-length mix, and compare speculative and baseline configurations under matching target laws and completion criteria. Include warmup, admission, cancellation, and EOS behavior as relevant. Record completed and dropped requests so an apparent latency improvement is not explained by excluding difficult work. vLLM 0.10.2 documents version-specific speculative compatibility and numerical limits; its examples and warnings are not a promise that all hardware or parallelism modes support the same path. Profile the supported configuration rather than extrapolate an isolated benchmark.
The queue lab shows only a fixed-rate backlog effect. For each separate run, Reset, set both arrival λ=4 and service μ to 3 or 5, predict, then Play or Step. The first four-unit fluid backlog grows by one unit per second; the fresh second backlog drains in four seconds. These normalized units can illustrate offered work versus completion capacity, but the model has no batches, token trees, priority, admission, or random arrivals. It cannot certify tail latency or scheduler fairness. Actual serving decisions need the work and request-level evidence described above.
Work it through
Budget measured verification rows for a batch
A fictional scheduler permits 64 target verification query rows per iteration. Its measured supported layout charges eight rows per speculative request, including its pending-input convention, or two rows per short-lookahead request. Ignore every other resource only for this count exercise.
At eight rows per speculative request, at most 64/8=8 such requests fit the row budget. This says nothing yet about how many proposed tokens each will commit.
At two rows per short-lookahead request, the same budget can fit 32 requests. A mixed batch of four eight-row requests leaves 32 rows for sixteen two-row requests, totaling twenty requests.
Compare actual iteration duration, acceptance, temporary memory, and request latency before preferring one mix. Row capacity alone cannot determine completed tokens per second or fairness.
The row budget admits eight large-lookahead requests, thirty-two short-lookahead requests, or the stated twenty-request mix. These are scheduler accounting counts, not backend benchmark results.
The living notebook
Explore the model
Interactive lab · queue
Separate offered work from completion capacity
For each run: Reset, set both λ=4 and μ, predict, then Play or Step. Compare μ=3 and μ=5. The first backlog grows at 1 unit/s; the fresh second backlog reaches zero at 4 seconds. This deterministic fluid queue has no continuous-batching scheduler, request priority, or stochastic tail-latency model.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA service must match offered work with effective completion capacity. Speculative acceptance and scheduler occupancy determine that capacity only in the actual measured implementation.
Pause & reason
Check your understanding
Your turn
Try it yourself
A fictional iteration budget is sixty rows. Six-row speculative requests and three-row short requests share it. How many short requests fit after five speculative requests are admitted? What remains unknown?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Subtract the speculative allocation before dividing the remainder.
Compare with the solution
Five speculative requests use 30 rows, leaving 30 for ten short requests. The batch has fifteen requests. Actual latency, committed token count, memory feasibility, and fairness remain unknown without the supported execution and workload measurements.
Keep the idea
Take it with you
- Account for verification work and temporary state separately from committed output.
- Continuous batching changes the interaction among lookahead, prefill, memory, and fairness.
- Measure a complete scheduling policy under the intended load and supported backend.
Read further
Original sources and deeper explanations to follow at your own pace.
- Yu et al.: Orca, Iteration-Level Transformer Serving
- Kwon et al.: Efficient Memory Management with PagedAttention
- Miao et al.: SpecInfer Tree Verification, v 4
- Transformers 4.56.2: Generation Strategies and Assisted Decoding
- vLLM 0.10.2: Speculative Decoding, Compatibility, and Numerical Limits
- Chen et al.: Accelerating Large Language Model Decoding with Speculative Sampling
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.