Key Moments

The Inference Frontier: 10x Faster Models to Self-Optimizing AI — Philip Kiely & Ali Taha, Baseten

Latent Space PodcastLatent Space Podcast
Science & Technology6 min read103 min video
Aug 3, 2026|790 views|49|7
Save to Pod

Want to know something specific about what's covered?

We've already dissected every moment. Ask and we will deliver (with timestamps).

TL;DR

AI models can now write their own optimized GPU kernels, but achieving peak inference performance involves complex, multi-layered engineering beyond just model weights.

Key Insights

1

GLM-5.2 can analyze performance profiles, identify bottleneck kernels, and rewrite them for optimization, with some of these kernels then being written by GLM-5.2 itself.

2

Speculative decoding, a technique to speed up token generation by having a smaller model predict multiple tokens at once, relies on traffic-specific training to maintain high acceptance rates.

3

Combining components from different open-source models, like a vision encoder from one with LLM weights from another, is a key strength of the open-source ecosystem.

4

Quantization, while a lossy optimization that improves speed, can sometimes lead to better fidelity if quantization errors are carefully managed and cancel each other out, as demonstrated by a research intern's work showing 20% more quantized models with better quality.

5

Inference engineering for data centers focuses on reducing latency (making models faster), while local AI inference engineering prioritizes fitting models onto hardware and reducing their 'dumbness' through quantization, pruning, and distillation.

6

Video diffusion models face significant challenges with attention bottlenecks due to the sheer number of tokens required, leading to a trade-off between full attention (high quality, infeasible compute) and sparse attention (lower quality) or an exploration of autoregressive video generation.

AI models writing their own optimization code

A fascinating demonstration of AI self-improvement involves models like GLM-5.2 being used to analyze their own performance. By plugging the model into a cloud code harness, it can perform forward passes, capture profile traces, identify bottleneck GPU kernels, and then rewrite those kernels for optimization. This iterative process, where the model optimizes itself by generating and testing new code, showcases a remarkable level of autonomy in performance tuning. Some GPU kernels within Baseten's inference engine have, in fact, been written by GLM-5.2 itself.

Optimizing inference speed with speculative decoding and cache-aware routing

When processing a long query (e.g., 200,000 tokens), the first consideration is whether parts of the query have been seen before, leveraging cache-aware routing to send requests to instances with available prefill workers and cached inputs. This significantly reduces the computational load by skipping the prefill step for cached tokens. For new inputs, some models employ disaggregated prefill and decode stages, with separate GPU sets handling input processing and token generation. Speculative decoding further enhances speed. A smaller, 'speculator' model rapidly generates several potential tokens, which are then verified by the main model. This drastically speeds up decode if the speculator has a high acceptance rate. However, the effectiveness of speculative decoding is highly traffic-specific; a speculator trained on coding tasks will perform poorly if the user is summarizing Harry Potter books. For dedicated deployments, custom speculative models can be trained, offering significant speedups tailored to specific use cases.

The complexities of production-ready model deployment

Moving from a model that can simply 'make a token' to a production-ready API involves substantial engineering. This includes re-performing quantization to ensure compatibility and optimal performance (e.g., using NVFP4 for Blackwell compatibility), and meticulously calibrating these quantized weights to avoid regressions in model intelligence. Training speculative decoders is crucial, leveraging public datasets representative of popular use cases like coding and agentic tasks. The process requires the actual model weights to extract hidden states for training the speculator. Furthermore, adapting to new model architectures, such as the sparse attention mechanisms seen in models like DeepSeek or the vision capabilities grafted onto GLM-5.2 by combining components from different models (e.g., a vision encoder from Kimi with GLM weights), adds layers of complexity. Each new model architecture can introduce novel challenges that require runtime support and careful integration.

Structured output and the challenges of tool calling

Tool calling, while seemingly straightforward, presents significant challenges, especially when customers require highly specific, post-trained models. The core issue often lies not in the sandboxing or containment of the LLM, but in its ability to correctly parse and utilize the JSON outputs required for tool invocation. If the post-training or quantization process is suboptimal, the model may struggle to reliably read JSON. A common failure mode is the model performing the 'thinking' and 'tool calling' but then hallucinating the result during decoding because it didn't properly see the complete response. To mitigate this, techniques like structured output generation, using state machines or BNF grammars to constrain the output format, are employed. This ensures the output adheres to a specific structure, though it doesn't guarantee the model will call the correct tool or avoid certainty issues.

Quantization: a balance of speed and fidelity

Quantization, a primary optimization technique, reduces model size and increases inference speed by using lower-precision data formats (e.g., FP16 to INT4). While technically a lossy process, the goal is to preserve model fidelity as closely as possible to the original full-precision model. Research has shown that it's not always a case of 'more quantization equals worse quality.' In some instances, by strategically quantizing specific layers and calibrating the weights, quantization errors can effectively cancel each other out, leading to a model that is more heavily quantized (e.g., 20% more) yet retains or even improves fidelity compared to less quantized models. This is assessed not just by standard benchmarks but also by comparing logit distributions using metrics like KL divergence to ensure the quantized model's output probabilities closely match the original.

The evolving landscape of AI hardware and parallelism

The field is seeing rapid advancements in AI hardware, with new generations like NVIDIA's Blackwell and the upcoming Rubin pushing boundaries in memory bandwidth and compute power. While tensor parallelism (sharding a model across GPUs) is beneficial for latency and requires high-bandwidth interconnects like NVLink, expert parallelism (placing entire 'experts' of a Mixture-of-Experts model on different GPUs) can increase throughput with less critical inter-GPU communication. Pipeline parallelism is typically reserved for multi-node inference when a model exceeds single-node capacity. The memory requirements for large models, especially with long context lengths, are immense; for instance, a 2.8 trillion parameter model in FP4 requires approximately 1.4 terabytes, necessitating substantial GPU VRAM (e.g., 288 GB per GB300 GPU) and efficient KV cache management. The trend suggests GPUs are becoming more specialized, incorporating tensor cores and instructions tailored for AI workloads, blurring the lines with ASICs.

Video generation's unique inference challenges

Inference engineering for video diffusion models presents distinct challenges compared to LLMs. Models are generally smaller, and batching is less common, with each request often served by a single GPU. However, the sheer number of tokens required for high-quality video (e.g., 16 frames per second at 480p) creates massive attention bottlenecks due to the quadratic complexity of full attention. This forces a choice between computationally infeasible full attention or sparse attention methods that compromise video quality. Autoregressive video generation offers a potential solution, allowing for streaming output and application of LLM-like optimizations, but current open-source models often suffer from degraded quality and frame-to-frame consistency issues, leading to 'drift' over longer sequences. While closed-source models use proprietary techniques to stitch video chunks effectively, the open-source community is still working towards robust autoregressive video generation or significant breakthroughs in efficient full attention.

The convergence of training and inference engineering

The lines between training and inference engineering are increasingly blurring. Inference optimizations are becoming critical for training pipelines, particularly for efficient rollouts and data generation. Conversely, training techniques are vital for inference, especially in areas like post-training quantization, where models may need fine-tuning after quantization to regain performance. Techniques like quantization distillation, where an FP4 model is trained to mimic the logits of a full-precision model, highlight this convergence. The ultimate goal is a continuous improvement loop where models learn from live inference data, dynamically adjust systems, and are then retrained and rolled out. This unification accelerates the development of more capable and efficient AI systems, with models potentially even optimizing their own inference processes, as seen with GLM-5.2's ability to write GPU kernels.

Common Questions

Baseten first checks for cached inputs to skip prefill. If not cached, it disaggregates prefill and decode, using separate GPUs for each, and may employ a speculative model, especially for coding tasks, to iteratively generate tokens.

Topics

Mentioned in this video

Software & Apps
GPU

Graphics Processing Unit, central to AI inference calculations, discussed in the context of kernel writing and processing queries.

CLIP

A foundational model for vision-language tasks, mentioned in the context of building questions off images.

VLM

A type of Visual Language Model or open-source inference engine, mentioned in comparison to proprietary stacks.

SGLang

An open-source inference engine, often receives weights ahead of time for new models.

LAVIS

A vision-language model, its paper described as foundational work for vision processing.

Jamba

A model from AI21 that specifically designs its architecture dimensions for a target hardware to maximize saturation.

Reuben

A future NVIDIA GPU, speculated to have architectural features that mitigate the need for mega kernels and emphasize system-level optimization.

GPT-5

A theoretical or future version of OpenAI's GPT model, used as a benchmark for open-source LLM capabilities.

Unreal Engine 5

A closed-source video generation model, chosen by media companies for higher quality despite higher cost.

Llama

An earlier version of Meta's open-source language model, highlighting model longevity and trust in enterprise settings.

Neotron models

NVIDIA's own models, known to run very well on Blackwell hardware, suggesting hardware-targeted training.

Nano Banana

An image generation model, cited as an example of an auto-regressive image model.

Midjourney

An AI art generator, its founder David Holtz was mentioned for his interest in text diffusion.

CUDA

NVIDIA's parallel computing platform and programming model, mentioned in the context of low-level GPU programming challenges.

Kling

A closed-source video generation model, noted for its higher quality compared to open-source alternatives.

Llama 3

An open-source language model, still seeing significant workloads despite newer models.

Cosmos

A new 'world model' type of AI, mentioned as an upcoming modality in AI research.

GPT Image

An image generation model, cited as an example of an auto-regressive image model.

Gemma

An open-source diffusion model for text, noted for its performance relative to its size.

Kimmy

A large language model, specifically the 3-trillion parameter version, used as an example of a model that requires specialized hardware like GB300s.

GPT

OpenAI's foundational language model, referenced for its early streaming behavior where text was generated progressively.

PyTorch

A popular open-source machine learning framework, mentioned in the context of guaranteeing execution order in GPU operations.

More from Latent Space

View all 241 summaries

Ask anything from this episode.

Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.

Get Started Free