Large Language ModelsInference & Performance Optimization
How do you design modality-aware admission control and scheduling to prevent expensive image, audio, and video requests from starving latency-sensitive text and real-time speech inference?
Question 288 of 309 · Updated
On this page
- 1. The production problem
- 2. Start with a resource-demand model, not request counts
- Estimating cost safely
- 3. Use staged admission control
- Stage A: Gateway admission
- Stage B: Post-preprocessing admission
- Stage C: GPU dispatch admission
- 4. Separate queues by service behavior
- 5. Schedule with deadlines, weighted fairness, and aging
- Why strict priority fails
- A practical priority score
- 6. Reserve capacity, but allow safe borrowing
- 7. Worked numerical example
- 8. Chunk expensive work and make preemption explicit
- 9. Production incident: video burst starves live speech
- 10. Reference scheduler pseudocode
- 11. What to monitor
- 12. Common mistakes
- 13. A practical rollout plan
- 14. Interview-ready answer
- 15. Further reading
1. The production problem#
A text prompt, a high-resolution image, a 30-second audio clip, and a 60-second video are not equivalent units of work. Counting each as one request hides enormous differences in preprocessing, encoder GPU time, decoder work, memory, network transfer, and deadline sensitivity.
Imagine one shared multimodal inference service. A burst of video requests arrives. Each video expands into dozens of frames, consumes vision-encoder capacity, creates a large multimodal context, and occupies decoder/KV-cache resources. Meanwhile, a user asking a short text question or speaking in a live conversation waits behind work that is much more expensive and often less latency-sensitive.
The result is cross-modality interference:
- Text time-to-first-token (TTFT) rises even though text traffic itself has not increased.
- Live speech misses first-audio and chunk cadence deadlines.
- Image and video queues grow, then trigger retries that make overload worse.
- GPU utilization can look high while customer-facing goodput falls.
- Strictly prioritizing text can create the opposite failure: large media jobs wait indefinitely.
The design goal is not simply “text first.” It is to protect latency-critical interactions while making measurable progress on expensive work and preventing starvation.
2. Start with a resource-demand model, not request counts#
Represent each request as a vector of predicted resource demand. A useful request descriptor includes:
- Modality and interaction type: text chat, image question, offline audio transcription, live speech, video understanding.
- Input shape: image count and resolution, audio duration/sample rate, video duration/frame sampling rate.
- Model path: vision/audio encoder, decoder, cross-attention or projection stages, tool or post-processing stages.
- Estimated GPU milliseconds by stage.
- Estimated CPU preprocessing milliseconds and bytes transferred.
- Estimated decoder tokens and KV-cache memory-time.
- Deadline or latency class: first-token, first-audio, chunk cadence, or batch completion.
- Tenant, service tier, and request age.
A simple cost vector is:
Do not collapse this into a single number too early. A request may be cheap in decoder time but expensive in vision encoding, or cheap in GPU time but costly in CPU decoding and network transfer. Admission must check every constrained resource.
For queue selection, a scalar scheduling cost can still be useful:
The weights normalize unlike units against current capacity. They are operational tuning parameters, not universal constants. Keep the original vector for hard limits.
Estimating cost safely#
Build estimates from measured stage times, conditioned on model, hardware, resolution, frame count, audio duration, prompt length, and expected output length. Use a conservative percentile such as P90 or P95 for admission under tight SLOs; a mean estimate systematically over-admits heavy-tailed requests.
For unknown shapes:
- Apply safe defaults or a conservative upper bound.
- Limit maximum dimensions, frames, duration, and decoded payload.
- Admit only a small probe or low-cost path if policy permits.
- Update estimates from completed stage spans.
- Track prediction error by modality and shape bucket.
Never trust client-supplied cost estimates. Derive cost from validated metadata and enforce limits again after decoding or preprocessing reveals the true shape.
3. Use staged admission control#
A robust design makes admission decisions at several points because the service learns more about a request as it progresses.
Stage A: Gateway admission#
Before expensive payload decoding:
- Authenticate and apply tenant quotas.
- Validate content type, declared size, dimensions, duration, frame count, and rate limits.
- Assign service class and deadline.
- Reject malformed or obviously over-budget requests early.
- Reserve a bounded place in the appropriate ingress queue.
This stage should be cheap. Do not decode a huge video merely to discover that the tenant has exceeded its quota.
Stage B: Post-preprocessing admission#
Once actual image dimensions, selected video frames, audio duration, and tokenized prompt length are known:
- Recalculate the resource vector.
- Check encoder queue delay and capacity.
- Check decoder/KV headroom.
- Decide whether to continue, defer, downsample under an explicit quality policy, or reject with a retry hint.
- Release reservations if the request is rejected.
Stage C: GPU dispatch admission#
Immediately before launching work:
- Recheck live GPU memory and stage availability.
- Enforce batch token, frame, and encoder-work limits.
- Respect active decode deadlines and live-audio cadence.
- Avoid launching a large prefill/encoder job that would block already admitted interactive work.
Admission must be atomic with capacity reservation, or concurrent gateway workers can all observe the same free capacity and over-admit.
4. Separate queues by service behavior#
A practical starting design uses distinct logical queues, even if they share physical GPUs:
- Live interaction queue: live speech, streaming responses, and other requests with tight first-response or cadence deadlines.
- Interactive text queue: short text prompts with TTFT objectives.
- Interactive media queue: image questions and short audio clips with user-facing latency objectives.
- Heavy media queue: long audio and video jobs with larger, more flexible completion windows.
- Batch queue: offline transcription, summarization, embedding, or bulk video analysis.
Separate queues prevent a large video from sitting at the head of a single FIFO queue. They do not require a separate GPU pool for every modality. The scheduler can still co-schedule work when resources permit.
For live speech, distinguish session continuity from one-shot requests. A session may need a small amount of reserved capacity to preserve audio chunk cadence even when no single chunk appears expensive.
5. Schedule with deadlines, weighted fairness, and aging#
No single priority rule is sufficient.
Why strict priority fails#
If text always wins, video may never run during sustained text load. If video is admitted in large batches, it may monopolize encoder and decoder resources. If the scheduler uses FIFO, one large request can block many small ones.
Use a layered policy:
- Deadline urgency: protect work whose predicted completion is approaching its deadline.
- Weighted fair service: allocate each class a configured share of schedulable work over time.
- Aging: increase the effective priority of requests that have waited too long.
- Cost-aware dispatch: choose work that fits current resource headroom without starving small requests.
- Per-tenant fairness: prevent one tenant or project from consuming an entire modality queue.
A weighted deficit round-robin (WDRR) scheduler is a useful baseline. Each class receives a quantum of service-cost credits per scheduling round. Dispatch a request only when its estimated cost fits the class deficit and the current resource vector. Unused credits can accumulate up to a cap, allowing bursts without permitting unlimited monopolization.
Deadline urgency can temporarily raise a class's rank, but it should not erase minimum service guarantees for other classes. Aging places a ceiling on starvation time.
A practical priority score#
One interpretable score is:
priority(r) = base_class_weight + deadline_urgency(r) + aging_factor × wait_time(r)
Then apply constraints:
- Never dispatch if predicted resource use exceeds hard capacity.
- Do not allow a low-priority class to consume protected live-interaction reservations.
- Do not let a high-priority class exceed its configured burst budget.
- If a request's predicted completion is already beyond its deadline, do not keep it in the interactive queue; defer, downgrade only with consent/policy, or reject.
A more advanced scheduler can use least-laxity-first:
laxity(r) = deadline(r) − now − predicted_remaining_service_time(r)
Lower laxity means greater urgency. Because predictions are imperfect, combine laxity with class reservations and aging rather than using it as the only policy.
6. Reserve capacity, but allow safe borrowing#
Reserve a minimum share of critical resources for live speech and interactive text. Reservations should cover the actual bottleneck stages:
- Audio encoder and streaming decoder capacity for live speech.
- Decoder slots and KV memory for text TTFT.
- Vision encoder capacity for interactive image requests.
- A bounded share for heavy video and batch processing.
A reservation is not necessarily a permanently idle GPU. Use borrowing: if the live queue is empty, other classes may use its spare capacity, but borrowed work must be bounded or preemptible at safe stage boundaries. Do not borrow in ways that leave no memory headroom for a sudden live-session burst.
Use separate limits for:
- Concurrent sequences.
- Active decoder tokens and KV-cache blocks.
- Vision frames or encoder batches in flight.
- Audio chunks in flight.
- CPU preprocessing workers and decoded payload bytes.
- Per-tenant outstanding estimated cost.
A single “GPU utilization below 90%” admission rule is insufficient. GPU memory, KV-cache capacity, encoder queue delay, CPU saturation, and network bandwidth can become bottlenecks independently.
7. Worked numerical example#
Assume a service has one normalized scheduling budget of 100 GPU-work units per 100 ms across its shared serving stages. This simplified unit is for illustrating policy; real systems should retain separate per-stage resource budgets.
Incoming demand in a 100 ms interval is:
- Text chat: 40 requests, each estimated at 0.5 units = 20 units.
- Live speech: 10 chunks, each estimated at 1 unit = 10 units.
- Image questions: 12 requests, each estimated at 2 units = 24 units.
- Video analysis: 4 requests, each estimated at 15 units = 60 units.
Total offered work is 114 units, exceeding capacity by 14 units. A request-count policy sees 66 requests and may treat them similarly. A cost-aware policy sees the video class alone asks for 60% of the budget.
Set minimum service reservations:
- Live speech: 15 units.
- Text: 25 units.
- Interactive image: 20 units.
- Heavy video/batch: 15 units.
- Shared opportunistic pool: 25 units.
The total is 100 units. In this interval, actual live speech needs only 10 units, text needs 20, and images need 24. Unused live and text reservation may be borrowed under the scheduler's rules. The scheduler can serve all 10 speech units, all 20 text units, all 24 image units, and 46 video units. That completes three 15-unit video jobs and 1 unit of the fourth only if the video work is safely chunkable; otherwise it schedules whole bounded chunks and carries the remainder forward.
The key is that the fourth video does not block the next text prompt or speech chunk. The service has protected interactive capacity, while video still receives a guaranteed share and makes progress.
Now suppose video demand doubles. The scheduler does not silently queue unlimited work. It applies the heavy-media outstanding-cost limit, returns a retry-after estimate or routes to batch processing, and preserves live and text SLO headroom.
8. Chunk expensive work and make preemption explicit#
Large media requests should be split at safe boundaries:
- Video into bounded frame groups or temporal windows.
- Long audio into bounded segments while preserving required context and timestamps.
- Large image sets into bounded image batches.
- Long decoder prefills into chunks if the serving runtime supports safe chunked prefill.
Chunking gives the scheduler more opportunities to interleave short interactive work. But it has costs: repeated setup, context stitching, possible quality loss, and additional state management.
Preemption is not always safe. Interrupting a decoder sequence can waste KV state or require recomputation. Prefer cooperative yield points and bounded execution quanta. Define whether a task can pause, resume, restart, or must finish once launched. Track wasted work caused by preemption.
For live audio, do not drop chunks casually: missing audio can damage transcription or conversational coherence. If the product supports it, use explicit backpressure and bounded buffering. For video, frame sampling or frame dropping is acceptable only when the task's quality contract permits it.
9. Production incident: video burst starves live speech#
Symptom: During a customer event, a burst of video summarization requests causes live speech first-audio latency to rise from 180 ms to 1.4 seconds. Text TTFT also rises. Average GPU utilization is 94%, and the video queue is growing.
Root cause: All modalities share a FIFO admission queue. The gateway limits request count but not frame count or estimated encoder work. Several long videos expand into large frame batches, occupy vision encoder workers, and increase decoder context/KV pressure. The live speech path has no reserved audio capacity. Automatic retries add more requests during overload.
Immediate containment:
- Stop unbounded retries and return explicit retry-after responses for heavy media.
- Cap video frame expansion and outstanding heavy-media cost.
- Protect live speech and text with separate queue budgets.
- Drain or move batch video work to a lower-priority pool.
- Preserve existing live sessions rather than repeatedly restarting them.
Permanent correction:
- Add validated per-request resource estimates.
- Introduce staged reservations and admission checks for encoder, decoder, CPU, and KV resources.
- Replace global FIFO with class queues and weighted fair cost scheduling.
- Add aging and per-tenant limits.
- Chunk video work and allow cooperative yield at safe boundaries.
- Load-test burst combinations, not just each modality in isolation.
Verification: Replay the same trace and compare P50/P95/P99 TTFT, first-audio latency, audio chunk gap, video completion time, class-level goodput, queue age, rejected cost, GPU memory, and wasted preemption work. The fix is successful only if interactive SLOs recover without video starvation or unacceptable quality degradation.
10. Reference scheduler pseudocode#
PYTHONdef admit(request, state): shape = validate_and_bound_shape(request) demand = estimate_resource_vector(shape, percentile="p95") if exceeds_hard_request_limits(shape): return reject("request exceeds supported limits") if not tenant_budget_available(request.tenant, demand): return reject_with_retry_after() if not stage_capacity_can_be_reserved(demand, state): if request.is_interactive and deadline_is_feasible(request, demand, state): return enqueue_bounded(request, demand) return defer_or_reject_with_retry_after() reserve_atomically(request, demand) return enqueue_by_class(request, demand) def choose_next(state, now): candidates = [] for queue in state.queues: request = queue.peek() if request is None: continue if not fits_current_stage_budgets(request.demand, state): continue urgency = deadline_urgency(request, now) aging = min(MAX_AGING, request.wait_seconds * AGING_RATE) fairness = queue.deficit_credits score = request.class_weight + urgency + aging candidates.append((score, fairness, request)) request = select_fair_candidate(candidates) if request is None: return None consume_deficit_and_reservations(request) return dispatch(request)
This is policy pseudocode, not a drop-in implementation. In production, reservation and dispatch must be concurrency-safe; queue state must be recoverable; and estimates must be corrected from observed resource use.
11. What to monitor#
Monitor by modality, service class, model, tenant, and stage—not only fleet-wide averages.
Admission and fairness
- Accepted, deferred, rejected, and shed requests by reason.
- Estimated versus actual cost error by resource and shape bucket.
- Queue depth, oldest age, and wait-time percentiles per class.
- Service share versus configured WDRR weight.
- Maximum wait and starvation events.
- Per-tenant outstanding cost and quota throttling.
Interactive experience
- Text TTFT and inter-token latency.
- Live speech time-to-first-audio and audio chunk gap.
- Session interruption, barge-in responsiveness, and deadline misses.
- Image response latency.
Heavy workloads
- Video queue wait and completion time.
- Audio/video throughput in meaningful units (seconds of media, frames, or clips), not just request count.
- Deadline miss rate and batch goodput.
Resource pressure
- GPU compute and memory by stage.
- KV-cache occupancy and allocation failures.
- Encoder batch size and queue delay.
- CPU preprocessing saturation, network ingress, and decoded payload bytes.
- Preemption, cancellation, and recomputation waste.
Alert on SLO violations and unfairness together. A healthy fleet average can conceal one modality or tenant being starved.
12. Common mistakes#
- One FIFO queue for every modality: large jobs create head-of-line blocking.
- Request-count quotas: one 100-frame video is not equivalent to one short text prompt.
- Strict priority without aging: low-priority media can starve forever.
- A single scalar cost model: it hides bottlenecks in KV memory, CPU, network, or a particular encoder.
- Mean-only cost estimates: heavy-tailed requests cause over-admission.
- Reservations without borrowing: capacity sits idle during quiet periods.
- Unbounded borrowing: a burst can consume the capacity supposedly reserved for live traffic.
- Preemption without resumability: the system wastes expensive partial work.
- Retries during overload: retries amplify the original burst.
- Quality degradation without a contract: dropping frames or lowering resolution can change the answer, not just the latency.
- Fleet-level metrics only: aggregate latency hides cross-modality and per-tenant unfairness.
13. A practical rollout plan#
- Observe first: add stage spans and estimate per-request resource vectors without changing dispatch.
- Shadow decisions: calculate admission and scheduling decisions in parallel with the existing scheduler; measure false accepts and false rejects.
- Bound ingress: introduce payload, frame, duration, queue, and per-tenant outstanding-cost limits.
- Create class queues: begin with live, interactive, heavy media, and batch.
- Protect critical capacity: reserve live speech and text headroom; allow bounded borrowing.
- Enable fair scheduling: introduce weighted cost-based service, aging, and deadline feasibility checks.
- Add chunking and cooperative yield: only where model/runtime semantics support it.
- Run mixed-modality stress tests: replay synchronized bursts and long-tail shapes.
- Canary by tenant or traffic slice: compare SLOs, fairness, cost, and quality.
- Tune from evidence: update weights and estimates from measured demand, not intuition.
14. Interview-ready answer#
I would not schedule multimodal requests by request count or use one global FIFO. I would estimate each request's stage-specific resource vector—vision/audio/decoder GPU time, CPU preprocessing, KV memory, and network demand—using conservative shape-conditioned estimates. I would apply staged admission at the gateway, after preprocessing, and before GPU dispatch, reserving capacity atomically.
I would isolate live speech, interactive text, interactive media, and heavy batch/video into bounded logical queues. A deadline-aware weighted fair scheduler with deficit accounting, aging, per-tenant limits, and bounded borrowing would protect latency-critical work while guaranteeing progress for expensive jobs. I would chunk long media where safe, prevent retry amplification, and shed or defer work when predicted completion cannot meet its deadline. Finally, I would validate the policy using mixed-modality trace replay and monitor per-class tail latency, goodput, queue age, fairness, resource pressure, and quality.
15. Further reading#
- Papaioannou and Doudali, *Rocks, Pebbles and Sand: Modality-aware Scheduling for Multimodal Large Language Model Inference* (2026). Explores cost-aware modality classification, priority scheduling, and aging to reduce interference and avoid starvation.
- *ModServe: Modality- and Stage-Aware Resource Disaggregation for Scalable Multimodal Model Serving* (SoCC 2025). Studies heterogeneous multi-stage inference traces, burstiness, modality-aware scheduling, and adaptive stage scaling.
- *Formal schedulability analysis for LLM inference: TTFT and TBT deadline guarantees via response-time theory* (2026). Connects admission decisions with TTFT and token-between-token constraints.
- *OmniCast: Interaction-Aware Serving for Real-Time Omni-Modal LLMs* (2026). Shows why playback progress, first-audio urgency, and user barge-in should influence real-time scheduling.
The central principle: admit and schedule predicted work, not request counts. Protect deadlines, guarantee fairness, and keep every expensive modality making bounded progress.
References
- 1.
- 2.
- 3.
- 4.
Related questions
- How do you design admission control and backpressure to prevent overload in production LLM inference?
- How do you benchmark mixed text, image, audio, and video inference workloads while accurately measuring modality-specific latency, throughput, and GPU resource utilization?
- How do you use the waiting request queue to schedule shared-prefix LLM requests and protect the KV cache from predictable eviction?
Explore other topics:Deep LearningRetrieval-Augmented GenerationAI Agents