arXiv:2605.05699cs.PFcs.AI2026-05

在苹果芯片上,4位量化KV缓存比16位更快,还省了3倍内存。

When Quantization Is Free: An int4 KV Cache That Outruns fp16 on Apple Silicon

  • 用融合金属内核实现4位量化,直接提速不降质。
  • 在1024~4096个词元下,延迟比fp16还低3%~8%。
  • 适合做推理加速的开发者,尤其用Apple Silicon跑大模型时。

KV缓存量化通常被视为质量与延迟之间的权衡。我们发现,在苹果芯片统一内存架构下,这一权衡被反转:一个单一融合的Metal内核(符号随机傅里叶变换+通道级λ+组级绝对最大值+4位半字节打包),作为HuggingFace Cache子类暴露,可在Gemma-3 1B(前缀长度256–4096)上实现比fp16更快的推理速度(每词元延迟降低3%至8%),在短上下文场景下对Qwen2.5-1.5B也保持更低延迟(1000词元内降低0.7%至2.6%),同时实现3倍持久内存压缩,且生成质量无损(Qwen短提示下dPPL=0.000;Gemma dPPL提升3.6)。该内核每向量仅约25纳秒开销,远低于3倍压缩带来的带宽收益。该融合内核还解决了Qwen的4位每令牌灾难(dPPL从+7975降至+638.6,降幅12.5倍),在182 GFLOPS、D=128条件下表现优异。支持性发现:SRFT与SRHT对KV质量影响无统计差异(选用SRFT以适配混合进制和矩阵乘法对齐);学习旋转的消融实验揭示固定随机SRFT基具有正则化作用(学习R+λ但不使用SRFT使校准均方误差下降84.9%对比50.3%,但导致更差PPL);Householder反射在k=d/2反射器下于d=256时基本无损。

原文摘要 · Abstract (English)

KV-cache quantization is framed as a quality--latency trade-off. We show it is \emph{inverted} on Apple Silicon's unified memory: a single fused Metal kernel (sign-randomized FFT $+$ per-channel $λ$ $+$ per-group abs-max $+$ int4 nibble pack), exposed as a HuggingFace \texttt{Cache} subclass, runs \emph{faster than fp16} across $256$--$4096$-token prefixes on Gemma-3 1B ($-3$ to $-8\%$ ms/tok) and at short context on Qwen2.5-1.5B ($-0.7$ to $-2.6\%$ through $1$K), with $3\times$ persistent memory compression and quality preserved ($\dPPL = 0.000$ Qwen short-prompt; $+3.6$ hook $\dPPL$ Gemma). The kernel's $\sim\!25$\,ns/vec overhead is below the bandwidth savings from $3\times$ compression. The fused kernel also closes Qwen's 4-bit per-token catastrophe ($\dPPL = +7975 \to +638.6$, $12.5\times$ reduction) at $182$\,GFLOPS / $D{=}128$. Supporting findings: $\SRFT$ and $\SRHT$ are statistically indistinguishable for KV quality (we pick $\SRFT$ for mixed-radix and matrix-multiply alignment); a learned-rotation ablation surfaces a regularization role for the fixed random SRFT base (learning $R+λ$ without SRFT lowers calibration MSE $84.9\%$ vs $50.3\%$ but yields worse PPL); Householder rotations at $k{=}d/2$ reflectors are effectively lossless at $d{=}256$.

量化推理加速Apple SiliconKV缓存

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。