SageBwd: A Trainable Low-bit Attention
Organizations: Tsinghua University, UC Berkeley
Abstract
Low-bit attention, such as SageAttention, has emerged as an effective approach for accelerating model inference, but its applicability to training remains poorly understood. In prior work, we introduced SageBwd, a trainable INT8 attention that quantizes six of seven attention matrix multiplications while preserving fine-tuning performance. However, SageBwd exhibited a persistent performance gap to full-precision attention (FPA) during pre-training. In this work, we investigate why this gap occurs and demonstrate that SageBwd matches full-precision attention during pretraining. Through experiments and theoretical analysis, we reach a few important insights and conclusions: (i) QK-norm is necessary for stable training at large tokens per step, (ii) quantization errors primarily arise from the backward-pass score gradient dS, (iii) reducing tokens per step enables SageBwd to match FPA performance in pre-training, and (iv) K-smoothing remains essential for training stability, while Q-smoothing provides limited benefit during pre-training.
Figures & tables
| Output | dQ | dK | dV | |||||
| CosSim | Rel- | CosSim | Rel- | CosSim | Rel- | CosSim | Rel- | |
| 1 | 0.9999 | 0.0160 | 0.9998 | 0.0184 | 0.9998 | 0.0220 | 0.9999 | 0.0159 |
| 3 | 0.9992 | 0.0389 | 0.9971 | 0.0758 | 0.9970 | 0.0777 | 0.9992 | 0.0387 |
| 5 | 0.9982 | 0.0603 | 0.9798 | 0.2014 | 0.9799 | 0.2007 | 0.9982 | 0.0605 |
| 8 | 0.9953 | 0.0972 | 0.8900 | 0.4666 | 0.8886 | 0.4699 | 0.9953 | 0.0973 |
| 10 | 0.9933 | 0.1161 | 0.7823 | 0.6648 | 0.7820 | 0.6684 | 0.9933 | 0.1157 |
| Metric | ||||||||
| CosSim | 0.9973 | 0.9917 | 1.0000 | 0.9789 | 0.9969 | 0.9664 | 0.9537 | 0.9985 |
| Rel-L2 | 0.0736 | 0.1293 | 0.0000 | 0.2045 | 0.0793 | 0.2579 | 0.3074 | 0.0540 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Attention Quantization
Attention quantization reduces the precision and memory cost of attention computations while preserving model quality.
See all 37 papers