DOE OSTI · code-186582
torch-einshard v1.0
Abstract
torch-einshard is a Python library for describing local and distributed PyTorch tensor computations with compact, einsum-like notation. Its expressions name logical axes, specify how they are sharded across a PyTorch DeviceMesh, and represent partial reductions. The library automatically performs contractions, permutations, reshaping, splitting, gathering, reduction, reduce-scatter, and repartitioning while preserving autograd. Additional features include sharding-aware FFTs, tensor rolls, halo exchange, sliding windows, 1D–3D convolutions, uneven-shard handling, parameter initialization and gradient management, and cost-based execution planning. It is designed for scientific machine learning and large-model workloads, including tensor-, sequence-, and spatial-parallel MLPs, attention, convolutions, and spectral operations. Compared with manually combining torch.einsum and distributed collectives, torch-einshard expresses both the mathematical operation and data placement in one readable formula. This reduces boilerplate and synchronization errors, keeps forward and backward communication consistent, and allows the library to select optimized collective strategies without changing model code.
Keep this discovery
Explore connections, maps & timelines
Morozov, Dmitriy [Lawrence Berkeley National Laboratory (LBNL), Berkeley, CA (United States)], Subramanian, Shashank [Lawrence Berkeley National Laboratory (LBNL), Berkeley, CA (United States)]. 2026-07-22. torch-einshard v1.0. https://doi.org/10.11578/dc.20260724.2
Cite the original work for its findings. Save a collection to share your selection of sources.