TL;DR
Quamba is a specialized 8-bit quantization "recipe" designed specifically for Selective State Space Models (SSMs) like Mamba. By combining percentile-based input clipping with Hadamard transforms for output activations, it achieves a 1.72× speedup on edge hardware (Nvidia Orin Nano) with less than a 1% drop in accuracy, finally making these highly efficient models viable for low-resource deployment.
The Challenge of Quantizing SSMs
While Transformers dominate the AI landscape, State Space Models (SSMs) like Mamba have emerged as a powerful alternative due to their linear scaling with sequence length. However, deploying them on edge devices or high-throughput cloud servers remains difficult due to memory and compute constraints.
The standard solution for Transformers is Post-Training Quantization (PTQ)—converting 16-bit floating-point weights and activations into 8-bit integers (INT8) to save memory and speed up math. Unfortunately, "off-the-shelf" quantization methods built for Transformers fail miserably on SSMs.
The authors discovered that SSMs have unique "outlier" patterns: massive spikes in output activations and extreme sensitivity in the "selective scan" (the core recurrent mechanism). Naive quantization causes these models to "collapse," losing significant accuracy and resulting in high quantization errors compared to standard self-attention models.
The Quamba Method
To address this, the authors propose Quamba, a static 8-bit per-tensor quantization method. Its novelty lies in a two-pronged approach to handling activations:
- Input Clipping (Percentile-based): The input tensor to the selective scan is highly sensitive. Even a few small outliers can skew the quantization scale, ruining the precision for the rest of the data. Quamba uses a 99.999th percentile clipping strategy to suppress these rare peaks, allowing for much finer precision for the remaining 99.999% of the values.
- Output Smoothing (Walsh-Hadamard Transform): The output activations of SSMs contain massive outliers that are difficult to represent in 8-bit. Quamba applies a Hadamard transform—a mathematically "cheap" operation—to rotate the activations into an outlier-free space before quantization. This spreads out the energy of the spikes across all dimensions.
- Kernel Fusion: To ensure these steps don't slow down the model, the authors fused the scaling factors, transforms, and element-wise operations (like SiLU and residual additions) directly into the CUDA kernels for the selective scan and causal convolutions.
Key Insights
- SSMs $\neq$ Transformers: The most critical insight is that SSMs exhibit outlier patterns fundamentally different from Transformers. In Transformers, outliers often appear in the token-mixing (attention) layers; in SSMs, they appear in the output of the linear recurrence.
- Causal Sensitivity: Because SSMs are recurrent, a small quantization error at step 1 can compound over thousands of steps. This makes the precision of the input tensor far more important than in a standard feed-forward network.
- Hadamard is "Free": By fusing the Hadamard transform into the linear projection layers, the authors achieved "compute-invariance"—the mathematical result is the same, but the activations are much easier to quantize without adding extra latency.
Results and Performance
The researchers evaluated Quamba across a wide range of standard LLM benchmarks, including zero-shot tasks (LAMBADA, HellaSwag, PIQA, ARC, WinoGrande) and language modeling (WikiText2, Pile subset). They tested the Mamba family (130M to 2.8B parameters) and Jamba (a 52B parameter hybrid model).
- Efficiency on the Edge: On an Nvidia Orin Nano 8G, Quamba 2.8B achieved a 1.72× lower generation latency compared to the FP16 version.
- Accuracy Preservation: On the Mamba 2.8B model, the average accuracy drop across six zero-shot tasks was only 0.9%.
- Scalability: When applied to the massive 52B Jamba model, Quamba maintained high performance with only a 1% accuracy drop, proving it works for frontier-scale hybrid models.
- Pareto Optimality: Quamba consistently sits on the Pareto front, providing the best possible trade-off between speed and accuracy compared to other methods like SmoothQuant or Mamba-PTQ.
Limitations and Future Work
While 8-bit quantization works excellently, the authors noted that 4-bit weight-activation quantization still leads to significant performance degradation or model failure. Additionally, the paper primarily uses symmetric quantization for hardware compatibility. Asymmetric quantization might improve accuracy further but requires better hardware/library support. Finally, porting these fused kernels from NVIDIA GPUs to other hardware (like mobile NPUs) remains a key area for future work.
Summary updated