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.


翻译:确定性推理对于大语言模型(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。

0
下载
关闭预览

相关内容

【WWW2024】博弈论式反事实解释图神经网络
专知会员服务
32+阅读 · 2024年2月17日
【ICCV2023】保留模态结构改进多模态学习
专知会员服务
31+阅读 · 2023年8月28日
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员