
Show Notes
When an AI model answers slowly, the problem usually isn't its intelligence — it's how the serving system moves data through a GPU. This episode goes one level below the basic inference loop covered in an earlier episode, into GPU memory, the key-value cache, attention kernels, and the scheduling techniques used by systems like vLLM and NVIDIA TensorRT-LLM.
It starts by separating prefill, which processes prompt tokens in parallel and benefits from raw compute throughput, from decode, which is autoregressive and becomes memory-bound because each step needs the model weights and the growing attention state for every prior token. The episode works through a concrete KV-cache size estimate: with 32 transformer layers, 8 key-value heads, a head dimension of 128, and 2 bytes per cached value, each token costs 131,072 bytes, or 128 kibibytes, of cache; at 8,192 tokens, one sequence's cache runs to roughly a gibibyte before overhead, showing why long context and concurrent users turn KV-cache capacity into a scheduling problem.
From there, it covers the main optimizations serving engines use: grouped-query attention (GQA), which shares key-value heads across multiple query heads to shrink the cache; FlashAttention, which computes exact attention while cutting memory traffic through tiling and on-chip memory; continuous batching, which replaces finished requests in an active batch instead of waiting for a fixed batch to clear; chunked prefill, which splits long prompts into pieces interleaved with decode work so one long prompt doesn't stall other users; PagedAttention, which allocates KV-cache memory in non-contiguous blocks to reduce fragmentation; prefix caching, which reuses cached state across requests sharing an identical prompt prefix; and quantization, which trades numerical precision for memory and speed.
The episode closes with the metrics that tie these optimizations to specific symptoms: time to first token for queueing and prefill issues, inter-token latency and throughput for decode and batching issues, and memory use and tail latency under concurrency for capacity issues, arguing that LLM inference is as much a hardware-and-scheduling problem as a model problem.
Sources & References NVIDIA Technical Blog: Co-Designing AI Model Attention for Fast, Interactive Long-Context Inference — https://developer.nvidia.com/blog/co-designing-ai-model-attention-for-fast-interactive-long-context-inference NVIDIA Technical Blog: Mastering LLM Techniques: Inference Optimization — https://developer.nvidia.com/blog/mastering-llm-techniques-inference-optimization vLLM Documentation: Automatic Prefix Caching — https://docs.vllm.cc/en/latest/design/automatic_prefix_caching.html vLLM Documentation — https://docs.vllm.cc/en/latest/ NVIDIA TensorRT-LLM Documentation: Paged Attention, IFB, and Request Scheduling — https://nvidia.github.io/TensorRT-LLM/1.2.0rc3/features/paged-attention-ifb-scheduler.html NVIDIA Technical Blog: Streamlining AI Inference Performance and Deployment with TensorRT-LLM Chunked Prefill — https://developer.nvidia.com/blog/?p=92052
Voice narration is AI-generated.
More from Learn AI in Bits
A wave of cybersecurity disclosures has made this week feel like a turning point, with people calling it "Black October." This episode treats it as a cluster of high-impact incidents, not proof that one AI-driven campaign caused them all, and separates where AI was directly involved from where the failures were conventional.
Recursive self-improvement is the idea that an AI can improve the very process it uses to improve itself, and this episode separates what's been demonstrated so far from the dramatic predictions often attached to the term. It draws a clear line between self-correction (revising one answer), automated optimization (keeping the best of several tested variants), and true recursive improvement, where the system changes the process that generates future improvements, so the next round starts with a better improver.
This week's AI News Sunday Wrap-Up covers a week where the industry moved on several fronts at once: new flagship and open models, enterprise agent governance, a serious safety warning, legal pressure, and the physical infrastructure limits behind the AI race.
Meta's Muse story is moving fast, and this episode takes a closer look at Muse Spark, the multimodal reasoning model family behind Meta's push into AI agents, including yesterday's release of an open-weight version for developers.
When a large language model generates text one token at a time, even a fast GPU hits a sequential bottleneck. This episode explains speculative decoding, an inference technique that prepares several tokens at once and checks them together, and when the extra computation pays off.