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.5.0.tar.gz (493.4 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.5.0-py3-none-any.whl (636.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for distensor-0.5.0.tar.gz
Algorithm Hash digest
SHA256 67210bb40b914fb2e49cfe2f0803099e7d39be5ec999445363ca23c8df7e7330
MD5 74a9305f2e5cf8047b49cec60761fe2e
BLAKE2b-256 54d324869bcc8db36138c483f9291f78b631462277d6aaeb979b29074f0368bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for distensor-0.5.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.5.0-py3-none-any.whl.

File metadata

  • Download URL: distensor-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 636.1 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a6a9d5c590bd7b35935d9ef54520ec4456bd6da59fa7a18148462d6d672e66c
MD5 a1a76e7f9e0ef92dca86b8869f214979
BLAKE2b-256 d6a35c420fc5574211bd3442a7f1c8d0f50d7eb45316740a341627c7bff55f89

See more details on using hashes here.

Provenance

The following attestation bundles were made for distensor-0.5.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