The Inference Engineering Masterclass — Philip Kiely & Ali Taha, Baseten
Episode
101 min
Read time
3 min
Topics
Productivity, Artificial Intelligence, Software Development
AI-Generated Summary
Key Takeaways
- ✓Cache-Aware Routing: When a long prompt (e.g., 200,000 tokens) arrives, route it to a replica that already holds a matching KV cache to skip prefill entirely. Baseten checks for cached inputs before assigning a prefill worker. For repeated agentic or coding workloads, this alone delivers significant latency reduction. Disaggregating prefill and decode across separate GPU sets further prevents decode throughput from being bottlenecked by heavy prefill computation on the same hardware.
- ✓Speculative Decoding Gains and Limits: A small draft model — typically one-sixteenth the size of the target model, around 1B parameters — predicts 3 tokens per step, which the full model verifies in one forward pass. Acceptance rates are traffic-dependent: a coding-specific speculator achieves near-perfect acceptance on coding prompts but degrades on unrelated tasks. For shared endpoints, general-purpose speculators trained on public coding and agentic datasets are the practical default, delivering roughly a 2x decode speed improvement.
- ✓Quantization Error Cancellation: Baseten's research intern Joshua demonstrated mathematically that quantizing more layers can produce better output fidelity than quantizing fewer, because quantization errors across layers can cancel out. By predicting which layers have offsetting error distributions — one skewed right, the next left — and selectively quantizing those, Baseten achieved 20% higher quantization than NVIDIA's baseline on GLM 5.2 while improving KL divergence between quantized and full-precision logit distributions, yielding both better throughput and better model fidelity simultaneously.
- ✓Stacking Optimizations for 4–10x Gains: A baseline GLM 5.2 deployment on Hoppers without optimization runs at roughly 30–40 tokens per second. Moving from BF16 to INT8 adds ~30–40%; INT8 to NVFP4 adds another ~30–40% (combined ~2x). A well-trained speculator adds another ~2x. Prefill/decode disaggregation adds a further ~2x under sufficient traffic. Stacking these three optimizations reaches approximately 8–10x over baseline, with the best-configured deployments hitting 300–400 tokens per second on latency-optimized parallelism settings.
- ✓Dedicated vs. Serverless Inference Threshold: The decision to move from pay-per-token serverless APIs to dedicated GPU deployments is driven by three factors: reliability requirements, traffic volume (millions of tokens per hour make hourly billing substantially cheaper), and workload specificity. Dedicated deployments unlock traffic-specific speculative decoders, custom quantization precision, tuned batch sizes, and parallelism strategies optimized for latency versus throughput — none of which are feasible on shared endpoints where traffic patterns are unknown and hardware is contended.
What It Covers
Philip Kiely and Ali Taha from Baseten walk through the full inference engineering stack — from cache-aware routing and prefill/decode disaggregation to speculative decoding, quantization strategies, and hardware parallelism — explaining how providers stack optimizations to achieve 4–10x speed improvements over baseline deployments, while covering video diffusion constraints and the convergence of training and inference workflows.
Key Questions Answered
- •Cache-Aware Routing: When a long prompt (e.g., 200,000 tokens) arrives, route it to a replica that already holds a matching KV cache to skip prefill entirely. Baseten checks for cached inputs before assigning a prefill worker. For repeated agentic or coding workloads, this alone delivers significant latency reduction. Disaggregating prefill and decode across separate GPU sets further prevents decode throughput from being bottlenecked by heavy prefill computation on the same hardware.
- •Speculative Decoding Gains and Limits: A small draft model — typically one-sixteenth the size of the target model, around 1B parameters — predicts 3 tokens per step, which the full model verifies in one forward pass. Acceptance rates are traffic-dependent: a coding-specific speculator achieves near-perfect acceptance on coding prompts but degrades on unrelated tasks. For shared endpoints, general-purpose speculators trained on public coding and agentic datasets are the practical default, delivering roughly a 2x decode speed improvement.
- •Quantization Error Cancellation: Baseten's research intern Joshua demonstrated mathematically that quantizing more layers can produce better output fidelity than quantizing fewer, because quantization errors across layers can cancel out. By predicting which layers have offsetting error distributions — one skewed right, the next left — and selectively quantizing those, Baseten achieved 20% higher quantization than NVIDIA's baseline on GLM 5.2 while improving KL divergence between quantized and full-precision logit distributions, yielding both better throughput and better model fidelity simultaneously.
- •Stacking Optimizations for 4–10x Gains: A baseline GLM 5.2 deployment on Hoppers without optimization runs at roughly 30–40 tokens per second. Moving from BF16 to INT8 adds ~30–40%; INT8 to NVFP4 adds another ~30–40% (combined ~2x). A well-trained speculator adds another ~2x. Prefill/decode disaggregation adds a further ~2x under sufficient traffic. Stacking these three optimizations reaches approximately 8–10x over baseline, with the best-configured deployments hitting 300–400 tokens per second on latency-optimized parallelism settings.
- •Dedicated vs. Serverless Inference Threshold: The decision to move from pay-per-token serverless APIs to dedicated GPU deployments is driven by three factors: reliability requirements, traffic volume (millions of tokens per hour make hourly billing substantially cheaper), and workload specificity. Dedicated deployments unlock traffic-specific speculative decoders, custom quantization precision, tuned batch sizes, and parallelism strategies optimized for latency versus throughput — none of which are feasible on shared endpoints where traffic patterns are unknown and hardware is contended.
- •Video Diffusion Attention Bottleneck: Generating five seconds of 480p video at 16 fps produces roughly 35,000 attention tokens after latent compression. Because diffusion attention is quadratic, doubling duration quadruples compute, making full-attention generation beyond ~10 seconds practically infeasible on current hardware. Sparse attention (top 12.5% of tokens) reduces compute but degrades quality. Autoregressive video models would enable streaming generation and allow LLM-style inference optimizations like speculative decoding, but no open-source autoregressive video model currently matches diffusion quality.
- •Training–Inference Convergence: Inference engineers at Baseten now routinely write training pipelines. Two workflows drive this: first, speculative decoder (Eagle-head) training requires running inference on the base model to extract hidden states as training data. Second, when NVFP4 post-training quantization (PTQ) degrades model quality, quantization-aware distillation — running full-precision and NVFP4 model versions in parallel and aligning their logit distributions — recovers fidelity. NVIDIA's quantization distillation paper formalizes this approach, and RL training rollout speed directly depends on inference engine throughput, making inference optimization a training bottleneck.
Notable Moment
Ali Taha describes a race condition bug where the same model weights on one GPU cluster produced token repetition loops while an identical deployment on a different cluster did not. The root cause traced to KV cache transfer speed between nodes: a slower interconnect exposed a kernel synchronization flaw that faster NVLink connections masked entirely, making the bug hardware-topology-dependent rather than a model or software issue.
Episode Transcript
Okay. We're here in the studio with, Philip, old friend from from, Inference Engineering, the book, as well as Base 10, and, everything that you've done, you and I have done before, as well as Ali. Welcome. Pleasure, mate. Waterloo intern. Waterloo intern. Always. When did you get Waterloo intern as a As a handle? Oh. Handle. I think the rebranding happened, like, mid March. When I saw it was open, I was like, I have to take it all for grabs. The problem is that Ali is really good at his job and is not gonna be an intern much longer, so we have to figure out, you know, who's gonna get the handle. Pass the torch over. Oh, okay. It it can be like, you just pass it to another Waterloo. Right? To another Waterloo. Enter. Enter. Yeah. And and You gotta get an interest from Yeah. We gotta get it from Waterloo. Right? Yeah. Right. Right. But they have to process Oh, it could but it could come from base ten. So it's like whoever base ten gets from Waterloo Right. Has the title of Waterloo. So they have to pass you exactly halfway through. Oh, you should You either get it or you're out. You should also do, like, a big graduation ceremony where you change the handle. Just say it like everybody. I mean, you guys are good at ceremonies, clearly. You know, we had a nice launch of the book, very successful. But before we get into all that, I wanna start off with a fun question for you. Okay. You're expert inference engineer. What happens when I send a long query, say, 200,000 tokens into base tens inference? What's the process of query through GPU model routing, balancing, all that? What is all the stuff that we don't think about? With a long query specifically, the first thing that I'm gonna ask is, have you sent me this query before or at least part of it? And I really hope you have because it's gonna be a lot easier for me and a lot cheaper for you. So the first thing that we're gonna look at is some kind of cache aware routing, where we're going to see we probably have a number of instances, a number of replicas up serving whatever model you're hitting. We want to send this one to something with, number one, available prefill workers, and number two, ideally, some cached input already there so that we can skip prefill on at least part of these 200,000 tokens. If you're doing 200,000 tokens, it's probably coding or a multi tone agent or or something where you would expect to have that cached. If you don't, we're gonna have to send it to a prefill worker. We've, at least on certain models, disaggregated prefill and decode. So you're going to have one set of GPUs that's solely going to process the input, create that k v cache, and get you …
Get the full transcript (20,624 words) + summary by email — free
One-time email with the complete transcript and AI summary of this episode. No account needed.
One email, no spam. We’ll also show you what SignalCast does.
You just read a 3-minute summary of a 98-minute episode.
Get Latent Space summarized like this every Monday — plus up to 2 more podcasts, free.
Pick Your Podcasts — FreeKeep Reading
More from Latent Space
Codex from 0 to 10M Users: Building ChatGPT Work — Akshay Nathan, OpenAI
Jul 28 · 69 min
The TWIML AI Podcast
How to Engineer AI Inference Systems with Philip Kiely - #766
Apr 30
More from Latent Space
Inside the Model Factory — Eiso Kant, Poolside AI
Jul 23 · 114 min
Invest Like the Best with Patrick O'Shaughnessy
Etched - Building AI Hardware to Make Inference Faster and Cheaper - [Invest Like the Best, EP.480]
Jun 30
More from Latent Space
We summarize every new episode. Want them in your inbox?
Codex from 0 to 10M Users: Building ChatGPT Work — Akshay Nathan, OpenAI
Inside the Model Factory — Eiso Kant, Poolside AI
🔬Causal Models Need Causal Data - Xaira’s X-Cell model for Drug Discovery (Bo Wang & Ci Chu, Chief Discovery Officer & Chief AI Scientist)
🔬 The Lab of the Future Should Feel Like a Data Center — Andy Beam & Rafa Gómez-Bombarelli, Lila Sciences
Why AI Infrastructure must evolve for Agent Experience — Akshat Bubna, Modal CTO
Similar Episodes
Related episodes from other podcasts
The TWIML AI Podcast
Apr 30
How to Engineer AI Inference Systems with Philip Kiely - #766
Invest Like the Best with Patrick O'Shaughnessy
Jun 30
Etched - Building AI Hardware to Make Inference Faster and Cheaper - [Invest Like the Best, EP.480]
The Joe Rogan Experience
Jul 30
#2533 - Diana Pasulka
The AI Breakdown
Jul 1
Fable is Back: Here's What You Should Try First
Software Engineering Daily
May 28
Autonomous Drone Delivery at Scale
Explore Related Topics
This podcast is featured in Best AI Podcasts (2026) — ranked and reviewed with AI summaries.
Read this week's AI & Machine Learning Podcast Insights — cross-podcast analysis updated weekly.
You're clearly into Latent Space.
Every Monday, we deliver AI summaries of the latest episodes from Latent Space and 192+ other podcasts. Free for one show.
Start My Monday DigestNo credit card · Unsubscribe anytime