FP32か死か?再現可能な推論の課題と解決策
Give Me FP32 or Give Me Death? Challenges and Solutions for Reproducible Reasoning
June 11, 2025
著者: Jiayi Yuan, Hao Li, Xinheng Ding, Wenya Xie, Yu-Jhe Li, Wentian Zhao, Kun Wan, Jing Shi, Xia Hu, Zirui Liu
cs.AI
要旨
大規模言語モデル(LLMs)は現在、さまざまな分野で不可欠な存在となり、印象的な性能を発揮している。しかし、その進歩はベンチマークスコアが正確かつ再現可能であるという前提に依存している。本論文では、LLMの性能の再現性が脆弱であることを示す:評価バッチサイズ、GPU数、GPUバージョンなどのシステム構成を変更すると、生成される応答に大きな違いが生じる可能性がある。この問題は特に推論モデルにおいて顕著であり、初期トークンにおけるわずかな丸め誤差が連鎖的に異なる思考プロセスを引き起こし、最終的に精度に影響を及ぼす。例えば、bfloat16精度と貪欲デコードを使用した場合、DeepSeek-R1-Distill-Qwen-7Bのような推論モデルでは、GPU数、タイプ、評価バッチサイズの違いにより、精度が最大9%変動し、応答長が9,000トークンも異なることがある。この変動の根本原因を、限られた数値精度下での浮動小数点演算の非結合性に遡る。本研究は、数値精度がLLM推論の再現性にどのように影響するかを体系的に調査した初めての研究である。さまざまなハードウェア、ソフトウェア、精度設定における慎重に制御された実験を通じて、モデル出力がいつ、どのように分岐するかを定量化する。我々の分析により、再現性にとって重要な浮動小数点精度が、評価実践においてしばしば無視されていることが明らかになった。これに着想を得て、重みを16ビット精度で保存しつつ、すべての計算をFP32で行う軽量な推論パイプライン「LayerCast」を開発し、メモリ効率と数値安定性のバランスを実現した。コードはhttps://github.com/nanomaoli/llm_reproducibilityで公開されている。
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 difference 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.