Stage routing: admit the complete path, not the emptiest prefill
Combine stage queues, transfer placement, destination capacity, and request identity in an explicit admission decision.
On this page
The question for today
What you’ll understand
- Calculate a simple route score across prefill and decode stages.
- Separate routing estimates from capacity reservations.
- Explain how compatibility and tenant scope constrain cache reuse.
Choosing the prefill worker with the shortest queue can send a request toward a saturated decoder or an expensive network cut. The routing unit is the complete request path: compatible model execution, prompt processing, state transfer, destination memory, iterative service, and output delivery. DistServe and Splitwise explore coordinated stage allocation and placement. Here we derive a small routing and reservation model, not a claim that every serving framework atomically reserves all stages or predicts request lengths perfectly.
Estimate the causal path with the right workload features
A route estimate should include prompt length, expected generated length, eligible prefix-cache reuse, model and adapter placement, prefill queue work, transfer bytes, decode queue state, and required service objectives. Queue length in requests is insufficient when one queued prompt is much larger than another. Predictions are uncertain, so retain errors by workload class and define conservative bounds or rejection behavior where required. A routing score ranks candidates; it does not itself reserve their resources or guarantee that an estimate will still be accurate when the request arrives.
Stage compatibility is also a correctness filter. The receiving decoder must interpret cache state from the exact intended model, adapter, position scheme, dtype, and layout, with supported reshaping where needed. Identical tensor dimensions do not establish semantic compatibility. Prefix reuse must be keyed by the actual token and configuration identity and authorized within the intended tenant scope. A cache hit on an incompatible or unauthorized prefix is not a latency optimization. Preserve identity and provenance across routing, transfer metadata, and the output stream.
Reserve destination obligations before producing stranded state
A prefill can consume expensive compute and create a large cache that no decoder can admit. One design reserves a bounded decode obligation before or during prefill, then expires or releases it through an explicit cancellation and ownership protocol. Count current allocations, unmaterialized reservations, and the new request in disjoint categories; double-counting a transferred block as both reserved and allocated can cause false rejection, while counting neither causes oversubscription. A reservation’s lifetime must include the handoff uncertainty it is intended to cover.
Coordinating multiple resources introduces hold-and-wait risks. A request holding source memory while waiting indefinitely for destination space can block other requests and retain stale transfer state. Bound reservation lifetimes, define retry and reroute conditions, and ensure stale owners cannot later spend an expired allocation. Estimated output lengths are not hard capacity guarantees; use a defined generation cap or an explicit extension/eviction policy for future growth. Resource availability snapshots and actual accepted reservations are different evidence, especially with concurrent routers.
Trace routing outcomes and abandoned obligations
Log candidate estimates, selected route, reservation identity, stage timestamps, actual lengths, transfer outcomes, and release events. Check rejected requests and expired reservations so a low completed-request latency cannot hide stranded work. Test concurrent admissions, decoder loss after prefill starts, cancellation during transfer, and a cache hit invalidated before use. A reroute needs a new compatible ownership transition rather than merely changing an address in an old transfer message. Preserve the client request and generation identity while distinguishing each internal attempt.
The queue lab isolates local average pressure. Reset, explicitly set arrival four and service three, predict growth from four items, then Play or Step. Compare a fresh Reset with arrival two and service three explicitly set before predicting drainage. Edits retain elapsed time and recompute from the initial backlog. This single fluid queue contains no second stage, routing score, reservations, model compatibility, or cancellation. Use it to motivate a local pressure measurement while validating end-to-end routing with the actual stage trace.
Work it through
A longer prefill queue can still give the better route
Two hypothetical compatible paths use the serial gated-first-output score. Path A has prefill queue five ms, compute 25 ms, transfer thirty ms, decode queue twenty ms, and first decode five ms. Path B has corresponding durations fifteen,25,5,5,5 ms.
Path A totals 5+25+30+20+5=85 ms. Its short prefill queue does not remove the transfer and decoder backlog that follow it.
Path B totals 15+25+5+5+5=55 ms. It is thirty ms lower under this estimate despite a ten-ms longer prefill queue. This is a ranking calculation, not a reservation or measured result.
Suppose B’s destination has capacity 120 blocks, ninety already allocated, and twenty reserved. Only ten blocks remain uncommitted; a new sixteen-block obligation cannot pass the stated admission inequality. The faster estimated path must still reject, wait, or choose a correctly reserved alternative.
B has the better estimated time but insufficient stated free capacity for this request. Routing quality and admission correctness must both hold.
The living notebook
Explore the model
Interactive lab · queue
One queue cannot rank a complete two-stage path
Use independent Reset → explicitly set BOTH rates → predict → Play/Step runs for (λ,μ)=(4,3) and (2,3), each from q=4. The instrument has no route pairs, cache compatibility, destination blocks, reservations, or transfer latency.
- 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 forLocal pressure is an input to a routing decision, not a complete admission proof.
Pause & reason
Check your understanding
Your turn
Try it yourself
A destination has 200 usable blocks, 140 allocated, and thirty disjoint pending reservations. Can it accept a twenty-block obligation under the stated budget? What about a 35-block obligation, assuming the same snapshot and correct concurrent enforcement?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Compute uncommitted capacity and keep the proposed obligation separate from existing reservations.
Compare with the solution
Thirty blocks are uncommitted. Twenty fits because 140+30+20=190≤200, while 35 fails because the sum is 205. The conclusion assumes the reservation categories are disjoint and the update is enforced correctly despite concurrency. It does not establish model compatibility, future unreserved token growth, or a latency guarantee. Record reservation identity, release rules, and how cancellation or rerouting invalidates a stale attempt.
Keep the idea
Take it with you
- Rank complete workload-conditioned paths rather than isolated queue counts.
- Reserve disjoint destination obligations through a correct concurrent protocol.
- Carry semantic cache and request identity across every route attempt.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.