Abstract: Training large language models (LLMs) at scale requires parallel execution across thousands of devices, incurring enormous computational costs. Yet, these costly distributed trainings are rarely verified, leaving them prone to silent errors and potentially wasting millions of GPU hours. We introduce TrainVerify, a system for verifiable distributed training of LLMs. Given a deep learning model's logical specification as the ground truth, TrainVerify formally verifies that a distributed parallel execution plan is mathematically equivalent to it. Direct verification is notoriously difficult due to the sheer scale of LLMs which often involves billions of variables and highly intricate computation graphs. Therefore, TrainVerify introduces shape-reduction techniques and a stage-wise parallel verification algorithm that significantly reduces complexity while preserving formal correctness. TrainVerify scales to frontier LLMs, including the successful verification of the Llama3 (405B) and DeepSeek-V3 (671B) training plans.
1. Introduction
The training of frontier Large Language Models (LLMs) has evolved into a massive orchestration task, requiring the coordination of thousands of GPUs using complex 3D parallelism strategies—combining data, tensor, and pipeline parallelism. This complexity introduces a significant risk of "silent bugs": errors in the distributed execution plan that do not cause immediate crashes but lead to subtle gradient corruption or accuracy degradation. In an era where a single training run can cost tens of millions of dollars and span several months, catching these bugs at the "blueprint" stage is a high-stakes necessity.
2. The TrainVerify System
TrainVerify is the first system capable of formally verifying that a distributed LLM training plan is mathematically identical to its original logical model definition. Rather than attempting to verify the entire software stack, which is often too complex for formal methods, TrainVerify focuses on the execution plan. This plan serves as the blueprint for how the model is partitioned and scheduled across a distributed cluster.
As shown in the workflow, the system converts both the logical model and the distributed plan into Symbolic Data Flow Graphs (sDFGs). It then utilizes an SMT solver (Z3) to formally check if the symbolic expressions representing the distributed plan are mathematically equivalent to the logical ground truth.
3. Key Technical Innovations
Directly verifying models with billions of parameters is computationally impossible for standard solvers. TrainVerify overcomes this through two primary innovations:
3.1 Shape Reduction
The core insight behind TrainVerify is that most LLM operations are SIMD (Single Instruction, Multiple Data). The authors prove a "SIMD shortcut": if a parallelization strategy is correct for a reduced, "tiny" version of a tensor (e.g., $2 \times 2$), it is mathematically guaranteed to be correct for the full-sized version. This allows the system to compress the problem dimensions significantly without losing the ability to prove formal correctness.
3.2 Staged Verification
To prevent symbolic expressions from becoming too long and "choking" the solver, TrainVerify employs a stage-wise verification algorithm. By breaking the model into concurrent stages (similar to pipeline stages), the system maintains manageable expression lengths while preserving the ability to verify the entire end-to-end plan.
4. Evaluation and Results
TrainVerify was evaluated against state-of-the-art models, including Llama3 (8B, 70B, and 405B) and DeepSeek-V3 (16B, 236B, and 671B), across configurations involving up to 8,192 GPUs.
- Scalability: The system successfully verified the training plans for the massive DeepSeek-V3 (671B) and Llama3 (405B) models.
- Efficiency: Verification for the largest 671B model took between 31 and 47 hours. While this sounds substantial, it is negligible compared to the weeks or months required for actual training.
- Bug Detection: TrainVerify successfully detected 14 real-world bugs reproduced from popular frameworks like Megatron-LM and DeepSpeed. It also uncovered two previously unknown bugs in the
nnScalerframework involving incorrect sharding of rotary embeddings and "dangling" tensors in the backward pass.
5. Conclusion and Future Work
TrainVerify provides a robust framework for squashing silent bugs in the world's largest LLM training runs. While it currently relies on graph-based representations and manual operator mapping for custom kernels, it represents a major step toward verifiable large-scale machine learning. Future work includes using automated program synthesis to handle new operators and extending verification to low-level kernel implementations.
Summary updated