veScale: Consistent and Efficient Tensor Programming with Eager-Mode SPMD

Youjie Li, Cheng Wan, Zhiqi Lin, Hongyu Zhu, Jiacheng Yang, Ziang Song, Xinyi Di, Jiawei Wu, Huiyao Shu, Wenlei Bao, Yanghua Peng, Haibin Lin, Li-Wen ChangarXiv 2025 · DOI

Training Large Language Models (LLMs) has traditionally forced developers into a difficult trade-off. On one hand, user-friendly "eager-mode" frameworks like PyTorch offer ease of debugging and rapid iteration but often suffer from performance bottlenecks and consistency issues at scale. On the other hand, highly optimized systems like Megatron-LM provide the necessary performance but require rigid, complex codebases where model logic is inextricably intertwined with distributed parallelization strategies.

Researchers at ByteDance Seed have introduced veScale, a system designed to bridge this gap. By utilizing a Single Program Multiple Data (SPMD) paradigm, veScale allows developers to write models as if they were targeting a single device while achieving performance that rivals or exceeds specialized distributed frameworks.

The Programming Dilemma in Distributed Training

Distributed training is currently hindered by three primary challenges:

  1. Code Complexity: In traditional systems, sharding and communication logic are baked into the model architecture. Modifying a model often requires a manual rewrite of its distributed components, creating a significant barrier to research.
  2. The Consistency Gap: Scaling from a single GPU to a cluster often changes how random numbers (for Dropout or weight initialization) are generated. This leads to statistically uncorrelated results, making it nearly impossible to determine if a training failure is a bug or a side effect of distributed randomness.
  3. The Eager Tax: While PyTorch’s DTensor (Distributed Tensor) attempted to simplify parallelization, it introduced substantial CPU overhead. The system spends excessive time on metadata dispatch, leaving high-performance GPUs idling.

System Architecture and Methods

veScale addresses these issues through a decoupled architecture that separates model definition from parallelization strategy.

The veScale architecture utilizes a Plan API to transform single-device models into parallelized versions without modifying source code.

The Plan API and Eager SPMD

Instead of modifying model code, veScale uses a separate Plan API. This API employs regex-based path matching to define how specific layers (e.g., linear weights) should be sharded across dimensions. This allows for zero-change adaptation of single-device scripts to complex 4D parallelism.

Overcoming the Eager Tax

To eliminate the CPU overhead associated with eager-mode dispatch, veScale introduces Static Eager Mode. Recognizing that most LLM metadata (tensor shapes and sharding) remains constant during training, veScale "bakes" the dispatch logic. This reduces dispatch overhead from hundreds of microseconds to nearly zero, providing the speed of a compiled graph with the flexibility of eager execution.

Ensuring Bit-wise Consistency

veScale solves the randomness problem through Thread-Based Distributed RNG. By virtualizing random number generation and mapping local GPU threads to a global virtual space, the system ensures that a tensor index receives the same random value regardless of whether it is processed on one GPU or one hundred. This enables bit-wise consistency, allowing distributed errors to be reproduced and debugged on a single device.

Performance Evaluation

The researchers evaluated veScale using several large-scale architectures, including LLaMA-3 (8B and 70B), Mixtral (8x7B), and LI-DiT (10B), on a cluster of 256 NVIDIA H100 GPUs.

veScale achieves bit-wise consistency in training loss (left) while providing significant throughput gains over TorchTitan (right).

Key Results

  • Throughput: veScale delivered up to a 2.2× end-to-end speedup over TorchTitan and outperformed Megatron-DeepSpeed by approximately 1.3× on LLaMA-3 70B.
  • Efficiency: The system reduced CPU overhead by 95% through its C++ core and eliminated it entirely in Static Eager mode.
  • Simplicity: Adapting scripts to 4D parallelism required 78.4% fewer lines of code compared to traditional baselines.
  • Accuracy: As shown in the training loss curves, veScale achieved exact alignment between single-device and multi-device runs, a feat not typically possible in other distributed frameworks.

Conclusion

veScale demonstrates that the "eager tax" is not an inherent cost of user-friendly frameworks. By decoupling parallelization logic and optimizing metadata dispatch, veScale provides a path forward for LLM research where high-performance distributed training is as accessible as single-GPU coding. The authors are currently working to upstream these innovations into the official PyTorch library to benefit the broader AI community.

Summary updated

BibTeX
@misc{li2025vescale,
  author = {Youjie Li and Cheng Wan and Zhiqi Lin and Hongyu Zhu and Jiacheng Yang and Ziang Song and Xinyi Di and Jiawei Wu and Huiyao Shu and Wenlei Bao and Yanghua Peng and Haibin Lin and Li-Wen Chang},
  title = {{veScale: Consistent and Efficient Tensor Programming with Eager-Mode SPMD}},
  year = {2025},
  eprint = {2509.07003},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.07003},
}
Figure