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.3.2.tar.gz (481.8 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.3.2-py3-none-any.whl (622.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for distensor-0.3.2.tar.gz
Algorithm Hash digest
SHA256 585b0cf37a95953dc7d437d95e00cc276060ec877100cb6537b04428d8e696c5
MD5 1232ebdd77cb5e0dd5c8b82aed65da77
BLAKE2b-256 ef68078a136ea7b95fb99a395f7fe3d5631937891acafad182573e14afc9868e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: distensor-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 622.2 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.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8866131d33b1f22ce89a731c8891ee8532b932da717419ad7d205ea2323091fa
MD5 b9e7ff938879474e5127c9522430cefa
BLAKE2b-256 64aa9e86fdeb749f58aa2dbfb4fe16b0e8f6d2e41443fce112ba64ace35039b5

See more details on using hashes here.

Provenance

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