In Situ Framework for Coupling Simulation and Machine Learning with Application to CFD

Riccardo Balin, Filippo Simini, Cooper Simpson, Andrew Shao, Alessandro Rigazzi, Matthew Ellis, Stephen Becker, Alireza Doostan, John A. Evans, Kenneth E. JansenarXiv 2023 · DOI

Introduction

High-fidelity Computational Fluid Dynamics (CFD) simulations, such as Direct Numerical Simulations (DNS), produce massive datasets that often exceed the storage and I/O capabilities of modern supercomputers. Traditionally, researchers have relied on an "offline" approach: running the simulation, saving terabytes of data to disk, and then training Machine Learning (ML) models later. This creates significant I/O bottlenecks and limits the temporal resolution of data available for training. Furthermore, bridging CFD solvers (typically written in Fortran or C++) with ML frameworks (primarily Python-based) often requires complex and fragile "glue" code.

The In Situ Framework

To address these challenges, researchers developed a high-performance framework using SmartSim and SmartRedis. This infrastructure enables "loosely-coupled" in situ training and inference, where ML tasks run concurrently with the simulation, eliminating the need for persistent disk storage.

In situ training workflow coupling CFD simulation with distributed ML training via a SmartSim database.

The framework utilizes a SmartSim database as a high-speed, in-memory buffer. The CFD solver acts as a data producer, writing simulation states directly to memory, while the ML workload acts as a consumer, pulling data for training or inference. This asynchronous communication allows the simulation to proceed without waiting for the ML model to finish its processing steps.

Co-located Deployment Strategy

A core innovation of this framework is the co-located deployment strategy. In a standard clustered setup, a central database on separate nodes can become a network bottleneck. By contrast, the co-located approach launches a small, in-memory Redis database on every compute node alongside the simulation and ML ranks.

Comparison of co-located and clustered database deployment strategies for in situ training and inference.

This "embarrassingly parallel" database architecture ensures that data transfers remain local to the node, effectively eliminating inter-node communication overhead for data movement. This design is the primary driver behind the framework's ability to achieve near-perfect scaling on large-scale supercomputers.

Validation and Performance

The framework was validated using a DNS of a turbulent flat plate boundary layer with 36 million elements. The primary ML task involved training a QuadConv autoencoder to compress 3D flow states (pressure and velocity fields).

Key Results

  • Perfect Scaling: The system demonstrated linear scaling up to 448 nodes (10,752 simulation ranks) on the Polaris supercomputer at Argonne National Laboratory.
  • Negligible Overhead: For autoencoder training, the framework's overhead was less than 1% of the total PDE integration time.
  • Extreme Compression: The autoencoder achieved a 1700x spatial compression of the simulation data.
  • Ease of Integration: Implementing in situ inference required fewer than 10 lines of code in the solver, compared to over 70 lines required by standard bridging libraries like LibTorch.

Conclusion and Future Work

While the framework provides exceptional scaling and ease of use, challenges remain in improving the reconstruction accuracy of ML models for complex 3D turbulent flows. Future work will focus on refining autoencoder architectures to better handle high-gradient physics and applying the framework to Turbulence Closure Modeling, where ML models help approximate small-scale physics that are otherwise too expensive to simulate directly.

Summary updated

BibTeX
@misc{balin2023situ,
  author = {Riccardo Balin and Filippo Simini and Cooper Simpson and Andrew Shao and Alessandro Rigazzi and Matthew Ellis and Stephen Becker and Alireza Doostan and John A. Evans and Kenneth E. Jansen},
  title = {{In Situ Framework for Coupling Simulation and Machine Learning with Application to CFD}},
  year = {2023},
  eprint = {2306.12900},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.12900},
}
Figure