Model and Inference EngineeringEnd-to-end serving and modalitiesStaff
How would you diagnose shape-dependent inference fallbacks and choose which execution paths to optimize?
By Amit Kumar3 min readWorked answer includedReviewed 27 Sept 2026
The question
Interview question
An engine benchmarks well on 1,024-token prompts and batches of eight or sixteen. Production has worse p99 latency, and traces show generic execution for some unusual input and batch shapes. Design a causal investigation and a bounded capture or routing policy. Explain the correctness and capacity costs of rejecting every unbenchmarked shape.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
Optimized execution often covers a defined set of shapes and operations. A CUDA graph records GPU work for replay with a compatible execution structure, avoiding some repeated host launch overhead. Eager execution dispatches operations through the ordinary runtime. Falling back to eager can be correct but slower, while graph capture or compilation may introduce a separate one-time cost.
First verify which path explains the observed tail. A batch of sixteen short text requests is not the same workload as eight requests containing a mixture of long prompts and images, even when a dashboard gives them the same aggregate token count. Record prompt and decode lengths, batch shape at each step, modality, cache state and time in queue, prefill and decode. Engine version and capture configuration determine which combinations are eligible. vLLM’s compilation configuration and vision graph fallback design describe concrete cases, not a universal rule for every engine.
The benchmark should replay the joint shape distribution, not just a histogram of input tokens. Measure request rate, concurrency, prompt and output length together, image or tool modes if supported, prefix-cache hit rate, and the scheduler's resulting batch shapes. Report latency and work by path: graph replay, compilation or capture miss, and normal eager execution. A fallback that affects two percent of requests may account for most SLO misses if those requests occupy the GPU longer and delay neighbors. A p99 chart alone cannot tell whether the rare requests are slow or whether they slow the common ones behind them.
Then choose a bounded response. If a few high-volume shape classes miss a fast path, add capture sizes or buckets and warm those paths before admission. Check the extra memory and startup time because graph capture is not free. If the generic path is valid but costly, route that class to a separate capacity pool or give it a different deadline and truthful estimate. If an operation is unsupported by the optimized path, fix or specialize it only when the traffic and quality benefit justify the work. A generic path can be the right compatibility behavior. Blindly rejecting unusual shapes may discard the users whose tasks most need the service.
I would test with a production-weighted replay, then hold out recent traffic so the newly chosen buckets are not just tuned to yesterday's sample. Include canary traces that prove each intended path actually runs. Protect the fleet while new shapes appear with admission headroom and an overload policy. If the interviewer says “GPU utilization is only 55 percent,” ask over what interval and whether the stalled request is waiting on a CPU preprocessing step, compilation, memory allocation or a serialized GPU path. Average utilization does not disprove a shape-specific p99 problem. A tokens per second benchmark looks great. What did it measure? asks what a tokens-per-second number represents. This answer connects a missed execution path to actual traffic shapes and a capacity decision.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux