Design Low-Latency Gemini Serving With Continuous Batching on TPUs

Last updated: November 29, 2026

Quick Overview

Design the serving system for a large chat model behind a consumer app, meeting time-to-first-token and tokens-per-second targets while maximizing accelerator utilization. Cover batching, KV cache management and model parallelism.

Google
ML System Design
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
System Design Round
ML System Design
Hard

0

0

0 solved


Design the serving system for a large chat model behind a consumer app, meeting time-to-first-token and tokens-per-second targets while maximizing accelerator utilization. Cover batching, KV cache management and model parallelism.

LLM serving efficiency drives the cost of every generative feature at Google, so infrastructure-leaning ML interviews dig into prefill versus decode, memory for the KV cache and sharding across TPU chips. Interviewers want concrete numbers and clear trade-offs between latency and throughput.

What the Interviewer Expects
  • Separate prefill and decode phases and their different bottlenecks
  • Use continuous batching and paged KV cache memory
  • Choose tensor and pipeline parallelism to fit the model
  • Set SLOs for time to first token and inter-token latency
  • Discuss prefix caching, quantization and speculative decoding
Key Topics to Cover
Continuous batching
KV cache
Model parallelism
Prefill and decode
Quantization
How to Approach This
  1. Start by mapping the business objective to a concrete ML objective and metric.
  2. Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
  3. Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
  4. Address the serving latency budget and whether batch or real-time inference is needed.
  5. Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
  • How big is the KV cache for a 32k-token context and how does that limit batch size?
  • When would you disaggregate prefill and decode onto different pools?
  • How do you prevent one very long prompt from hurting everyone's latency?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice ML System Design Problems
Sample Answer
Requirements

Targets: time to first token under 500 ms at p50, inter-token latency under 30 ms, at a peak of hundreds of thousands of concurrent conversations. Model: tens of billions of parameters, context up to ...

High-Level Design
  1. Frontend: authenticates, applies safety pre-checks, routes to a region and model replica.
  2. Scheduler per replica: continuous batching, admitting new requests every decode step.
  3. **Model...

Submit Your Answer
Markdown supported