Post-Transformer LLM Efficiency Lab

Standard Transformer Attention suffers from quadratic $O(N^2)$ memory bandwidth and KV-cache explosion. Explore how Mamba SSMs, RWKV Linear Attention, BitNet 1.58-bit ternary quantization, and Hybrids eliminate bottlenecks, slash DRAM energy by up to 88%, and unlock million-token inference.

Scenarios:
KV Cache Memory
64.0 GB
SSM State: 0.12 GB (99.8% saved)
Energy / 1k Tokens
42.8 J
BitNet/Mamba: 6.2 J (-85%)
Inference Speed
128 tok/s
Mamba 4.2x faster at 64k
VRAM Fit Status
Fits 80GB H100
6.4 GB headroom
Transformer
Mamba SSM
RWKV
BitNet b1.58
Hybrid 75/25
Hover or scrub anywhere on the chart to inspect context scaling metrics. Current: 64,000 tokens • Batch: 16
Selective State Space (SSM)

Continuous Time Recurrence

h_t = Ā h_{t-1} + B̄ x_t, y_t = C h_t

Replaces the full $N \times N$ attention matrix with an input-dependent recurrent state matrix. Training is parallelized via associative scan; generation requires zero KV cache reads from high-power DRAM.

1.58-Bit Ternary Weights

Matrix Multiplication Elimination

W ∈ {-1, 0, +1} → Y = Add / Subtract

Replaces energy-heavy FP16 floating-point multiply-accumulate (MAC) units with pure integer additions. Slashes silicon area and cuts memory transfer energy by ~85% on standard DRAM.

Linear Attention & Decay

Receptance Weighted Key-Value

wkv_t = (e^{-w} wkv_{t-1} + e^{k_t} v_t) / ...

Formulates attention as an exponential time-decay channel. Maintains transformer-quality perplexity while matching RNN inference speed and constant memory consumption.

Exact Architecture Metrics at Current Operating Point (64k Tokens, Batch 16)
Architecture Weight Mem State / Cache Mem Total VRAM Prefill FLOPs Decode Latency Energy / Token

Why Transformers Need Next-Generation Successors

The Quadratic KV-Cache Wall

In standard Softmax Attention, generating each subsequent token requires computing attention against all previous $N$ tokens. Storing these Key-Value activations requires $2 \times b \times N \times d \times L$ bytes. At a context of 128,000 tokens with a batch size of 16, the KV cache alone demands over 120 GB of VRAM—far surpassing the model weights themselves. This turns autoregressive inference into a memory-bandwidth-bound problem that burns massive energy fetching data from off-chip HBM.

State Space Models (SSMs) & Selection

Mamba introduces time-varying, selective matrices $B(x_t)$ and $C(x_t)$ into classical linear state-space models. By filtering out irrelevant tokens and selectively propagating critical facts into a fixed-dimensional hidden state $h_t \in \mathbb{R}^{d \times d_{state}}$, Mamba processes tokens with $O(1)$ constant memory overhead during generation, achieving linear $O(N)$ computational complexity while sustaining long-range associative recall.

BitNet 1.58b: Elimination of Silicon Matrix Multiplication

Every parameter in a 1.58-bit model is constrained to $\{-1, 0, +1\}$. This fundamentally changes GPU and NPU hardware design: matrix multiplications ($\sum W_{ij} X_j$) are replaced with simple additions and subtractions. SRAM and DRAM transfers drop by up to 88%, drastically cutting memory bus energy, which accounts for over 70% of an inference server's thermal dissipation.

The Hybrid Frontier (Jamba / Zamba)

While pure SSMs excel at streaming and reasoning over long contexts, they can occasionally struggle with exact verbatim "needle-in-a-haystack" retrieval across millions of tokens compared to quadratic attention. Modern production architectures combine 1 Attention layer for every 3 or 4 Mamba layers. This achieves 75% of the memory and energy savings while maintaining 100% retrieval fidelity.

Enjoy this tool? Build your own with Super