DTorch¶
DTorch is an easy-to-use distributed inference API for PyTorch. No multi-processes, no SPMD, no ProcessGroup setup — just write single-device code, then make one small change: replace Tensor with DTensor — DTorch will automatically handle resource management, scheduling, and communication.
Example¶
For example, here is how to shard a tensor across two GPUs — the same task written both ways:
Highlights¶
- 🔥🔥🔥 Easy to Use. By far the easiest-to-use distributed API for PyTorch — just like writing single-device PyTorch code. You describe the distributed computation as ordinary PyTorch code on a single thread, and the framework automatically handles task dispatch, scheduling, and communication across the cluster. (This makes it easy to orchestrate heterogeneous workloads — placing different models on different GPUs, or interleaving inference and training across RL rollouts and updates.)
- 🔥Lower CPU overhead. Benefiting from DTorch's asynchronous execution, the Python thread only constructs compute nodes — it never executes them directly. Combined with awaitable
TensorFutures, this keeps the interpreter light and minimizes GPU idle time caused by slow CPU-side kernel launches. - Single-Controller. One Python thread drives the entire cluster — no multi-process launch, no SPMD, no
ProcessGroup. - DTensor Native. Every tensor in DTorch is a
DTensor, and every operator works on it natively. No manual shape sharding, no manualall_gatheracross ranks — you just declare the tensor and print it directly. - Unified parallel strategies. Data Parallel, Tensor Parallel, Context Parallel (Ulysses & Ring) and Pipeline Parallel — all expressible in the same code, and freely composable. See the Llama parallel guide for a complete DP + TP + PP + CP example.
Documentation¶
The core guides are available in English; the remaining advanced topics are linked to the Chinese site from the Document Index until they are translated.
Not sure where to start?
- 🚀 New to DTorch? Read Get Started — build DTorch from source, then verify distributed inference of Llama and diffusion models (SD3 / FLUX).
- 📖 Want to write distributed programs? Follow the User Guide: DTensor core concepts → Python API → Module Parallel → the complete Llama DP + TP + PP + CP example.
- 🏗️ Want to understand the engine? Start with the Project Overview and Key Concepts, then read the Design Decisions and the four-layer Eager Graph Architecture. The Document Index lists all the remaining documents.
- ⚡ Performance — see the Performance guide.
Call for Support¶
The Single-Controller + Distributed Tensor architecture that DTorch builds on is a promising technical direction. However, my personal resources alone are not enough to carry all of these ideas through. If you are interested in this direction, feel free to reach out at peitingkuan@163.com.