SpinQuant: LLM quantization with learned rotations

Zechun Liu, Changsheng Zhao, Igor Fedorov, Bilge Soran, Dhruv Choudhary, Raghuraman Krishnamoorthi, Vikas Chandra, Yuandong Tian, Tijmen Blankevoort

arXiv:2405.16406 · 2026-07-27 공개 · arXiv · PDF

transformer kv-cache llama-3 post-training-quantization llm-quantization llama-2 quarot rotation-matrices

Abstract

Post-training quantization (PTQ) techniques applied to weights, activations, and the KV cache greatly reduce memory usage, latency, and power consumption of Large Language Models (LLMs), but may lead to large quantization errors when outliers are present. Rotating activation or weight matrices helps remove outliers and benefits quantization. In this work, we identify a collection of applicable rotation parameterizations that lead to identical outputs in full-precision Transformer architectures while enhancing quantization accuracy. In addition, we find that some random rotations lead to much better quantization than others, with an up to 13 points difference in downstream zero-shot reasoning performance. As a result, we propose SpinQuant, a novel approach that incorporates learned rotation matrices for optimal quantized network accuracy. With 4-bit quantization of weight, activation, and KV-cache, SpinQuant narrows the accuracy gap on zero-shot reasoning tasks with full precision to merely 2.9 points on the LLaMA-2 7B model, surpassing LLM-QAT by 19.1 points and SmoothQuant by 25.0 points. Furthermore, SpinQuant also outperforms concurrent work QuaRot, which applies random rotations to remove outliers. In particular, for LLaMA-3 8B models that are hard to quantize, SpinQuant reduces the gap to full precision by up to 45.1% relative to QuaRot. Code is available at https://github.com/facebookresearch/SpinQuant.

한국어 요약

한 줄 요약

SpinQuant은 LLM의 4비트 양자화 성능을 회전 행렬 학습을 통해 2.9% 이하로 감소시키는 새로운 양자화 기법이다.

핵심 기여도

핵심 아이디어

SpinQuant은 LLM의 가중치와 활성화 분포에서 이상치를 제거하기 위해 학습된 회전 행렬을 도입함. 회전 불변성은 전체 정밀도 네트워크 출력을 유지하면서 양자화 성능을 향상시키는 핵심 통찰이다. 회전 행렬은 Cayley SGD를 사용해 Stiefel 매니폴드 상에서 최적화되며, 이는 직교 행렬 최적화에 효과적인 알고리즘이다. 회전 행렬은 두 가지 전략으로 구현되며, SpinQuant_no_had는 가중치에 직접 통합되고, SpinQuant_had는 MLP 블록과 KV 캐시의 활성화 이상치를 처리하는 온라인 하다마드 회전을 추가한다.

기술적 접근법

주요 결과

의의 및 한계

SpinQuant은 LLM의 4비트 양자화 성능을 현저히 향상시키며, 특히 LLaMA-3 8B처럼 양자화가 어려운 모델에도 효과적임. 회전 행렬 최적화는 기존 랜덤 회전 기반 방법보다 안정적이고 정확도 향상이 뚜렷함. 그러나 회전 최적화는 추가적인 계산 비용을 유발할 수 있으며, 모든 LLM 아키텍처에 적용 가능한지는 추가 연구가 필요함. 또한, 회전 행렬이 네트워크 구조에 영향을 주지 않는다는 가정은 일부 모델에서는 성립되지 않을 수 있음.

실용적 활용

SpinQuant은 서버 측 및 장치 측 LLM 추론에서 메모리 사용량과 전력 소모를 줄이는 데 유용함. 특히, 고정된 하드웨어 자원에서 성능을 유지하면서 LLM을 배포해야 하는 의료, 교육, 게임 등 산업 분야에서 활용 가능함. 또한, GPTQ와 같은 고급 양자화 기법과의 호환성도 보장되어 실용적 적용 범위가 넓음.