{"id":46646,"library":"torchmonarch","title":"Monarch","description":"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.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/meta-pytorch/monarch","tags":["distributed-training","pytorch","monarch"],"install":[{"cmd":"pip install torchmonarch","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency: Monarch wraps PyTorch for distributed training.","package":"torch","optional":false}],"imports":[{"wrong":"from torchmonarch import Monarch","symbol":"Monarch","correct":"from torchmonarch.monarch import Monarch"}],"quickstart":{"code":"import torch\nimport torch.nn as nn\nfrom torchmonarch import Monarch, MonarchConfig\n\nconfig = MonarchConfig(\n    num_gpus=torch.cuda.device_count(),\n    backend='nccl',\n    checkpoint_dir='/tmp/checkpoints'\n)\nmonarch = Monarch(config)\n\nmodel = nn.Linear(10, 5)\noptimizer = torch.optim.SGD(model.parameters(), lr=0.01)\n\ndata = torch.randn(32, 10)\ntarget = torch.randn(32, 5)\n\nmonarch.train(model, optimizer, data, target)\nprint(\"Training step completed.\")","lang":"python","description":"Initialize Monarch with a config, then train a simple linear model."},"warnings":[{"fix":"Update code to pass `num_gpus=torch.cuda.device_count()` (or an integer) to `MonarchConfig`.","message":"The API changed significantly from v0.4.x to v0.5.0. `MonarchConfig` now requires explicit `num_gpus` instead of inferring from CUDA_VISIBLE_DEVICES.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Replace `monarch.run(...)` with `monarch.train(...)`.","message":"The old `run` method has been renamed to `train` in v0.5.0.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Install PyTorch with CUDA support and ensure NCCL is installed.","message":"Monarch requires NCCL backend for multi-GPU training. If NCCL is not available, it will fall back to Gloo silently, which may cause performance issues.","severity":"gotcha","affected_versions":"all"},{"fix":"Create the directory beforehand: `import os; os.makedirs(config.checkpoint_dir, exist_ok=True)`.","message":"The `checkpoint_dir` in `MonarchConfig` must exist before training; Monarch does not create it automatically.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.5.0':39 '3.10':43 'activ':47 'central':13 'checkpoint':32 'communic':31 'control':7 'current':36 'develop':48 'distribut':17,50 'distributed-train':49 'fault':34 'gpu':23 'layer':15 'librari':8 'manag':30 'monarch':1,2,53 'multi':22,26 'multi-gpu':21 'multi-nod':25 'node':27 'orchestr':14 'provid':11 'python':42 'pytorch':10,52 'requir':41 'simplifi':20 'singl':6 'single-control':5 'toler':35 'train':18,28,51 'version':38","created_at":"2026-06-07T13:00:56.882722+00:00","updated_at":"2026-06-07T13:00:56.882722+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nModuleNotFoundError: No module named 'torchmonarch'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/meta-pytorch/monarch","github":"https://github.com/meta-pytorch/monarch","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}