Stanford CS25: Transformers United V6 I On the Tradeoffs of State Space Models and Transformers
TL;DR
Albert Gu analyzes the fundamental tradeoffs between State Space Models (SSMs) and Transformers, framing SSMs as "brain-like" fixed-size state compressors that enable linear inference complexity versus Transformers' "database-like" KV cache approach that scales quadratically but enables precise retrieval.
🔄 The Rise of Linear Architectures 3 insights
Explosion of sub-quadratic alternatives
Since Mamba's release two years ago, the field has rapidly adopted linear-complexity architectures including Mamba 2/3, xLSTM, DeltaNet, and gated DeltaNet as production-viable alternatives to transformers.
Production-scale hybrid adoption
Major AI labs now deploy hybrid models (Jamba, Zamba, Samba, Qwen, Hunyuan, NeMo-Megatron) combining SSM layers with attention mechanisms, with several models scaled to hundreds of billions of parameters.
Convergent nomenclature
Terms like linear attention, modern RNNs, linear RNNs, and state space models now largely refer to the same family of input-dependent recurrent architectures with similar computational characteristics.
🧠 State Compression vs. Database Caching 3 insights
The KV cache bottleneck
Transformers function like expandable databases, maintaining a growing KV cache of every past token that enables precise pairwise comparisons but creates quadratic scaling in both memory and computation during inference.
Fixed-state compression paradigm
SSMs operate like brains, compressing all historical context into a fixed-size hidden state that remains constant regardless of sequence length, enabling linear time complexity and constant memory per generation step.
Architectural tradeoff fundamentals
The distinction between these approaches centers on what they store between generation steps: transformers cache raw tokens for exact lookup while SSMs maintain compressed summaries for efficient processing.
⚙️ Three Critical Ingredients for SSMs 3 insights
Expanded state dimensions
Modern SSMs expand input dimensions by 64-128x (state size of 64-128), creating a much wider information bottleneck than LSTMs to preserve critical information from dense modalities like language.
Input-dependent selectivity
Parameters become functions of the input itself (A and B matrices vary by token), allowing the model to dynamically control what information to remember or discard based on current context.
Parallel training algorithms
Efficient computation via associative scans (original Mamba) and chunked matrix multiplications (Mamba 2/DeltaNet) makes training these large-state models feasible despite their recurrent formulation.
🏆 Current Landscape and Recommendations 3 insights
Leading production variants
Mamba 2 and gated DeltaNet currently represent the most tried-and-true implementations, with gated DeltaNet offering greater modeling power at slightly reduced computational speed compared to Mamba 2.
Architectural convergence
Modern SSM variants share more structural similarities with each other than with attention mechanisms, differing primarily in specific parameterizations while maintaining the core linear-recurrent paradigm.
Framework for model selection
Choose Transformers for tasks requiring exact retrieval from long contexts and SSMs for efficient inference with compressed representations, with hybrid architectures offering practical middle-ground solutions.
Bottom Line
Select State Space Models for linear-inference efficiency and fixed memory footprint when tasks tolerate compressed context representations, but retain Transformers when precise retrieval from arbitrary past tokens is critical, with hybrid models emerging as the dominant production architecture.
More from Stanford Online
View all
Stanford Robotics Seminar ENGR319 | Spring 2026 | Towards Trustworthy Autonomy
As learning-based robotics deploy at scale—exemplified by Waymo's 500,000 weekly rides—they face dangerous 'semantic anomalies' where context causes system-level confusion rather than visual novelty. The speaker presents a 'fast and slow' reasoning framework using lightweight embedding models for real-time detection and large language models for safety interventions, enabling trustworthy autonomy without requiring perfect prediction models.
Stanford MS&E435 Economics of the AI Supercycle | Spring 2026 | Applications, Coding AI
Vercel founder Guillermo Rauch explains how AI coding agents have expanded the software development market by 10-100x, driving a fundamental shift from traditional web services to 'agentic infrastructure' where tokens replace pixels as the primary commodity and deployment becomes the critical value creator.
Stanford MS&E435 Economics of the AI Supercycle | Spring 2026 | Building AI Factories
Crusoe Energy CEO Chase Lockmiller explains how AI data centers represent history's second-largest infrastructure investment, driven by the economic potential of scalable 'digital labor.' He reveals Crusoe's strategy of building massive AI factories in stranded-power locations like Abilene, Texas, to overcome the industry's critical bottleneck: energized data center capacity.
AI in Healthcare Series: Inside the Rise of AI in Healthcare, Open Evidence and Cyber Risks
Former U.S. Chief Data Scientist DJ Patil warns that healthcare systems are dangerously unprepared for AI-enabled cyberattacks from nation states, while simultaneously seeing rapid democratization of medical knowledge through tools like Open Evidence that are fundamentally reshaping the doctor-patient relationship.