Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Async scheduling | Planning step N+1 on the CPU while step N is still running on the GPU. |
| Placeholder | A position the scheduler has reserved for a token that has not been sampled yet. |
| Batch queue | The engine’s list of steps already sent to the GPU but not yet finished (16.g). |
| In flight | Scheduled and sent to the GPU, result not yet back. |
| Stale output | A result that arrives for a request after it was preempted and reset. |
| Structured output | Forcing the model’s output to follow a grammar or JSON schema (18.e). |
| Fence | A sequence number that says “nothing may happen until step k has finished”. |
1. What is it?#
To keep the GPU from idling between steps, vLLM schedules step N+1 while step N is still
running. But step N+1 of a generating request must feed the model the token that step N is
about to sample, a token that does not exist yet.
vLLM resolves this with a placeholder: the scheduler reserves one position for “whatever step
N produces”, and the worker, which will hold the real token on the GPU by then, fills it in. The
scheduler runs one step ahead of reality and reconciles when results arrive.
This is on by default for generative models. It is why two counters in the scheduler seem to disagree, and it costs one wasted forward pass for every request that ends on a stop token.
Facts checked on 12 November 2026 against vLLM v0.32.0.
2. Why does it exist?#
Without overlap, each step goes: GPU runs → CPU reads the results, updates every request, checks stops, plans the next batch → GPU runs again. The CPU part is Python and grows with the number of requests (17.a). At small batch sizes and fast GPUs it can be a large share of each step, and the GPU sits idle during it (5.d covers launch overheads in general).
Async scheduling hides that CPU time behind the GPU’s work. The gain is largest exactly where latency matters most: small models, fast GPUs, decode-heavy traffic.
3. Simple analogy#
A chef plating dishes while the next tray is already in the oven. The chef does not yet know whether the current dish will be the last one a table orders, so the next tray always includes one more portion for each table. If a table says “that’s all” when its dish comes out, the extra portion in the oven is thrown away. One wasted portion per table is cheap compared with an oven that stands empty while the chef plates.
4. Tiny example: why the gap would be zero#
A generating request just before schedule() in the ordinary, synchronous engine:
num_tokens = 107 (100 prompt + 7 output; the 7th was just sampled)
num_computed_tokens = 106 (the 7th has not been through the model)
gap = 1 → schedule 1 tokenNow schedule the next step before the current one has returned. num_tokens is still 107,
because token 108 does not exist yet, and num_computed_tokens was already advanced to 107 when
the current step was scheduled. The gap is zero, and there would be nothing to overlap.
With a placeholder: 107 + 1 − 107 = 1. One token is scheduled, ID unknown.
5. Technical explanation#
When it is on#
--async-scheduling defaults to “decide automatically” (None), and the automatic answer is yes
unless one of these holds (vllm/config/vllm.py):
| Condition | Reason given in the source |
|---|---|
| A pooling (embedding) model | “negatively impacts performance of pooling models” |
| Speculative decoding with a method other than EAGLE/MTP, draft model, GPU n-gram, DSpark or DFlash | Next-step draft tokens must be produced on the worker |
disable_padded_drafter_batch is set | Incompatible batch shapes |
| The distributed executor backend does not support it | |
| ROCm with DeepEP high-throughput dual-batch overlap | “can corrupt DP+EP generation accuracy” |
| Pipeline parallelism with the older V1 model runner | “the V1 model runner does not support it with pipeline parallelism” |
When it is on, the scheduler class is AsyncScheduler (vllm/v1/core/sched/async_scheduler.py),
a subclass of Scheduler that overrides two methods. Force it off with --no-async-scheduling;
if you force it on with an incompatible option, startup fails instead of silently turning it off.
The overlap depth is max_concurrent_batches: 2 for async scheduling on one pipeline stage, and
pipeline_parallel_size + 1 with Model Runner V2 (the default for dense models since v0.25.0).
note
A custom scheduler passed with --scheduler-cls that subclasses Scheduler rather than
AsyncScheduler loses this optimisation. vLLM warns: “If you have subclassed Scheduler instead
of AsyncScheduler, you will see degraded performance due to async scheduling being disabled.”
The fix: count the token before it exists#
AsyncScheduler._update_after_schedule adds bookkeeping for every scheduled request that will
sample this step:
for req_id in scheduler_output.num_scheduled_tokens:
request = self.requests[req_id]
if request.is_prefill_chunk:
continue
scheduler_output.pending_structured_output_tokens |= (
request.use_structured_output and request.num_output_placeholders > 0
)
# The request will generate num_sampled_tokens_per_step new tokens
# plus num_spec_tokens in this scheduling step.
cur_num_spec_tokens = len(spec_decode_tokens.get(req_id, ()))
request.num_output_placeholders += (
self.num_sampled_tokens_per_step + cur_num_spec_tokens
)A placeholder is a promise: “a step in flight will produce one token for this request.” The gap formula from 17.a always contained a term that was zero until now:
num_new_tokens = (
request.num_tokens_with_spec
+ request.num_output_placeholders
- request.num_computed_tokens
)is_prefill_chunk decides whether a step samples:
request.is_prefill_chunk = request.num_computed_tokens < (
request.num_tokens + request.num_output_placeholders
)A step that ends in the middle of the prompt is a prefill chunk: nothing will be sampled, so no placeholder is added.
Who knows the token#
The worker. After sampling in step N, the model runner keeps the sampled token IDs in a tensor
on the GPU. When step N+1 arrives saying “one token for this request, at position 108”, the
runner writes its own previous sample into that input position. The token ID never makes the trip
worker → scheduler → worker; it stays on the GPU, and a copy goes to the scheduler afterwards for
bookkeeping, detokenising and stop checks.
That is also why CachedRequestData.new_token_ids carries the comment “new_token_ids is only used
for pipeline parallelism”: normally the scheduler sends no token IDs for a running request at all.
Reconciling when the result arrives#
AsyncScheduler._update_request_with_output:
new_token_ids, stopped = super()._update_request_with_output(request, new_token_ids)
# Placeholders were zeroed at preemption; a stale delivery must not
# decrement them (it would underflow).
if not is_stale:
request.num_output_placeholders -= len(new_token_ids)
assert request.num_output_placeholders >= 0
# Cache the new tokens. Preempted requests should be skipped.
if status_before_update == RequestStatus.RUNNING:
self.kv_cache_manager.cache_blocks(
request, request.num_computed_tokens - request.num_output_placeholders
)The promise is redeemed: num_tokens goes up by one and num_output_placeholders down by one.
Their sum is unchanged, so the gap is unaffected.
The last statement matters for the prefix cache (17.f). A block may get a hash only once its
contents are final, and a hash depends on token IDs. num_computed_tokens includes positions
whose IDs are still unknown, so the cacheable frontier is
num_computed_tokens − num_output_placeholders.
Not scheduling past the end#
A request about to hit max_tokens should not be scheduled again. That much is knowable, and
the first check in pass 1 handles it:
if (
request.num_output_placeholders > 0
# This is (num_computed_tokens + 1) - (num_output_placeholders - 1).
and request.num_computed_tokens + 2 - request.num_output_placeholders
>= request.num_prompt_tokens + request.max_tokens
):
# Async scheduling: Avoid scheduling an extra step when we are sure that
# the previous step has reached request.max_tokens.
req_index += 1
continueWhat cannot be known in advance is whether the token in flight is end-of-sequence. If it is,
the step already scheduled behind it is waste: it computes one token for a finished request.
update_from_output discards the leftover:
if request is None or request.is_finished():
# The request is already finished. This can happen if the
# request is aborted while the model is executing it (e.g.,
# in pipeline parallelism or in async scheduling).
continueSo the cost of async scheduling is one extra token of compute per request that ends on a stop token (more with a deeper pipeline), in exchange for no idle gap on every step of every request. For a 300-token answer that is a third of a percent of work.
Structured output gives up part of the overlap#
A grammar constrains the next token given all earlier ones. To build the mask of allowed tokens
for step N+1, the grammar must first consume step N’s token, which is exactly what async
scheduling does not have yet. AsyncScheduler flags such steps
(pending_structured_output_tokens, above), and EngineCore.step_with_batch_queue reacts by
starting the forward pass of step N+1 at once but deferring its sampling until step N’s
output has been processed:
if not scheduler_output.pending_structured_output_tokens:
grammar_output = self.scheduler.get_grammar_bitmask(scheduler_output)
future = self.model_executor.sample_tokens(grammar_output, non_block=True)
else:
# We need to defer sampling until we have processed the model output
# from the prior step.
deferred_scheduler_output = scheduler_outputThe forward pass still overlaps; only sampling waits. That is why execute_model and
sample_tokens are two separate calls to the worker.
6. Under the hood#
The picture#
flowchart LR
subgraph T1["While step N runs on the GPU"]
direction TB
S["schedule(N+1)<br/><small>this request: 1 token, ID unknown</small>"] --> PH["num_output_placeholders += 1<br/><small>num_computed_tokens += 1</small>"]
end
subgraph T2["Step N finishes"]
direction TB
W[":nvidia: worker keeps the sampled<br/>token on the GPU"] --> U["update_from_output(N)<br/><small>real token ID arrives<br/>placeholders -= 1</small>"]
end
subgraph T3["Step N+1 starts at once"]
direction TB
X[":nvidia: worker substitutes its own<br/>last sampled token as the input"]
end
T1 --> T2 --> T3
class S,PH queue
class W,X compute
class U neutralPreemption while steps are in flight#
Suppose a request is preempted while one of its steps is still on the GPU. The scheduler has just
reset it (num_computed_tokens = 0, placeholders zeroed), and then a result arrives for the old
step. _preempt_request prepares for that:
# Async scheduling: mark all in-flight output as stale. Its tokens are
# still delivered on return (dropping them would perturb spec-decode
# acceptance) but must not mutate the reset counters; ...
request.num_stale_output_tokens = request.num_in_flight_tokens
request.num_output_placeholders = 0The late token is still valid (it was sampled from a correct context), so it is delivered. But it
must not be subtracted from the reset counters; is_stale above is that distinction. Pass 2 will
not re-admit the request while deliverable stale output is outstanding:
if request.num_stale_output_tokens and not request.drop_stale_output:
# Deliverable stale output still in flight: resuming now
# could resample a position that output later delivers.
skip_request(request_queue)
continueA “drop” mode exists for two cases where delivering would be wrong: reset_prefix_cache
resuming requests in the same step, and KV connectors that must hand off valid KV
(requires_kv_delivery).
Deferred frees: only with a KV connector#
Could a finished request’s blocks be handed to a new request while an in-flight step still writes to them? On one GPU stream, no: the new owner’s writes are queued after the old step’s, so the order is safe and blocks are freed at once.
The danger appears with a KV connector that loads data into blocks (the receiving side of
prefill/decode disaggregation, 19.b). Its copies are not ordered against the GPU stream. So when
there are overlapping batches and the connector is a KV consumer, the scheduler sets
defer_block_free and fences frees with two counters:
def _request_blocks_can_be_freed(self, request: Request) -> bool:
# We must defer freeing blocks if an async kv connector may
# write to them immediately (not ordered with GPU stream).
return not self.defer_block_free or (
request.last_sched_seq <= self.processed_step_seq
)Each non-empty step gets a number when scheduled (sched_step_seq); processed_step_seq
advances when its output is processed. Until then the request’s blocks wait on a
deferred_frees list.
The counters, in one table#
| Counter | Advances when | Decreases when | Meaning |
|---|---|---|---|
num_tokens | A real token ID arrives | Tokens whose IDs the scheduler knows | |
num_computed_tokens | A step is scheduled | Draft tokens rejected; request preempted | Positions computed or promised |
num_output_placeholders | A sampling step is scheduled | Its token arrives | Tokens in flight, IDs unknown |
num_in_flight_tokens | A step is scheduled | Its output is processed | Scheduled tokens not yet settled |
num_stale_output_tokens | Preempted with steps in flight | Those steps return | In-flight results that predate a reset |
The invariant: a request needs scheduling exactly when
num_tokens + num_output_placeholders > num_computed_tokens.
One request through a batch queue of depth two#
Watch placeholders rise when a step is scheduled and fall when its result arrives, and what
happens when the model ends the answer itself.
package main
import "fmt"
type request struct {
prompt, maxTokens int
output int // tokens whose IDs the scheduler knows
computed int // num_computed_tokens (advanced at schedule time)
placeholders int // num_output_placeholders
finished bool
}
func (r *request) numTokens() int { return r.prompt + r.output }
type step struct {
id int
samples bool // false for a prefill chunk that does not reach the prompt's end
}
// run drives one request through an engine with a batch queue of depth 2.
// eosAt is the output position at which the model emits end-of-sequence (0 = never).
func run(r *request, budget, eosAt int) {
var inFlight []step
wasted := 0
for id := 1; !r.finished || len(inFlight) > 0; id++ {
// --- schedule(): runs before the previous step's output is known ---
scheduled := false
surelyDone := r.placeholders > 0 &&
r.computed+2-r.placeholders >= r.prompt+r.maxTokens
if !r.finished && !surelyDone {
gap := r.numTokens() + r.placeholders - r.computed
if n := min(gap, budget); n > 0 {
r.computed += n
s := step{id: id, samples: r.computed == r.numTokens()+r.placeholders}
if s.samples {
r.placeholders++ // a token will exist; its ID is not known yet
}
inFlight = append(inFlight, s)
scheduled = true
fmt.Printf(" schedule step %d: %d token(s) -> computed=%d known=%d placeholders=%d\n",
id, n, r.computed, r.numTokens(), r.placeholders)
}
}
if scheduled && len(inFlight) < 2 {
continue // keep the batch queue full before waiting on the GPU
}
// --- update_from_output(): the oldest step finishes ---
s := inFlight[0]
inFlight = inFlight[1:]
switch {
case r.finished:
wasted++
fmt.Printf(" output step %d: request already finished, result discarded\n", s.id)
case s.samples:
r.output++
r.placeholders--
what := fmt.Sprintf("token %d", r.output)
if r.output == eosAt {
what += " = EOS, finished (stop)"
r.finished = true
} else if r.output == r.maxTokens {
what += ", finished (length)"
r.finished = true
}
fmt.Printf(" output step %d: %s -> known=%d placeholders=%d\n",
s.id, what, r.numTokens(), r.placeholders)
default:
fmt.Printf(" output step %d: prefill chunk, nothing sampled\n", s.id)
}
}
fmt.Printf(" wasted forward passes for this request: %d\n\n", wasted)
}
func main() {
fmt.Println("Case 1: 6-token prompt, budget 4, stops at max_tokens=3")
run(&request{prompt: 6, maxTokens: 3}, 4, 0)
fmt.Println("Case 2: same request, but the model emits EOS as its 2nd token")
run(&request{prompt: 6, maxTokens: 8}, 4, 2)
}Output:
Case 1: 6-token prompt, budget 4, stops at max_tokens=3
schedule step 1: 4 token(s) -> computed=4 known=6 placeholders=0
schedule step 2: 2 token(s) -> computed=6 known=6 placeholders=1
output step 1: prefill chunk, nothing sampled
schedule step 3: 1 token(s) -> computed=7 known=6 placeholders=2
output step 2: token 1 -> known=7 placeholders=1
schedule step 4: 1 token(s) -> computed=8 known=7 placeholders=2
output step 3: token 2 -> known=8 placeholders=1
output step 4: token 3, finished (length) -> known=9 placeholders=0
wasted forward passes for this request: 0
Case 2: same request, but the model emits EOS as its 2nd token
schedule step 1: 4 token(s) -> computed=4 known=6 placeholders=0
schedule step 2: 2 token(s) -> computed=6 known=6 placeholders=1
output step 1: prefill chunk, nothing sampled
schedule step 3: 1 token(s) -> computed=7 known=6 placeholders=2
output step 2: token 1 -> known=7 placeholders=1
schedule step 4: 1 token(s) -> computed=8 known=7 placeholders=2
output step 3: token 2 = EOS, finished (stop) -> known=8 placeholders=1
output step 4: request already finished, result discarded
wasted forward passes for this request: 1How to read it: in case 1, after “output step 3” no step 5 is scheduled, because the max_tokens
check knew the request was about to end. In case 2 there is no such knowledge: step 4 is already
on the GPU when step 3 returns end-of-sequence, and its result is thrown away. That single
discarded step is the whole price of the optimisation.
7. Performance implications#
- The win is the CPU time per step, now hidden behind GPU work. It matters most at small to medium batch sizes on fast GPUs.
- The cost is one discarded step per stop-token finish per request (up to the pipeline depth with PP). Negligible for answers of more than a few tokens.
- Structured output keeps most of the benefit: the forward pass overlaps, only sampling waits.
- Rejected speculative tokens roll
num_computed_tokensand placeholders back inupdate_from_output; the scheduler simply sees a larger gap next step.
8. Production implications#
- Leave it on. Turn it off only to debug, or if a feature you need refuses to start with it.
- Check the startup log for “Async scheduling … disabled” warnings: an unsupported speculative method, the V1 runner with pipeline parallelism, or an executor backend can switch it off silently.
- Custom schedulers must subclass
AsyncScheduler. - Disaggregated decode servers (KV consumers) pay a little extra memory for deferred frees; this is expected.
9. Common mistakes#
- Reading
num_computed_tokens > num_tokensas a bug. Under async scheduling it includes promised positions. - Expecting the scheduler to know the next token ID. Only the worker does, on the GPU.
- Assuming every request wastes a step. Only those that end on a stop token do; length-capped ones do not.
- Thinking structured output disables async scheduling. It defers sampling only.
- Believing blocks are always freed late under async scheduling. Deferral is only for KV consumer connectors.
10. Hands-on exercise#
- In case 2, move the EOS to the 1st token. How many steps are wasted? Can it ever be more than one with a queue depth of two?
- Change the queue depth test from
< 2to< 3(Model Runner V2 with pipeline parallelism of 2). How many steps are wasted on EOS now? Relate it tomax_concurrent_batches. - Start a server with
--no-async-schedulingand one with the default, and compare output tokens per second at 64 concurrent requests withvllm bench serve(19.d).
11. Interview questions#
- Why is the ordinary gap zero when scheduling one step ahead, and what makes it one again?
- Which component substitutes the real token for a placeholder, and why that one?
- Why can blocks holding placeholder positions not be added to the prefix cache yet?
- What does async scheduling cost, and for which requests?
- Why does vLLM defer freeing blocks only when a KV consumer connector is present?
12. Further reading#
Checked on 12 November 2026, against the v0.32.0 tag.
vllm/v1/core/sched/async_scheduler.pyvllm/v1/core/sched/scheduler.py: themax_tokensguard, stale output, deferred freesvllm/v1/engine/core.py:step_with_batch_queue, deferred samplingvllm/config/vllm.py: when async scheduling is enabled,max_concurrent_batches- The engine core loop and batch queue: 16.g. Structured output: 18.e.