Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Yuan, Jiayi, Li, Hao, Ding, Xinheng, Xie, Wenya, Li, Yu-Jhe, Zhao, Wentian, Wan, Kun, Shi, Jing, Hu, Xia, Liu, Zirui
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866918170826113024
author Yuan, Jiayi
Li, Hao
Ding, Xinheng
Xie, Wenya
Li, Yu-Jhe
Zhao, Wentian
Wan, Kun
Shi, Jing
Hu, Xia
Liu, Zirui
author_facet Yuan, Jiayi
Li, Hao
Ding, Xinheng
Xie, Wenya
Li, Yu-Jhe
Zhao, Wentian
Wan, Kun
Shi, Jing
Hu, Xia
Liu, Zirui
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2506_09501
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference
Yuan, Jiayi
Li, Hao
Ding, Xinheng
Xie, Wenya
Li, Yu-Jhe
Zhao, Wentian
Wan, Kun
Shi, Jing
Hu, Xia
Liu, Zirui
Computation and Language
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.
title Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference
topic Computation and Language
url https://arxiv.org/abs/2506.09501