Skip to content

Part IV: Where to Start, Diagnostics, and ~100B Blueprint


Which principles are most beneficial

Start every project with the quality-safe foundation: 256-aligned per-device dimensions (Principle 1), static shapes with SMEM scalar-prefetch dropless routing (Principle 3), one parallelism plan mapped onto physical links (Principles 2 and 10), wall-clock ablations on a tuned baseline (Appendix A.6), and published reference targets to judge the result (Appendix A.8). Together these cover the largest measured efficiency gaps with near-zero model-quality risk.

For any MoE architecture, add LatentMoE (Principle 4) after a validation ablation: it cuts the routing and dispatch traffic that dominates MoE training steps and shrinks the expert weight reads that bound low-batch decode. Beyond that foundation, prioritize by bottleneck regime:

Bottleneck regime Reach first for Why
High expert count (> 100 experts) Principles 4, 5, 9, 10 Routing and dispatch dominate step time: compress the routed token path (LatentMoE + FP8 dispatch), pair every LatentMoE layer with a large shared expert, trade excessive (N, K) fragmentation for wider d_ff so each dispatched byte feeds a larger expert GEMM, offload dispatch sorts/gathers to SparseCore, and keep EP on one short torus axis.
Long context (> 64K) Principles 7, 11 (App. A.3), 1, 10, 13 Quadratic attention FLOPs and activation memory dominate: hybrid local/global or linear attention is the primary structural lever and selective rematerialization is second; head_dim = 256 gains widen sharply with sequence length, load-balanced CP governs exposed collectives, and multi-pass BF16 accelerates BF16-sensitive attention on supported hardware.
Multi-pod scale (> ~100B) Principles 2, 10, 4, 6, 8, 12 Inter-chip and cross-pod communication become the binding constraint: restrict DCN to DP or PP, verify EP viability via roofline arithmetic, bake in range-bounded block-scaled FP8 as matmul share rises, and size serving concurrency and disaggregation upfront rather than retrofitting them.
Latency & goodput serving Principles 8, 12, 10, App. A.4, App. A.7, 7 At low concurrency, decode is bound by HBM weight reads and sequential layer count: size active bytes to real serving concurrency, scale out over low-diameter topologies (Boardfly) or wider decode TP, add MTP speculative decoding, and apply 4-bit/FP8 PTQ. At high concurrency or long context, shrink KV cache bytes via hybrid attention and FP8 KV.

Treat these regime labels as practical entry points rather than rigid cutoffs; use the diagnostic checks below to identify your actual bottleneck from a live trace.


Diagnosing your own runs

Every principle in this guide maps to observable signals in standard open-source profiling tools (jax.profiler, enabled in open-source MaxText with profiler=xplane). Open a captured profile in the XProf / TensorBoard profiler and inspect six numbers:

# XProf signal (profiler=xplane) Healthy range Action if off-target
1 Exposed (un-overlapped) communication share A few % of step Try overlap first: latency-hiding scheduler + SparseCore collective offload flags (Principle 10). If still exposed, compute per byte transferred sits below the physical link's arithmetic-intensity ridge and no schedule can hide it; reduce communication bytes via sharding changes or LatentMoE + FP8 compression (Principles 4, 10).
2 Backward : forward wall-clock ratio ≈ 2 (no remat) to ≈ 3 (full remat) Anything in the 2–3 band reflects an intentional compute-for-HBM trade. Act when the ratio exceeds what HBM pressure requires: checkpoint more projections (save_qkv_proj, save_out_proj) or shard weights further (Principle 11). Ratios above ~4 point to exposed backward collectives or unoptimized backward kernels.
3 Large GEMMs (% of chip peak FLOP/s) 80–95% Large dense and grouped matmuls should individually run near MXU peak; lower utilization indicates MXU tile padding from dimensions not divisible by 256 (Principle 1) or suboptimal kernel block sizes (tune-jax, Principle 11).
4 Non-matmul share of step time < ~15% dense; < ~30% MoE Above these bands, standalone elementwise VPU fusions, fine-grained FP8 block rescales, or MoE routing ops (sort, argmax/one-hot, cumsum, gather/scatter) are eating the step. Fuse RMSNorm/SwiGLU and size FP8 blocks to the MXU window (Principle 9), compress routed tokens (Principle 4), widen experts (Principle 5), and offload dispatch.
5 Engine executing sorts, gathers, and scatters SparseCore (in tuned configs) If routing data movement runs on the TensorCore, SparseCore offload flags are disabled or changed across runtime versions (Principle 10). Enable offload and verify the step-time reduction (typically 15–22%) with a short profile.
6 Step-time variance after warmup Steady, near-zero jitter Compiled TPU programs are deterministic for fixed inputs; beyond dropless MoE routing skew or variable sequence packing, step-to-step jitter points outside the accelerator to host CPU or data-loading stalls.

These ranges are triage thresholds rather than universal constants. Achievable utilization depends on model size and sharding: small models will not reach a flagship model's GEMM peak share, and high-communication shardings carry a higher floor. Compare your run against a tuned reference of similar scale (Appendix A.8), and separate execution gaps (fixable via compiler flags and kernel block tuning) from design gaps (fixable only by changing model shapes, routing compression, or mesh sharding).

Roofline a kernel before tuning it. While the table above triages the full step, channel roofline arithmetic establishes what speed is physically achievable for an individual kernel or collective. Arithmetic intensity equals FLOPs divided by bytes transferred across the feeding channel (HBM for an on-chip kernel, ICI or DCN for a collective), bounding achievable throughput at \(\min(\text{Intensity} \times \text{Bandwidth}, \text{Peak Compute})\). Judge each op's measured FLOP/s against that roofline ceiling rather than raw chip peak: a memory-bound op sitting at its HBM ceiling cannot be accelerated by tile search, and only gets faster by moving fewer bytes (fusion, lower precision, smaller KV or latent widths). jax.experimental.roofline computes static FLOPs and bytes per JAX function.

Budget HBM before sweeping. Total HBM usage splits into fixed state and batch-scaling activations. Fixed state (weights, gradients, and Adam optimizer moments: ≈ 16 bytes/parameter at standard mixed-precision defaults, before temporary all-gather and workspace buffers) divides across FSDP, TP, and PP, and across EP for routed experts (plus non-expert weights when FSDP spans the EP axis, as in MaxText), whereas plain DP replicates it. Activations scale linearly with per-device batch × sequence length (plus quadratic terms if attention is un-flashed). When a configuration runs out of HBM, apply memory levers in decreasing performance order:

  1. Shard weights further (increase FSDP or EP degree within the slice).
  2. Adjust activation rematerialization (custom, save_qkv_proj, save_out_proj before full).
  3. Reduce per-device microbatch size.
  4. Enable host memory offload (parameter_memory_host_offload, optimizer_memory_host_offload) last, as PCIe offload typically costs throughput (Appendix A.3).

Run optimization as a disciplined program. Modify one knob per run; 20–30 steps after compilation warmup is sufficient to measure steady-state step time. Capture a fresh XProf trace after every change to confirm the physical mechanism (for example, verifying that remat recomputations disappeared or that dispatch gathers moved onto SparseCore), not just the aggregate step time. Record negative experiments alongside wins so settled questions are never re-run, and gate every systems or kernel optimization on a fixed-seed loss-parity check against your baseline.


Putting it together: ~100B Ironwood LatentMoE

The reference configuration below combines the shape, architecture, and systems principles into a concrete ~100B-total (~17.5B-active) LatentMoE blueprint for TPU v7x (Ironwood):

Reference config

Component Reference choice Why it fits TPU
Backbone d_model = 6144 (\(24 \times 256\)), 48 uniform LatentMoE layers Exact 256×256 MXU alignment; uniform layers simplify jax.lax.scan compilation and divide cleanly across PP degrees (2, 4, 6, 8, 12, 16) and eight 5:1 attention cycles (Principles 1, 2, 10, App. A.1–A.2).
Attention & KV head_dim = 256, 24 Q / 4 KV heads (QK-norm); 5:1 sliding-window (512 or 1,024, Splash-aligned) : global (NoPE); FP8 KV cache (or MLA-style 512-dim latent) Full MXU tile utilization; bounded long-context prefill FLOPs and decode KV bytes; length extrapolation on global layers (Principles 1, 6, 7).
Shared expert 1 large shared expert (d_shared = 8192 at full d_model) in all 48 layers Dense, MXU-friendly GEMMs (free of all-to-all dispatch, FSDP-shardable) overlap EP dispatch/combine, stabilize early routing, and amortize across every decode token (Principles 4, 5).
Routed LatentMoE 64 routed experts, top-4, ℓ = 2048 (\(3\times\) compression), expert d_ff = 4096, FP8 all-to-all dispatch, full-d router Fewer, wider experts yield well-filled grouped GEMMs while \(3\times\) latent + \(2\times\) FP8 compression cuts cross-chip dispatch bytes \(6\times\) (Principles 4, 5).
MTP drafter 1–2 BF16 draft heads Denser pretraining supervision signal plus built-in speculative drafter to verify multiple tokens per decode weight read (Principle 8.2).
Precision FP8 (E4M3/E5M2, block size ≥ 512 on v7x) for GEMMs; BF16/FP32 router, norms, softmax inputs, embeddings, and final layers 2× MXU compute throughput over BF16 with range-bounded numerical stability and hidden VPU block rescales; ready for 4-bit serving PTQ (Principles 6, 9, App. A.7).
Training mesh FSDP × EP8 (1D torus axis) × TP2 (D2D chiplets); SparseCore offload; zero-init attention outputs; global-batch load balancing; dropless Megablox Parallelism hierarchy matched to physical link bandwidths (D2D → ICI); async collectives and dispatch gathers overlapped on SparseCore (Principles 3, 10).
Serving stack Disaggregated prefill and decode pools; FP8 weights and FP8 KV (block-size = 256); decoupled attention DP + expert EP Separates TTFT and TPOT operating points; the shared expert + MTP verification reach the ~300-token dense ridge early while coarser 64-expert routing raises tokens per routed expert (Principles 8, 10, 12).