The Transformer architecture, built on the self-attention mechanism, has been the dominant paradigm for NLP since 2017. Its quadratic scaling in sequence length — O(L²) in both computation and memory — is increasingly problematic as enterprise applications demand longer contexts: legal document review (50K-200K tokens), code repository analysis (100K+ tokens), financial report processing (20K-100K tokens), and multi-turn conversation histories (10K-50K tokens).

A new generation of architectures — state-space models (SSMs), linear attention variants, and hybrid approaches — has emerged to address the Transformer's scaling limitations while maintaining competitive quality. This article provides a formal comparison of these alternatives from an enterprise deployment perspective, with empirical benchmarks on latency, throughput, memory, and long-context accuracy.

The Quadratic Bottleneck

The core issue is self-attention's scaling: for a sequence of length L with hidden dimension d, the attention matrix QKáµ€ ∈ RLÃL requires O(L²d) compute and O(L²) memory. At L = 128K tokens with d = 4096, a single attention head requires 32 TFLOPS and 16 GB of memory for the attention matrix alone — before any feed-forward layers, KV cache, or batch dimension. For context windows approaching 1M tokens (a target for many enterprise applications), standard self-attention is computationally prohibitive.

Enterprise NLP deployments are uniquely affected because they combine long contexts with strict latency requirements (p50 < 2s for interactive applications), cost sensitivity (private infrastructure has fixed compute budgets), and batch processing of large document collections.

Transformer Memory (128K ctx)
16 GB
Per attention head, single layer
Mamba Memory (128K ctx)
0.2 GB
Total, all layers, recurrent state
Enterprise Context Demand
50-200K
Typical token length required
SSM Quality Gap
<1%
vs. Transformer on standard benchmarks
16 GB
Transformer Memory (128K ctx)
Per attention head, single layer
0.2 GB
Mamba Memory (128K ctx)
Total, all layers, recurrent state
50-200K
Enterprise Context Demand
Typical token length required
<1%
SSM Quality Gap
vs. Transformer on standard benchmarks

State-Space Models: Theoretical Foundation

State-space models represent sequences through a continuous-time, latent-state dynamical system. The continuous-time SSM maps an input signal u(t) → y(t) through a hidden state h(t):

h'(t) = Ah(t) + Bu(t)
y(t) = Ch(t) + Du(t)

where A ∈ RNÃN is the state evolution matrix, B ∈ RNÃ1 the input projection, C ∈ R1ÃN the output projection, and D is the skip connection. For discrete sequences, the SSM is discretized with a time step Δ, yielding:

ht = Āht-1 + B̄ut
yt = Cht

where Ā = exp(ΔA) and B̄ = (ΔA)⁻¹(exp(ΔA) - I) · ΔB. The key computational advantage: the recurrence processes sequences in O(L) time and constant memory per layer — independent of sequence length.

Mamba (Gu & Dao, 2024)

Mamba introduces two critical innovations over prior SSMs: selectivity (the parameters B, C, and Δ are input-dependent functions B(x), C(x), Δ(x) rather than learned constants), and a hardware-aware parallel scan algorithm that makes the recurrent computation GPU-efficient.

Selectivity is the key to competitive quality. By making the SSM parameters depend on the input, Mamba achieves content-aware reasoning — the model can "select" which information to remember and which to forget based on the current token, similar to gating mechanisms in LSTMs but with the parallel training efficiency of modern architectures. The parallel scan algorithm (work-efficient parallel prefix sum) computes all hidden states in O(L log L) time on GPU, compared to O(L²) for attention.

Mamba-2 (Gu & Dao, 2025)

Mamba-2 reformulates the SSM as a structured state-space duality (SSD), showing an equivalence between SSMs and a particular form of linear attention. This unification allows Mamba-2 to reuse optimized attention kernel infrastructure (FlashAttention-style tiling) while maintaining the O(L) recurrent inference cost. The SSD formulation also enables a simpler and more stable training recipe, matching Transformer perplexity more closely on standard NLP benchmarks.

RWKV (Peng et al., 2023)

RWKV (Receptance Weighted Key Value) combines Transformer-style attention with RNN-style recurrence through a time-mixed attention mechanism that decomposes into a linear-time recurrence. It uses four learned matrices R, W, K, V where W is a learnable decay vector. The attention-free formulation processes sequences in O(L) time and can be trained with standard Transformer infrastructure.