A State Space Model (SSM) is a mathematical framework that maps an input sequence to an output sequence through a latent state vector, using a set of linear differential equations. Architectures like Mamba leverage a selective scan mechanism, allowing the model to dynamically filter or retain information based on the input, achieving linear time complexity relative to sequence length.
Glossary
State Space Model (SSM)

What is State Space Model (SSM)?
A State Space Model (SSM) is a sequence modeling architecture that defines a linear state space representation to process long sequences with linear computational complexity, offering an alternative to the quadratic complexity of self-attention.
Unlike the Transformer's self-attention, which computes pairwise token interactions with O(n²) complexity, SSMs process sequences recurrently. This makes them highly efficient for modeling long-range dependencies in continuous data streams, audio, and genomics, directly addressing the context window limitations of traditional large language models.
Key Features of State Space Models
State Space Models (SSMs) represent a fundamental shift in sequence modeling, replacing the quadratic complexity of self-attention with a linear-time recurrence derived from classical control theory.
Linear Computational Complexity
The defining advantage of SSMs is their O(N) time and memory complexity, where N is sequence length. Unlike Transformers, which scale quadratically (O(N²)) due to pairwise token comparisons in self-attention, SSMs process sequences recurrently.
- Mechanism: The model maintains a fixed-size hidden state that summarizes all past information, updating it token by token.
- Impact: Enables processing of sequences with 1M+ tokens on a single GPU without the memory explosion seen in standard attention.
- Contrast: A 32K context in a Transformer requires ~8GB of memory for the attention matrix alone; an SSM processes the same sequence with a constant memory footprint.
Structured State Space Duality
SSMs are governed by a continuous-time linear differential equation: ẋ(t) = Ax(t) + Bu(t), with output y(t) = Cx(t). The HiPPO (High-order Polynomial Projection Operators) framework defines the optimal A matrix to compress the entire history of the input signal into the hidden state.
- Discretization: The continuous system is converted to a discrete recurrence using a Zero-Order Hold (ZOH) rule with a learnable step size Δ, producing: x_k = Āx_{k-1} + B̄u_k.
- Duality: This recurrence can be equivalently computed as a global convolution during training, enabling parallel processing across the entire sequence, then switched to the recurrent mode for efficient autoregressive inference.
Selective Scan Mechanism (Mamba)
The Mamba architecture introduces input-dependent parameters, making the SSM selective. Unlike prior SSMs (S4, H3) where A, B, and C are time-invariant, Mamba makes B, C, and Δ functions of the current input.
- Selectivity: The model learns to ignore or focus on specific inputs, filtering out irrelevant information dynamically—a capability previously exclusive to attention mechanisms.
- Hardware-Aware Algorithm: Because selectivity prevents the use of efficient static convolutions, Mamba implements a parallel scan in custom CUDA kernels (fused with memory I/O) to compute the linear recurrence without materializing the full state in slow GPU HBM.
- Result: Matches or exceeds Transformers of the same size on language modeling while maintaining linear scaling.
Convolutional Training Mode
For a time-invariant SSM, the sequential recurrence can be unrolled into a single depthwise convolution with a kernel derived from the discretized system matrices (Ā, B̄, C).
- Parallelism: This allows the entire sequence to be processed in one pass during training, leveraging highly optimized FFT-based convolution algorithms on GPUs.
- SSM Kernel: The kernel K̄ = (CB̄, CĀB̄, ..., CĀ^{L-1}B̄) captures the system's impulse response, effectively computing all hidden states simultaneously.
- Constraint: This mode requires the parameters to be static (time-invariant), which is why Mamba's selective mechanism necessitates a return to recurrent computation with hardware-aware scan operations.
Gated MLP Integration
Modern SSM architectures, including Mamba, integrate the state space layer into a gated block inspired by the Gated Linear Unit (GLU) and the SwiGLU activation used in Transformers.
- Architecture: The input is projected through two linear layers. One branch passes through the SSM core and a SiLU (Swish) activation. The other branch is gated by a second SiLU activation, and the two are combined via element-wise multiplication.
- Purpose: The gating mechanism provides a non-linear information bottleneck, allowing the block to control the flow of information from the linear SSM recurrence.
- Design Philosophy: This hybrid approach treats the SSM as a powerful linear sequence mixer, while relying on proven MLP gating components for channel mixing and non-linearity.
Long-Range Arena Dominance
SSMs were originally validated on the Long-Range Arena (LRA) benchmark, a suite of tasks designed to test a model's ability to handle sequences from 1K to 16K tokens across modalities including text, images, and mathematical reasoning.
- Path-X: A 16K×16K pixel image classification task requiring the model to identify whether two markers are connected by a path. SSMs (S4) were the first non-attention models to solve this task.
- Performance: SSMs achieve state-of-the-art accuracy on LRA while using a fraction of the compute and memory required by Transformer variants.
- Significance: Demonstrated that the quadratic attention mechanism is not a strict requirement for capturing long-range dependencies, validating the SSM approach for ultra-long context applications.
SSM vs. Transformer: Architectural Comparison
A technical comparison of State Space Models and Transformer architectures across computational complexity, memory footprint, and sequence modeling capabilities.
| Feature | State Space Model (SSM) | Transformer (Self-Attention) | Hybrid (SSM + Attention) |
|---|---|---|---|
Computational Complexity | O(N) linear | O(N²) quadratic | O(N) for SSM layers, O(N²) for attention layers |
Memory Footprint (Inference) | O(1) constant state | O(N) KV-Cache | O(1) for SSM, O(N) for attention |
Long-Range Dependency Modeling | Strong on regular patterns, weaker on irregular recall | Excellent, direct token-to-token interaction | Combines structured and arbitrary recall |
Training Parallelization | Requires associative scan for parallelization | Fully parallelizable across sequence | Partial parallelization depending on layer mix |
Context Length Scaling | Linear scaling to 1M+ tokens | Quadratic bottleneck, requires optimizations | Linear for SSM layers, quadratic for attention |
Selective Copy Task | Requires gating mechanisms (Mamba) | Native capability via attention | Strong via attention layers |
Hardware Efficiency on GPU | Lower utilization, memory-bound | High utilization, compute-bound | Mixed utilization profile |
State Representation | Fixed-size latent state vector | Explicit token-level representations | Both fixed state and token-level |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Explore the core mechanics, advantages, and implementation details of State Space Models, the sub-quadratic sequence modeling architecture challenging the dominance of the Transformer.
A State Space Model (SSM) is a sequence modeling architecture that defines a linear state space representation to process long sequences with linear computational complexity. It operates by continuously evolving a hidden state ( h(t) ) based on an input signal ( x(t) ), governed by a state equation ( h'(t) = Ah(t) + Bx(t) ), and then projecting that state to an output ( y(t) = Ch(t) + Dx(t) ). In deep learning, these continuous dynamics are discretized using a timescale parameter ( \Delta ), transforming the continuous matrices ( (A, B) ) into discrete equivalents ( (\bar{A}, \bar{B}) ). This allows the model to be computed as a convolution during training for parallelism, and as a recurrent network during inference for constant-time per-step generation, offering a direct alternative to the quadratic complexity of the self-attention mechanism.
Related Terms
Key concepts that define, optimize, or interact with State Space Models in the context of long-sequence processing and efficient attention alternatives.
KV-Cache
A memory buffer in Transformer decoders that stores pre-computed Key and Value tensors from previous time steps to avoid redundant computation during autoregressive generation. The cache size grows linearly with sequence length, creating a significant memory bottleneck. A primary advantage of recurrent SSMs like Mamba is the elimination of the explicit KV-Cache, as the model's fixed-size latent state inherently captures historical context without requiring a growing memory allocation.
Linear Attention
A class of attention approximations that reformulate the softmax attention kernel to achieve linear O(n) complexity. By expressing attention as a kernel function and changing the order of matrix multiplication, linear attention avoids computing the full N×N attention matrix. However, many linear attention variants suffer from degraded recall quality. SSMs like Mamba are often viewed as a more principled evolution of this idea, using a data-dependent gating mechanism to dynamically filter information without the kernel approximation trade-offs.
Gated MLP
A simple architecture that uses a gating mechanism (element-wise multiplication of two linear projections) to control information flow, popularized by architectures like Gated Linear Units (GLU). Mamba's Selective SSM block integrates this concept directly into the state space framework by making its continuous-time parameters (B, C, Δ) input-dependent functions. This data-dependence is the key innovation that allows the model to selectively propagate or forget information, overcoming the rigidity of purely linear time-invariant SSMs.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us