Decentralized distributed training with explicit 4D parallelism control
Project description
Decentralized distributed training with explicit 4D parallelism control.
disTensor trains large models across heterogeneous consumer compute. You declare the parallelism strategy — data, tensor, pipeline, and (soon) context — and disTensor handles orchestration, synchronization, and fault tolerance while keeping familiar PyTorch semantics.
Status: alpha. APIs and wire formats may change between minor releases.
Why disTensor
- Explicit 4D parallelism. No auto-magic sharding — you define
StageMappingandShardingSpec, the system executes them predictably. - Driver-mediated execution. Your process owns the training loop and data pipeline. The hub coordinates topology but stays off the critical path.
- Control/data plane split. gRPC for orchestration (
:50051), direct P2P for tensor transfers. Workers sync without round-tripping through the hub. - Heterogeneous compute. CUDA, Apple Silicon (MPS/MLX), and CPU backends with auto-detected capabilities.
- Cloud or standalone. Run a local hub for experiments, or point at the managed cloud for persistence, auth, billing, and a web console.
Installation
# Trainer SDK (PyPI)
pip install distensor
# Compute provider — macOS Apple Silicon (one-liner installer)
DISTENSOR_API_KEY=dt_p_... curl -fsSL https://api.distensor.com/install/macos.sh | bash
# Provider node app, install manually
pip install distensor-server distensor-tui
# Development (editable, from source)
git clone https://github.com/don-arash/distensor
cd distensor && make dev
Role-specific extras: distensor[worker], distensor[worker-cuda], distensor[worker-mlx], distensor[cloud], distensor[dev].
Quick Start
import distensor as ds
from distensor.core import ParallelConfig
from distensor.nn import DistributedModel, StageMapping, ShardingSpec, Shard, Replicate
ds.init(mode="cloud", api_key="dt_u_...")
# Inspect available compute before committing
mesh = ds.query_mesh()
print(f"Workers online: {mesh.available_workers}")
# Declare parallelism explicitly
parallel = ParallelConfig(data_parallel=4, tensor_parallel=2, pipeline_parallel=2)
stages = StageMapping([
["model.embed"],
["model.layers.[0-5]"],
["model.layers.[6-11]"],
["model.norm", "lm_head"],
])
tp_spec = ShardingSpec({
"model.layers.*.self_attn.q_proj.weight": Shard(dim=0),
"model.layers.*.self_attn.o_proj.weight": Shard(dim=1),
"model.layers.*.input_layernorm.weight": Replicate(),
})
model = DistributedModel(my_module, stage_mapping=stages, tp_spec=tp_spec)
trainer = ds.Trainer(model, parallel=parallel)
trainer.fit(data_loader, epochs=1)
See the docs for full training examples, mesh planning, and the cloud API reference.
Architecture
disTensor uses a hub-and-spoke topology. The hub coordinates, workers compute and sync directly, and the cloud layer adds persistence and a web surface on top.
| Component | Package | Description |
|---|---|---|
| Hub | distensor.hub |
Control plane — node / job / topology registries, gRPC services (mesh, job, training, checkpoint, sync) |
| Cloud API | distensor.cloud |
Production HTTP layer — FastAPI + Postgres + Redis + Prometheus. Auth, billing, worker registry, telemetry |
| Node | distensor.node |
Compute worker daemon — model shard execution, P2P data plane, CUDA / MPS / CPU backends |
| Trainer | distensor.training |
Orchestration — Trainer.fit(), pipeline scheduling (GPipe, 1F1B), shard loading, execution plans |
| Sync | distensor.sync |
4D parallel coordination — TP AllReduce, PP transfers, DP gradient sync, worker topology |
| Optimizer | distensor.optim |
Distributed optimizer — ZeRO-3, gradient sync with bucketing, LR schedulers, distributed state dict |
| Console | ui/ |
React web UI for trainers, providers, and admins |
| Node App | distributions/ |
Provider surface — distensor-server supervisor + distensor TUI dashboard |
See Architecture.md for diagrams, execution flows, and design principles.
Parallelism
| Mode | Strategy | |
|---|---|---|
| Data Parallel | DP | Replicate model across workers, split data batches |
| Tensor Parallel | TP | Shard individual layers across workers |
| Pipeline Parallel | PP | Split model into sequential stages across workers |
| Context Parallel | CP | Split sequence dimension across workers (coming soon) |
Development
make dev # Full bootstrap (uv sync + proto generation)
make test # Run full test suite
make lint # Ruff linting
make format # Auto-format
make cloud-up # Start Postgres, Redis, MinIO, Prometheus
make cloud-api # Run HTTP API server (:8000)
make cloud-hub # Run gRPC hub server (:50051)
make console-dev # Vite dev server (:5173, proxies /api to :8000)
make sandbox-up # Docker sandbox (coordinator + 8 workers)
make sandbox-cloud-up # Full cloud stack in Docker
make help # All available targets
Contributions welcome — see CONTRIBUTING.md. Commit messages follow Conventional Commits; releases are cut by commitizen and published to PyPI via GitHub Actions Trusted Publishing on v* tags.
Community & Support
- Documentation: distensor.com/docs
- Issues & bugs: GitHub Issues
- Discussions: GitHub Discussions
- Changelog: CHANGELOG.md
License
Apache 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file distensor-0.2.0.tar.gz.
File metadata
- Download URL: distensor-0.2.0.tar.gz
- Upload date:
- Size: 467.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b39a54c74c11b92133c87f34043ba39166f2101c69696740a75f99c9cc1f9fd
|
|
| MD5 |
2ffa99847df5fe69cc7326251cdfcaaa
|
|
| BLAKE2b-256 |
d4e7e95d6d5317bdf2c5d5f9d607fee96c2a44da3e794d143aa50a364f285d21
|
Provenance
The following attestation bundles were made for distensor-0.2.0.tar.gz:
Publisher:
ci.yml on don-arash/distensor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
distensor-0.2.0.tar.gz -
Subject digest:
0b39a54c74c11b92133c87f34043ba39166f2101c69696740a75f99c9cc1f9fd - Sigstore transparency entry: 1341691628
- Sigstore integration time:
-
Permalink:
don-arash/distensor@3e0d4e18836883a933c66abd3d9fccd2a6ec1866 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/don-arash
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3e0d4e18836883a933c66abd3d9fccd2a6ec1866 -
Trigger Event:
push
-
Statement type:
File details
Details for the file distensor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: distensor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 605.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c83c6e330c8b07928f24259f4d1c589cc60898882c162c0f2204951ea2c0e3f9
|
|
| MD5 |
02b52250686cae2ca239ba269d3a31a9
|
|
| BLAKE2b-256 |
210d823cc502f08876e16f05985e06dbb21427e00e5ad42a46a06cc57547ba4e
|
Provenance
The following attestation bundles were made for distensor-0.2.0-py3-none-any.whl:
Publisher:
ci.yml on don-arash/distensor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
distensor-0.2.0-py3-none-any.whl -
Subject digest:
c83c6e330c8b07928f24259f4d1c589cc60898882c162c0f2204951ea2c0e3f9 - Sigstore transparency entry: 1341691634
- Sigstore integration time:
-
Permalink:
don-arash/distensor@3e0d4e18836883a933c66abd3d9fccd2a6ec1866 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/don-arash
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3e0d4e18836883a933c66abd3d9fccd2a6ec1866 -
Trigger Event:
push
-
Statement type: