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

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

Introduction

In the realm of high-performance computing and Large Language Models (LLMs), a fundamental quirk of floating-point arithmetic often goes unnoticed: $1 + 2 + 3$ does not always equal $3 + 2 + 1$. Because floating-point math is non-associative, the sequence in which numbers are summed dictates the accumulation of tiny rounding errors.

When deploying modern LLMs, practitioners frequently adjust the "Tensor Parallel" (TP) size—sharding a model across multiple GPUs—to optimize inference speed. However, altering the TP size inherently changes the order of operations in matrix multiplications and inter-GPU communications (like All-Reduce). Consequently, even when utilizing greedy decoding, a model might yield entirely different outputs on two GPUs compared to four.

This nondeterminism is particularly disastrous for Reinforcement Learning (RL) pipelines. In RL, a "rollout" engine (such as vLLM) generates data using a multi-GPU setup for speed, while a "training" engine (like FSDP) updates the model using a different parallelization strategy. This architectural difference creates a "probability mismatch," where the training engine observes different probabilities than the rollout engine actually produced. Such numerical noise can destabilize training, slow down convergence, or cause the model to fail entirely.

Tree-Based Invariant Kernels (TBIK)

To address this critical bottleneck, researchers have developed Tree-Based Invariant Kernels (TBIK). TBIK is a suite of custom kernels written in Triton designed to replace standard operations like cuBLAS GEMM and NCCL All-Reduce, ensuring bit-wise identical model outputs regardless of the hardware configuration.

  • Fixed Reduction Topology: Instead of allowing the hardware to dynamically determine the fastest reduction path (which varies based on GPU count), TBIK enforces a strict, invariant binary-tree reduction order.
  • Intra-GPU and Inter-GPU Alignment: The binary tree spans the entire cluster. Whether operating on a single GPU or eight, the mathematical path taken to reach the final sum remains mathematically identical.
  • Seamless Integration: TBIK is integrated directly into popular frameworks like vLLM (for inference) and FSDP (for training), ensuring both sides of the RL pipeline execute mathematics identically.
  • Complementing BIO: TBIK builds upon previous work on Batch-Invariant Operations (BIO), which resolved nondeterminism caused by varying batch sizes but left the TP-size variance unsolved. Together, they secure the "last mile" of determinism.

Experimental Setup

The researchers evaluated TBIK using prominent open-weight models, including Qwen3-8B/32B, Mistral-7B, and Llama-3.1-8B. The evaluation spanned several rigorous benchmarks:

  • AIME24 & AMC23: Challenging mathematical reasoning datasets utilized to measure output fluctuation due to nondeterminism.
  • GSM8K: A standard grade-school math dataset used specifically to benchmark Reinforcement Learning (GRPO) stability and performance.

Key Results and Insights

The implementation of TBIK yields profound improvements in pipeline stability, proving that RL is highly sensitive to numerical "butterfly effects." Even a sub-1% probability divergence can cause an RL agent to select a different expert in a Mixture-of-Experts (MoE) model, leading to training collapse. TBIK eliminates this hidden off-policy behavior.

  • Bit-wise Identity: With TBIK enabled, the count of unique outputs for a single prompt across 12 different hardware configurations (varying both batch and TP sizes) dropped to exactly 1. In contrast, baseline models produced up to 12 different answers for the exact same prompt.
  • Zero Probability Divergence: TBIK achieved a maximum probability divergence of 0. The probabilities calculated by the inference engine and the training engine were identical down to the last bit.
  • Superior RL Performance: During RL training on GSM8K, the TBIK-enabled pipeline reached a Pass@1 accuracy of 0.73, significantly outperforming the vanilla BF16 setup (0.60) and the BIO-only setup (0.68). Furthermore, the model converged much faster due to the pristine training signal.
  • Acceptable Overhead: Standard libraries like NCCL use dynamic scheduling or "Ring Reduce" to maximize throughput. By intentionally choosing a slightly less efficient tree structure, TBIK trades speed for stability, introducing a 22% to 63% end-to-end latency overhead. The authors argue this is a necessary and acceptable price for the reliability required in high-stakes evaluation and RL research.

Limitations and Future Work

While TBIK successfully enables true on-policy RL at scale, there are areas for future refinement:

  • Performance Gap: TBIK is currently slower than highly optimized proprietary kernels like cuBLAS. Future low-level optimizations, such as warp specialization and advanced block-size tuning, could narrow this latency gap.
  • Quantization Support: The current implementation focuses on 16-bit formats (BF16/FP16). Extending these deterministic guarantees to 4-bit or 8-bit quantized models (like INT8 or FP8) is a critical next step.
  • Hardware Portability: Although tested extensively on NVIDIA GPUs (L40S, RTX 6000, H20) via Triton, extending TBIK to other hardware backends, such as AMD GPUs or Google TPUs, remains an open area for future work.

Summary updated

BibTeX
@inproceedings{zhang2026deterministic,
  author = {Ziyang Zhang and Xinheng Ding and Jiayi Yuan and Rixin Liu and Huizi Mao and Jiarong Xing and Zirui Liu},
  title = {{Deterministic Inference across Tensor Parallel Sizes That Eliminates Training-Inference Mismatch}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=5eZmlUyFpl},
}
Figure