# Poster 28449

- Kind: Poster
- Talk page and recording: https://iclr.cc/virtual/2025/poster/28449

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hello, I'm Hongyu. I'm presenting Quanba, pose training quantization for selective state space models. This is a joint work with JiZhi, Natalia, Kaiqiang and Diana. Currently transformers are still dominating the sequence modeling. However, during the inference stage, transformers need to depend on all the previous input tokens, and therefore the complexity of the generation is linear.
State-space model update the hidden state by using the current input, and then use the hidden state to generate output so that the current output does not depends on older input history. As a result, the generation complexity is constant time per step. The Mamba block uses a SSM to perform linear recurrence mechanism in the model.
We have X and Z that are generated from input projection, and then pass X through a causal convolution layer in order to allow the model selectively remember or ignore input based on their content. There are two projection layers, X projection and DT projection, that compute the DT, B, C based on the input X.
Although several papers saying that Mamba is highly numerical sensitive to the precision because of the recurrent dynamics, but we found that may not be the major issue for quantizing state-space model. We visualize the spectrum norm of cumulative production of the A matrix from a trended model.
The figure shows that the quantization error will not propagate and are actually converge. These observations make SSM quantization possible. Instead, we observe the huge outliers present at the SSM output. The numerical of the outliers are larger than 100, which makes quantizing SSM difficult.
Therefore, for the SSM output, we transform y to an outlier-free space with Hadamard matrices, and we get the scaling factors after y is transformed. We fuse the quantization with forward Hadamard transforms so the quantization does not incur additional cost, and we fuse the backward Hadamard transform matrix with output projection.
We plot the distribution for SSM input X_T for every layers, and we found that although the values are small which may be easy to quantize, the output values are very sensitive to quantization errors, which cause huge deviations in the output Y_T.
To solve the issue, we propose to apply a simple clip on the SSM input activation to improve the quantization precisions. We found that clipping the values from the input XT can help us largely reduce the error in the output YT. Also, the clip does not incur any computational overhead during the inference.
We clip the xt by using the percentile max. For example, we use a 99.9 percentile as our scaling factor to quantize input xt during inference.
We fuse scale -in factors into the quantized operators so that all the quantized operators write 8-bit outputs. And element-wise operations like activations and residual additions are also fused into the corresponding operators. For example, the causal convolutions take quantized X and weights as well as scale-in factors as input and write 8-bit output to the memory.
CuMMAO achieves Pareto optimality on Nano-Age and with practical speed up on the Cloud GPU such as A5000. Our methods speed up CuMMAO by 1 .2x and it is more than 2 .6x faster than the same size transformer. We reduce the memory for CuMMAO by 2x which is less than 4GB.
And the memory usage of the Mamba is constant to the input sequence length, making input long sequence context feasible on edge devices. We showed the real-time demo on a Nvidia Nano AG. Our method is 1.7 times faster than the half-precision Mamba.
In summary, our work enhanced the efficiency of SSM and delivered practical speed-up. We also provide the theoretical groundings for quantizing SSM and in-depth comparison to transformer quantization. Please check out our code, paper, and project page for more details.
