Part IV Train at scale¶
The big grid is one slice: every chip talks to its neighbours over ICI, and the arcs close each row and column into a ring. The small grid on the left is a second slice, reachable only through the hosts over the far slower data-center network. Part IV is about deciding which traffic travels on which of those two kinds of line.
Part III ended with a model that is profiled, optimized and, where it paid, given a custom kernel, all on one TPU device. Part IV spreads that model across many devices. You will learn how PyTorch describes a tensor that lives on several devices, which collective operations move its pieces, what each one costs on a TPU's interconnect, and how to lay out a device mesh so that heavy traffic stays on fast links. Then you will apply that to real training: fully sharded data parallelism with TorchTitan, reinforcement learning with Ray, and a case study of a 30B model trained on Ironwood.
TorchTPU keeps the PyTorch programming model for all of this. You start one process per TPU device, initialize torch.distributed with the "tpu_dist" backend, and use the same DeviceMesh, DTensor, DDP and FSDP code you would use on GPUs. What changes is underneath: there is no NCCL, every collective is compiled by XLA into the TPU program, and the physical layout of the chips decides what a collective costs. Each chapter in this Part ends with a measured check that the scaled-out program does what the cost model says it should.
The chapters¶
| Chapter | Summary | Reading time (min) |
|---|---|---|
| 13. Sharding, meshes and collectives | How a tensor is split across devices, which collectives move it, what each costs on ICI and DCN, and how to lay out the mesh. | 35 |
| 14. FSDP and TorchTitan on TPU | Sharding a model's parameters, gradients and optimizer state across devices so that communication overlaps compute. | 40 |
| 15. Reinforcement learning with Ray | Running a GRPO loop, with rollouts, rewards and policy updates, as Ray actors on TPU devices. | 30 |
| 16. Case study: Muse Glimmer 30B training | A real 30B training run on Ironwood, and how good its measured throughput is. | 30 |
Read end to end, Part IV takes about two and a quarter hours, plus the time to run the examples on a slice.
What links them¶
Chapter 13 gives the vocabulary and the arithmetic for the rest of the Part. A DeviceMesh names the devices along logical axes such as dp and tp; a DTensor placement (Shard, Replicate, Partial) says how a tensor sits on each axis; and moving between placements costs one of four collectives: all-gather, reduce-scatter, all-reduce or all-to-all. The chapter derives the ring cost of each from the interconnect numbers of chapter 1, shows how TorchTPU lowers a torch.distributed call into the compiled program, and explains why the order of mesh dimensions decides whether a collective runs on ICI or crosses DCN.
Chapter 14 applies those collectives to the most common training layout. FSDP is an all-gather of each layer's weights before use and a reduce-scatter of its gradients after, so chapter 13's costs tell you when it is communication-bound. TorchTPU's FSDP guide recommends SimpleFSDP, which keeps the collectives inside one compiled training step where XLA can overlap them with the matmuls, and TorchTitan provides the trainer around it.
Chapter 15 changes the shape of the program, not the parallelism. Reinforcement learning alternates generation, scoring and policy updates. Ray schedules one worker per TPU device, each requesting resources={"TPU": 1} and joining a "tpu_dist" process group, so the training side reuses chapter 14 while Ray coordinates the loop.
Chapter 16 studies a complete run. The Muse Glimmer 30B training example shards a full model with FSDP on one Ironwood host and reports its throughput. The chapter takes the run apart with the tools of chapters 13 and 14 and compares its numbers with the hardware's peak.
Chapter 13 is a prerequisite of every other chapter in this Part, so its arrows to 15 and 16 share one line. Chapters 15 and 16 both build on 13 and 14 and not on each other: read them in either order.
Chapter 13 builds on the ICI and DCN numbers of chapter 1, the roofline reasoning of chapter 2 and the XProf reading of chapter 10, which it uses to check collective times against the ring model. It also points to the tolerances of chapter 6 for sharded parity, but you can follow it without that chapter. Chapters 15 and 16 both build on chapter 14 and can be read in either order.
What this Part covers¶
- What each device holds under a DeviceMesh and a DTensor placement, which collective a redistribution issues, and how long it should take on ICI or DCN by the ring cost model.
- Multi-process TorchTPU jobs with the
"tpu_dist"backend, topology-aware meshes whose most communication-heavy dimension is innermost, and traces that show the collectives taking about as long as the model predicts. - FSDP training on a TPU slice, with loss and memory checked against an unsharded reference and the step classified as limited by compute or by communication.
- A GRPO loop with Ray actors on TPU devices, and where its weights move between steps.
- Recomputing a published training run's throughput and utilization from its reported numbers, and what limits it.
Part V turns from training to serving: the arithmetic of prefill and decode, vLLM and SGLang on TorchTPU, and llm-d on GKE.

