根据词元重要性动态分配比特数,显著降低大模型本地推理的内存与延迟。
Don't Waste Bits! Adaptive KV-Cache Quantization for Lightweight On-Device LLMs
- 基于词元频率、注意力方差等特征,动态选择2/4/8位或FP16精度
- 在SmolLM-360M上降低17.75%延迟,准确率提升7.60点
- 适合移动端和边缘设备部署,兼顾性能与效率
大型语言模型在推理、生成和决策任务中表现卓越,但其在移动、嵌入式及边缘设备上的部署仍面临挑战。本地推理受限于随上下文长度线性增长的键值(KV)缓存内存与带宽开销,常成为解码瓶颈。现有量化方法多采用固定精度或人工规则,导致低价值词元浪费比特,高价值词元过度压缩,引发可避免的精度下降。受霍夫曼编码启发,本文提出自适应KV缓存量化:通过学习策略按词元重要性分配比特数,在不牺牲竞争力精度的前提下最小化预期内存与延迟。框架提取轻量级词元级特征(如词元频率、质量评分、注意力方差、熵不确定性),输入紧凑数据驱动控制器,解码时从{2比特, 4比特, 8比特, FP16}中动态选择精度。实验在SmolLM-135M、SmolLM-360M、SmolLM-1.7B上验证,跨多个常识推理基准测试,该方法持续优化精度-延迟权衡。例如,于SmolLM-360M在HellaSwag任务中,相较静态量化降低17.75%解码延迟,准确率提升7.60点,仅比FP16推理低0.30点。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have achieved remarkable progress across reasoning, generation, and decision-making tasks, yet deploying them on mobile, embedded, and edge devices remains particularly challenging. On-device LLM inference is heavily constrained by the memory and bandwidth overhead of the key-value (KV) cache, which grows linearly with context length and often dominates decoding cost. Existing KV-cache quantization schemes typically rely on fixed precision or hand-crafted heuristics, thereby wasting bits on low-impact tokens while over-compressing informative ones, leading to avoidable accuracy degradation. Inspired by Huffman coding's principle of variable-length allocation, we propose adaptive KV-cache quantization, a learned policy that assigns bit-width proportional to token importance, minimizing expected memory and latency without sacrificing competitive accuracy. Our framework extracts lightweight token-level features, including token frequency, quality score, attention variance, and entropy-based uncertainty, and feeds them into a compact data-driven controller that dynamically selects KV precision from {2-bit, 4-bit, 8-bit, FP16} during decoding. This adaptive precision policy reduces KV memory footprint and latency while improving accuracy compared to static KV quantization and rule-based baselines, and maintaining competitive accuracy close to FP16 inference across standard LLM benchmarks. Extensive experiments across multiple commonsense reasoning benchmarks using SmolLM-135M, SmolLM-360M, and SmolLM-1.7B demonstrate that our controller consistently improves the accuracy-latency trade-off. For instance, with SmolLM-360M on HellaSwag, our method reduces decoding latency (ms/token) by 17.75% relative to static KV quantization, improves accuracy by 7.60 points, and remains within only 0.30 points of FP16 inference.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。