arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2511.17826cs.LGcs.CLstat.ML
收藏

跨张量并行大小的确定性推理,消除训练-推理不匹配

Deterministic Inference across Tensor Parallel Sizes That Eliminates Training-Inference Mismatch

Independent Researcher(独立研究者);University of Minnesota, Minneapolis, Minnesota, USA(明尼苏达大学);Rice University, Houston, Texas, USA(里士满大学);NVIDIA Corp., Santa Clara, California, USA(NVIDIA公司)

Ziyang Zhang, Xinheng Ding, Jiayi Yuan, Rixin Liu, Huizi Mao, Jiarong Xing, Zirui Liu

AI总结:

针对不同张量并行大小导致浮点运算非结合性引起的推理非确定性问题,提出基于树的核(TBIK)实现跨TP大小的比特级一致结果,消除RL训练中推理与训练引擎间的精度不匹配。

摘要:

确定性推理对于大型语言模型(LLM)应用(如LLM-as-a-judge评估、多智能体系统和强化学习(RL))日益关键。然而,现有的LLM服务框架表现出非确定性行为:当系统配置(例如张量并行(TP)大小、批大小)变化时,即使采用贪心解码,相同的输入也可能产生不同的输出。这是由于浮点运算的非结合性以及GPU间归约顺序不一致导致的。虽然先前的工作通过批不变核解决了与批大小相关的非确定性,但跨不同TP大小的确定性仍然是一个开放问题,特别是在RL设置中,训练引擎通常使用全分片数据并行(即TP=1),而部署引擎依赖多GPU TP以最大化推理吞吐量,从而在两者之间产生自然的不匹配。这种精度不匹配问题可能导致RL训练性能次优甚至崩溃。我们识别并分析了TP引起不一致的根本原因,并提出了基于树的核(TBIK),这是一组TP不变的矩阵乘法和归约原语,无论TP大小如何,都能保证比特级相同的结果。我们的关键见解是通过统一的层次二叉树结构对齐GPU内和GPU间的归约顺序。我们在Triton中实现了这些核,并将其集成到vLLM和FSDP中。实验证明,在不同TP大小下,确定性推理的概率发散为零,且具有比特级可重复性。此外,在采用不同并行策略的RL训练流程中,我们在vLLM和FSDP之间实现了比特级相同的结果。代码可在https://github.com/nanomaoli/llm_reproducibility获取。

英文摘要:

Deterministic inference is increasingly critical for large language model (LLM) applications such as LLM-as-a-judge evaluation, multi-agent systems, and Reinforcement Learning (RL). However, existing LLM serving frameworks exhibit non-deterministic behavior: identical inputs can yield different outputs when system configurations (e.g., tensor parallel (TP) size, batch size) vary, even under greedy decoding. This arises from the non-associativity of floating-point arithmetic and inconsistent reduction orders across GPUs. While prior work has addressed batch-size-related nondeterminism through batch-invariant kernels, determinism across different TP sizes remains an open problem, particularly in RL settings, where the training engine typically uses Fully Sharded Data Parallel (i.e., TP = 1) while the rollout engine relies on multi-GPU TP to maximize the inference throughput, creating a natural mismatch between the two. This precision mismatch problem may lead to suboptimal performance or even collapse for RL training. We identify and analyze the root causes of TP-induced inconsistency and propose Tree-Based Invariant Kernels (TBIK), a set of TP-invariant matrix multiplication and reduction primitives that guarantee bit-wise identical results regardless of TP size. Our key insight is to align intra- and inter-GPU reduction orders through a unified hierarchical binary tree structure. We implement these kernels in Triton and integrate them into vLLM and FSDP. Experiments confirm zero probability divergence and bit-wise reproducibility for deterministic inference across different TP sizes. Also, we achieve bit-wise identical results between vLLM and FSDP in RL training pipelines with different parallel strategy. Code is available at https://github.com/nanomaoli/llm_reproducibility.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑