Cloud TPU Operations
Overview
This page focuses on workload efficiency and model execution patterns.
For planning and provisioning topics, see:
TPU Core Optimization: The MXU
The Matrix Multiplier Unit (MXU) is the main performance engine in a Cloud TPU.
- MXU is optimized for high-throughput matrix math.
- Matrix-heavy models usually get better TPU efficiency.
It is important to note that non-matrix operations such as reshapes, concatenations, and element-wise operations can reduce MXU utilization.
To improve performance, design the model so more execution time stays on MXU-friendly operations.
Best Practices For Model Development
Principle 1: Layout for efficiency
The XLA compiler is responsible for transforming your code to run efficiently on the TPU hardware. It uses tiling to break down large matrix multiplications into smaller, manageable blocks.

The MXU uses a 256x256 systolic array on Trillium, while pre-Trillium TPUs use 128x128. TPU memory paths generally prefer dimensions that are multiples of 8, and XLA uses these hardware characteristics for efficient tiling.
After XLA sets the tiling strategy, tensor layout and shape choices drive the remaining efficiency.
Some layouts are more conducive to TPU tiling and usually run more efficiently.
- They align naturally with matrix tiling patterns.
- They reduce pre-processing work before compute.
Other layouts may require reshape steps before tiling can run effectively.
- Reshape-heavy paths are often memory-bound.
- They can slow down computations by requiring more memory.
- Memory-bound reshapes can lower throughput.
Principle 2: Fixed shapes for Predictable Performance
The XLA compiler compiles the model graph just in time using the first batch shape. This just-in-time (JIT) compilation is highly optimized for performance.

After compilation, TPU execution expects shape consistency.
Note that if later batches use different shapes, performance and correctness can break down.
- Re-compiling on every shape change is too slow for TPU throughput.
- Dynamic shapes increase runtime variability.
- Fixed shapes keep execution stable and efficient.
Any model that has tensors with dynamic shapes (where the size of a tensor can change from one step to the next) is generally not well-suited for TPUs. It is recommended to design your model to use fixed tensor shapes for consistent execution.
Principle 3: Minimize Padding
High TPU efficiency depends on how well dense matrix operations fill the MXU. In practice, that means keeping dimensions aligned to TPU-friendly sizes, especially for dense paths.
- XLA performs best when matrix dimensions align with 128-based tiling.
- Non-aligned dimensions trigger zero padding before execution.
When padding is added, watch for these two tradeoffs:
- Underutilization
- Zero-padded regions still consume compute cycles.
- Utilization drops because some work is on empty values.
- Effective throughput decreases for dense matrix paths.
- Increased memory
- Padding expands tensor footprint in memory.
- In larger workloads, this can increase OOM risk.
- Larger tensors can reduce room for larger batch sizes.
To manage padding:
| Approach | Description |
|---|---|
| Automatic behavior | XLA pads matrix operations to the nearest multiple of 128. |
| Detection | Use op_profile to measure how much padding your model introduces. |
| Prevention | Prefer dimensions that are multiples of 8, and ideally multiples of 128 for dense matrix operations. |
Common Use Cases
Training And Fine-Tuning Foundation Models
Foundation model training is one of the most common TPU use cases. Large teams use TPU Pods to train LLMs and generative models at scale.

In practice, TPUs help reduce training time and cost for very large runs.
- They update billions to trillions of parameters across many chips in parallel.
- They support fine-tuning on smaller domain datasets after base pretraining.
- They speed up delivery of task-specific models, such as support assistants.
Accelerating Recommendation Systems
Recommendation systems are another strong fit for TPU acceleration. These workloads process large volumes of user interaction data to predict preferences.
They usually depend on high-dimensional sparse matrices and embedding-heavy pipelines.

Because of this structure, TPU SparseCores are especially useful.
- SparseCores accelerate sparse matrix and embedding operations.
- Platforms can process more interactions with lower serving latency.
- Users receive faster and more personalized recommendations.
Scientific Research And Complex Data Analysis
Scientific computing is also a major TPU use case. Many research workloads map naturally to large-scale matrix math and parallel execution.
Common examples include drug discovery, protein folding, genomics, and climate modeling.

In these scenarios, TPU throughput shortens simulation cycles and improves experiment velocity.