spmd-types
A type system for distributed (SPMD) tensor computations in PyTorch
What it is and what it does
spmd_types is a type system for writing distributed tensor computations with explicit, verifiable semantics. It provides two complementary abstractions: local SPMD types track whether gradients are pending reduction or fully synchronized, enabling safe use of Megatron-style differentiable collectives; global SPMD types offer a DTensor-like interface where code has identical semantics whether run on a single device or distributed, but with explicit communication operations so redistributes are never implicit.
The package lets you verify correctness of distributed training logic—checking gradient computation and parallelization equivalence—without running full end-to-end distributed training. It includes runtime type checking via a checker module, allowing you to annotate tensors with their layout and synchronization state and assert those invariants hold at each step.
Use it for:
- Porting training frameworks to verify gradients are correctly reduced across ranks without E2E training runs.
- Typechecking distributed code to catch mismatches between expected and actual tensor layouts before deployment.
- Writing distributed logic that is semantically identical whether run on a single device or across multiple ranks.
- Verifying that collective operations are applied to tensors in the correct synchronization state.
- Debugging gradient flow by asserting tensor state at each computation step.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides type annotations and runtime checking for distributed tensor computations, tracking data layout and synchronization state across SPMD parallelism patterns.
Yes, if you are building or maintaining distributed training code. The package is actively maintained, has no external dependencies, and offers a concrete way to catch synchronization bugs before expensive distributed runs. It is in beta (global SPMD types are under construction), so expect the API to evolve; use it for new projects where you can adapt to changes.
Install
spmd-types on PyPI
pip
pip install spmd-typesuv
uv add spmd-typespoetry
poetry add spmd-typesInstalling spmd-types
Before you install
Installs with no runtime dependencies and low friction. The package is actively maintained with a recent release 8 days old; the repository shows steady activity.
License in practice
BSD 3-Clause License permits commercial and private use with attribution and liability disclaimer. No restrictions on modification or redistribution.
Quickstart
pip install spmd_types
import spmd_types as spmd
import spmd_types.checker
with spmd.set_current_mesh(mesh), spmd.checker.typecheck():
spmd.assert_type(x, {dp: spmd.R, tp: spmd.P})
y = spmd.all_reduce(x, tp, src=spmd.P, dst=spmd.R)
spmd.assert_type(y, {dp: spmd.R, tp: spmd.R})
Requires Python 3.10 or later; integration with distributed tensor frameworks assumed in usage context.
Verify before relying
- Whether the type system catches all realistic gradient-reduction bugs in production training code.
- Performance overhead of runtime type checking during training.
- Maturity and completeness of global SPMD types (noted as 'actively under construction').
- Compatibility with frameworks beyond those mentioned in documentation.
Package facts
| License | BSD 3-Clause License (c) Meta Platforms, Inc. and affiliates. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 8 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 111,736/month — #12,403 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: spmd_types-0.2.3-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
megatron-fsdpMegatron-FSDP implements Fully Sharded Data…
permissive · top 15,000 on PyPI
megatron-coreMegatron Core provides GPU-optimized building…
permissive · top 15,000 on PyPI
instanttensorInstantTensor provides a high-throughput…
permissive · top 15,000 on PyPI
torchtypingAdds type annotations for PyTorch tensor shape,…
permissive · top 15,000 on PyPI
torchtitantorchtitan is a PyTorch-native platform for…
permissive · top 15,000 on PyPI
torchmetricsTorchmetrics provides a collection of PyTorch…
permissive · top 5,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
cutensornet-cu13cuTensorNet is a GPU-accelerated library for…
unclear · top 15,000 on PyPI
entmaxEntmax provides PyTorch implementations of…
permissive · top 15,000 on PyPI
jaxtypingProvides type annotations and runtime…
permissive · top 5,000 on PyPI