TL;DR
HPAC-ML is a new directive-based programming model that allows researchers to swap computationally expensive scientific code for fast machine learning (ML) surrogates with just a few lines of code. By automating data collection, layout transformation, and model inference, it achieves up to 83.6× speedups in high-performance computing (HPC) applications with minimal accuracy loss.
What Problem Does This Paper Address?
Scientific discovery often relies on massive simulations in fields like quantum chemistry or climate modeling. As Moore’s Law slows down, researchers are increasingly turning to approximate computing—specifically Neural Network (NN) surrogates—to replace slow, complex functions with fast, learned approximations.
However, integrating ML into traditional HPC applications (usually written in C++ or Fortran) is a nightmare. There is a massive "handshake" problem: domain scientists know the physics, but ML experts know the tensors. Bridging the gap requires manual, error-prone data transformations because scientific data layouts (like stencils or unstructured meshes) rarely match the dense, contiguous tensor formats expected by ML frameworks like PyTorch. HPAC-ML aims to automate this engineering burden, allowing scientists to focus on their models rather than the plumbing.
Methods
The authors introduce HPAC-ML, which extends the LLVM/Clang compiler infrastructure with OpenMP-like pragmas. The system consists of two main pillars:
- The Data Bridge: This is the core innovation. It uses two abstractions—Tensor Functors and Tensor Maps—to describe how application memory (e.g., a 5-point stencil in a 2D grid) should be packed into a tensor. This allows the runtime to handle complex memory patterns without the developer writing manual copy loops.
- Execution Control: Using the
#pragma approx mldirective, developers can toggle between two modes: - Collect: The runtime runs the original code but saves the inputs and outputs to an HDF5 database for training.
- Infer: The runtime replaces the original code region with a trained ML model (using LibTorch, the C++ interface for PyTorch).
To find the best models, the authors also implemented an automated Bayesian Optimization (BO) workflow that searched through over 5,000 different neural architectures to find the optimal balance between inference speed and prediction error.
Datasets
The authors evaluated HPAC-ML using five representative GPU-based HPC benchmarks:
- MiniBUDE: A molecular docking application.
- Binomial Options & Bonds: Financial models for stock and interest rate calculations.
- MiniWeather: A simulation of atmospheric dynamics.
- ParticleFilter: A statistical estimation tool for object tracking.
Training data was generated directly from these applications using HPAC-ML's collect mode, ensuring the ML models were trained on the exact data distributions they would encounter during production runs.
Key Insights and Ideas
- Hardware Alignment Matters: One surprising finding was that ML surrogates often run faster not just because they do less math, but because they use dense linear algebra. These operations are highly optimized by GPU vendors, allowing the surrogate to achieve much higher hardware utilization (47.2% of peak compute) compared to the original scattered memory access patterns of the scientific code (33.5%).
- The "Iteration Trap": In iterative simulations like MiniWeather, tiny errors in the ML surrogate compound over time, eventually leading to unstable results.
- Interleaving for Stability: To combat error propagation, HPAC-ML allows for "mixed simulations." By interleaving accurate timesteps with surrogate timesteps, researchers can significantly reduce cumulative error while still gaining a performance boost.
- Low Friction Integration: The programming model is remarkably efficient; on average, it required increasing the application's source code by less than 2%.
Key Results
The evaluation showed that HPAC-ML is both powerful and practical:
- Massive Speedups: The system achieved a maximum end-to-end speedup of 83.6× for Binomial Options and a geometric mean of 13.0× across all benchmarks.
- High Fidelity: Accuracy remained high, with Root Mean Square Error (RMSE) as low as 0.001 for some financial models.
- Outperforming Custom Code: For the ParticleFilter benchmark, the ML surrogate was not only faster than the original algorithmic approximation but also more accurate (RMSE of 0.12 vs 0.5).
Limitations and Future Work
While HPAC-ML simplifies integration, the authors acknowledge that data collection overhead can be significant (up to 44× slower than a normal run) because of the I/O required to save training data. However, this is a one-time cost.
The most significant challenge remains iterative auto-regressive scenarios (like weather modeling), where error accumulation is difficult to manage. Future work will likely focus on more sophisticated "guardrails" or error-correction mechanisms to allow surrogates to run for longer periods without needing to fall back to the expensive, accurate simulation.
Summary updated