High-resolution imaging on TPUs

Fantine Huot, Yi-Fan Chen, Robert G. Clapp, Carlos Boneti, John R. AndersonarXiv 2019

Abstract

This study demonstrates that Google’s Cloud Tensor Processing Units (TPUs), hardware specifically designed for artificial intelligence, can be effectively repurposed for high-resolution scientific imaging. By adapting Full-Waveform Inversion (FWI) algorithms to leverage the TPU's matrix-multiplication units, researchers achieved performance competitive with high-end NVIDIA Tesla V100 GPUs while utilizing high-level Python code.

Introduction

Full-Waveform Inversion (FWI) is a computationally demanding process used in geophysics and medical ultrasound to create high-resolution 3D images of internal structures. It works by iteratively solving complex wave equations to match simulated data with observed signals. Traditionally, FWI has required massive CPU clusters or specialized CUDA code on GPUs. As AI-specific hardware like TPUs becomes more accessible, a critical question arises: Can these accelerators, hard-wired for the matrix math of deep learning, be used for the partial differential equations (PDEs) found in physics simulations?

Architectural Adaptation

To make physics simulations compatible with AI hardware, the researchers implemented a 3D acoustic wave equation solver using TensorFlow on Cloud TPU v3 hardware.

Hardware Mapping

The TPU v3 architecture is built around Matrix Units (MXUs) that excel at $128 \times 128$ multiplications. As shown in Figure 1, each core integrates these MXUs with High-Bandwidth Memory (HBM). The researchers mapped finite-difference numerical stencils—the mathematical operations used to calculate wave movement—directly onto these matrix operations.

Figure 1: TPU v3 architecture highlighting the Matrix Units (MXU) and High-Bandwidth Memory (HBM).

Higher-Order Stencils and Arithmetic Intensity

A key innovation was the use of 8th-order and 16th-order numerical stencils. While mathematically more complex, these higher-order stencils (illustrated in Figure 5) are better suited for TPUs because they increase "arithmetic intensity." This allows the processor to perform more work relative to the amount of data moved, effectively saturating the MXU's compute capacity.

Figure 5: Comparison of lower-order (left) and higher-order (right) 3D numerical stencils used to increase arithmetic intensity.

Implementation and Software Stack

The implementation leveraged the XLA (Accelerated Linear Algebra) compiler to transform high-level Python/TensorFlow code into efficient machine code for the TPU. This approach avoids the need for low-level assembly or C++, significantly improving developer productivity while maintaining high performance.

Results and Performance

The performance was evaluated using a synthetic 3D simulation domain with a $1024^3$ grid (one billion cells).

  • Throughput: On the same grid, the TPU implementation ran at approximately 6.85 Gcells/s, compared to 11.96 Gcells/s for the optimized GPU baseline.
  • Total Time Parity: When leveraging the 16th-order stencil to reduce the domain size (due to higher accuracy per grid point), the TPU's total computation time became comparable to the GPU (9.14 seconds vs. 8.98 seconds).
  • Scalability: The dedicated high-speed torus network in TPU Pods allowed for efficient "halo exchanges" (sharing data between chips), overcoming a common bottleneck in distributed scientific computing.

Discussion and Limitations

The study proves that the "AI-only" label for TPUs is a misnomer. The hardware features that accelerate neural networks—HBM, dedicated interconnects, and massive matrix units—are exactly what high-end physics simulations require. However, TPUs primarily use bfloat16 for matrix multiplications. While sufficient for this prototype, some scientific applications require the higher precision of float64. Future work will explore more complex physics, such as elastic propagation or anisotropy.

Conclusion

Repurposing TPUs for scientific imaging offers a powerful alternative to traditional GPU-based high-performance computing. By achieving competitive performance with high-level code, this approach lowers the barrier to entry for complex 3D modeling and simulation.

Summary updated

BibTeX
@misc{huot2019high,
  author = {Fantine Huot and Yi-Fan Chen and Robert G. Clapp and Carlos Boneti and John R. Anderson},
  title = {{High-resolution imaging on TPUs}},
  year = {2019},
  eprint = {1912.08063},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.08063},
}
Figure