Skip to main content

A type system for distributed (SPMD) tensor computations in PyTorch

Project description

spmd_types

A type system for distributed (SPMD) tensor computations in PyTorch.

spmd_types tracks per-mesh-axis types on tensors -- Replicate (R), Invariant (I), Varying (V), Partial (P), and Shard (S) -- and enforces type-correct transitions through collective operations and local rewrites. It catches distributed programming errors at development time without requiring a GPU cluster.

Installation

pip install spmd-types

Quick start

import torch
import torch.distributed as dist
from spmd_types import R, V, P, S, typecheck, assert_type, all_reduce

dist.init_process_group(backend="nccl")
pg = dist.distributed_c10d._get_default_group()

with typecheck():
    x = torch.randn(4, device="cuda")
    assert_type(x, {pg: P})       # x is partial (pending sum)
    y = all_reduce(x, pg, src=P, dst=R)  # sum across ranks
    assert_type(y, {pg: R})       # y is now replicated

Documentation

See DESIGN.md for the full type system specification, including type inference rules, collective signatures, and forward-backward pairs.

License

BSD 3-Clause License. See LICENSE for details.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

spmd_types-0.1.1-py3-none-any.whl (95.0 kB view details)

Uploaded Python 3

File details

Details for the file spmd_types-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spmd_types-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 95.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CentOS Stream","version":"9","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for spmd_types-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9d6b3616ed09ef7603868e01d81320e9533b15b4229a65537c3611442dd409b1
MD5 a61393b550dc857090385c4298b3cf0c
BLAKE2b-256 9d1c9b193802cc26981c54c6e8d243f898e5cf01ed18f3441258eb01b0d65dc4

See more details on using hashes here.

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