To benchmark mixture-of-experts (MoE) training on Ironwood (TPU7x), Google Cloud's seventh-generation TPU, we ran DeepSeek-V3 671B pretraining across 2,048, 4,096, and 8,192 chips achieving 4,997, 4,790, and 3,689 tokens/sec/chip and an effective model FLOPs utilization (EMFU) of 57%, 55%, and 45%, respectively.
This post builds on Part 1, which showed that Ironwood can scale DeepSeek-V3 training to 8,192 chips connected entirely by ICI, and laid the groundwork with FP8 quantization and custom kernels. However, as we scaled from 2k to 8k chips, each device processed fewer sequences per step, so the TensorCores often sat idle during ICI communication and per-chip throughput dropped.
In this post, we show how we eliminated those stalls by fully utilizing Ironwood's ICI while pushing memory and compute efficiency even further. First, we introduce batch-split scheduling, which keeps ICI links saturated and hides both token and weight communication under compute even at 8,192 chips. With communication no longer stalling the chip, we turn to memory and compute efficiency. We cut high-bandwidth memory (HBM) usage by sizing ragged MoE activation buffers for the tokens that actually exist, and we eliminate wasted HBM traffic, such as unpacking low-precision tokens and relayout copies, so that HBM bandwidth goes to useful work. Finally, we push our custom kernels further by fusing data movement and quantization directly into the grouped matmul (GMM) and attention kernels to keep the TensorCores running at peak efficiency.
The post wraps up with our takeaways for anyone pretraining a large MoE model on TPUs. Without further ado, let's dive in!
Speeding up end-to-end pretraining means pushing strong scaling as far as possible. The global batch is fixed, so adding chips divides the same work more finely (Figure 1). Each chip however still needs to do almost the same amount of communication, even though compute is decreasing. This communication is hardest to hide at 8,192 chips, where each device processes a per-device batch size (PDBS) of just one sequence per step in our benchmark.
Two kinds of communication have to overlap with that shrinking amount of compute per device:
The problem is that reducing one kind of communication increases the other. If we increase the EP degree, the experts are spread over more devices, so each device has fewer weights to all-gather, but the tokens then have to travel across a larger group of devices. On Ironwood's 3D torus, that traffic takes multi-hop paths around a ring, so its cost grows with the size of the EP group. This means that at 8,192 chips, there is no EP degree that hides both kinds of communication without batch-split scheduling (Figure 2). If we use low EP, the weight all-gather for the next layer takes longer than the current layer's compute. If we use high EP, the weight all-gather fits, but dispatch and combine can no longer be overlapped under expert computation, which is typically how they are hidden.
Since we need high EP to make the weight communication fit under each layer's computation, we need a way to hide token communication under more than just expert computation. Batch-split scheduling is how we do this.
We can simplify an MoE layer to four main stages: attention, token dispatch, expert computation, and token combine. These four stages form one dependency chain, where each stage needs the previous stage's output. The layer weights also need to be all-gathered at some point before being used in the layer. We build the batch-split schedule up from these parts one step at a time.
Start with a single sequence per device and no pipelining (Figure 3), where each layer all-gathers its weights right before they are needed. The TensorCore sits idle while waiting for either the weights to be all-gathered or the tokens to be communicated (or both!). Thus, neither the TensorCore nor the SparseCores, which handle the token and weight communication over ICI, are well utilized.
Pipeline the weight all-gathers across layers (Figure 4). Because the weights are known at the beginning of the training step, we can prefetch the next layer's weights on SparseCore 1 while the current layer runs. Weight communication now finishes completely under the layer's computation, removing all weight stalls from the critical path. The TensorCore now only waits for token dispatch and combine.
Split each device's batch into two microbatches, each half the size (half a sequence at PDBS 1; see "Final sharding scheme" for how attention handles this), and run them one after the other (Figure 5). Every stage is now half as long, but each microbatch still waits for its own tokens, so the layer takes as long as before. What the split gives us is two chains that do not depend on each other.
Interleave the two microbatches, offset by one stage (Figure 6). While microbatch 0's tokens are being dispatched, the TensorCore runs microbatch 1's attention. While microbatch 1's tokens are dispatched, it runs microbatch 0's experts, and microbatch 0's results are combined while microbatch 1's experts run. Each of those transfers now has a full stage of the other microbatch's compute to hide under. Only microbatch 1's combine is left exposed, because the layer has no compute left to run.
Shift the next layer's microbatch 0 (MB0) attention to execute at the end of the current layer during microbatch 1 (MB1) combine (Figure 7) to eliminate all TensorCore idle time! Now, every token transfer is hidden, and we get full utilization of both the TensorCore and the SparseCores. The next layer's attention weights are now needed before the rest of its weights, so we all-gather them first.
Figure 8 summarizes the four steps by putting them on the same time axis. Without batch-split scheduling, the TensorCore and both SparseCores sit idle for part of every layer. In the last step, which is the full batch-split schedule, all three are busy the whole time, and the same layer finishes much sooner. The backward pass uses a similar pattern in reverse, along with reduce-scattering the weight gradients in a pipelined fashion to fully hide weight communication.
Because token communication can now hide under the whole layer with batch-split scheduling, we can afford a higher EP degree at PDBS 1. The final sharding scheme on Ironwood's 3D torus (X×Y×Z) is therefore (Figure 9):
At PDBS 1 there is only one sequence to split into two microbatches for batch-split scheduling on each device, so each microbatch is half a sequence. Because batch-split scheduling requires both microbatches to be independent, they must come from different sequences, so each device actually processes two half-sequences rather than one full sequence.
Because attention needs a whole sequence, we need to shard the attention phase by at least two. We chose to shard attention heads across the two chiplets of each chip, all-gather the compressed attention latents over the D2D link, and split the work by attention head: each chiplet computes 64 of the 128 heads. The D2D link is extremely fast, so this incurs minimal overhead.
XLA schedules a program for good general-case performance, but it has no notion of two microbatches that must interleave, so we had to enforce this schedule ourselves. To implement the batch-split schedule in JAX and XLA, we had four main problems to solve.
First, we need to stagger the two microbatches and ensure XLA does not fuse the computation of the two microbatches back together. We split each layer's forward pass into eight phases and place optimization barriers between them. XLA must keep the phases in the order we chose but is free to schedule and fuse within each one (Figure 10).
You will notice four of the phases (1, 3, 6, and 8) are small and do not overlap between microbatches. We did this simply to make scheduling easier, and it has little performance impact since they are so small.
Each Ironwood chiplet has one TensorCore and two SparseCores, and each SparseCore runs its collectives one at a time. If token and weight collectives shared a SparseCore, each would queue behind the other. We pin every collective to a single SparseCore in JAX, so token collectives over the EP axes run on SparseCore 0 and FSDP weight collectives run on SparseCore 1.
We have described above the need to prefetch weights in the previous layer for use in the current layer and how we also pipeline the gradient reduce-scatters in the backward pass. We implemented this using a hand-written pipelined scan over the 58 MoE layers. Each layer not only does its computation, but it also explicitly all-gathers the weights for the next layer and passes them through the scan carry. We use a custom VJP in JAX to do the same in the backward pass along with the gradient reduce-scatter pipelining.
Our pipelined scan exposed a subtle cost: with one layer per scan step, the scan carry holds the current weights in buffer A while the next layer's weights are gathered into buffer B, and the compiler must copy B into A at every step boundary. Running two layers per scan step lets A and B swap roles (a technique called double buffering), so no copy is needed.
Phases fix the order of the stages in each layer, but inside each phase XLA still decides where each asynchronous collective starts and where the program waits for it. It often started them later than necessary and waited earlier than necessary, which left communication that should have been hidden partly exposed.
To solve this, we used a custom XLA post-scheduler transform, which is a custom compiler pass, registered from JAX, that runs right after XLA's scheduler (no changes to XLA needed!). Our pass reorders instructions and nothing else, so it cannot change the numerics. It does two primary things:
After the pass, the next layer's weight gathers start at the very beginning of each layer and finish at its end, and each token collective covers exactly the compute it was meant to hide under!
With communication hidden, step time was now determined by what each TensorCore does, and there were three primary remaining bottlenecks. The first was HBM capacity, which decides whether the backward pass can reuse saved activations or has to recompute them. The second was HBM bandwidth, much of which was going to padding, relayout copies, and token unpacking instead of useful work. The third was TensorCore time, which was often spent in data movement around the matmuls.
HBM capacity matters in pretraining because we need to store not only weights, gradients, and optimizer state, but also the intermediate activations from the forward pass that the backward pass needs for backpropagation. If these activations fit in HBM, we save them and reuse them. If they do not, we have to rematerialize them by re-running part of the forward pass during the backward pass.
Using EP for dropless MoE models like DeepSeek-V3 requires large ragged activation buffers to store and process the worst-case number of tokens routed to experts that live on each device. For example, at EP=16, each ragged token buffer on each device is sized to 16× the average token load, in case all tokens are routed to the experts that live only on a single device. Saving these large padded buffers across all layers for use in the backward pass simply occupied too much HBM. We used two optimizations to decrease HBM usage while remaining dropless (Figure 13):
Gathering tokens to prepare them for efficient expert matmuls (and scattering them after) is surprisingly expensive if not done carefully. Normally, tokens are stored as a 2D [B, D] array, so one (8, 128) tile holds slices of eight different tokens. When the token is in BF16 or FP8, a single tile holds even more tokens due to packing. Therefore, moving a single token takes strided memory operations and relayouts, which uses HBM bandwidth poorly.
Storing tokens as [B, D/128, 128] makes each token a contiguous run of whole tiles, and moving it becomes a single direct memory access (DMA) operation (Figure 14). Almost everything the MoE layer does to tokens moves them individually, so this optimization greatly improves HBM bandwidth utilization. This also removes the need to use the SparseCores for token gathering and scattering. SparseCores can move much smaller packets of data at a time, which makes strided memory operations less costly, but they have less HBM bandwidth than the TensorCore and are already fully occupied with ICI communication. With whole-tile tokens, it is much more efficient for us to run the token gathers and scatters on the TensorCore.
Two smaller changes removed the rest of the wasted traffic:
The last bottleneck was TensorCore time. Around each matmul, there were gathers, scatters, and quantization steps, and each one was a round trip through HBM. Fusing them into the kernels keeps the data closer to the TensorCore and reduces TensorCore stalls.
Fused expert kernels. After moving the token gathers and scatters from SparseCore to TensorCore, we could fuse them into the matmul kernels themselves (Figure 15). The first GMM gathers its input rows straight from the dispatched tokens, then applies SwiGLU, the routing weight, and FP8 quantization before writing into the activation bank. The second performs the top-k scatter-add as it writes its output. The permuted token buffer never exists in HBM: token gather and scatter latency nearly disappears, and the matmuls barely slow down.
Attention. DeepSeek-V3's multi-head latent attention (MLA) uses different head sizes for queries and keys (192) than for values (128), which forced non-square tiles in splash attention and disabled the causal diagonal skipping that Part 1 describes. We extended diagonal skipping to non-square tiles and made the backward pass accumulate query gradients on-chip and skip masked work. We also replaced the query, key, and value up-projections with fused kernels that normalize, quantize to FP8, and apply rotary embeddings in on-chip memory, writing their outputs directly in the layout that splash attention consumes, so no transposes are needed.
In this post, we showed how we pushed DeepSeek-V3 pretraining on Ironwood toward peak performance, even at 8,192 chips where each device processes just one sequence per step. We started with batch-split scheduling, which interleaves two microbatches so that the token communication of one microbatch overlaps with the compute of the other, and prefetches each layer's weights in the previous layer so that weight communication is hidden as well. This allowed us to use a higher EP degree of 16 and to keep token and weight traffic on separate ICI links and separate SparseCores. To implement the schedule, we used phase ordering, core assignment, FSDP pipelining, and a custom XLA post-scheduler transform to maximize overlap. With communication hidden, we then optimized the three remaining bottlenecks: HBM capacity, HBM bandwidth, and TensorCore time.
Altogether, these optimizations allowed our DeepSeek-V3 671B benchmark runs to reach target quality on 2,048, 4,096, and 8,192 Ironwood chips at 4,997, 4,790, and 3,689 tokens/sec/chip and an EMFU of 57%, 55%, and 45%, with every run inside a single ICI domain.
Here are our main takeaways for anyone pretraining a large MoE model on TPUs:
The implementation of all of these techniques described in this post for the DeepSeek-V3 benchmark can be found in MaxText.
This work was a collaboration across many engineering and program teams. This post builds directly on the work described in Part 1, which provided the DeepSeek-V3 training recipe, the FP8 recipe, and the infrastructure that the batch-split schedule plugged into. We would like to thank the following core contributors:
Kevin Wang, Jesse Lu, Caitlin Stanton, Daniel Mandragona, Ran Ran, Matt Davidow, Nuojin Cheng, Shuning Jin, Suraj Kolla, Zhengxian He, Shuwen Fang, Snehal Verma, Amanda Tomlinson, Burkay Donderici, Mohamed Omar, Vipul Aneja, Cory Kleinheksel, Xiongfei Wei, Ani Udipi, Vaibhav Singh, Jet Jiang, Andi Gavrilescu, Durlabh Malik, Deepak Patil, Carlos Araya
We also thank the JAX, XLA, Tokamax, and TPU Performance teams who worked closely with us.