Field note / PyTorch performance

ROCm · TorchTitan · distributed training

Performance is a systems property.

Recent PyTorch work on ROCm shows why an AI workload cannot be reduced to a GEMM benchmark. Useful performance comes from matching precision, kernels, memory traffic, collective communication, and recovery behaviour to the workload that actually runs.

Performance work on ROCm is no longer just about getting a model to run on an AMD GPU. The useful question is more specific: which part of this workload is limiting progress? For one job it is matrix-multiply throughput; for another it is a chain of small kernels moving intermediate tensors through HBM. For an MoE model it may be token routing and All-to-All communication. At scale, it may be whether a node failure discards useful work.

01 / Let the workload choose the bottleneck

Dense and sparse models need different performance stories.

Dense transformers and sparse Mixture-of-Experts models can both use FP8, but they do not accelerate for the same reasons. In a dense transformer, large GEMMs are often the primary opportunity. The upstream TorchAO and TorchTitan FP8 study reports a 13.4% throughput gain over BF16 for Llama 3 8B on eight MI300X GPUs, using torch.compile, FSDP2, and selective activation checkpointing. Peak memory remained near 39 GB, so the reported win was faster FP8 matrix-core execution—not simply making room for a larger model.

MoE changes the shape of the problem. A router sends each token to only a few experts, creating irregular and often small expert batches. The system must now contend with micro-GEMMs that may not saturate a GPU, tokens moving to remote expert owners, and idle bubbles where FSDP, pipeline, tensor, and expert parallelism do not line up.

A workload is performant only when its math, memory, network, compiler, and operating model agree on the bottleneck.

The 1,024-GPU TorchTitan MoE study makes that interaction concrete. Its DeepSeek-V3 and Llama 4 experiments pair FSDP, pipeline parallelism, and expert parallelism with ROCm-tuned kernels. The authors report a 2.77× end-to-end improvement for DeepSeek-V3 671B from kernel-level optimization and 96% scaling efficiency from 128 to 1,024 MI325X GPUs in their measured environment. Those numbers are engineering evidence, not universal platform promises: the study used 400 Gb/s RoCE v2 and a full-bisection fat-tree topology. Change the model, fabric, routing distribution, or software revision and the bottleneck can move.

02 / Look beyond the GEMM

Most of an MoE win can live in the work surrounding arithmetic.

The most useful result from the FP8 work is that quantization overhead can dominate the supposedly faster low-precision path. Before optimization, a DeepSeek-V3-shaped workflow computed scales, applied them, clamped values, and cast data in separate kernels. Each stage wrote an intermediate value to HBM before the next one read it back. Across many experts, the surrounding launches and movement cost more than the 8-bit arithmetic they were meant to prepare.

  1. Eliminate redundant layout work.Removing an unnecessary transpose and copy before GEMM produced a 4.2× backward-pass improvement on the studied DeepSeek-MoE-16B shape.
  2. Fuse the preparation path.Fusing scale-and-cast operations into Triton kernels recovered 89% of FP8 overhead and delivered a reported 17% end-to-end gain for the measured DeepSeek-V3 671B case.
  3. Write data cooperatively.Using local data share to transpose before storage improved the per-MoE-layer scale kernel by 6.2× on the reported DeepSeek-V3 shapes.
  4. Autotune with a hypothesis.Expanding a Triton search space for Llama 4 shapes on MI300X did not yield a measurable gain and increased first-iteration compilation time.

The practical rule is simple: before tuning a GEMM, inspect how much data is being moved to prepare for it. A trace with a small computation surrounded by scale, cast, copy, and synchronization kernels is an invitation to fuse or remove work—not merely to add more arithmetic tuning.

Recent PyTorch releases extend this work beyond FP8. PyTorch 2.12 added expandable ROCm allocator segments, rocSHMEM support for symmetric-memory collective operations, and ROCm improvements to FlexAttention. PyTorch 2.14 adds ROCm grouped-GEMM lowering, Composable Kernel templates under JIT compilation, and an analytical tile-size selector for ROCm max-autotune. Together, these features help irregular expert work avoid an inefficient loop of isolated BLAS calls.

03 / Protect correctness

Performance figures are only useful when the training result is trustworthy.

FP8 exposes a failure mode that ordinary throughput charts can hide. AMD Instinct uses an FNUZ FP8 variant whose range differs from a format initially assumed in parts of the training stack. Selecting the wrong maximum value silently clipped activations and corrupted gradients without producing a NaN signal. The upstream solution was platform detection, the appropriate dtype and scale selection, accurate MFU reporting, and hardware-appropriate loss baselines—not a single performance flag.

That is the discipline worth keeping for any PyTorch workload: measure tokens per second, latency, memory, and compile time while validating loss, numerical parity, and convergence. Save the exact GPU, ROCm, PyTorch, compiler, model, sequence length, batch shape, and parallelism configuration with every result. A faster run that changes model quality is not a faster training system.

04 / Profile the right layer

Start from the workload, then descend to the kernel.

A model operation can look slow because its kernel is slow, because data was not ready, because a collective held the stream, or because the host waited to launch the next unit of work. ROCm's documentation supports a layered investigation rather than beginning with a long list of low-level counters.

  1. Trace the application first.Use PyTorch Profiler or ROCm tracing to locate long kernels, memory copies, GPU idle time, and host-side gaps.
  2. Attribute framework work to kernels.ROCm Compute Profiler's experimental --torch-trace mode connects PyTorch operations, GPU kernels, and counters.
  3. Collect counters to test a hypothesis.After locating a hot kernel, select occupancy, cache, memory-traffic, or instruction counters that answer one specific question.
  4. Measure communication independently.A clean kernel trace does not prove that a distributed step is healthy; inspect its critical collective and overlap as well.
rocprof-compute profile --experimental --torch-trace \
  --name workload -- python train.py

That command is a diagnostic tool, not a benchmark harness. Instrumentation changes timing, and ROCm describes this tracing mode as experimental. Coverage also depends on the supported PyTorch version: newer integrations provide fuller operator traces, while older ones can omit backward-pass operations created in child threads. Keep a non-instrumented steady-state measurement beside the trace, and record the installed PyTorch and ROCm package combination before comparing results.

05 / Design for the network

The collective library and topology are part of the model architecture.

At multi-GPU scale, it is not enough for an AllReduce or All-to-All to work. The process layout, memory mode, network, and library version must let the collective overlap useful work. RCCL is ROCm's communication library for multi-GPU and multi-node collectives across AMD GPU paths such as PCIe and xGMI; its guidance is deliberately version- and hardware-aware.

In the TorchTitan study, increasing the expert-parallel degree caused baseline communication share to grow and tokens per second to fall. The DeepEP communication path kept communication to a substantially smaller portion of the step for that cluster and model configuration. This does not mean a library alone solves MoE. It shows that token routing, expert placement, network bandwidth, and communication scheduling must be designed together.

One RCCL usage-tips example reports roughly 315 GB/s for an optimized single-OAM MI300X AllReduce configuration versus roughly 170 GB/s for its default configuration. That is a useful diagnostic reference, not an application-throughput promise: topology, collective size, software version, and configuration all matter. The safest approach is to test a prospective setting against the real message sizes, number of ranks, and fabric used in production—and retain the baseline that proves it helped.

06 / Make recovery performance

Useful throughput includes the time saved after a failure.

At hundreds of GPUs, a memory error, failed node, or network partition is an operating condition, not an exceptional thought experiment. The Monarch-on-ROCm work connects performance to this reality by combining a single-controller runtime, RCCL, RDMA, TorchTitan, and TorchFT across SLURM, Kubernetes, and SkyPilot.

When an actor fails, a supervision tree isolates it, healthy replicas keep progressing, the failed unit is restarted, and a peer can provide the state needed to rejoin at a quorum boundary. The published validation includes fault injection on a 16-node MI300 cluster and a 32-node MI355 Kubernetes cluster. The reported loss curves continued to converge while workers recovered rather than requiring a full-job restart. A system that spends less time idle after a fault delivers more useful training even when its nominal kernel benchmark is unchanged.

07 / Run a durable plan

Make performance evidence survive contact with production.

  1. Describe the workload.Record the model family, precision, sequence-length distribution, batch shape, GPU topology, interconnect, and parallelism plan. Keep dense, attention-heavy, and MoE paths distinct.
  2. Establish a reproducible baseline.Measure eager and compiled runs using the same inputs. Capture steady-state throughput, first-iteration compile cost, peak memory, and a correctness signal.
  3. Profile by category.Break time into GEMM, attention, quantization, allocator activity, host waits, collectives, and communication-compute overlap.
  4. Apply the smallest fitting lever.Fuse quantization work, reduce HBM round-trips, use grouped GEMM for MoE, tune communication overlap, or address fragmentation only when the trace supports it.
  5. Test representative shapes.A single maximum-throughput shape can hide decode latency, dynamic batches, skewed routing, long-context attention, and different collective sizes.
  6. Keep the evidence.Save the trace, recipe, environment, and pass/fail threshold alongside the change. Otherwise the next ROCm, PyTorch, or cluster upgrade turns the investigation back into guesswork.

This is also a useful CI boundary. Correctness CI should protect builds, APIs, numerical behaviour, and representative small workloads. Performance regression tracking needs controlled hardware, pinned configurations, warm-up rules, and noise-aware thresholds. Mixing the two into one undifferentiated pass makes both signals less trustworthy.

Sources and further reading

Use the original measurements and versioned guidance.

The findings above are intentionally scoped to the models, hardware, and software versions in the source material. Use the official PyTorch studies for their benchmark conditions and ROCm documentation for the current hardware- and release-specific operating guidance.