Hugging Face Blog

Overview of natively supported quantization schemes in 🤗 Transformers

arXiv Machine Learning
Nov 6

The Quantization Benefits of Residual-Free Transformers

The paper investigates how residual connections in transformers affect the distribution of activations, making them heavy‑tailed and more difficult to quantize accurately. By comparing standard residual transformers with residual‑free variants, the authors show that residuals increase quantization error and accuracy loss at low precision, while residual‑free models maintain near‑Gaussian activations and better robustness to low‑bit quantization. They further demonstrate that residual‑free transformers can be trained effectively using orthogonal initialization, spectral or second‑order optimization, and depth‑aware scaling of attention temperature, achieving comparable full‑precision performance with improved quantization friendliness.

By Yiping Ji, Mahalakshmi Sabanayagam, Peyman Moghadam, Hemanth Saratchandran, Simon Lucey
arXiv Machine Learning
5d ago

Implementing Binary Transformers with Approximate Memories with Permutation Invariance Enabled Selective (PIES) Protection

The paper evaluates the reliability of binary Transformers, specifically BERT, when stored in approximate memory that introduces bit errors. It finds that significant accuracy loss only occurs at high bit error rates (5–10%). To mitigate this, the authors propose a Permutation Invariance Enabled Selective (PIES) protection scheme that selectively safeguards critical weights, achieving near‑full performance recovery at high error rates with much lower overhead than traditional error‑correcting codes.

By Zhen Gao, Xiao Yin, Kexin Liang, Pedro Reviriego, Shanshan Liu, Fabrizio Lombardi
arXiv Machine Learning
Jul 24

KroQuant: Kronecker-Structured Block Transforms for Efficient Post-Training Quantization of Diffusion Transformers

arXiv:2607. 21446v1 Announce Type: new Abstract: Post-training quantization (PTQ) of diffusion transformers (DiTs) to W4A4 severely degrades output quality, because activations entering each linear layer contain outliers that 4-bit formats cannot represent.

By Yann Bouquet, Alireza Khodamoradi, Kristof Denolf, Mathieu Salzmann
arXiv Machine Learning
Oct 8

ResidualQuant: KV Cache Quantization for Looped Transformers with 2-Bit Residuals

ResidualQuant introduces a 2‑bit residual quantization scheme for KV caches in looped Transformers, leveraging the similarity of KV states across loops. By using the final‑loop KV states as a reference and applying least‑square scaling, rotations, and loop‑wise mixed precision, the method achieves accurate quantization down to INT2. Experiments on various looped Transformer models show that ResidualQuant improves the accuracy‑memory tradeoff, retaining near BF16 accuracy while reducing KV storage by 80.7% and boosting decode throughput and batch size on an RTX 5090.

By Heejun Kim, Junyoung Lee, SangLyul Cho, Dongsu Han, Insu Han, Sehoon Kim
arXiv AI
Oct 28

An Algebra of Transformers

The paper "An Algebra of Transformers" proposes a formal algebraic framework for reasoning about transformer models, building on functional decomposition results. It introduces atomic actions based on these decompositions, along with sequential and parallel composition, recursion for feedback, and abstraction for hidden layers. This marks the first logical modeling attempt for transformers, enabling verification of transformer‑based applications.

By Yong Wang, Zhiyan Wang, Hexiao Kang