揭秘LLM推理中的数值不稳定性:使用HEAL实现关键任务的可复现推理
Demystifying Numerical Instability in LLM Inference: Achieving Reproducible Inference for Mission-Critical Tasks with HEAL
AI总结:
针对LLM在关键任务中因16位精度导致输出不一致的问题,提出HEAL方法,通过INT16量化和代数误差补偿,在保持FP32精度的同时减少性能开销。
摘要:
随着大型语言模型(LLM)部署到关键任务领域(如金融、医学和法律),输出可复现性已成为严格的系统要求。虽然从业者使用贪婪解码来消除算法随机性,但采用16位精度的实际部署在异构GPU上仍然表现出灾难性的输出差异。通过SASS级分析,我们揭示这种不一致性根本上是由内核边界处下转换引入的截断误差驱动的。然而,通过全局FP32流水线实现可复现性会带来高昂的系统代价:绕过16位硬件加速器会损害计算效率,而升级KV缓存会使内存开销翻倍。为弥补这一差距,我们提出混合误差缓解(HEAL),这是一种针对性干预方法,通过两种机制近似FP32精度同时解决硬件限制。首先,认识到浮点格式对Q、K、V张量未充分利用其位宽,HEAL应用INT16量化,在不扩大KV缓存占用的情况下保持数值稳定性。其次,HEAL通过代数误差补偿策略合成高精度矩阵乘法,完全在高吞吐量的16位张量核心上执行。为实际评估我们的方法,我们引入MCR-Bench,一个针对关键任务可复现性的基准测试。HEAL在下游任务上实现了与FP32基线相同的可复现性,同时将性能开销降低高达7.1倍。
英文摘要:
As Large Language Models (LLMs) deploy into mission-critical domains (e.g., finance, medicine, and law), output reproducibility has become a strict system requirement. While practitioners use greedy decoding to eliminate algorithmic stochasticity, empirical deployments with 16-bit precisions still exhibit catastrophic output divergence across heterogeneous GPUs. Through SASS-level profiling, we reveal that this inconsistency is fundamentally driven by truncation errors introduced during downcasting at kernel boundaries. However, achieving reproducibility via a global FP32 pipeline incurs prohibitive system penalties: bypassing 16-bit hardware accelerators hurts compute efficiency, while upcasting the KV cache doubles memory overhead. To bridge this gap, we propose Hybrid Error ALleviation (HEAL), a targeted intervention that approximates FP32 precision while resolving hardware constraints through two targeted mechanisms. First, recognizing that floating-point formats underutilize their bit-width for Q, K, V tensors, HEAL applies INT16 quantization that preserves numerical stability without expanding the KV cache footprint. Second, HEAL synthesizes high-precision matrix multiplications via an algebraic error compensation strategy, executing entirely on high-throughput 16-bit Tensor Cores. To evaluate our approach practically, we introduce MCR-Bench, a benchmark targeting reproducibility in mission-critical tasks. HEAL achieves the same level of reproducibility on downstream tasks as the FP32 baseline while reducing the performance overhead by up to 6.0$\times$.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。