arXiv:2506.09501cs.CL2025-06NeurIPS被引 51

LLM推理结果受硬件配置影响大,易因浮点数精度差异导致不一致。

Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference

  • 发现浮点运算非结合性是导致推理结果不稳定的根源。
  • 同一模型在不同GPU配置下准确率差异可达9%,响应长度差超9000词元。
  • 提出LayerCast轻量方案,用FP32计算保障稳定性,兼顾内存效率。

大型语言模型在多个领域已广泛应用并展现优异性能,但其评测结果的准确性与可复现性依赖于稳定输出。我们发现LLM性能的可复现性极脆弱:评估批大小、GPU数量和型号等系统配置变化会显著改变生成内容。该问题在推理类模型中尤为突出,早期词元的微小舍入误差可能引发思维链分歧,最终影响准确率。例如,在bfloat16精度与贪婪解码下,DeepSeek-R1-Distill-Qwen-7B模型因GPU配置不同,准确率波动达9%,响应长度差异高达9,000词元。根本原因在于有限数值精度下的浮点运算非结合性。本文首次系统研究数值精度对LLM推理可复现性的影响。通过跨硬件、软件及精度设置的受控实验,量化了输出差异的发生条件与程度。分析表明,浮点精度虽关键却常被评测实践忽略。为此,我们提出轻量级推理流水线LayerCast:权重以16位存储,计算全程使用FP32,兼顾内存效率与数值稳定性。代码开源于https://github.com/nanomaoli/llm_reproducibility。

原文摘要 · Abstract (English)

Large Language Models (LLMs) are now integral across various domains and have demonstrated impressive performance. Progress, however, rests on the premise that benchmark scores are both accurate and reproducible. We demonstrate that the reproducibility of LLM performance is fragile: changing system configuration, such as evaluation batch size, GPU count, and GPU version, can introduce significant differences in the generated responses. This issue is especially pronounced in reasoning models, where minor rounding differences in early tokens can cascade into divergent chains of thought, ultimately affecting accuracy. For instance, under bfloat16 precision with greedy decoding, a reasoning model like DeepSeek-R1-Distill-Qwen-7B can exhibit up to 9% variation in accuracy and 9,000 tokens difference in response length due to differences in GPU count, type, and evaluation batch size. We trace the root cause of this variability to the non-associative nature of floating-point arithmetic under limited numerical precision. This work presents the first systematic investigation into how numerical precision affects reproducibility in LLM inference. Through carefully controlled experiments across various hardware, software, and precision settings, we quantify when and how model outputs diverge. Our analysis reveals that floating-point precision - while critical for reproducibility - is often neglected in evaluation practices. Inspired by this, we develop a lightweight inference pipeline, dubbed LayerCast, that stores weights in 16-bit precision but performs all computations in FP32, balancing memory efficiency with numerical stability. Code is available at https://github.com/nanomaoli/llm_reproducibility.

大模型推理数值精度可复现性浮点误差

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