Registry / devops / torchmonarch

torchmonarch

JSON →
library0.5.0pypypiunverified

Monarch is a single-controller library for PyTorch, providing a centralized orchestration layer for distributed training. It simplifies multi-GPU and multi-node training by managing communication, checkpointing, and fault tolerance. Currently at version 0.5.0, it requires Python >=3.10 and is under active development.

pip install torchmonarch
INSTALL
IMPORT
SIG · TORCHMONARCH
T
torchmonarch
devopspythonv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Monarch
from torchmonarch.monarch import Monarch
from torchmonarch import Monarch

Initialize Monarch with a config, then train a simple linear model.

import torch import torch.nn as nn from torchmonarch import Monarch, MonarchConfig config = MonarchConfig( num_gpus=torch.cuda.device_count(), backend='nccl', checkpoint_dir='/tmp/checkpoints' ) monarch = Monarch(config) model = nn.Linear(10, 5) optimizer = torch.optim.SGD(model.parameters(), lr=0.01) data = torch.randn(32, 10) target = torch.randn(32, 5) monarch.train(model, optimizer, data, target) print("Training step completed.")
Debug
Known issues
breakingThe API changed significantly from v0.4.x to v0.5.0. `MonarchConfig` now requires explicit `num_gpus` instead of inferring from CUDA_VISIBLE_DEVICES.
fix
Update code to pass `num_gpus=torch.cuda.device_count()` (or an integer) to `MonarchConfig`.
affects: >=0.5.0
deprecatedThe old `run` method has been renamed to `train` in v0.5.0.
fix
Replace `monarch.run(...)` with `monarch.train(...)`.
affects: >=0.5.0
gotchaMonarch requires NCCL backend for multi-GPU training. If NCCL is not available, it will fall back to Gloo silently, which may cause performance issues.
fix
Install PyTorch with CUDA support and ensure NCCL is installed.
affects: all
gotchaThe `checkpoint_dir` in `MonarchConfig` must exist before training; Monarch does not create it automatically.
fix
Create the directory beforehand: `import os; os.makedirs(config.checkpoint_dir, exist_ok=True)`.
affects: all
Upgrade
Version history
0.5.0latest on PyPI · released May 20, 2026
Audit
Dependencies
torchrequiredCore dependency: Monarch wraps PyTorch for distributed training.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
torchmonarch — pip install torchmonarch · libregistry