Skip to content
HN On Hacker News ↗

Bringing PyTorch Monarch to AMD GPUs: Single-Controller Distributed Training on ROCm – PyTorch

▲ 81 points 7 comments by gmays 4w ago HN discussion ↗

Pangram verdict · v3.3

We believe that this document is primarily human-written, with some AI-generated content detected

25 %

AI likelihood · overall

Mixed
83% human-written 17% AI-generated
SEGMENTS · HUMAN 3 of 4
SEGMENTS · AI 1 of 4
WORD COUNT 1,242
PEAK AI % 88% · §1
Analyzed
Jul 25
backend: pangram/v3.3
Segments scanned
4 windows
avg 311 words each
Distribution
83 / 17%
human / AI fraction
Verdict
Mixed
Pangram v3.3

Article text · 1,242 words · 4 segments analyzed

Human AI-generated
§1 AI · 88%

Featured projects

Training state-of-the-art large language models (LLMs) with billions of parameters requires distributed training across hundreds or thousands of GPUs. At this scale, hardware failures are not exceptional events—they are expected. A single GPU memory error, network partition, or node crash can bring down an entire training run that has been progressing for days or weeks. While our previous work demonstrated near-linear scaling of FP8 training at scale (achieving 96.16% scaling efficiency on a 1024-GPU MI325 cluster with DeepSeekV3-671B), the key challenge remains: reliability at scale. To address these challenges, we have brought PyTorch Monarch to AMD Instinct GPUs with ROCm, expanding the single-controller model beyond CUDA environments and bringing this emerging runtime to a broader hardware ecosystem. In this blog, we will explore the architecture of PyTorch Monarch, walk through the engineering effort required to port Monarch’s GPU runtime and distributed communication stack to ROCm, and demonstrate how the system dynamically recovers from node failures without halting the entire training job. By the end, you will understand how Monarch enables elastic, fault-tolerant distributed training on AMD GPUs and why this represents a significant step toward stable, large-scale AI infrastructure. The Challenge: Reliability at Scale Traditional fault-tolerance strategies rely heavily on periodic checkpointing: saving the full model state to persistent storage at regular intervals. When a failure occurs, the entire job restarts from the last checkpoint. While conceptually simple, this approach has significant drawbacks.

Challenge Impact

Checkpoint overhead Writing hundreds of gigabytes of model state to storage consumes time and I/O bandwidth.

Wasted computation All progress since the last checkpoint is lost upon failure.

Cluster idle time The entire cluster sits idle while the failed node is replaced and the job restarts.

Scalability limits As cluster size grows, the probability of failure during any checkpoint interval increases.

§2 Human · 10%

For truly large-scale training, scaling is not enough—training must also recover from failures. We need a more dynamic approach, one that allows healthy nodes to continue training while failed nodes recover and rejoin, minimizing wasted computation and maximizing GPU utilization. This is where PyTorch Monarch comes in. What is PyTorch Monarch? PyTorch Monarch introduces a new distributed programming paradigm that enables developers to orchestrate entire GPU clusters from a single Python program. With its actor-based runtime, process mesh abstraction, and asynchronous execution model, Monarch simplifies large-scale distributed training and enables complex workflows that combine training, evaluation, and reinforcement learning within one unified script. The architecture operates at multiple distinct levels:

Python API: A single-program interface where developers write simple Python code to get distributed GPU execution. Monarch Runtime: Manages actors and meshes, supervision trees, and tensor sharding. Rust Runtime (Tokio): Ensures high performance and memory safety. Infrastructure: Integrates with RDMA, RCCL/NCCL, SLURM, Kubernetes, and SkyPilot.

Figure 1: PyTorch Monarch architecture decoupling Python API from the Rust runtime and infrastructure. By decoupling the parallelism strategy used within each training replica from the fault-tolerance mechanism used across replicas, Monarch provides a cleaner fault-tolerance model. Failures are isolated (actors have private state, crashes do not propagate), hierarchical (handled at the lowest possible level), and recovery is fast (seconds for local restart, minutes only if escalated).

Figure 2: Monarch’s hierarchical fault-handling model and supervision tree. Porting Monarch to ROCm: Ecosystem Integration Bringing Monarch to AMD GPUs required significant engineering effort to port the GPU runtime and distributed communication stack to ROCm. We successfully implemented three main porting paths:

Collective Communications: We used hipify_torch to convert the C++ bridge code from CUDA to HIP and linked against RCCL, which mirrors NCCL’s API. GPU Memory Management: We extended the build system to auto-detect the platform and route CUDA driver API calls through their HIP equivalents. RDMA Integration: Configuring GPU_PLATFORM=rocm keeps the libibverbs-based RDMA path intact while swapping the GPU-side bindings from CUDA to HIP for GPU-direct transfers.

§3 Human · 7%

Figure 3: Porting Monarch from CUDA to ROCm via hipify_torch and auto-detection. Moreover, two cross-cutting issues shaped the port and deserve a closer look:

No static link for the HIP runtime: NVIDIA ships libcudart_static.a, so the CUDA path links cudart_static directly. ROCm ships no static equivalent for libamdhip64, so the ROCm build links amdhip64 dynamically. Both platforms additionally dlopen the GPU driver API functions, including hipMemCreate, cuMemCreate, and related calls, keeping the runtime contract identical on either side. Rust compatibility shim instead of forking the bindings: Once hipify_torch rewrites the C/C++ headers, bindgen emits HIP-named types such as hipError_t, hipDeviceptr_t, and hipStream_t. Rather than add #ifdef branches at every Rust call site, we added a rocm_compat module in nccl-sys and rdmaxcel-sys that re-exports HIP symbols under their CUDA names, for example pub type cudaError_t = hipError_t and pub use hipSetDevice as cudaSetDevice. The rest of the Rust code stays platform-agnostic.

These efforts culminated in the introduction of HIP type aliases in Rust, with all 1,171 tests passing, ensuring full support for ROCm 7.0+. We have upstreamed these contributions to the open-source community (see PR #2393 and PR #2891). Today, Monarch on ROCm provides full ecosystem support, including the Actor runtime, RDMA, Supervision, and Tensor sharding. It runs seamlessly on SLURM (HPC), Kubernetes (Cloud native), and SkyPilot (Multi-cloud), enabling downstream engines like TorchTitan (Training engine) and TorchFT (Fault tolerance) for production workloads. Case Study: Fault-Tolerant Training at Scale To demonstrate the power of Monarch on AMD GPUs, we integrated it with TorchTitan and TorchFT to build a resilient, checkpoint-less distributed training architecture. Architecture Overview The architecture consists of three layers:

Monarch: Acts as the orchestrator, managing process and cluster orchestration. It spawns ReplicaActors and a Lighthouse service, organizing GPUs into Process Meshes.

§4 Human · 16%

TorchFT: Handles fault tolerance at the step level. It contacts the Lighthouse for quorum coordination, performs Quorum AllReduce, and skips failed nodes. TorchTitan: Serves as the training engine, executing the Forward (FSDP), Backward, and Optimizer steps, while managing checkpoints and metrics.

Figure 4: The resilient training stack on AMD GPUs integrating Monarch, TorchFT, and TorchTitan. In this setup, Monarch provides a supervision tree for fine-grained fault detection and isolation. When a failure is injected into the training actors, it is detected by the Lighthouse and handled by TorchFT. The healthy replicas continue training independently despite peer failures, without requiring a global interruption. Dynamic Fault Recovery Workflow Let us walk through a concrete scenario with four replica groups to understand the recovery workflow.

Normal Training: The OrchestrationManager spawns 4 ReplicaActors (Monarch Supervisors) and a Lighthouse. Each ReplicaActor spawns a Replica with 8 GPU processes running TorchTitan trainers. All 4 replicas are ready (quorum_id=1) and DiLoCo gradient synchronization occurs every 20 steps. Failure Detection: A GPU process in Replica 0 crashes. The Monarch supervisor captures the report_training_error (with full traceback) before the process dies. Replicas 1, 2, and 3 are marked as unaffected and continue training. Local Restart: ReplicaActor 0 initiates an in-place restart (_stop_and_restart()), stopping the old process mesh and spawning a new one. Meanwhile, the other 3 replicas continue syncing (quorum_id=2)  Peer Checkpoint Transfer: The Lighthouse selects Replica 1 as the donor. A peer checkpoint transfer (model, optimizer, scheduler, and trainer state) is initiated from Replica 1 to the recovering Replica 0. All replicas pause briefly at the quorum boundary while the new quorum forms. Resumed Training: Once Replica 0 is synced, the new quorum (quorum_id=3) is established with all 4 replicas, and DiLoCo synchronization resumes.

Figure 5: Dynamic fault recovery workflow demonstrating peer checkpoint transfer without global checkpoint reload. The entire recovery process completes without any manual intervention, without full checkpoint restarts, and with minimal disruption to the overall training throughput.