QMamba: Post-Training Quantization for Vision State Space Models

Yinglong Li, Xiaoyu Liu, Jiacheng Li, Ruikang Xu, Yinda Chen, Zhiwei XiongarXiv 2025 · DOI

Abstract

State Space Models (SSMs), such as Mamba, have emerged as efficient alternatives to Vision Transformers (ViTs) due to their linear-time complexity. However, deploying these models on resource-constrained edge devices remains challenging due to significant memory and power requirements. While Post-Training Quantization (PTQ) is a common solution, standard techniques often fail when applied to SSMs because of their unique activation distributions. We introduce QMamba, a specialized PTQ framework that utilizes Long-tailed Skewness Quantization (LtSQ) and Temporal Group Quantization (TGQ) to address these challenges. QMamba achieves substantial performance gains, including a 21% accuracy improvement on 4-bit ImageNet classification compared to state-of-the-art methods.

Introduction

The rapid evolution of Vision State Space Models (SSMs) has provided a powerful toolset for computer vision, offering the performance of Transformers with improved computational efficiency. Despite these advantages, the transition from high-precision floating-point models to low-bit integer representations—essential for edge deployment—is non-trivial. Existing PTQ frameworks, designed primarily for Convolutional Neural Networks (CNNs) and Vision Transformers (ViTs), do not account for the specific mathematical properties of SSM operators. QMamba addresses this gap by tailoring the quantization process to the inherent distributional characteristics of SSMs.

Distributional Challenges in SSMs

Quantizing SSMs is difficult because their internal states and parameters do not follow the Gaussian or near-uniform distributions typically assumed by standard quantizers. Two primary issues arise:

  1. Skewed Discrete Parameters ($\bar{A}_t$): The parameters governing the state transition exhibit a "long-tailed" distribution. Most values are concentrated near the maximum (often close to 1.0), acting as a "forgetting gate." Standard uniform quantization in this region is too coarse, leading to the loss of critical long-range dependency information.
  2. Dynamic Hidden States ($h_t$): The range of hidden states fluctuates significantly across different time steps in a sequence. Applying a single global scaling factor results in massive rounding errors for steps with smaller ranges or clipping for steps with larger ranges.
Distributional characteristics of SSM parameters and hidden states.

The QMamba Framework

QMamba introduces two novel quantization strategies to handle these unique distributions:

Long-tailed Skewness Quantization (LtSQ)

LtSQ is specifically designed for the discrete parameters $\bar{A}_t$. It employs a median-based check to identify skewness in the distribution. When skewness is detected, LtSQ applies a non-uniform, log2-based quantization scheme. This provides high precision in dense regions and coarser precision in the tails. Notably, this approach is hardware-friendly, as log2-based quantization allows for efficient bit-shift operations instead of expensive multiplications.

Temporal Group Quantization (TGQ)

To manage the dynamic nature of hidden states $h_t$, QMamba utilizes TGQ. Instead of a single scaling factor for the entire sequence, TGQ partitions the sequence into temporal groups. Optimal scaling factors are calculated for each group, allowing the quantizer to adapt to local variations in the hidden state's range. This exploits the temporal locality inherent in SSMs, where adjacent states are more likely to share similar distributions.

Temporal variations in the distribution of hidden states $h_t$.

Block-wise Reconstruction

Following the initial quantization, QMamba performs a lightweight block-wise optimization. By minimizing the Mean Squared Error (MSE) on a small calibration dataset (e.g., 1,024 ImageNet samples), the framework fine-tunes the scaling factors to further recover performance lost during quantization.

Experimental Results

The effectiveness of QMamba was evaluated on the ImageNet classification task using representative vision SSMs like Vim and VMamba.

  • Superior 4-bit Performance: On the Vim-S model with 4-bit activations, QMamba achieved a Top-1 accuracy of 45.9%, a dramatic improvement over the 24.9% achieved by the previous state-of-the-art method, QDrop.
  • Near-Lossless High-bit Quantization: For 8-bit (W8A8) and 6-bit (W6A6) configurations, QMamba maintains performance levels very close to the original floating-point models.
  • Efficiency Gains: A quantized Vim-B model demonstrated an 80% reduction in storage and a 75% reduction in FLOPs, while still maintaining a robust Top-1 accuracy of 75.8%.

Conclusion

QMamba represents a significant step forward in making Vision SSMs viable for edge deployment. By recognizing and addressing the unique distributional properties of SSMs through LtSQ and TGQ, the framework enables high-accuracy low-bit quantization. Future work will involve extending these techniques to dense prediction tasks such as object detection and conducting benchmarks on actual edge hardware to quantify real-world latency improvements.

Summary updated

BibTeX
@misc{li2025qmamba,
  author = {Yinglong Li and Xiaoyu Liu and Jiacheng Li and Ruikang Xu and Yinda Chen and Zhiwei Xiong},
  title = {{QMamba: Post-Training Quantization for Vision State Space Models}},
  year = {2025},
  eprint = {2501.13624},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.13624},
}
Figure