Monarch: Single controller library
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Monarch 🦋
Monarch is a distributed programming framework for PyTorch based on scalable actor messaging. It provides:
- Remote actors with scalable messaging: Actors are grouped into collections called meshes and messages can be broadcast to all members.
- Fault tolerance through supervision trees: Actors and processes form a tree and failures propagate up the tree, providing good default error behavior and enabling fine-grained fault recovery.
- Point-to-point RDMA transfers: cheap registration of any GPU or CPU memory in a process, with the one-sided transfers based on libibverbs
- Distributed tensors: actors can work with tensor objects sharded across processes
Monarch code imperatively describes how to create processes and actors using a simple python API:
from monarch.actor import Actor, endpoint, this_host
# spawn 8 trainer processes one for each gpu
training_procs = this_host().spawn_procs({"gpus": 8})
# define the actor to run on each process
class Trainer(Actor):
@endpoint
def train(self, step: int): ...
# create the trainers
trainers = training_procs.spawn("trainers", Trainer)
# tell all the trainers to take a step
fut = trainers.train.call(step=0)
# wait for all trainers to complete
fut.get()
The introduction to monarch concepts provides an introduction to using these features.
⚠️ Early Development Warning Monarch is currently in an experimental stage. You should expect bugs, incomplete features, and APIs that may change in future versions. The project welcomes bugfixes, but to make sure things are well coordinated you should discuss any significant change before starting the work. It's recommended that you signal your intention to contribute in the issue tracker, either by filing a new issue or by claiming an existing one.
📖 Documentation
View Monarch's hosted documentation at this link.
Installation
Note for running distributed tensors, the local torch version must match the version that monarch was built with.
On Fedora distributions
Stable
pip install torchmonarch
torchmonarch stable is built with the latest stable torch.
Nightly
pip install torchmonarch-nightly
torchmonarch-nightly is built with torch nightly.
or manually
# Create and activate the conda environment
conda create -n monarchenv python=3.10 -y
conda activate monarchenv
# Install nightly rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup toolchain install nightly
rustup default nightly
# Install non-python dependencies
conda install libunwind -y
# Install the correct cuda and cuda-toolkit versions for your machine
sudo dnf install cuda-toolkit-12-0 cuda-12-0
# Install clang-dev and nccl-dev
sudo dnf install clang-devel libnccl-devel
# Or, in some environments, the following may be necessary instead
conda install -c conda-forge clangdev nccl
conda update -n monarchenv --all -c conda-forge -y
# If you are building with RDMA support, build monarch with `USE_TENSOR_ENGINE=1 pip install --no-build-isolation .` and dnf install the following packages
sudo dnf install -y libibverbs rdma-core libmlx5 libibverbs-devel rdma-core-devel
# Install build dependencies
pip install -r build-requirements.txt
# Install test dependencies
pip install -r python/tests/requirements.txt
# Build and install Monarch
pip install --no-build-isolation .
# or setup for development
pip install --no-build-isolation -e .
# Run unit tests. consider -s for more verbose output
pytest python/tests/ -v -m "not oss_skip"
On Ubuntu distributions
# Clone the repository and navigate to it
git clone https://github.com/meta-pytorch/monarch.git
cd monarch
# Install nightly rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup toolchain install nightly
rustup default nightly
# Install Ubuntu-specific system dependencies
sudo apt install -y ninja-build
sudo apt install -y libunwind-dev
sudo apt install -y clang
# Set clang as the default C/C++ compiler
export CC=clang
export CXX=clang++
# Install build dependencies
pip install -r build-requirements.txt
# Install test dependencies
pip install -r python/tests/requirements.txt
# Build and install Monarch (with tensor engine support)
pip install --no-build-isolation .
# or
# Build and install Monarch (without tensor engine support)
USE_TENSOR_ENGINE=0 pip install --no-build-isolation .
# or setup for development
pip install --no-build-isolation -e .
# Verify installation
pip list | grep monarch
On MacOS
You can also build Monarch to run locally on a MacOS system.
Note that this does not support tensor engine, which is tied to CUDA and RDMA (via ibverbs).
# Create and activate the conda environment
conda create -n monarchenv python=3.10 -y
conda activate monarchenv
# Install nightly rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup toolchain install nightly
rustup default nightly
# Install build dependencies
pip install -r build-requirements.txt
# Install test dependencies
pip install -r python/tests/requirements.txt
# Build and install Monarch
USE_TENSOR_ENGINE=0 pip install --no-build-isolation .
# or setup for development
USE_TENSOR_ENGINE=0 pip install --no-build-isolation -e .
Running examples
Check out the examples/ directory for demonstrations of how to use Monarch's APIs.
We'll be adding more examples as we stabilize and polish functionality!
License
Monarch is BSD-3 licensed, as found in the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torchmonarch_nightly-2025.10.1-cp313-cp313-manylinux2014_x86_64.whl.
File metadata
- Download URL: torchmonarch_nightly-2025.10.1-cp313-cp313-manylinux2014_x86_64.whl
- Upload date:
- Size: 45.2 MB
- Tags: CPython 3.13
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4869e5e8cf77942e6ed6753947643903940adef638636197dd6c22a52551b1a4
|
|
| MD5 |
4efa2fab3031c54adb354b9732ffbfbf
|
|
| BLAKE2b-256 |
d92a6df02c999df854b8fa46f52d79fc5f7f41b04b7d3603370777de20fe90f7
|
Provenance
The following attestation bundles were made for torchmonarch_nightly-2025.10.1-cp313-cp313-manylinux2014_x86_64.whl:
Publisher:
wheels.yml on meta-pytorch/monarch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchmonarch_nightly-2025.10.1-cp313-cp313-manylinux2014_x86_64.whl -
Subject digest:
4869e5e8cf77942e6ed6753947643903940adef638636197dd6c22a52551b1a4 - Sigstore transparency entry: 574794537
- Sigstore integration time:
-
Permalink:
meta-pytorch/monarch@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/meta-pytorch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Trigger Event:
schedule
-
Statement type:
File details
Details for the file torchmonarch_nightly-2025.10.1-cp312-cp312-manylinux2014_x86_64.whl.
File metadata
- Download URL: torchmonarch_nightly-2025.10.1-cp312-cp312-manylinux2014_x86_64.whl
- Upload date:
- Size: 45.2 MB
- Tags: CPython 3.12
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee0670b334a19e4212908a70deb29a431e198d1ee9dd9697fc05321ef5445770
|
|
| MD5 |
2ed99a980b4622079c54be572c59885d
|
|
| BLAKE2b-256 |
14349ed0fe7f0441a8818c1ad7799342949bd719fad89b67a0767861840487dc
|
Provenance
The following attestation bundles were made for torchmonarch_nightly-2025.10.1-cp312-cp312-manylinux2014_x86_64.whl:
Publisher:
wheels.yml on meta-pytorch/monarch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchmonarch_nightly-2025.10.1-cp312-cp312-manylinux2014_x86_64.whl -
Subject digest:
ee0670b334a19e4212908a70deb29a431e198d1ee9dd9697fc05321ef5445770 - Sigstore transparency entry: 574794536
- Sigstore integration time:
-
Permalink:
meta-pytorch/monarch@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/meta-pytorch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Trigger Event:
schedule
-
Statement type:
File details
Details for the file torchmonarch_nightly-2025.10.1-cp311-cp311-manylinux2014_x86_64.whl.
File metadata
- Download URL: torchmonarch_nightly-2025.10.1-cp311-cp311-manylinux2014_x86_64.whl
- Upload date:
- Size: 45.3 MB
- Tags: CPython 3.11
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed4e1efe345013ee1c3c899469e01384b7f3937ccde886bcab29057daa9ec3a9
|
|
| MD5 |
3dfb42b241a0f483150e22aad08e7c32
|
|
| BLAKE2b-256 |
947879f4e34e14d62ff4dc7c1a86fcdd30fb8f1643dcbebdeefa9d767e648238
|
Provenance
The following attestation bundles were made for torchmonarch_nightly-2025.10.1-cp311-cp311-manylinux2014_x86_64.whl:
Publisher:
wheels.yml on meta-pytorch/monarch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchmonarch_nightly-2025.10.1-cp311-cp311-manylinux2014_x86_64.whl -
Subject digest:
ed4e1efe345013ee1c3c899469e01384b7f3937ccde886bcab29057daa9ec3a9 - Sigstore transparency entry: 574794531
- Sigstore integration time:
-
Permalink:
meta-pytorch/monarch@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/meta-pytorch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Trigger Event:
schedule
-
Statement type:
File details
Details for the file torchmonarch_nightly-2025.10.1-cp310-cp310-manylinux2014_x86_64.whl.
File metadata
- Download URL: torchmonarch_nightly-2025.10.1-cp310-cp310-manylinux2014_x86_64.whl
- Upload date:
- Size: 45.2 MB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5224acad691fe2ac37566067dc625e131057c30571872c60bc5702923d09e69e
|
|
| MD5 |
bbe184905713595bd8ea4492a85bcbeb
|
|
| BLAKE2b-256 |
ef346cef33c11bb39c2186de1f60cdf09a039919315f78b87ee906f7fc65052f
|
Provenance
The following attestation bundles were made for torchmonarch_nightly-2025.10.1-cp310-cp310-manylinux2014_x86_64.whl:
Publisher:
wheels.yml on meta-pytorch/monarch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchmonarch_nightly-2025.10.1-cp310-cp310-manylinux2014_x86_64.whl -
Subject digest:
5224acad691fe2ac37566067dc625e131057c30571872c60bc5702923d09e69e - Sigstore transparency entry: 574794521
- Sigstore integration time:
-
Permalink:
meta-pytorch/monarch@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/meta-pytorch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@01cd8333a943327bab9ec3410267619c02e7b8b3 -
Trigger Event:
schedule
-
Statement type: