Pace v0.2: a Python-based performance-portable atmospheric model

Johann Dahm, Eddie Davis, Florian Deconinck, Oliver D. Elbert, Rhea George, Jeremy McGibbon, Tobias Wicky, Elynn Wu, Christopher Kung, Tal Ben‐Nun, Lucas Harris, Linus Groner, Oliver FuhrerGeoscientific 2023

Abstract

Progress in leveraging current and emerging high-performance computing infrastructures using traditional weather and climate models has been slow. This has become known more broadly as the software productivity gap. With the end of Moore's law driving forward rapid specialization of hardware architectures, building simulation codes on a low-level language with hardware-specific optimizations is a significant risk. As a solution, we present Pace, an implementation of the nonhydrostatic FV3 dynamical core and GFDL cloud microphysics scheme which is entirely Python-based. In order to achieve high performance on a diverse set of hardware architectures, Pace is written using the GT4Py domain-specific language. We demonstrate that with this approach we can achieve portability and performance, while significantly improving the readability and maintainability of the code as compared to the Fortran reference implementation. We show that Pace can run at scale on leadership-class supercomputers and achieve performance speeds 3.5–4 times faster than the Fortran code on GPU-accelerated supercomputers. Furthermore, we demonstrate how a Python-based simulation code facilitates existing or enables entirely new use cases and workflows. Pace demonstrates how a high-level language can insulate us from disruptive changes, provide a more productive development environment, and facilitate the integration with new technologies such as machine learning.

Introduction: Bridging the Software Productivity Gap

For decades, weather and climate models have relied on low-level, compiled languages like Fortran. While historically efficient, this reliance has created a "software productivity gap." As hardware evolves toward specialized architectures like GPUs, maintaining massive legacy codebases requires complex, hardware-specific directives (e.g., OpenACC) that are difficult to maintain and port across different supercomputers. Pace v0.2 addresses this by separating scientific logic from performance implementation, ensuring that atmospheric models can keep pace with rapid hardware innovation.

Methodology: The Pace Toolchain

The core of Pace is built on the GT4Py (GridTools for Python) domain-specific language. Scientists define mathematical operations on a grid—known as "stencils"—using high-level Python syntax. These stencils are then transpiled into optimized C++ or CUDA code for specific hardware targets.

The Pace compilation toolchain: High-level Python code is processed through the GT4Py pipeline and DaCe for global optimization before generating C++ or CUDA code.

To maximize efficiency, Pace integrates DaCe (Data-Centric Parallel Programming). Unlike traditional compilers that look at operations in isolation, DaCe analyzes the entire program's data flow. This enables global optimizations like kernel fusion and sophisticated memory management, which are critical for achieving high performance on GPUs.

GT4Py Stencils and Grid Operations

In Pace, the atmospheric physics are defined as stencils that describe how data at one grid point relates to its neighbors. This abstraction allows for different computation modes, such as parallel horizontal operations or sequential vertical sweeps, without changing the underlying scientific logic.

GT4Py stencil examples: The PARALLEL computation (left) shows horizontal dependencies, while the FORWARD computation (right) shows vertical dependencies in a 3D grid.

Performance and Validation

Pace was validated using standard benchmarks, including the Baroclinic Instability Test and NCEP Reanalysis data. By using the Serialbox tool to extract data from the original Fortran model, the team ensured that the Python implementation matched the reference within a numerical tolerance of $10^{-14}$.

Key performance results include:

  • GPU Speedup: Pace achieved performance 3.5–4 times faster than the highly optimized Fortran reference on GPU-accelerated supercomputers like Piz Daint.
  • Perfect Weak Scaling: The model demonstrated the ability to maintain constant execution time as problem size and hardware resources were scaled proportionally.
  • CPU Trade-off: Currently, the Pace CPU backend runs at approximately 0.2x the speed of Fortran, as optimization efforts have prioritized GPU viability.

Conclusion and Future Directions

Pace demonstrates that a "Python-first" approach can provide a more productive development environment without sacrificing performance. This architecture makes it trivial to integrate modern machine learning workflows, such as swapping traditional physics stencils for neural networks using PyTorch or TensorFlow. Future work will focus on completing the full GFS physics suite and optimizing the CPU backend to close the performance gap with legacy Fortran implementations.

Summary updated

BibTeX
@inproceedings{dahm2023pace,
  author = {Johann Dahm and Eddie Davis and Florian Deconinck and Oliver D. Elbert and Rhea George and Jeremy McGibbon and Tobias Wicky and Elynn Wu and Christopher Kung and Tal Ben‐Nun and Lucas Harris and Linus Groner and Oliver Fuhrer},
  title = {{Pace v0.2: a Python-based performance-portable atmospheric model}},
  booktitle = {Geoscientific},
  year = {2023},
  doi = {10.5194/gmd-16-2719-2023},
}
Figure