Hadamard rotation

分类: 量化与低秩

type:: concept aliases:: Hadamard Transform, 哈达玛旋转, Incoherence Processing

  • Hadamard rotation

  • 定义

  • 用 Hadamard 矩阵对权重/激活进行正交旋转变换,使分布更均匀(更 incoherent),改善量化精度

  • 数学形式

W=WHn,HnTHn=nI\mathbf{W}' = \mathbf{W} \mathbf{H}_n, \quad \mathbf{H}_n^T \mathbf{H}_n = n\mathbf{I}
  • Hn\mathbf{H}_n: n×nn \times n Hadamard 矩阵,元素为 ±1\pm 1

  • Input rotation: 旋转输入激活

  • Output rotation: 旋转输出激活

  • 计算复杂度 O(nlogn)O(n \log n)(Fast Walsh-Hadamard Transform)

  • 核心要点

  • 消除权重/激活中的异常值(outlier),使量化误差更均匀

  • Quip# 首次将 Hadamard incoherence 引入 lattice VQ

  • Quarot 将其推广到标量量化

  • LLVQ 发现高维 lattice VQ(24-dim shape-gain)大幅降低对旋转的依赖——无旋转 LLVQ 已优于有旋转的 Quip#

  • 代表工作

  • Quip#: Hadamard incoherence + E8 lattice codebook

  • Quarot: Outlier-free 4-bit inference with rotated LLMs

  • LLVQ: 展示高维 VQ 降低旋转依赖

  • 相关概念

  • Quip#

  • Quarot

  • 向量量化

  • PTQ