State Space Models (SSMs) and Hybrid Mamba-Transformer Architectures in 2026: HiPPO & S4 Cauchy Kernels, Selective State Spaces (Mamba S6), Structured State Space Duality (Mamba-2 SSD), Parallel Scans, and Jamba & Griffin Interleaving

For nearly a decade, autoregressive foundation models have relied on the causal self-attention mechanism of the Transformer (Y = \text{softmax}(QK^\top / \sqrt{d})V) to route information across sequence positions. While dense pairwise attention excels at arbitrary in-context retrieval and associative recall, its computational and memory physics degrade severely as context windows scale from thousands to hundreds of thousands of tokens. Materializing the $T \times T$ causal attention matrix requires $O(T^2 d)$ training FLOPs, while autoregressive token generation must retain and repeatedly stream an uncompressed Key-Value (KV) cache of size $O(T d)$ from High-Bandwidth Memory (HBM) into on-chip SRAM for every single decoded token (arXiv:2312.00752, arXiv:2405.21060). At a $256\text{K}$-token context length in 16-bit precision (FP16/BF16), the KV cache alone consumes $128\text{ GB}$ on a 6.7B-parameter multi-head Transformer (LLaMA-2 6.7B) and $32\text{ GB}$ even with Grouped-Query Attention (Mistral-7.2B and Mixtral-8x7B), saturating datacenter GPU memory capacity and driving batch-size throughput down by $3\times\text{--}5\times$ (arXiv:2403.19887).

Structured State Space Models (SSMs), Gated Linear Recurrences, and Hybrid SSM-Transformer Architectures resolve this fundamental memory-bandwidth and quadratic-compute bottleneck by replacing or interleaving dense softmax attention with continuous-time or discrete-time linear recurrences that compress sequence history into a fixed-dimension latent state $h_t \in \mathbb{R}^N$. Across the foundational theoretical and systems breakthroughs driving sequence modeling in 2026—from S4 (arXiv:2111.00396), RWKV (arXiv:2305.13048), and Mamba (S6) (arXiv:2312.00752) to Mamba-2 Structured State Space Duality (SSD) (arXiv:2405.21060), Griffin / Hawk (RG-LRU) (arXiv:2402.19427), and Jamba (arXiv:2403.19887)—modern sub-quadratic sequence architectures overcome four long-standing mathematical and hardware barriers:

  1. Overcoming the Linear Time-Invariance (LTI) Bottleneck via Input-Dependent Selection (S6): First-generation structured SSMs (S4, S4D, S5, H3, Hyena) kept their state transition parameters $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C})$ fixed across all timesteps (Linear Time-Invariance) so the recurrence $h_t = \overline{\mathbf{A}}h_{t-1} + \overline{\mathbf{B}}x_t$ could be unrolled into a global FFT convolution $y = x \ast \overline{\mathbf{K}}$ (arXiv:2111.00396). While LTI SSMs achieved $86.09\%$ average accuracy on the Long Range Arena (LRA) and solved the $16,384$-token Path-X benchmark ($96.35\%$), constant dynamics prevent content-aware filtering on discrete text: on the Selective Copying benchmark, non-selective S4 scores only $18.3\%$ (arXiv:2312.00752). Mamba (S6) makes $(\Delta_t, \mathbf{B}_t, \mathbf{C}_t)$ input-dependent functions of the current token $x_t$, raising Selective Copying accuracy to $99.8\%$, extrapolating perfectly on Induction Heads up to $2^{20} = 1,048,576$ tokens, and dropping $350\text{M}$-scale Pile validation perplexity from $10.93$ (LTI) to $8.71$ (Selective S6).
  2. SRAM-Fused Parallel Associative Scans vs. GPU Memory-Hierarchy Bandwidth: Because input-dependent selectivity breaks global shift-invariance, selective SSMs cannot be trained via FFT convolution and would naively materialize an expanded latent state tensor $h \in \mathbb{R}^{B \times L \times D \times N}$ in GPU HBM (arXiv:2312.00752). Mamba's hardware-aware Selective Scan loads $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C})$ directly from HBM into fast on-chip SRAM, fuses Zero-Order Hold (ZOH) discretization and a work-efficient parallel associative scan ($O(BLDN)$ FLOPs, $O(\log L)$ span) inside SRAM, and writes only the contracted $(B, L, D)$ output back to HBM while recomputing intermediate states during backpropagation—delivering a $20\times\text{--}40\times$ speedup over standard PyTorch scans and $4\times\text{--}5\times$ higher inference throughput than parameter-matched Transformers.
  3. Structured State Space Duality (SSD) and Tensor Core Matrix Multiplication (Mamba-2): Even with SRAM kernel fusion, Mamba-1's elementwise associative scan operates on CUDA vector cores rather than specialized GPU Tensor Cores (MMA matrix multiplication units), causing runtime to scale linearly with state expansion $N$ (arXiv:2405.21060). In Mamba-2, Dao and Gu prove that state space models with state size $N$ are mathematically identical to multiplication $y = Mx$ by an $N$-Semiseparable ($N$-SS) matrix $M_{ji} = C_j^\top A_j \cdots A_{i+1} B_i$. Restricting $A_t = a_t I$ to scalar-times-identity structure establishes an exact duality (SSD) between selective SSMs and 1-Semiseparable Structured Masked Attention $Y = (L \circ (QK^\top)) \cdot V$. By partitioning $M$ into $Q \times Q$ chunks (chunk_size = 256), Mamba-2 evaluates intra-chunk diagonal blocks via Tensor Core batched matrix multiplications (BMM) and inter-chunk low-rank blocks via rank-$N$ factorizations—running $2\times\text{--}8\times$ faster than Mamba-1, supporting $8\times$ larger state dimensions ($N = 128\text{--}256$ vs. $N = 16$), crossing over FlashAttention-2 at sequence length $2\text{K}$, and running $6\times$ faster than FlashAttention-2 at $16\text{K}$.
  4. Hybrid SSM-Attention Interleaving (Jamba, Griffin, Mamba-2-Attention): Pure fixed-state recurrent models face a theoretical capacity ceiling on exact multi-query associative recall, phonebook lookup, and few-shot in-context format imitation over long contexts (arXiv:2402.19427, arXiv:2403.19887, arXiv:2405.21060). Interleaving a small fraction ($\approx 10\%\text{--}33\%$) of global or local sliding-window attention layers with selective SSM or gated linear recurrence layers yields a Pareto-dominant hybrid architecture: Mamba-2-Attention (58 SSD + 6 Attention layers at 2.7B scale) outperforms both pure Mamba-2 and pure Transformer++ (5.95 vs. 6.09 and 6.13 Pile PPL); Griffin-7B/14B (2 RG-LRU blocks : 1 local 1024-token MQA block) matches LLaMA-2-7B/13B using $6.7\times$ fewer training tokens (300B vs. 2T); and Jamba ($1:7$ Attention-to-Mamba ratio with top-2 of 16 MoE every 2 layers, $52\text{B}$ total / $12\text{B}$ active parameters) slashes the $256\text{K}$-context KV cache from $32\text{ GB}$ to $4\text{ GB}$ while delivering $3\times$ the throughput of Mixtral-8x7B.
Continuous-Time Linear Time-Invariant State-Space Block Diagram Showing Input Matrix B, State Matrix A Integrator Feedback Loop, Output Matrix C, and Feedthrough Matrix D

Continuous-Time Linear Time-Invariant State-Space Block Diagram Showing Input Matrix B, State Matrix A Integrator Feedback Loop, Output Matrix C, and Feedthrough Matrix D

This architectural deep dive provides a rigorous mathematical and systems engineering analysis of continuous and discrete state space models, HiPPO and S4 Cauchy-Woodbury kernels, Mamba's selective S6 scan, Mamba-2's semiseparable matrix duality and Tensor Core block decomposition, RWKV and Griffin's gated linear recurrences, and hybrid SSM-Attention-MoE architectures in 2026.

Executive Summary: Verified Mathematical & Empirical Benchmarks Across S4, RWKV, Mamba (S6), Mamba-2 (SSD), Griffin (RG-LRU) & Jamba

  • S4 Normal Plus Low-Rank (NPLR) & Cauchy Kernels (arXiv:2111.00396): By decomposing HiPPO state matrices into unitary Diagonal Plus Low-Rank form $\mathbf{A} = \mathbf{V}\boldsymbol{\Lambda}\mathbf{V}^* - \mathbf{P}\mathbf{Q}^\top$ ($r \in \{1, 2\}$) and evaluating the truncated SSM generating function at roots of unity via the Woodbury identity and 4 Cauchy kernel multiplies, S4 reduces convolution filter computation to $\widetilde{O}(N+L)$ time and $O(N+L)$ space. At dimension $512$, S4 is 29.6× faster (4.75 ms vs. 140.7 ms) and uses 392× less memory (33.5 MB vs. 13,140 MB) than LSSL, achieving 86.09% average accuracy on LRA (solving length-16,384 Path-X at 96.35%), 98.32% on raw length-16,000 SC10 speech waveforms, and 60×–65.1× faster autoregressive generation than Transformers on WikiText-103 (48K tok/s) and CIFAR-10 (20.84 img/s).
  • Mamba Selective State Spaces (S6) & SRAM Scan Fusion (arXiv:2312.00752): Parameterizing $(\Delta_t, \mathbf{B}_t, \mathbf{C}_t)$ as input-dependent projections of $x_t$ enables content-based token selection, boosting Selective Copying from 18.3% (S4) and 57.0% (H3) to 99.8%, generalizing Induction Heads from length $256$ to $2^{20} = 1,048,576$ tokens at 100% accuracy, and improving Great Apes DNA classification at $1\text{M}$ base pairs to 81.31% (vs. 54.87% HyenaDNA). Fusing ZOH discretization, parallel associative scan, and activation recomputation in GPU SRAM yields a 20–40× scan speedup and 4–5× higher inference throughput, while Mamba-2.8B (6.22 Pile PPL, 63.3% 6-task / 59.9% 7-task zero-shot avg) outperforms Pythia-2.8B (6.73 PPL) and even Pythia-6.9B (6.51 PPL).
  • Mamba-2 Structured State Space Duality (SSD) (arXiv:2405.21060, ICML 2024): Proving the equivalence between rank-$N$ sequentially semiseparable matrices $M = \mathsf{SSS}(A, B, C)$ and 1-Semiseparable Structured Masked Attention $Y = (L \circ (QK^\top))V$ under scalar-identity transitions $A_t = a_t I$, Mamba-2 computes chunked diagonal blocks ($Q = 256$) on GPU Tensor Cores (`BMM`) in $O(TN^2)$ FLOPs and $O(TN)$ memory. SSD is 2–8× faster than Mamba-1's fused scan, scales state size $8\times$ from $N=16$ to $N=128\text{--}256$, beats FlashAttention-2 above $L=2\text{K}$ (6× faster at $L=16\text{K}$), and elevates Mamba-2-2.7B to 6.09 Pile PPL (60.2% zero-shot average).
  • Gated Linear Recurrences (RWKV, Griffin RG-LRU) & Hybrid Interleaving (Jamba): RWKV (arXiv:2305.13048) scales linear-attention WKV recurrences up to 14.15B parameters ($r^2 = 0.994$ compute scaling fit). Griffin (arXiv:2402.19427) mixes 2 RG-LRU blocks ($h_t = a_t \odot h_{t-1} + \sqrt{1-a_t^2} \odot (i_t \odot x_t)$) with 1 local 1024-token MQA block, reaching 65.8% (7B) and 69.5% (14B) downstream accuracy on 300B tokens—matching LLaMA-2-7B/13B trained on 2T tokens. Jamba (arXiv:2403.19887) interleaves Attention and Mamba at a 1:7 ratio with top-2 of 16 MoE ($52\text{B}$ total / $12\text{B}$ active), shrinking 256K-token KV cache to 4 GB, eliminating explicit RoPE positional embeddings, solving pure Mamba's in-context learning gap (jumping from 48.8% to 90.9% on IMDB), and achieving 87.1% HellaSwag, 82.5% WinoGrande, and 67.4% MMLU at 3× Mixtral's throughput.

1. Continuous-Time State Space Foundations, HiPPO Memory Orthogonal Polynomials, and S4 Cauchy-Woodbury Kernels

The theoretical lineage of modern deep state space models begins with classical control theory (Kalman, 1960), where a continuous-time linear dynamical system maps a 1D scalar input signal $u(t) \in \mathbb{R}$ to an output signal $y(t) \in \mathbb{R}$ via an $N$-dimensional latent state vector $x(t) \in \mathbb{R}^N$ (arXiv:2111.00396, Section 2.1):

$$x'(t) = \mathbf{A}x(t) + \mathbf{B}u(t), \qquad y(t) = \mathbf{C}x(t) + \mathbf{D}u(t)$$

where $\mathbf{A} \in \mathbb{R}^{N \times N}$ is the state transition matrix governing internal memory decay and oscillation frequencies, $\mathbf{B} \in \mathbb{R}^{N \times 1}$ is the input projection matrix, $\mathbf{C} \in \mathbb{R}^{1 \times N}$ is the output projection matrix, and $\mathbf{D} \in \mathbb{R}$ is a direct skip feedthrough (typically set to $\mathbf{D} = 0$ or absorbed into a residual skip connection).

Verified Technical Lecture: Intuition behind Mamba and State Space Models | Enhancing LLMs! by Maarten Grootendorst (verified via live YouTube oEmbed HTTP 200).

1. Bilinear (Tustin) vs. Zero-Order Hold (ZOH) Discretization

To apply a continuous-time differential system to a discrete token or sample sequence $(u_0, u_1, \dots, u_{L-1})$ separated by an integration step size (timescale parameter) $\Delta \in \mathbb{R}^+$, the continuous parameters $(\Delta, \mathbf{A}, \mathbf{B})$ must be converted into discrete-time recurrence matrices $(\overline{\mathbf{A}}, \overline{\mathbf{B}})$ such that $x_k = \overline{\mathbf{A}}x_{k-1} + \overline{\mathbf{B}}u_k$ and $y_k = \overline{\mathbf{C}}x_k$. Two primary discretization rules govern the SSM literature:

  • Bilinear (Tustin) Transform (S4, arXiv:2111.00396 Eq. 3): Approximates the derivative $x'(t)$ via the trapezoidal midpoint rule between $t_k$ and $t_{k+1}$, yielding rational matrix inverses: $$\overline{\mathbf{A}} = \left(\mathbf{I} - \frac{\Delta}{2}\mathbf{A}\right)^{-1}\left(\mathbf{I} + \frac{\Delta}{2}\mathbf{A}\right), \qquad \overline{\mathbf{B}} = \left(\mathbf{I} - \frac{\Delta}{2}\mathbf{A}\right)^{-1}\Delta\mathbf{B}, \qquad \overline{\mathbf{C}} = \mathbf{C}$$
  • Zero-Order Hold (ZOH, Mamba, arXiv:2312.00752 Eq. 4): Holds the discrete input value $u_k$ constant over the continuous interval $[t_k, t_k + \Delta]$ and integrates the exact matrix exponential solution: $$\overline{\mathbf{A}} = \exp(\Delta \mathbf{A}), \qquad \overline{\mathbf{B}} = (\Delta \mathbf{A})^{-1}\left(\exp(\Delta \mathbf{A}) - \mathbf{I}\right) \cdot \Delta \mathbf{B} \approx \Delta \mathbf{B}$$ where the first-order Euler approximation $\overline{\mathbf{B}} = \Delta \mathbf{B}$ is adopted inside Mamba's selective scan kernel because $\mathbf{A}$ is parameterized diagonally and $\Delta \mathbf{B}$ avoids division by small eigenvalues while preserving the exact exponential decay $\overline{\mathbf{A}} = \exp(\Delta \mathbf{A})$ (arXiv:2312.00752, Section 3.2).

2. Dual Execution Modes of Linear Time-Invariant (LTI) SSMs: Recurrence vs. Global Convolution

When $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C})$ are constant across all sequence positions $k \in \{0, \dots, L-1\}$, unrolling the discrete recurrence from $x_{-1} = 0$ reveals an explicit linear time-invariant (LTI) discrete convolution (arXiv:2111.00396, Equations 4–5): $$x_0 = \overline{\mathbf{B}}u_0, \quad x_1 = \overline{\mathbf{A}}\overline{\mathbf{B}}u_0 + \overline{\mathbf{B}}u_1, \quad x_k = \sum_{j=0}^{k} \overline{\mathbf{A}}^{k-j}\overline{\mathbf{B}}u_j$$ $$y_k = \sum_{j=0}^{k} \overline{\mathbf{C}}\overline{\mathbf{A}}^{k-j}\overline{\mathbf{B}}u_j \quad \Longleftrightarrow \quad y = \overline{\mathbf{K}} \ast u, \qquad \overline{\mathbf{K}} = \left(\overline{\mathbf{C}}\overline{\mathbf{B}},\; \overline{\mathbf{C}}\overline{\mathbf{A}}\overline{\mathbf{B}},\; \dots,\; \overline{\mathbf{C}}\overline{\mathbf{A}}^{L-1}\overline{\mathbf{B}}\right) \in \mathbb{R}^L$$

This dual representation gives LTI SSMs two complementary execution paths (arXiv:2111.00396, Table 1):

  1. Convolutional Mode (Parallel Training): Given the precomputed filter $\overline{\mathbf{K}} \in \mathbb{R}^L$, the full sequence output $y = \overline{\mathbf{K}} \ast u$ is computed across all $L$ tokens in parallel in $O(L \log L)$ time via the Fast Fourier Transform (FFT) and Inverse FFT (iFFT).
  2. Recurrent Mode ($O(1)$ Stateful Inference): During autoregressive generation, the model discards the convolution filter and steps the latent state $x_k = \overline{\mathbf{A}}x_{k-1} + \overline{\mathbf{B}}u_k$ in $O(N)$ operations per token and $O(N)$ constant memory—completely eliminating the Transformer's $O(L)$ KV cache.

3. Why Naive Diagonalization of HiPPO Explodes ($2^{4N/3}$) and How S4 Solves It via NPLR & Cauchy Kernels

Randomly initialized state matrices $\mathbf{A}$ suffer from exponentially vanishing or exploding gradients over long horizons (arXiv:2111.00396, Section 4.4). To memorize long-range history online, HiPPO (High-order Polynomial Projection Operators, Gu et al. 2020) derives a closed-form state matrix $\mathbf{A} \in \mathbb{R}^{N \times N}$ that continuously projects the input history $u(s){s \le t}$ onto a basis of $N$ orthogonal Legendre polynomials (HiPPO-LegS): $$\mathbf{A}{nk} = -\begin{cases} (2n+1)^{1/2}(2k+1)^{1/2} & \text{if } n > k \\ n + 1 & \text{if } n = k \\ 0 & \text{if } n < k \end{cases}, \qquad \mathbf{B}_n = (2n+1)^{1/2}$$

In sequential CIFAR-10 ablations constrained to $100\text{K}$ parameters (arXiv:2111.00396, Section 4.4 & Figure 4), training an SSM from random Gaussian or random diagonal initialization leaves a $>15\%$ validation accuracy deficit relative to HiPPO initialization, which reaches $84.27\%$ test accuracy with just $100\text{K}$ parameters. However, computing the length-$L$ filter $\overline{\mathbf{K}}$ with a dense $N \times N$ HiPPO matrix in the Linear State Space Layer (LSSL) requires $O(N^2 L)$ operations and $O(NL)$ memory. Furthermore, in "Efficiently Modeling Long Sequences with Structured State Spaces" (arXiv:2111.00396), Gu, Goel, and Ré prove (Lemma 3.2) that naively diagonalizing the HiPPO matrix $\mathbf{A} = \mathbf{V}\boldsymbol{\Lambda}\mathbf{V}^{-1}$ is numerically impossible in finite-precision arithmetic because the eigenvector matrix $\mathbf{V}{ij} = \binom{i+j}{i-j}$ contains entries of magnitude: $$\mathbf{V}{3i, i} = \binom{4i}{2i} \approx 2^{4i} \implies \max_{i,j} |\mathbf{V}_{ij}| \sim 2^{4N/3}$$ At a standard state dimension $N = 64$, $2^{4(64)/3} = 2^{85.3} \approx 4.8 \times 10^{25}$, overflowing single-precision floating point conditioning!

S4's Normal Plus Low-Rank (NPLR) and Diagonal Plus Low-Rank (DPLR) Solution (arXiv:2111.00396, Theorem 1 & Algorithm 1): Gu et al. prove (Theorem 1) that every HiPPO matrix (HiPPO-LegS, HiPPO-LegT, HiPPO-LagT) can be written as the sum of a skew-symmetric Normal matrix (unitarily diagonalizable via a perfectly conditioned unitary matrix $\mathbf{V} \in \mathbb{C}^{N \times N}$ with condition number $\kappa(\mathbf{V}) = 1$) and a rank-$1$ or rank-$2$ correction: $$\mathbf{A} = \mathbf{V}\boldsymbol{\Lambda}\mathbf{V}^* - \mathbf{P}\mathbf{Q}^\top = \mathbf{V}\left(\boldsymbol{\Lambda} - (\mathbf{V}^\mathbf{P})(\mathbf{V}^\mathbf{Q})^\right)\mathbf{V}^$$ By conjugating into the unitary basis $\tilde{x} = \mathbf{V}^* x$ (Lemma 3.1), S4 parameterizes $\mathbf{A}$ directly in Diagonal Plus Low-Rank (DPLR) form over $\mathbb{C}$ using just $5N$ trainable parameters $(\boldsymbol{\Lambda}, \mathbf{P}, \mathbf{Q}, \mathbf{B}, \mathbf{C}) \in \mathbb{C}^N$ (stabilized in follow-up S4 work as $\boldsymbol{\Lambda} - \mathbf{P}\mathbf{P}^*$ so eigenvalues strictly stay in the left half-plane $\text{Re}(\lambda) < 0$). S4 then computes $\overline{\mathbf{K}} \in \mathbb{R}^L$ in five exact steps (Algorithm 1, Theorem 3):

  1. Truncated SSM Generating Function (SSMGF): Instead of powering $\overline{\mathbf{A}}^k$ in the time domain, S4 switches to the z-transform frequency domain $\widehat{\mathbf{K}}(\omega) = \sum_{k=0}^{L-1} \overline{\mathbf{C}}\overline{\mathbf{A}}^k\overline{\mathbf{B}}\omega^k = \widetilde{\mathbf{C}}^* (\mathbf{I} - \overline{\mathbf{A}}\omega)^{-1}\overline{\mathbf{B}}$, where $\widetilde{\mathbf{C}} \leftarrow (\mathbf{I} - \overline{\mathbf{A}}^L)^* \overline{\mathbf{C}}$.
  2. Woodbury Matrix Identity Reduction: Substituting the bilinear transform and DPLR decomposition $\mathbf{A} = \boldsymbol{\Lambda} - \mathbf{P}\mathbf{Q}^$ turns the matrix power into a DPLR matrix inverse $\left(\frac{2}{\Delta}\frac{1-\omega}{1+\omega}\mathbf{I} - \boldsymbol{\Lambda} + \mathbf{P}\mathbf{Q}^\right)^{-1}$. Applying the Woodbury Matrix Identity $(\mathbf{M} + \mathbf{P}\mathbf{Q}^)^{-1} = \mathbf{M}^{-1} - \mathbf{M}^{-1}\mathbf{P}(\mathbf{I} + \mathbf{Q}^\mathbf{M}^{-1}\mathbf{P})^{-1}\mathbf{Q}^\mathbf{M}^{-1}$ reduces the full DPLR resolvent to a $2 \times 2$ scalar system of diagonal inverses $\mathbf{R}(\omega) = \left(\frac{2}{\Delta}\frac{1-\omega}{1+\omega}\mathbf{I} - \boldsymbol{\Lambda}\right)^{-1}$: $$\begin{bmatrix} k_{00}(\omega) & k_{01}(\omega) \\ k_{10}(\omega) & k_{11}(\omega) \end{bmatrix} \leftarrow \begin{bmatrix} \widetilde{\mathbf{C}} & \mathbf{Q} \end{bmatrix}^ \left(\frac{2}{\Delta}\frac{1-\omega}{1+\omega}\mathbf{I} - \boldsymbol{\Lambda}\right)^{-1} \begin{bmatrix} \mathbf{B} & \mathbf{P} \end{bmatrix}$$ $$\widehat{\mathbf{K}}(\omega) \leftarrow \frac{2}{1+\omega}\left[k_{00}(\omega) - k_{01}(\omega)\left(1 + k_{11}(\omega)\right)^{-1}k_{10}(\omega)\right]$$
  3. Black-Box Cauchy Kernel Evaluation & iFFT: Evaluating $k_{ij}(\omega)$ across all $L$ complex roots of unity $\omega \in \Omega_L = \{\exp(2\pi i k / L)\}{k=0}^{L-1}$ is an instance of 4 Cauchy matrix-vector multiplications $M{jk}^{\text{Cauchy}} = \frac{1}{\omega_j - \zeta_k}$, computable in $\widetilde{O}(N + L)$ operations and $O(N + L)$ space via the Fast Multipole Method (or a fused $O(NL)$ GPU kernel without materializing the $N \times L$ Cauchy matrix), followed by a single $\mathsf{iFFT}(\widehat{\mathbf{K}})$ to recover $\overline{\mathbf{K}}$.
Benchmark / Metric (arXiv:2111.00396) Standard Transformer Linear Trans. / Performer LSSL (Unstructured SSM) Structured S4 (NPLR)
Training Step Time / Memory ($D=512$, Table 2) Baseline ($1\times$ at $L=1024$) $1.58\times / 1.23\times$ speed ($L=1024$) 140.7 ms / 13,140 MB 4.75 ms (29.6×) / 33.5 MB (392×)
Long Range Arena (LRA) Path-X ($L=16,384$, Table 4) ✗ (Fails / Out of Memory) ✗ / ✗ (Random 50% Guess) ✗ (Infeasible Memory) 96.35% Accuracy
LRA 6-Task Average Accuracy (Table 4) 53.66% 50.46% / 51.18% — 86.09% (ListOps 59.6, Retr. 90.9)
Raw Speech Commands SC10 ($L=16,000$, Table 5) ✗ (90.75% on 161-step MFCC) 30.77% Raw (30.68% at $0.5\times$) ✗ (93.58% on MFCC) 98.32% Raw (96.30% zero-shot $0.5\times$)
Sequential 1D CIFAR-10 (sCIFAR, Table 6) 62.20% — 84.65% 91.13% (no aug.) / 93.16% (with aug.)
CIFAR-10 Autoregressive Density & Speed (Table 7) 3.47 bpd @ 0.32 img/s ($1\times$) 3.40 bpd @ 17.85 img/s ($56\times$) — 2.92 bpd @ 20.84 img/s (65.1×) / 2.85 bpd
WikiText-103 PPL & Generation Speed (Table 8) 20.51 PPL @ 0.8K tok/s (247M) — — 20.95 PPL @ 48K tok/s (60×, 249M)

Following S4, DSS (Gupta et al., 2022) and S4D (Gu et al., 2022) demonstrated that dropping the low-rank term $\mathbf{P}\mathbf{Q}^*$ and initializing a purely diagonal state matrix $\mathbf{A} = \text{diag}(\mathbf{A}_1, \dots, \mathbf{A}_N)$ using the diagonal approximation to HiPPO—either complex S4D-Lin ($\mathbf{A}_n = -\frac{1}{2} + ni$) or real S4D-Real ($\mathbf{A}_n = -(n+1)$)—preserves nearly all of S4's long-range empirical accuracy while reducing the SSM kernel to a simple Vandermonde product (arXiv:2312.00752, Section 3.6).


2. Selective State Spaces (Mamba / S6): Content-Aware Input-Dependent Dynamics and Gated RNN Unification

Despite S4 and S4D's dominance on continuous signal benchmarks (audio waveforms, physiological time series, pixel sequences), LTI state space models consistently trailed Transformers on discrete, information-dense modalities such as natural language and genomics (arXiv:2312.00752, Section 3.1). In "Mamba: Linear-Time Sequence Modeling with Selective State Spaces" (Gu & Dao, COLM 2024, arXiv:2312.00752), the authors diagnose the root cause of this gap as the fundamental tension between sequence compression and Linear Time-Invariance (LTI):

  • Attention Does Not Compress Context: Autoregressive self-attention retains every historical token representation $(k_1, v_1), \dots, (k_t, v_t)$ explicitly in an $O(L)$-sized KV cache. It achieves lossless recall within its context window at the cost of quadratic compute and linear per-token decoding memory traffic.
  • LTI Recurrences Compress Blindly: A finite-state recurrent model compresses all past context into a fixed $O(DN)$ hidden state. However, when the transition matrices $(\overline{\mathbf{A}}, \overline{\mathbf{B}}, \mathbf{C})$ are constant across time, the recurrence applies the exact same temporal decay and input mixing weight to every token—regardless of whether $x_t$ is a vital entity key or an irrelevant filler word ("um", whitespace, boilerplate punctuation). From the dual convolutional viewpoint $y = x \ast \overline{\mathbf{K}}$, a fixed global convolution filter can solve fixed-offset Copying (where the target tokens always appear at a fixed lag $T_0$), but fails catastrophically on Selective Copying (where relevant tokens appear at variable, randomly spaced positions amidst noise) and Induction Heads (associative in-context lookup where seeing [A][B] ... [A] requires outputting [B]).

1. The S6 Selection Parameterization (Algorithm 1 vs. Algorithm 2)

To endow state space models with content-dependent reasoning, Mamba (S6) makes the step size $\Delta$, the input projection matrix $\mathbf{B}$, and the output projection matrix $\mathbf{C}$ direct functions of the input tensor $x \in \mathbb{R}^{B \times L \times D}$ (arXiv:2312.00752, Section 3.2 & Algorithm 2):

$$s_B(x) = \mathsf{Linear}N(x) \in \mathbb{R}^{B \times L \times N}, \qquad s_C(x) = \mathsf{Linear}_N(x) \in \mathbb{R}^{B \times L \times N}$$ $$s\Delta(x) = \mathsf{Broadcast}D\left(\mathsf{Linear}_1(x)\right) \quad \xrightarrow{\text{generalized rank } R} \quad \mathsf{Linear}_D\left(\mathsf{Linear}_R(x)\right) \in \mathbb{R}^{B \times L \times D}$$ $$\Delta = \tau\Delta\left(\mathsf{Parameter} + s_\Delta(x)\right) = \mathsf{softplus}\left(\mathsf{Parameter} + s_\Delta(x)\right) \in \mathbb{R}^{B \times L \times D}$$

where $\tau_\Delta(z) = \mathsf{softplus}(z) = \ln(1 + e^z)$ guarantees strictly positive step sizes $\Delta_{b,\ell,d} > 0$, and the low-rank bottleneck dimension for $\Delta$ is set to $R = \lceil D / 16 \rceil$ (dt_rank in MambaConfig, huggingface.co/docs/transformers/en/model_doc/mamba). Notice the shift in tensor shapes between LTI S4 (Algorithm 1) and Selective S6 (Algorithm 2):

  • In LTI S4, $\mathbf{A} \in \mathbb{R}^{D \times N}$, $\mathbf{B} \in \mathbb{R}^{D \times N}$, $\mathbf{C} \in \mathbb{R}^{D \times N}$, and $\Delta \in \mathbb{R}^D$ are static parameter tensors independent of batch $B$ and sequence length $L$.
  • In Selective S6, $\mathbf{A} \in \mathbb{R}^{D \times N}$ remains a static diagonal matrix (initialized via S4D-Real $\mathbf{A}{d,n} = -(n+1)$), while $\mathbf{B} \in \mathbb{R}^{B \times L \times N}$, $\mathbf{C} \in \mathbb{R}^{B \times L \times N}$, and $\Delta \in \mathbb{R}^{B \times L \times D}$ acquire the batch and sequence length dimensions $(B, L)$, creating time-varying discretized tensors $\overline{\mathbf{A}}, \overline{\mathbf{B}} \in \mathbb{R}^{B \times L \times D \times N}$: $$\overline{\mathbf{A}}{b,\ell,d,n} = \exp\left(\Delta_{b,\ell,d} \cdot \mathbf{A}{d,n}\right), \qquad \overline{\mathbf{B}}{b,\ell,d,n} = \Delta_{b,\ell,d} \cdot \mathbf{B}_{b,\ell,n}$$

2. Mechanistic Interpretation of $(\Delta_t, \mathbf{A}, \mathbf{B}_t, \mathbf{C}_t)$ and Theorem 1 (Equivalence to Gated RNNs)

Making $(\Delta_t, \mathbf{B}_t, \mathbf{C}_t)$ input-dependent provides three distinct mechanistic controls over sequence memory (arXiv:2312.00752, Section 3.5.2):

  1. Interpretation of $\Delta_t$ (Continuous Integration Step Size / RNN Reset & Forget Gate): $\Delta_t \in (0, \infty)$ controls the balance between focusing on the current token $x_t$ versus preserving the historical hidden state $h_{t-1}$: * When $\Delta_t \to \infty$ (large step size), $\overline{\mathbf{A}}t = \exp(\Delta_t \mathbf{A}) \to 0$ (since $\mathbf{A}{d,n} < 0$) and $\overline{\mathbf{B}}t$ increases: the system resets its hidden state, forgets stale context (e.g., at document or episode boundaries), and focuses intensely on the current input $x_t$. * When $\Delta_t \to 0$ (infinitesimal step size), $\overline{\mathbf{A}}_t = \exp(\Delta_t \mathbf{A}) \to \mathbf{I}$ and $\overline{\mathbf{B}}_t \to 0$: the system ignores the current transient input $x_t$ (filtering out filler tokens or noise) and persists the historical latent state $h{t-1}$ unmodified across arbitrarily long variable spacing.
  2. Interpretation of $\mathbf{B}t$ and $\mathbf{C}_t$ (Input & Output Content Gates): While $\Delta_t$ controls channel-wise persistence across the $D$ channels, $\mathbf{B}_t \in \mathbb{R}^N$ and $\mathbf{C}_t \in \mathbb{R}^N$ control whether token $x_t$ writes into the $N$-dimensional latent state ($h_t = \overline{\mathbf{A}}_t h{t-1} + \overline{\mathbf{B}}_t x_t$) and whether the latent state $h_t$ is read out into the current output ($y_t = \mathbf{C}_t^\top h_t$).
  3. Theorem 1 — Exact Mathematical Equivalence to Classical Gated RNNs (arXiv:2312.00752, Section 3.5.1 & Appendix C): Gu and Dao prove that when $N = 1$, $\mathbf{A} = -1$, $\mathbf{B} = 1$, $s_\Delta(x_t) = \mathsf{Linear}(x_t)$, and $\tau_\Delta = \mathsf{softplus}$, the ZOH-discretized selective SSM equations simplify algebraically to: $$\Delta_t = \mathsf{softplus}\left(\mathsf{Linear}(x_t)\right) = \ln\left(1 + \exp\left(\mathsf{Linear}(x_t)\right)\right)$$ $$\overline{\mathbf{A}}t = \exp(\Delta_t \mathbf{A}) = \exp(-\Delta_t) = \frac{1}{1 + \exp\left(\mathsf{Linear}(x_t)\right)} = \sigma\left(-\mathsf{Linear}(x_t)\right) = 1 - g_t$$ $$\overline{\mathbf{B}}_t = (\Delta_t \mathbf{A})^{-1}\left(\exp(\Delta_t \mathbf{A}) - 1\right)\Delta_t \mathbf{B} = -\left(\exp(-\Delta_t) - 1\right) = 1 - \overline{\mathbf{A}}_t = g_t$$ where $g_t = \sigma(\mathsf{Linear}(x_t))$ is the sigmoid gate, recovering the exact convex gated recurrence: $$h_t = (1 - g_t)h{t-1} + g_t x_t$$

3. Empirical Selectivity and State-Expansion Ablations

Table 8 and Table 11 of arXiv:2312.00752 (evaluated on $\approx 350\text{M}$-parameter models trained to Chinchilla token counts on the Pile) demonstrate why both input-dependent selectivity $(\Delta_t, \mathbf{B}_t, \mathbf{C}_t)$ and state expansion $N > 1$ are jointly required:

Ablation Dimension (arXiv:2312.00752, ~350M Scale) Configuration / Active Selective Tensors Model Params Pile Perplexity ↓ Selective Copying Acc ↑
No Gate + LTI S4 vs. Selective S6 (Table 2) S4 Layer (LTI) → S6 Layer (Selective) without gating Matched 10.56 (Mamba+S4) 18.3% → 97.0% (99.8% Full Mamba)
Selectivity Ablation — LTI Baseline (Table 8) Selective $\Delta$: ✗ | Selective $\mathbf{B}$: ✗ | Selective $\mathbf{C}$: ✗ ~371.5M ($N=16$) 10.93 Fails variable spacing
Selectivity Ablation — Single Tensor (Table 8) Only $\mathbf{B}$: 10.15 | Only $\mathbf{C}$: 9.98 | Only $\Delta$: 9.81 ~371.5M ($N=16$) 9.81 – 10.15 $\Delta$ provides strongest single gain
Selectivity Ablation — Full S6 (Table 8) Selective $\Delta$: ✓ | Selective $\mathbf{B}$: ✓ | Selective $\mathbf{C}$: ✓ 371.5M ($N=16$) 8.71 (−2.22 PPL vs. LTI) 99.8% (Mamba + S6)
State Size $N$ Scaling — LTI Mode (Table 11) $N = 1 \to 2 \to 4 \to 8 \to 16$ (Non-Selective LTI) 367.1M → 371.5M 9.88 → 9.86 → 9.82 → 9.82 → 9.81 Stagnates (−0.07 PPL total)
State Size $N$ Scaling — Selective S6 (Table 11) $N = 1 \to 2 \to 4 \to 8 \to 16$ (Selective S6) 367.1M → 371.5M 9.73 → 9.40 → 9.09 → 8.84 → 8.71 −1.02 PPL for +1.2% params

Look closely at the bottom two rows of the table above (arXiv:2312.00752, Table 11): when an SSM is non-selective (LTI), expanding the latent state dimension $16\times$ from $N = 1$ to $N = 16$ barely improves perplexity (9.88 → 9.81, only $-0.07$ PPL) because the model lacks a selection gate to route distinct tokens into the extra state capacity. Once $(\Delta_t, \mathbf{B}_t, \mathbf{C}_t)$ are selective, scaling $N$ from $1 \to 16$ increases total parameter count by just $1.2\%$ (367.1M → 371.5M) while slashing Pile perplexity by $-1.02$ points (9.73 → 8.71)!


3. Hardware-Aware Parallel Associative Scans, SRAM Kernel Fusion, and the Homogeneous Mamba Block

Introducing input-dependent $(\Delta_t, \mathbf{B}t, \mathbf{C}_t)$ creates an immediate systems challenge: because the transition matrices $\overline{\mathbf{A}}_t$ and $\overline{\mathbf{B}}_t$ vary at every timestep $t$, the recurrence $h_t = \overline{\mathbf{A}}_t \odot h{t-1} + \overline{\mathbf{B}}_t x_t$ is no longer equivalent to a shift-invariant convolution $y = x \ast \overline{\mathbf{K}}$ and cannot be computed with an FFT (arXiv:2312.00752, Section 3.3). Moreover, for batch size $B$, sequence length $L$, model channel dimension $D$, and state expansion factor $N$, the expanded latent state $h$ has shape $(B, L, D, N)$. At standard training dimensions ($B = 16$, $L = 2048$, $D = 4096$, $N = 16$ in FP16/BF16), materializing a single layer's expanded tensors $(\overline{\mathbf{A}}, \overline{\mathbf{B}}, h)$ in GPU High-Bandwidth Memory (HBM) would require $3 \times 4.29\text{ GB} \approx 12.88\text{ GB}$ per layer—exhausting an 80 GB A100 GPU within 6 layers!

Blelloch Work-Efficient Parallel Prefix-Sum Associative Scan Circuit Diagram on 16 Elements Showing Up-Sweep Reduction Tree and Down-Sweep Distribution Tree

Blelloch Work-Efficient Parallel Prefix-Sum Associative Scan Circuit Diagram on 16 Elements Showing Up-Sweep Reduction Tree and Down-Sweep Distribution Tree

1. The Associative Scan Operator for First-Order Linear Recurrences

Even though the first-order recurrence $h_t = a_t h_{t-1} + b_t$ (where $a_t = \overline{\mathbf{A}}t$ and $b_t = \overline{\mathbf{B}}_t x_t$) has time-varying coefficients, it is strictly linear in $h{t-1}$. As formalized in Martin & Cundy (2018), S5 (Smith et al., 2023), and Mamba-2 Appendix B.2.2 (arXiv:2405.21060, Equations 21–22), writing the affine update in $2 \times 2$ homogeneous matrix form reveals an exact associative binary composition operator $\otimes$:

$$\begin{bmatrix} h_t \\ 1 \end{bmatrix} = \begin{bmatrix} a_t & b_t \\ 0 & 1 \end{bmatrix} \begin{bmatrix} h_{t-1} \\ 1 \end{bmatrix}, \qquad \begin{bmatrix} a_t & b_t \\ 0 & 1 \end{bmatrix} \begin{bmatrix} a_s & b_s \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} a_t a_s & a_t b_s + b_t \\ 0 & 1 \end{bmatrix}$$ $$(a_t, b_t) \otimes (a_s, b_s) = \left(a_t \cdot a_s,\; a_t \cdot b_s + b_t\right)$$

Because matrix multiplication is associative, $\left((a_r, b_r) \otimes (a_s, b_s)\right) \otimes (a_t, b_t) = (a_r, b_r) \otimes \left((a_s, b_s) \otimes (a_t, b_t)\right)$. Consequently, all $L$ prefix products can be evaluated in parallel using a Blelloch work-efficient parallel associative scan (up-sweep reduction tree followed by down-sweep distribution tree) in $O(L)$ total work ($O(BLDN)$ FLOPs) and $O(\log L)$ parallel depth/span across GPU threads.

2. Mamba's Three Hardware-Aware Optimizations: Kernel Fusion, Parallel Scan, and Recomputation

On modern GPUs (such as the NVIDIA A100 with $1.5\text{--}2.0\text{ TB/s}$ HBM bandwidth and $\approx 19\text{ TB/s}$ on-chip SRAM bandwidth, or H100 with $3.35\text{ TB/s}$ HBM3), elementwise scans are strictly memory-bandwidth bound (arXiv:2312.00752, Section 3.3.2 & Appendix D). Mamba eliminates the $O(BLDN)$ HBM memory bottleneck via three coupled techniques:

  1. SRAM Kernel Fusion ($O(N)$ HBM I/O Reduction): Instead of computing $(\overline{\mathbf{A}}, \overline{\mathbf{B}})$ in HBM, Mamba's custom CUDA kernel streams the unexpanded parameters $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C}, x)$ of total size $O(BLD + DN + BLN)$ bytes from slow HBM directly into fast on-chip SRAM. Inside SRAM registers/shared memory, the kernel executes the ZOH discretization ($\overline{\mathbf{A}} = \exp(\Delta \mathbf{A})$, $\overline{\mathbf{B}} = \Delta \mathbf{B}$), runs the parallel associative scan over $(B, D, N)$ channels to produce $h \in \mathbb{R}^{B \times L \times D \times N}$ strictly in SRAM, contracts $y_t = \mathbf{C}_t^\top h_t$ across the $N$ axis, and writes only the final $(B, L, D)$ output tensor back to HBM. By never materializing the $(B, L, D, N)$ state in HBM, total HBM memory traffic drops by a factor of $O(N)$ ($16\times$ at $N = 16$).
  2. Long-Sequence Segmented Scan Tiling: When sequence length $L$ is too large for the entire $(B, L, D, N)$ state to fit into a streaming multiprocessor's SRAM at once, the sequence is partitioned into sub-chunks of length $L_{\text{chunk}}$ (e.g., $2048$ tokens) that fit in SRAM, passing only the terminal $(B, D, N)$ boundary state from chunk $k$ to chunk $k+1$.
  3. Backward-Pass Activation Recomputation: Saving the $(B, L, D, N)$ intermediate hidden states for backpropagation would reintroduce the HBM memory explosion. Mamba does not save intermediate scan states during the forward pass; instead, during the backward pass, the kernel reloads $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C}, x)$ and the output gradients $\partial \mathcal{L} / \partial y$ from HBM into SRAM and recomputes the intermediate hidden states on the fly in SRAM—matching the training memory footprint of FlashAttention-2 (4.8 GB vs. 4.6 GB at $B=1$, and 38.2 GB vs. 34.5 GB at $B=32$ for a $125\text{M}$ model at $L=2048$, arXiv:2312.00752 Table 22).

3. The Homogeneous Mamba Block (MambaMixer)

Prior SSM architectures such as H3 (arXiv:2212.14052) and Hyena (arXiv:2302.10866) copied the Transformer's alternating two-sublayer template: an H3 sequence-mixing block followed by a separate position-wise MLP block. Inspired by the Gated Attention Unit (GAU), Mamba unifies sequence mixing (H3) and channel mixing (SwiGLU MLP) into a single homogeneous Mamba block stacked uniformly throughout the network (arXiv:2312.00752, Section 3.4 & Figure 3):

  1. Input Expansion Projections (in_proj): Given layer input $u \in \mathbb{R}^{L \times D}$ (after RMSNorm), two linear projections expand the model dimension $D$ by an expansion factor $E = 2$ (expand = 2 in MambaConfig) into two branches $x, z \in \mathbb{R}^{L \times ED}$ ($2ED^2$ parameters total).
  2. Depthwise Causal 1D Convolution (conv1d): On the main branch $x$, a local depthwise separable 1D causal convolution (conv_kernel = 4, contributing just $4ED$ weight parameters) followed by a SiLU / Swish activation $\sigma(x) = x \cdot \text{sigmoid}(x)$ computes local token n-gram context $x_c = \text{SiLU}(\text{Conv1D}(x)) \in \mathbb{R}^{L \times ED}$.
  3. Selective S6 Scan (x_proj, dt_proj, SSM): From $x_c$, a linear projection (x_proj) produces $(\Delta_{\text{low}}, \mathbf{B}, \mathbf{C})$ of dimensions $(R, N, N)$, dt_proj expands $\Delta_{\text{low}} \in \mathbb{R}^R \to \Delta \in \mathbb{R}^{ED}$, and the selective scan computes $y = \mathsf{SSM}_{\mathbf{A}, \mathbf{B}, \mathbf{C}, \Delta}(x_c) \in \mathbb{R}^{L \times ED}$ (plus a per-channel skip connection $\mathbf{D} \odot x_c$).
  4. Multiplicative SiLU Gating & Output Contraction (out_proj): The SSM output is multiplied elementwise by the gated branch $y_g = y \odot \text{SiLU}(z) \in \mathbb{R}^{L \times ED}$ and projected back to model dimension $D$ via $W^{(o)} \in \mathbb{R}^{D \times ED}$ ($ED^2$ parameters).

Because the outer linear projections account for $2ED^2 + ED^2 = 3ED^2 = 6D^2$ parameters (when $E = 2$), while a standard Transformer layer (MHA $4D^2$ + SwiGLU MLP $8D^2$) contains $12D^2$ parameters, two homogeneous Mamba blocks match the exact $12D^2$ parameter count of one Transformer layer (arXiv:2312.00752, Section 3.4).


4. Structured State Space Duality (Mamba-2 / SSD): Semiseparable Matrices, 1-SS Masked Attention, and Tensor Core Block Decomposition

While Mamba-1 (S6) achieved linear-time scaling and strong language modeling accuracy, it remained harder to train on large GPU clusters than Transformers for two architectural reasons (arXiv:2405.21060, Sections 1 & 6):

  1. Underutilization of Hardware Matrix Multiplication Units (Tensor Cores): Modern accelerators dedicate the vast majority of their silicon compute to specialized matrix-matrix multiplication engines—NVIDIA GPU Tensor Cores (165 TFLOPS FP16 on RTX 4090, 312 TFLOPS on A100, 989 TFLOPS on H100) and Google TPU MXUs—which deliver $8\times\text{--}16\times$ higher FLOP throughput than general vector/scalar arithmetic units. Because Mamba-1's selective scan is an elementwise tree recurrence rather than a GEMM, it cannot use Tensor Cores, and its wall-clock execution time slows down linearly as state dimension $N$ increases beyond $N = 16$.
  2. Sequential Parameter Projections Blocking Tensor Parallelism (TP): In Mamba-1, the selective parameters $(\Delta, \mathbf{B}, \mathbf{C})$ are projected from $x_c = \text{SiLU}(\text{Conv1D}(x))$ after the initial input projection $x = u W^{(x)\top}$. Under Megatron-LM Tensor Parallelism (TP), sharding $(\Delta, \mathbf{B}, \mathbf{C})$ across GPUs requires an extra all-reduce synchronization barrier inside the middle of every block (2 all-reduces per block instead of 1).

In "Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality" (Dao & Gu, ICML 2024, arXiv:2405.21060), Princeton and CMU unify state space models and attention through the algebraic bridge of Semiseparable Matrices.

1. Theorem 3.5: State Space Models Are $N$-Semiseparable ($N$-SS) Matrix Transformations

Consider the time-varying discrete state space recurrence $h_t = A_t h_{t-1} + B_t x_t$, $y_t = C_t^\top h_t$ mapping a 1D input sequence $x \in \mathbb{R}^T \mapsto y \in \mathbb{R}^T$ with state dimension $N$. Unrolling $h_t$ by induction from $h_0 = B_0 x_0$ expresses the entire sequence-to-sequence transformation as a single lower-triangular matrix-vector multiplication $y = M x$ (arXiv:2405.21060, Section 3.1, Equation 3):

$$h_t = \sum_{s=0}^{t} A_{t:s}^\times B_s x_s \implies y_t = \sum_{s=0}^{t} C_t^\top A_{t:s}^\times B_s x_s \quad \Longleftrightarrow \quad y = M x, \qquad M_{ji} \coloneqq C_j^\top A_j A_{j-1} \cdots A_{i+1} B_i \quad (j \ge i)$$

where $A_{j:i}^\times \coloneqq A_j A_{j-1} \cdots A_{i+1}$. In numerical linear algebra, a lower-triangular matrix $M \in \mathbb{R}^{T \times T}$ with this generator structure is called a Sequentially Semiseparable (SSS) representation ($M = \mathsf{SSS}(A_{0:T}, B_{0:T}, C_{0:T})$). By Definition 3.1 and Lemma 3.3 (arXiv:2405.21060), any $N$-SSS matrix is an $N$-Semiseparable ($N$-SS) matrix: every contiguous submatrix $M_{j:j', i':i}$ contained strictly on or below the main diagonal ($j' > j \ge i > i'$) has rank at most $N$ via the explicit rank-$N$ factorization (arXiv:2405.21060, Equation 5):

$$M_{j:j', i':i} = \underbrace{\begin{bmatrix} C_j^\top A_{j:j}^\times \\ \vdots \\ C_{j'-1}^\top A_{j'-1:j}^\times \end{bmatrix}}{(j'-j) \times N\text{ Left Factor}} \cdot \underbrace{A{j:i-1}^\times}{N \times N\text{ Center}} \cdot \underbrace{\begin{bmatrix} A{i-1:i'}^\times B_{i'} & \cdots & A_{i-1:i-1}^\times B_{i-1} \end{bmatrix}}_{N \times (i-i')\text{ Right Factor}}$$

This establishes Theorem 3.5: The state space model transformation $y = \mathsf{SSM}(A, B, C)(x)$ with state dimension $N$ is identical to matrix multiplication by an $N$-semiseparable matrix $y = \mathsf{SSS}(A, B, C) \cdot x$.

2. Tensor Contraction Duality and 1-Semiseparable Structured Masked Attention (SSD)

From the opposite direction, Dao and Gu formulate Structured Masked Attention (SMA) (arXiv:2405.21060, Section 4, Definition 4.2) on queries $Q \in \mathbb{R}^{T \times N}$, keys $K \in \mathbb{R}^{S \times N}$, values $V \in \mathbb{R}^{S \times P}$, and any structured causal mask matrix $L \in \mathbb{R}^{T \times S}$ as a single 4-way tensor contraction (einsum):

$$Y = \mathsf{contract}\left(\mathtt{TN, SN, SP, TS \to TP}\right)(Q, K, V, L)$$

Evaluating this single 4-way contraction in two different pairwise contraction orders yields the Quadratic Mode and Linear Mode duals:

  • SMA Quadratic (Attention) Contraction Order (arXiv:2405.21060, Eq. 13): $$G = \mathsf{contract}(\mathtt{TN, SN \to TS})(Q, K) = QK^\top, \quad M = G \circ L, \quad Y = MV = \left(L \circ (QK^\top)\right) \cdot V$$
  • SMA Linear (Recurrent) Contraction Order (arXiv:2405.21060, Eq. 15): $$Z = \mathsf{contract}(\mathtt{SP, SN \to SPN})(V, K), \quad H = \mathsf{contract}(\mathtt{TS, SPN \to TPN})(L, Z), \quad Y = \mathsf{contract}(\mathtt{TN, TPN \to TP})(Q, H)$$ When $L$ is the lower-triangular all-1s causal mask ($L_{ji} = 1$ for $j \ge i$), multiplying by $L$ in step 2 is a simple cumulative sum $H_t = H_{t-1} + V_t K_t^\top$, providing a one-line tensor-contraction proof of Linear Attention (Katharopoulos et al., 2020).

The Exact Intersection — Structured State Space Duality (SSD, Section 5): When the SSM state transition matrix $A_t \in \mathbb{R}^{N \times N}$ is simplified from diagonal to scalar-times-identity structure $A_t = a_t I$ (where $a_t \in [0, 1]$ is an input-dependent scalar decay per head), the products $A_{j:i}^\times = a_j a_{j-1} \cdots a_{i+1} I$ factor out as scalars, and the $N$-SSS matrix becomes the Hadamard product of a 1-Semiseparable (1-SS) matrix $L = \mathsf{1SS}(a_{0:T})$ and the outer-product Gram matrix $C B^\top$ (arXiv:2405.21060, Section 5.1):

$$M_{ji} = a_{j:i}^\times \cdot \left(C_j^\top B_i\right) \quad \Longleftrightarrow \quad M = L \circ \left(C B^\top\right), \qquad L = \mathsf{1SS}(a) = \begin{bmatrix} 1 & & & & \\ a_1 & 1 & & & \\ a_2 a_1 & a_2 & 1 & & \\ \vdots & \vdots & \ddots & \ddots & \\ a_{T-1}\cdots a_1 & a_{T-1}\cdots a_2 & \cdots & a_{T-1} & 1 \end{bmatrix}$$

Thus, Scalar-Identity Selective SSMs and 1-Semiseparable Structured Masked Attention (1-SS SMA) are 100% mathematically identical under the duality isomorphism (arXiv:2405.21060, Table 24 & Figure 4):

$$\text{SSM Output Projection } C \in \mathbb{R}^{T \times N} \;\longleftrightarrow\; \text{Attention Queries } Q \in \mathbb{R}^{T \times N}$$ $$\text{SSM Input Projection } B \in \mathbb{R}^{T \times N} \;\longleftrightarrow\; \text{Attention Keys } K \in \mathbb{R}^{T \times N}$$ $$\text{SSM Input Sequence } X \in \mathbb{R}^{T \times P} \;\longleftrightarrow\; \text{Attention Values } V \in \mathbb{R}^{T \times P}$$ $$\text{SSM State Transitions } A_{j:i}^\times \;\longleftrightarrow\; \text{1-SS Attention Mask } L_{ji} = a_j \cdots a_{i+1}$$

3. The Hardware-Efficient Chunked SSD Algorithm (Theorem 6.1)

Neither the pure linear recurrent scan (which cannot use Tensor Cores) nor the pure quadratic attention mode (which scales as $O(T^2)$) is optimal across all sequence lengths. Mamba-2's SSD Algorithm (arXiv:2405.21060, Section 6) partitions the sequence transformation matrix $M \in \mathbb{R}^{T \times T}$ into a $\frac{T}{Q} \times \frac{T}{Q}$ grid of submatrix blocks $M^{(j,i)} \in \mathbb{R}^{Q \times Q}$ of chunk length $Q$ (chunk_size = 256 by default in Mamba2Config):

  1. Diagonal (Intra-Chunk) Blocks $M^{(j,j)}$ (Quadratic Attention Mode on Tensor Cores): Within each local chunk of $Q$ tokens, interactions are computed via the quadratic dual $(L^{(j,j)} \circ (C_j B_j^\top)) X_j$ using two batched matrix multiplications of cost $\mathsf{BMM}(T/Q, Q, Q, N)$ and $\mathsf{BMM}(T/Q, Q, P, Q)$.
  2. Off-Diagonal (Inter-Chunk) Low-Rank Blocks $M^{(j,i)}$ ($j > i$) (Rank-$N$ Semiseparable Recurrence): Because every strictly lower-triangular block $M^{(j,i)}$ has rank at most $N$, its contribution across all past chunks $i < j$ decomposes via Equation (5) into three pipelined stages: * Step 1 — Right Factors (Chunk Inputs $\to$ Chunk Final States): For each chunk $i \in \{0, \dots, T/Q - 1\}$, compute the chunk's local state contribution via a single batched matrix multiplication of cost $\mathsf{BMM}(T/Q, N, P, Q)$. * Step 2 — Center Factors (Chunk-to-Chunk State Passing Scan): Pass the $(N, P)$-dimensional hidden state across the $T/Q$ chunk boundaries using a 1-SS scalar recurrence scan of length $T/Q$ (which is $Q = 256\times$ shorter than Mamba-1's token-level scan and takes only $TNP/Q$ scalar work). * Step 3 — Left Factors (Chunk Initial States $\to$ Chunk Outputs): Project the incoming chunk boundary state onto the $Q$ output positions of chunk $j$ via a single batched matrix multiplication of cost $\mathsf{BMM}(T/Q, Q, P, N)$ and add to the diagonal block outputs.

When state dimension, head dimension, and chunk size are matched ($N = P = Q$), every batched matrix multiplication has shape $\mathsf{BMM}(T/N, N, N, N)$, achieving the tight theoretical bounds of Theorem 6.1 (arXiv:2405.21060, Table 27):

Efficiency Axis (arXiv:2405.21060, Table 27) Softmax Self-Attention Mamba-1 Selective SSM (S6) Mamba-2 State Space Dual (SSD)
Effective Autoregressive State Size $O(T)$ (Uncompressed KV Cache) $O(N)$ (Default $N=16$, $P=1$) $O(N)$ (Default $N=128$, $P=64$)
Training Compute Complexity (FLOPs) $O(T^2 N)$ (Quadratic in $T$) $O(T N^2)$ (Linear in $T$) $O(T N^2)$ (Linear in $T$)
Autoregressive Inference FLOPs (Total) $O(T N)$ per step ($O(T^2 N)$ total) $O(N^2)$ per step ($O(TN^2)$ total) $O(N^2)$ per step ($O(TN^2)$ total)
Naive Activation Memory Footprint $O(T^2)$ ($O(TN)$ with FlashAttention) $O(T N^2)$ ($O(TN)$ with SRAM fusion) $O(T N)$ (Naturally block-Factored)
Leverages Hardware Tensor Cores (`GEMM`/`BMM`) ✓ Yes ($QK^\top$ and $PV$ GEMMs) ✗ No (Vector associative scan) ✓ Yes (2–8× faster than Mamba-1 scan; 6× faster than FlashAttn-2 at 16K)

4. Mamba-2 Block Design, Multi-Input SSM (MIS / MVA) Head Structure, and Tensor Parallelism

Beyond the core SSD kernel, Mamba-2 introduces three architectural refinements (arXiv:2405.21060, Sections 7–8 & Tables 38–39):

  • Parallel $(A, B, C, X, Z)$ Projections (1 All-Reduce per TP Block): Instead of computing $(\Delta, B, C)$ sequentially from $\text{Conv1D}(x)$, Mamba-2 produces $A, X, B, C, Z$ in parallel from the block input $u$ via a single fused column-parallel linear layer, applies the depthwise Conv1D across $(X, B, C)$, passes them into the SSD layer, multiplies by $\text{Swish}(Z)$, applies an extra GroupNorm / RMSNorm layer $y_n = \text{GroupNorm}(y_g)$ (with the number of groups divisible by the Tensor Parallel degree), and projects out via row-parallel $W^{(o)}$. This cuts Megatron Tensor Parallel synchronization points from 2 all-reduces down to 1 all-reduce per block and lowers $126.5\text{M}$-model Pile perplexity from $11.76$ (Mamba-1 block) to $11.49$ (Mamba-2 block) (Table 38).
  • Multi-Input SSM (MIS) / Multi-Value Attention (MVA) Head Pattern (Table 39): Viewing $X$ as attention Values $V$, $B$ as Keys $K$, and $C$ as Queries $Q$, Mamba-1's broadcasting of $(B, C)$ across $D$ input channels is the exact dual of Multi-Value Attention (MVA)—where $X$ has $H$ independent heads of dimension $P = 64$, while $B$ and $C$ share $1$ head (or $G$ grouped heads, e.g. n_groups = 8 in Mamba2Config, analogous to Grouped-Value Attention GVA). In controlled ablations at $126.5\text{M}$ and $361.8\text{M}$ parameters (arXiv:2405.21060, Table 39), the MIS / MVA head pattern (11.66 and 8.73 Pile PPL) dramatically outperforms Multi-Contract / Multi-Query Attention (MCS/MQA) (12.62 and 9.33 PPL), Multi-Expand / Multi-Key (MES/MKA) (12.59 and 9.36 PPL), and Multi-Head (MHS/MHA) (12.06 and 9.01 PPL).
  • Sequence Parallelism & Zero-Padding Variable-Length Sequences (Section 8.2–8.3): For sequences too long for a single GPU's activation memory, Mamba-2 partitions sequence tokens across GPUs and passes only the compact $(N, P)$ recurrent chunk boundary state between devices. For variable-length fine-tuning batches, Mamba-2 packs concatenated sequences without padding tokens and simply sets the scalar transition decay $a_t = 0$ at sequence boundary indices, preventing cross-document state leakage in $O(1)$ instructions.

5. Gated Linear Recurrences and Linear Attention Variants: RWKV WKV Time-Decay and Griffin / Hawk RG-LRU

Parallel to the continuous-time discretization path of S4 and Mamba, two major industrial recurrent architectures—RWKV (arXiv:2305.13048) and Google DeepMind's Hawk & Griffin (RecurrentGemma) (arXiv:2402.19427)—arrive at diagonal linear recurrences directly from attention-free gating and discrete RNN stability analysis.

Recurrent Neural Network Unfolding Diagram Showing Compressed Cyclic Recurrent State Loop on the Left and Unrolled Directed Acyclic Graph Across Time Steps t-1, t, and t+1 on the Right

Recurrent Neural Network Unfolding Diagram Showing Compressed Cyclic Recurrent State Loop on the Left and Unrolled Directed Acyclic Graph Across Time Steps t-1, t, and t+1 on the Right

1. RWKV: Receptance Weighted Key Value, Token Shift, and Numerically Stabilized WKV Recurrence

In "RWKV: Reinventing RNNs for the Transformer Era" (Peng et al., EMNLP 2023, arXiv:2305.13048), EleutherAI and the RWKV Foundation scale a dense linear-attention RNN across six checkpoints (169M, 430M, 1.5B, 3B, 7.39B, and 14.15B parameters) trained on $330\text{B}$ Pile tokens, proving that dense recurrent models follow the exact log-log compute-optimal scaling law of Transformers ($r^2 = 0.994$ Pareto fit, $r^2 = 0.875$ extrapolated; parameter count $= 2VD + 13D^2L + D(11L+4)$ and forward compute $= 2(2VD + 13D^2L)\text{ FLOPs/token}$). Each RWKV residual block consists of a Time-Mixing sub-block and a Channel-Mixing sub-block built on three mathematical primitives (arXiv:2305.13048, Section 3.1; huggingface.co/docs/transformers/en/model_doc/rwkv):

  1. Temporal Token Shift ($\mu$-Interpolation): Before any linear projection $W_\lambda \in \{W_r, W_k, W_v, W'r, W'_k\}$, RWKV linearly interpolates the current token embedding $x_t$ with the immediate predecessor $x{t-1}$ via learnable channel-wise mixing vectors $\mu_\lambda \in \mathbb{R}^d$ (implemented via a zero-cost temporal offset nn.ZeroPad2d((0, 0, 1, -1))): $$r_t = W_r \cdot \left(\mu_r \odot x_t + (1 - \mu_r) \odot x_{t-1}\right), \quad k_t = W_k \cdot \left(\mu_k \odot x_t + (1 - \mu_k) \odot x_{t-1}\right), \quad v_t = W_v \cdot \left(\mu_v \odot x_t + (1 - \mu_v) \odot x_{t-1}\right)$$
  2. Channel-Wise Exponential Time-Decay WKV Operator (arXiv:2305.13048, Eq. 16–17): Inspired by the Attention-Free Transformer (AFT), RWKV replaces quadratic pairwise dot-product scores $q_t^\top k_i$ with a non-negative channel-wise temporal decay vector $w \in \mathbb{R}{\ge 0}^d$ (time_decay) multiplied by relative distance $(t - 1 - i)$, plus a separate current-token bonus vector $u \in \mathbb{R}^d$ (time_first) to prevent self-decay: $$wkv_t = \frac{\sum{i=1}^{t-1} e^{-(t-1-i)w + k_i} \odot v_i + e^{u + k_t} \odot v_t}{\sum_{i=1}^{t-1} e^{-(t-1-i)w + k_i} + e^{u + k_t}}, \qquad o_t = W_o \cdot \left(\sigma(r_t) \odot wkv_t\right)$$ Followed by the Channel-Mixing block with squared-ReLU activation (arXiv:2305.13048, Eq. 18): $$o'_t = \sigma(r'_t) \odot \left(W'_v \cdot \max(k'_t, 0)^2\right)$$
  3. Exact $O(d)$ Recurrent State with Running-Maximum Numerical Stabilization: As documented in the Hugging Face Transformers RWKV specification (huggingface.co/docs/transformers/en/model_doc/rwkv), unrolling the numerator $\hat{N}{j+1} = e^{K_j}V_j + e^w \hat{N}_j$ and denominator $\hat{D}{j+1} = e^{K_j} + e^w \hat{D}j$ directly would overflow floating-point exponents when $K_j$ is large. RWKV maintains a 3-tuple recurrent state $(\tilde{N}_j, \tilde{D}_j, M_j) \in \mathbb{R}^d \times \mathbb{R}^d \times \mathbb{R}^d$ normalized by the running maximum exponent $M_j$: $$q{\text{step}} = \max(u + K_i, M_i), \quad N_i = e^{u + K_i - q_{\text{step}}}V_i + e^{M_i - q_{\text{step}}}\tilde{N}i, \quad D_i = e^{u + K_i - q{\text{step}}} + e^{M_i - q_{\text{step}}}\tilde{D}i, \quad O_i = \sigma(R_i)\frac{N_i}{D_i}$$ $$q{\text{next}} = \max(K_i, w + M_i), \quad \tilde{N}{i+1} = e^{K_i - q{\text{next}}}V_i + e^{w + M_i - q_{\text{next}}}\tilde{N}i, \quad \tilde{D}{i+1} = e^{K_i - q_{\text{next}}} + e^{w + M_i - q_{\text{next}}}\tilde{D}i, \quad M{i+1} = q_{\text{next}}$$

2. Google DeepMind's Real-Gated Linear Recurrent Unit (RG-LRU) in Hawk and Griffin

In "Griffin: Mixing Gated Linear Recurrences with Local Attention for Efficient Language Models" (De et al., Google DeepMind 2024, arXiv:2402.19427), the authors introduce the Real-Gated Linear Recurrent Unit (RG-LRU), which underpins both Hawk (a pure recurrent LLM) and Griffin / RecurrentGemma (a hybrid LLM alternating 2 RG-LRU recurrent blocks with 1 local sliding-window Multi-Query Attention block of window size $W = 1024$ tokens).

Given an input $x_t \in \mathbb{R}^{D_{\text{RNN}}}$ (where $D_{\text{RNN}} \approx \frac{4}{3}D$ is expanded and passed through a temporal filter-4 separable Conv1D), the RG-LRU layer computes (arXiv:2402.19427, Section 2.4, Equations 1–4):

$$r_t = \sigma\left(W_a x_t + b_a\right) \quad \text{(Recurrence Gate)}, \qquad i_t = \sigma\left(W_x x_t + b_x\right) \quad \text{(Input Gate)}$$ $$a_t = a^{c \cdot r_t} \quad \text{where } a = \sigma(\Lambda) \in [0, 1],\; c = 8$$ $$h_t = a_t \odot h_{t-1} + \sqrt{1 - a_t^2} \odot \left(i_t \odot x_t\right), \qquad y_t = h_t$$

Four key mathematical and systems engineering properties distinguish the RG-LRU (arXiv:2402.19427, Sections 2.4 & 4):

  1. Super-Exponential Memory Preservation via $a_t = a^{c r_t}$: Unlike Mamba's step-size gate $\Delta_t$ (which acts like a GRU update gate resetting the state when $\Delta_t \to \infty$), the RG-LRU separates the input gate $i_t$ from the recurrence gate $r_t$. When $r_t \to 0$, $a_t = a^{c r_t} \to 1$ and $\sqrt{1 - a_t^2} \to 0$, allowing the unit to smoothly interpolate between the standard Linear Recurrent Unit update ($r_t = 1 \implies a_t = a^c \in [0.9, 0.999]$) and lossless identity preservation ($h_t = h_{t-1}$), discarding uninformative inputs without decaying historical memory.
  2. Real-Valued Variance-Preserving Multiplier $\sqrt{1 - a_t^2}$: The input scaling factor $\sqrt{1 - a_t^2}$ ensures that if $h_{t-1}$ and $i_t \odot x_t$ have unit variance, $h_t$ maintains unit variance across arbitrarily deep sequence horizons without requiring complex eigenvalues or HiPPO polynomial initialization.
  3. 16-Block-Diagonal Gate Matrices for Zero-Communication Tensor Parallelism: To prevent cross-device synchronization inside the RG-LRU under Megatron Tensor Parallelism, $W_a$ and $W_x$ are structured as 16-block-diagonal matrices (each containing $D_{\text{RNN}}^2 / 16$ parameters), allowing the Conv1D and RG-LRU scan to execute completely independently across device shards with only 1 all-reduce per residual block (arXiv:2402.19427, Section 4.1).
  4. Hardware Roofline Physics (0.75 FLOPs/Byte) & Pallas Linear Scan vs. Associative Scan: In BF16 ($2\text{ bytes/element}$), each elementwise update of Equation (4) reads $6\text{ bytes}$ ($h_{t-1}, a_t, x_t$) and writes $2\text{ bytes}$ ($h_t$) while executing $6\text{ FLOPs}$, yielding an arithmetic intensity of $0.75\text{ FLOPs/Byte}$—far below TPU-v3's elementwise roof of $4.2\text{ FLOPs/Byte}$. Because tree recombination in parallel associative scans induces non-sequential memory accesses that exacerbate HBM-to-VMEM memory transfers on TPU-v3, DeepMind implements a custom Pallas linear scan kernel that pins $h_t$ permanently in on-chip VMEM SRAM, delivering a $3\times$ kernel speedup over native JAX and $10\text{--}20\%$ faster end-to-end training steps (arXiv:2402.19427, Section 4.2).

6. Hybrid SSM-Attention-MoE Architectures (Jamba, Griffin, Mamba-2-Attention): Solving In-Context Retrieval & KV-Cache Scaling

Why has the frontier AI ecosystem in 2026 converged on Hybrid SSM-Transformer architectures rather than pure SSMs or pure Transformers? Both theoretical information-capacity bounds and empirical evaluations in Griffin (arXiv:2402.19427 Section 6.2), Jamba (arXiv:2403.19887 Section 6.2), and Mamba-2 (arXiv:2405.21060 Section 9.2.3) reveal a sharp functional complementarity:

  • Pure Fixed-State SSMs Struggle with Exact Multi-Query Retrieval and In-Context Format Imitation: Because a pure recurrent layer funnels the entire prompt history through a fixed state vector of size $O(DN)$, it faces an information bottleneck when asked to perform zero-shot exact lookup over an unstructured list (such as DeepMind's Phonebook Lookup task, where Hawk-7B degrades rapidly as phonebook length grows, arXiv:2402.19427 Figure 6c) or few-shot in-context format copying. On $1.3\text{B}$-parameter models trained on $250\text{B}$ tokens (arXiv:2403.19887, Table 6), pure Mamba lags pure Attention severely on IMDB (48.8% vs. 84.1%), QuAC (20.2% vs. 27.9%), and NarrativeQA (27.7% vs. 45.8%) because pure Mamba struggles to copy the exact answer formatting template demonstrated in few-shot prompts.
  • Adding Just $10\%\text{--}12.5\%$ Attention Layers Restores Full In-Context Retrieval While Preserving SSM Efficiency:
  • In Jamba's $1.3\text{B}$ Ablation (arXiv:2403.19887, Tables 4 & 6), replacing just 1 out of every 8 Mamba layers with a standard Attention layer ($a:m = 1:7$ ratio) causes IMDB accuracy to surge from 48.8% (Pure Mamba) to 90.9% (Attention-Mamba Hybrid), QuAC from 20.2% to 26.6%, NarrativeQA from 27.7% to 43.7%, and OpenLLM average from 59.4 (Mamba) / 59.6 (Attention) to 61.7 (Hybrid 1:7)—with virtually zero difference between $1:3$ and $1:7$ Attention-to-Mamba ratios!
  • In Mamba-2's 48-Layer $350\text{M}$ Ablation (arXiv:2405.21060, Table 36), pure Mamba-2 (0 Attention blocks) achieves 8.60 Pile PPL and pure Transformer++ achieves 8.68 Pile PPL. Inserting just 1 Attention block drops PPL to 8.38; inserting 6 Attention blocks ($12.5\%$ of layers) reaches the global optimum of 8.26 Pile PPL ($-0.34$ PPL below pure Mamba-2 and $-0.42$ PPL below pure Transformer++). At the $2.7\text{B}$ 64-layer scale trained on $300\text{B}$ Pile tokens (arXiv:2405.21060, Table 37), Mamba-2-Attention (58 SSD layers + 6 Attention layers at layer indices 9, 18, 27, 36, 45, 56) achieves 5.95 Pile PPL, 3.85 LAMBADA PPL, and 61.0% average zero-shot accuracy, beating both pure Mamba-2 (6.09 PPL, 60.2% avg) and pure Transformer++ (6.13 PPL, 60.2% avg).

1. AI21 Jamba Architecture (1:7 Attention:Mamba + Top-2 of 16 MoE)

In "Jamba: A Hybrid Transformer-Mamba Language Model" (Lieber et al., AI21 Labs, arXiv:2403.19887), the production Jamba architecture stacks 4 Jamba blocks of $l = 8$ layers each ($L = 32$ layers total, hidden_size = 4096) configured via five structural degrees of freedom (arXiv:2403.19887, Section 3.1; huggingface.co/docs/transformers/en/model_doc/jamba):

  1. Attention-to-Mamba Ratio ($a:m = 1:7$): Out of every $8$ layers (attn_layer_period = 8, attn_layer_offset = 4), exactly 1 layer is a Grouped-Query Attention (GQA) layer and 7 layers are Mamba layers (mamba_expand = 2, mamba_d_state = 16, mamba_d_conv = 4). Across the full 32-layer model, only 4 layers maintain a KV cache!
  2. Mixture-of-Experts Interleaving ($e = 2, n = 16, K = 2$): Every other layer's SwiGLU MLP ($e = 2$) is replaced with an MoE router selecting the top $K = 2$ out of $n = 16$ experts per token. This expands total model capacity to $52\text{B}$ available parameters while keeping active per-token compute to just $12\text{B}$ active parameters (matching Mixtral-8x7B's $12.9\text{B}$ active / $46.7\text{B}$ total parameters).
  3. Internal Mamba RMSNorm Stabilization (arXiv:2403.19887, Section 6.4): When scaling beyond $1.3\text{B}$ to $12\text{B}/52\text{B}$ parameters, internal Mamba activations develop high-magnitude outliers causing severe training loss spikes; applying RMSNorm (use_mamba_rmsnorm) to internal Mamba states completely eliminates loss spikes.
  4. Zero Explicit Positional Embeddings (NoPE, Section 6.5 & Table 8): Because the causal Mamba layers preceding each attention layer naturally encode sequential order into hidden representations, Jamba omits Rotary Position Embeddings (RoPE) entirely—achieving 39.6% HellaSwag, 71.5% WinoGrande, 50.5% ARC-C (+4.3% over Jamba+RoPE at 46.2%), and identical -0.516 / -0.623 / -0.299 C4/Books/Code log-prob per byte while extrapolating up to $256\text{K}$ (and $1\text{M}$ trained) context lengths.
Model Architecture (arXiv:2403.19887, Tables 1–3) Total / Active Params 256K Context 16-Bit KV Cache ↓ HellaSwag / WinoGrande / PIQA ↑ MMLU (5-shot) / GSM8K / BoolQ ↑ L-Eval Long-QA 5-Task Avg F1 ↑
LLaMA-2 6.7B / 13B (Dense MHA) 6.7B / 6.7B (13B / 13B) 128 GB (at 6.7B) 80.7 / 72.8 / 80.5 (13B) 54.8 / 34.7 / 81.7 (13B) OOM at 128K–256K
LLaMA-2 70B (Dense GQA) 70B / 70B Exceeds single 80GB GPU 85.3 / 80.2 / 82.8 69.8 / 55.3 / 85.0 OOM on 4× A100 at 128K
Mistral 7.2B / Gemma 7B 7.2B / 7.2B 32 GB (Mistral GQA) 81.2 / 72.3 / 81.2 (Gemma) 64.3 / 54.5 / 87.2 (Gemma) —
Mixtral 8×7B (Pure Attention MoE) 46.7B / 12.9B 32 GB 86.7 / 81.2 / 83.0 70.6 / 60.4 / 88.4 0.43 (1× throughput @ 128K)
Jamba (1:7 Attn:Mamba + 2/16 MoE) 52B / 12B 4 GB (8× smaller vs. Mixtral; 32× vs. LLaMA-2) 87.1 / 82.5 / 83.2 67.4 / 59.9 / 88.2 0.44 (3× throughput @ 128K)

7. Cross-Architecture Empirical Benchmarks: Zero-Shot Language Modeling, DNA Genomics, and Inference Throughput

To evaluate pure and hybrid state space models on a strictly controlled footing, Table 65 of Mamba-2 (arXiv:2405.21060), Table 3 of Mamba-1 (arXiv:2312.00752), and Table 1 of Griffin (arXiv:2402.19427) benchmark models trained on $300\text{B}$ tokens against open-weight Transformer baselines (Pythia, OPT, GPT-Neo, GPT-J, and LLaMA-2):

Model & Scale Tokens Pile PPL ↓ LAMBADA PPL ↓ / Acc ↑ HellaSwag ↑ PIQA ↑ ARC-E / ARC-C ↑ WinoGrande ↑ OpenBookQA / Avg ↑
Pythia-160M / Mamba-2-130M 300B 29.64 → 10.48 38.10 / 33.0 → 16.86 / 43.9 30.2 → 35.3 61.4 → 64.9 43.2/24.1 → 47.4/24.2 51.9 → 52.1 29.2 / 39.0 → 30.6 / 42.6
Pythia-410M / Mamba-2-370M 300B 9.95 → 8.21 10.84 / 51.4 → 8.02 / 55.8 40.6 → 46.9 66.9 → 70.5 52.1/24.6 → 54.9/26.9 53.8 → 55.7 30.0 / 45.6 → 32.4 / 49.0
Pythia-1B / Mamba-2-780M 300B 7.82 → 7.26 7.92 / 56.1 → 5.86 / 61.7 47.2 → 54.9 70.7 → 72.0 57.0/27.1 → 61.0/28.5 53.5 → 60.2 31.4 / 49.0 → 36.2 / 53.5
Pythia-1.4B / RWKV4-1.5B 300B / 330B 7.51 / 7.70 6.08 / 61.7 | 7.04 / 56.4 52.1 / 52.5 71.0 / 72.4 60.5/28.5 | 60.5/29.4 57.2 / 54.6 30.8 / 51.7 | 34.0 / 51.4
Mamba-1.4B / Mamba-2-1.3B 300B 6.80 / 6.66 5.04 / 65.0 | 5.02 / 65.7 59.1 / 59.9 74.2 / 73.2 65.5/32.8 | 64.3/33.3 61.5 / 60.9 36.4 / 56.4 | 37.8 / 56.4
Pythia-2.8B / RWKV4-3B 300B / 330B 6.73 / 7.00 5.04 / 64.7 | 5.24 / 63.9 59.3 / 59.6 74.0 / 73.7 64.1/32.9 | 67.8/33.1 59.7 / 59.6 35.2 / 55.7 | 37.0 / 56.4
Mamba-2.8B / Mamba-2-2.7B 300B 6.22 / 6.09 4.23 / 69.2 | 4.10 / 69.7 66.1 / 66.6 75.2 / 76.4 69.7/36.3 | 69.6/36.4 63.5 / 64.0 39.6 / 59.9 | 38.8 / 60.2
Mamba-2-Attention-2.7B (58 SSD + 6 Attn) 300B 5.95 3.85 / 71.1 67.8 75.8 69.9 / 37.8 65.3 39.0 / 61.0
Pythia-6.9B / RWKV4-7.4B 300B / 330B 6.51 / 6.31 4.45 / 67.1 | 4.38 / 67.2 64.0 / 65.5 75.2 / 76.1 67.3/35.5 | 67.8/37.5 61.3 / 61.0 38.0 / 58.3 | 40.2 / 59.3
Hawk-3B / Griffin-3B (MassiveText) 300B — MMLU: 31.3 / 32.6 71.7 / 73.5 78.8 / 78.1 68.4/40.2 | 71.5/41.4 66.5 / 67.2 6-Task Avg: 59.5 / 60.7
Griffin-7B / Griffin-14B (vs. LLaMA-2 7B/13B @ 2T) 300B (6.7× fewer) — MMLU: 39.3 / 49.5 78.6 / 81.4 81.0 / 81.8 75.4/47.9 | 79.1/50.8 72.6 / 74.1 Avg: 65.8 (vs 65.3) / 69.5 (vs 69.3)

Autoregressive Decoding Latency & Cache Memory Calculus (arXiv:2402.19427, Equation 5)

As derived in Griffin (arXiv:2402.19427, Section 5.1, Equation 5), during memory-bandwidth-bound autoregressive token generation ($B \lesssim 128$), the wall-clock time required to sample the next token across a batch of $B$ sequences is governed by the ratio of parameter + cache bytes to HBM memory bandwidth:

$$\text{Time to sample next token} \approx \frac{\text{Parameter Bytes} + B \times \text{Cache Bytes per Sequence}}{\text{HBM Memory Bandwidth}}$$

  • For a Global Attention Transformer with $L_{\text{layers}}$ layers, $G_{\text{KV}}$ KV head groups, head dimension $P$, and sequence length $T$ in 16-bit precision (2 bytes), $\text{Cache Bytes per Sequence} = 4 \cdot L_{\text{layers}} \cdot G_{\text{KV}} \cdot P \cdot T$, scaling linearly with $T$ until $B \times \text{Cache Bytes}$ dwarfs the static parameter bytes and forces smaller batch sizes.
  • For a Selective SSM (Mamba-1 / Mamba-2), each layer stores only the conv1d window of length $d_{\text{conv}} - 1 = 3$ and the recurrent SSM state of shape $(E \cdot D, N)$ (or $(H, P, N)$ in Mamba-2), which is 100% independent of sequence length $T$ ($O(1)$ in $T$).
  • For Hybrid Models (Jamba and Griffin), Jamba reduces global KV cache bytes by $8\times$ ($4$ attention layers out of $32$, taking only $4\text{ GB}$ at $T = 256\text{K}$), while Griffin bounds KV cache length strictly to the local sliding window $W = 1024$ tokens across its $1/3$ local MQA layers.

8. Programmatic Verification & Production Implementation: Pure Python SSD Dual Equivalence, Associative Scan, and KV-Cache Roofline Profiler

To verify the mathematical equivalence between the Recurrent (Linear) Mode, Attention (Quadratic 1-SS) Mode, and Chunked Block-Decomposition Mode of Mamba-2 Structured State Space Duality (SSD) (arXiv:2405.21060), as well as the Blelloch Parallel Associative Scan (Eq. 22), Griffin's RG-LRU (arXiv:2402.19427 Eq. 1–4), and RWKV's Running-Max WKV Recurrence (huggingface.co/docs/transformers/en/model_doc/rwkv), the self-contained Python 3 module below implements each algorithm from first principles and profiles exact KV/state cache footprints at $T = 256\text{K}$ tokens:

#!/usr/bin/env python3
"""Programmatic verification of Mamba-2 SSD Duality, Parallel Associative Scan,
Griffin RG-LRU, RWKV Running-Max WKV Recurrence, and 256K Cache Memory Calculus.

Sources:
  - Gu, Goel, & Re (ICLR 2022, S4): https://arxiv.org/abs/2111.00396
  - Gu & Dao (COLM 2024, Mamba S6): https://arxiv.org/abs/2312.00752
  - Dao & Gu (ICML 2024, Mamba-2 SSD): https://arxiv.org/abs/2405.21060
  - Lieber et al. (ICLR 2025, Jamba): https://arxiv.org/abs/2403.19887
  - De et al. (2024, Griffin / RG-LRU): https://arxiv.org/abs/2402.19427
  - Peng et al. (EMNLP 2023, RWKV): https://arxiv.org/abs/2305.13048
"""

from __future__ import annotations

from dataclasses import dataclass
import math
from typing import Dict, List, Tuple

@dataclass(frozen=True)
class CacheMemoryProfile:
    """Immutable cache and throughput profile for a sequence model at context T."""

    architecture: str
    total_params_b: float
    active_params_b: float
    context_tokens: int
    kv_or_state_cache_gib: float
    relative_cache_reduction: float

def associative_scan_1ss(
    a_seq: Tuple[float, ...],
    b_seq: Tuple[float, ...],
) -> Tuple[float, ...]:
    """Compute scalar SSM recurrence h_t = a_t * h_{t-1} + b_t via associative operator (Eq. 22).

    In Mamba-2 Appendix B.2.2 (arXiv:2405.21060), the binary operator
    (a_t, b_t) (x) (a_s, b_s) = (a_t * a_s, a_t * b_s + b_t) is associative.
    """
    if len(a_seq) != len(b_seq):
        raise ValueError("a_seq and b_seq must have identical sequence length.")
    items: List[Tuple[float, float]] = list(zip(a_seq, b_seq))
    n = len(items)
    # Parallel tree prefix-scan simulation using associative composition op
    stride = 1
    while stride < n:
        prev = list(items)
        for idx in range(stride, n):
            a_t, b_t = prev[idx]
            a_s, b_s = prev[idx - stride]
            items[idx] = (a_t * a_s, a_t * b_s + b_t)
        stride *= 2
    return tuple(b_val for _, b_val in items)

def ssd_linear_recurrent_mode(
    x_seq: List[List[float]],
    a_seq: List[float],
    b_seq: List[List[float]],
    c_seq: List[List[float]],
) -> List[List[float]]:
    """Compute Mamba-2 SSD in O(T * N * P) linear recurrent mode (arXiv:2405.21060 Eq. 2 & 8).

    Args:
        x_seq: Input V/X tensor of shape (T, P).
        a_seq: Scalar decay a_t in [0, 1] of shape (T,).
        b_seq: Expansion K/B tensor of shape (T, N).
        c_seq: Contraction Q/C tensor of shape (T, N).
    """
    t_len = len(x_seq)
    p_dim = len(x_seq[0])
    n_dim = len(b_seq[0])
    h_state = [[0.0 for _ in range(p_dim)] for _ in range(n_dim)]
    outputs: List[List[float]] = []

    for t in range(t_len):
        a_t = a_seq[t]
        h_state = [
            [a_t * h_state[n][p] + b_seq[t][n] * x_seq[t][p] for p in range(p_dim)]
            for n in range(n_dim)
        ]
        y_t = [
            sum(c_seq[t][n] * h_state[n][p] for n in range(n_dim))
            for p in range(p_dim)
        ]
        outputs.append(y_t)
    return outputs

def ssd_quadratic_attention_mode(
    x_seq: List[List[float]],
    a_seq: List[float],
    b_seq: List[List[float]],
    c_seq: List[List[float]],
) -> List[List[float]]:
    """Compute Mamba-2 SSD in dual 1-SS Structured Masked Attention mode Y = (L o (C B^T)) X."""
    t_len = len(x_seq)
    p_dim = len(x_seq[0])
    n_dim = len(b_seq[0])

    # Build 1-Semiseparable mask L_{j,i} = a_j * a_{j-1} * ... * a_{i+1} for j >= i
    m_matrix = [[0.0 for _ in range(t_len)] for _ in range(t_len)]
    for j in range(t_len):
        for i in range(j + 1):
            l_ji = 1.0
            for k in range(i + 1, j + 1):
                l_ji *= a_seq[k]
            cb_ji = sum(c_seq[j][n] * b_seq[i][n] for n in range(n_dim))
            m_matrix[j][i] = l_ji * cb_ji

    return [
        [sum(m_matrix[j][i] * x_seq[i][p] for i in range(j + 1)) for p in range(p_dim)]
        for j in range(t_len)
    ]

def ssd_chunked_block_mode(
    x_seq: List[List[float]],
    a_seq: List[float],
    b_seq: List[List[float]],
    c_seq: List[List[float]],
    chunk_size: int = 2,
) -> List[List[float]]:
    """Compute Mamba-2 SSD via Section 6 Block Decomposition (Diagonal + Low-Rank Off-Diagonal)."""
    t_len = len(x_seq)
    p_dim = len(x_seq[0])
    n_dim = len(b_seq[0])
    num_chunks = t_len // chunk_size

    outputs: List[List[float]] = []
    # Running inter-chunk state H_prev of shape (N, P)
    h_chunk = [[0.0 for _ in range(p_dim)] for _ in range(n_dim)]

    for c_idx in range(num_chunks):
        start = c_idx * chunk_size
        end = start + chunk_size
        x_c = x_seq[start:end]
        a_c = a_seq[start:end]
        b_c = b_seq[start:end]
        c_c = c_seq[start:end]

        # 1. Diagonal block: local quadratic 1-SS attention inside chunk
        y_diag = ssd_quadratic_attention_mode(x_c, a_c, b_c, c_c)

        # 2. Left factor: project incoming inter-chunk state h_chunk onto chunk outputs
        cum_a = 1.0
        for local_t in range(chunk_size):
            cum_a *= a_c[local_t]
            y_off = [
                sum(c_c[local_t][n] * (cum_a * h_chunk[n][p]) for n in range(n_dim))
                for p in range(p_dim)
            ]
            outputs.append([y_diag[local_t][p] + y_off[p] for p in range(p_dim)])

        # 3. Right + Center factor: update inter-chunk state to end of current chunk
        for local_t in range(chunk_size):
            a_t = a_c[local_t]
            h_chunk = [
                [a_t * h_chunk[n][p] + b_c[local_t][n] * x_c[local_t][p] for p in range(p_dim)]
                for n in range(n_dim)
            ]

    return outputs

def rg_lru_step(
    h_prev: Tuple[float, ...],
    x_t: Tuple[float, ...],
    r_gate: Tuple[float, ...],
    i_gate: Tuple[float, ...],
    lambda_param: Tuple[float, ...],
    c_const: float = 8.0,
) -> Tuple[float, ...]:
    """Execute one step of Google DeepMind's RG-LRU recurrence (arXiv:2402.19427 Eq. 1-4)."""
    next_h: List[float] = []
    for h_val, x_val, r_val, i_val, lam in zip(h_prev, x_t, r_gate, i_gate, lambda_param):
        a_base = 1.0 / (1.0 + math.exp(-lam))
        a_t = a_base ** (c_const * r_val)
        in_scale = math.sqrt(max(0.0, 1.0 - a_t * a_t))
        next_h.append(a_t * h_val + in_scale * (i_val * x_val))
    return tuple(next_h)

def profile_256k_caches() -> Dict[str, CacheMemoryProfile]:
    """Compare verified 256K-token 16-bit cache footprints from Jamba Table 1 & Mamba-2."""
    return {
        "LLaMA-2 6.7B (32 MHA layers)": CacheMemoryProfile("LLaMA-2 6.7B", 6.7, 6.7, 262144, 128.0, 1.0),
        "Mistral 7.2B (32 GQA layers)": CacheMemoryProfile("Mistral 7.2B", 7.2, 7.2, 262144, 32.0, 4.0),
        "Mixtral 8x7B (32 GQA MoE layers)": CacheMemoryProfile("Mixtral 8x7B", 46.7, 12.9, 262144, 32.0, 4.0),
        "Jamba 52B/12B (4 GQA + 28 Mamba)": CacheMemoryProfile("Jamba 52B/12B", 52.0, 12.0, 262144, 4.0, 32.0),
        "Mamba-2 2.7B (64 SSD layers, N=128)": CacheMemoryProfile("Mamba-2 2.7B", 2.7, 2.7, 262144, 0.064, 2000.0),
    }

if __name__ == "__main__":
    x_demo = [[0.5, -1.2], [1.1, 0.3], [-0.4, 0.8], [0.9, -0.5]]
    a_demo = [0.9, 0.5, 0.8, 0.7]
    b_demo = [[0.2, 0.6], [-0.3, 0.4], [0.5, -0.1], [0.7, 0.2]]
    c_demo = [[0.4, -0.2], [0.1, 0.8], [-0.5, 0.3], [0.6, 0.5]]

    y_rec = ssd_linear_recurrent_mode(x_demo, a_demo, b_demo, c_demo)
    y_att = ssd_quadratic_attention_mode(x_demo, a_demo, b_demo, c_demo)
    y_chk = ssd_chunked_block_mode(x_demo, a_demo, b_demo, c_demo, chunk_size=2)

    max_err_att = max(abs(y_rec[t][p] - y_att[t][p]) for t in range(4) for p in range(2))
    max_err_chk = max(abs(y_rec[t][p] - y_chk[t][p]) for t in range(4) for p in range(2))
    print(f"SSD Linear vs. Quadratic Max Abs Diff: {max_err_att:.2e}")
    print(f"SSD Linear vs. Chunked Block Max Diff: {max_err_chk:.2e}")
    for name, prof in profile_256k_caches().items():
        print(f"{name:36} | Cache @ 256K: {prof.kv_or_state_cache_gib:7.3f} GB | {prof.relative_cache_reduction:6.1f}x reduction")

9. Frequently Asked Questions (FAQ) on State Space Models and Hybrid Mamba-Transformers

Why did first-generation Structured State Space Models (S4, S4D, H3, Hyena) struggle on natural language modeling compared to Mamba (S6)? First-generation structured SSMs enforced Linear Time-Invariance (LTI)—keeping $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C})$ fixed across all sequence tokens so the recurrence $h_t = \overline{\mathbf{A}}h_{t-1} + \overline{\mathbf{B}}x_t$ could be trained in parallel as an FFT convolution $y = x \ast \overline{\mathbf{K}}$ (arXiv:2111.00396). While LTI dynamics excel on uniformly sampled continuous signals (reaching $86.09\%$ on Long Range Arena and $98.32\%$ on raw SC10 audio waveforms), constant transition matrices cannot perform content-based filtering: every token is decayed and mixed with the exact same weight regardless of its semantic relevance. Consequently, S4 scores only $18.3\%$ on Selective Copying (arXiv:2312.00752, Table 2). Mamba (S6) breaks LTI by projecting $(\Delta_t, \mathbf{B}_t, \mathbf{C}_t)$ directly from each input token $x_t$, allowing the step size $\Delta_t$ to selectively ignore irrelevant noise tokens ($\Delta_t \to 0 \implies \overline{\mathbf{A}}_t \to \mathbf{I}, \overline{\mathbf{B}}_t \to 0$) or reset stale memory ($\Delta_t \to \infty \implies \overline{\mathbf{A}}_t \to 0$), boosting Selective Copying to $99.8\%$ and dropping $350\text{M}$ Pile perplexity from $10.93$ to $8.71$.

How does Mamba train a time-varying selective recurrence in parallel without an FFT convolution or materializing $O(BLDN)$ tensors in GPU HBM? Although input-dependent $(\overline{\mathbf{A}}t, \overline{\mathbf{B}}_t)$ break shift-invariant convolution, the first-order recurrence $h_t = a_t h{t-1} + b_t$ remains strictly linear in $h_{t-1}$ and obeys the associative composition operator $(a_t, b_t) \otimes (a_s, b_s) = (a_t a_s, a_t b_s + b_t)$ (arXiv:2312.00752, arXiv:2405.21060 Eq. 22). Mamba's hardware-aware Selective Scan streams the compact projections $(\Delta, \mathbf{A}, \mathbf{B}, \mathbf{C}, x)$ from GPU HBM directly into on-chip SRAM, executes Zero-Order Hold discretization and a Blelloch work-efficient parallel associative scan inside SRAM, contracts $y_t = \mathbf{C}_t^\top h_t$ in SRAM, and writes only the $(B, L, D)$ output back to HBM while recomputing intermediate states during backpropagation. This reduces HBM memory I/O by a factor of $O(N)$ ($16\times$ at $N=16$) and runs $20\times\text{--}40\times$ faster than standard PyTorch scans.

What is Structured State Space Duality (SSD) in Mamba-2, and why is it $2\times\text{--}8\times$ faster than Mamba-1? In Mamba-2 (arXiv:2405.21060, ICML 2024), Dao and Gu prove (Theorem 3.5) that any state space transformation $y = \mathsf{SSM}(A, B, C)(x)$ with state dimension $N$ is identical to matrix multiplication $y = Mx$ by a lower-triangular $N$-Semiseparable ($N$-SS) matrix $M_{ji} = C_j^\top A_j \cdots A_{i+1} B_i$. When $A_t = a_t I$ is simplified from diagonal to scalar-times-identity per head, the linear-time SSM recurrence is the exact mathematical dual (SSD) of quadratic 1-Semiseparable Structured Masked Attention $Y = (L \circ (QK^\top))V$ where $L_{ij} = a_i \cdots a_{j+1}$ for $i \ge j$. By partitioning $M$ into $Q \times Q$ blocks (chunk_size = 256), Mamba-2 computes intra-chunk diagonal blocks via quadratic attention matrix multiplications and inter-chunk low-rank blocks via rank-$N$ factorizations—shifting computation from vector CUDA cores onto specialized GPU Tensor Cores (BMM). This makes SSD $2\times\text{--}8\times$ faster than Mamba-1's fused scan, allows $8\times$ larger state dimensions ($N=128\text{--}256$ vs. $N=16$), and runs $6\times$ faster than FlashAttention-2 at sequence length $16\text{K}$.

Why do hybrid models like Jamba, Griffin, and Mamba-2-Attention outperform both pure SSMs and pure Transformers? Pure fixed-state recurrent models compress the entire context into a fixed $O(DN)$ hidden state, creating an information capacity bottleneck on exact arbitrary-offset retrieval (such as synthetic Phonebook Lookup beyond short lengths in arXiv:2402.19427) and few-shot in-context format imitation (where pure $1.3\text{B}$ Mamba scores $48.8\%$ on IMDB vs. $84.1\%$ for pure Attention in arXiv:2403.19887 Table 6). Interleaving a small ratio ($\approx 10\%\text{--}12.5\%$) of global attention layers (Jamba's $1:7$ ratio or Mamba-2-Attention's 6 attention layers out of 64) or $1/3$ local 1024-token sliding-window attention layers (Griffin) provides direct token-to-token retrieval while the SSM layers handle bulk contextual compression and provide implicit causal position encoding. Empirically, Jamba (1:7) surges to $90.9\%$ on IMDB while cutting the $256\text{K}$-token KV cache from $32\text{ GB}$ to $4\text{ GB}$, and Mamba-2-Attention (2.7B) drops Pile perplexity to $5.95$ (beating pure Mamba-2 at $6.09$ and pure Transformer++ at $6.13$).

How does Griffin's Real-Gated Linear Recurrent Unit (RG-LRU) differ from Mamba and RWKV? Unlike S4 and Mamba, Griffin's RG-LRU (arXiv:2402.19427, Section 2.4) is not formulated as the discretization of a continuous differential system and does not use HiPPO initialization. Instead, it gates its real diagonal decay via $a_t = a^{c r_t}$ ($a = \sigma(\Lambda)$, $c = 8$, $r_t = \sigma(W_a x_t + b_a)$) and applies a variance-preserving input multiplier $h_t = a_t \odot h_{t-1} + \sqrt{1 - a_t^2} \odot (i_t \odot x_t)$ with 16-block-diagonal gate weights ($D_{\text{RNN}}^2 / 16$ params) for zero-communication Tensor Parallelism. Conversely, RWKV (arXiv:2305.13048) combines temporal token-shift interpolation ($\mu \odot x_t + (1-\mu)\odot x_{t-1}$) with a channel-wise exponential time-decay ratio $wkv_t = \frac{\sum_{i < t} e^{-(t-1-i)w + k_i} v_i + e^{u+k_t}v_t}{\sum_{i < t} e^{-(t-1-i)w + k_i} + e^{u+k_t}}$ stabilized by a 3-tuple running-maximum state $(\tilde{N}_i, \tilde{D}_i, M_i)$.

Why does Jamba omit Rotary Position Embeddings (RoPE) in its Transformer attention layers? In standard Transformers, self-attention is permutation-equivariant without explicit positional encodings (RoPE or ALiBi). In a hybrid architecture like Jamba (arXiv:2403.19887, Section 6.5 & Table 8) where 7 causal Mamba layers precede each attention layer, the recurrent state transitions $h_t = \overline{\mathbf{A}}t h{t-1} + \overline{\mathbf{B}}_t x_t$ and depthwise causal 1D convolutions inherently inject sequential position and relative distance information into the hidden representations. AI21's controlled $1.3\text{B}$-parameter ablation over $250\text{B}$ tokens (Table 8) confirmed that Jamba without RoPE matches or outperforms Jamba+RoPE (50.5% vs. 46.2% ARC-C, 68.9% vs. 67.9% BoolQ, and identical -0.516 / -0.623 / -0.299 C4/Books/Code log-probability).


10. Primary Sources & Technical References

  1. Gu, A., Goel, K., & Ré, C. (ICLR 2022, Outstanding Paper Honorable Mention). Efficiently Modeling Long Sequences with Structured State Spaces (S4, HiPPO, NPLR & Cauchy Kernels). https://arxiv.org/abs/2111.00396
  2. Gu, A., & Dao, T. (COLM 2024). Mamba: Linear-Time Sequence Modeling with Selective State Spaces (S6 Selection Mechanism & Hardware-Aware SRAM Parallel Scan). https://arxiv.org/abs/2312.00752
  3. Dao, T., & Gu, A. (ICML 2024). Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality (Mamba-2, Semiseparable Matrices & SSD Block Decomposition). https://arxiv.org/abs/2405.21060
  4. Lieber, O., Lenz, B., Bata, H., Cohen, G., Osin, J., Dalmedigos, I., Safahi, E., Meirom, S., Belinkov, Y., Shalev-Shwartz, S., Abend, O., Alon, R., Asida, T., Bergman, A., Glozman, R., Gokhman, M., Manevich, A., Ratner, N., Rozen, N., Shwartz, E., Zusman, M., & Shoham, Y. (AI21 Labs, ICLR 2025). Jamba: A Hybrid Transformer-Mamba Language Model (1:7 Attention-Mamba Ratio, MoE & 256K Context Evaluation). https://arxiv.org/abs/2403.19887
  5. De, S., Smith, S. L., Fernando, A., Botev, A., Cristian-Muraru, G., Gu, A., Haroun, R., Berrada, L., Chen, Y., Srinivasan, S., Desjardins, G., Doucet, A., Budden, D., Teh, Y. W., Pascanu, R., De Freitas, N., & Gulcehre, C. (Google DeepMind, 2024). Griffin: Mixing Gated Linear Recurrences with Local Attention for Efficient Language Models (Hawk, Griffin & Real-Gated Linear Recurrent Unit RG-LRU). https://arxiv.org/abs/2402.19427
  6. Peng, B., Alcaide, E., Anthony, Q., Albalak, A., Arcadinho, S., Biderman, S., Cao, H., Cheng, X., Chung, M., Grella, M., GV, K. K., He, X., Hou, H., Kazienko, P., Kocon, J., Kong, J., Koptyra, B., Lau, H., Mantri, K. S. I., Mom, F., Saito, A., Tang, X., Wang, B., Wind, J. S., Wozniak, S., Zhang, R., Zhang, Z., Zhao, Q., Zhou, P., Zhu, J., & Zhu, R.-J. (EMNLP 2023). RWKV: Reinventing RNNs for the Transformer Era (Receptance Weighted Key Value & 14B Scaling Laws). https://arxiv.org/abs/2305.13048
  7. Hugging Face Transformers Documentation (2026). Mamba Architecture & MambaConfig (state_size=16, expand=2, conv_kernel=4, MambaMixer, TorchAO INT4 & PEFT LoRA Specification). https://huggingface.co/docs/transformers/en/model_doc/mamba
  8. Hugging Face Transformers Documentation (2026). Mamba-2 Architecture & Mamba2Config (state_size=128, chunk_size=256, head_dim=64, n_groups=8 Grouped-Value SSD Specification). https://huggingface.co/docs/transformers/en/model_doc/mamba2
  9. Hugging Face Transformers Documentation (2026). Jamba Hybrid Architecture & JambaConfig (attn_layer_period=8, attn_layer_offset=4, num_experts=16, num_experts_per_tok=2). https://huggingface.co/docs/transformers/en/model_doc/jamba
  10. Hugging Face Transformers Documentation (2026). RecurrentGemma (Griffin) Architecture & RecurrentGemmaConfig (RG-LRU & Local Sliding-Window Attention). https://huggingface.co/docs/transformers/en/model_doc/recurrent_gemma
  11. Hugging Face Transformers Documentation (2026). RWKV Architecture, RwkvConfig, and Numerically Stabilized Recurrent Numerator/Denominator State Equations. https://huggingface.co/docs/transformers/en/model_doc/rwkv
🔗 Share Post

Reading next story...

Back to Feed