Skip to main content

Decentralized distributed training with explicit 4D parallelism control

Project description

disTensor

PyPI Python CI License Docs

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 StageMapping and ShardingSpec, 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

License

Apache 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distensor-0.6.0.tar.gz (501.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

distensor-0.6.0-py3-none-any.whl (646.0 kB view details)

Uploaded Python 3

File details

Details for the file distensor-0.6.0.tar.gz.

File metadata

  • Download URL: distensor-0.6.0.tar.gz
  • Upload date:
  • Size: 501.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for distensor-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ec9c7d10a625cefe593ea58f5d1e6231903a2d33bee0e9dac1bbb03cebdc275a
MD5 114619f8585c7eb8e1ffb4420a375d23
BLAKE2b-256 526db229a4c5669a892fdee3057b335313fc0974b8065851560171e9f1aecf43

See more details on using hashes here.

Provenance

The following attestation bundles were made for distensor-0.6.0.tar.gz:

Publisher: release.yml on don-arash/distensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file distensor-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: distensor-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 646.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for distensor-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e20a996c4d0bef00210df21f065ddf2b1807231a8d6f8f5e069bb359f52d6d6
MD5 b645a8d48d0b36bfbc06def857d20d4b
BLAKE2b-256 5bd61c7c41be3282e7b429ed0d8923196cd7037cea8af19b420ee0b37681db7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for distensor-0.6.0-py3-none-any.whl:

Publisher: release.yml on don-arash/distensor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page