Leveraging LLMs to Automate Energy-Aware Refactoring of Parallel Scientific Codes
Matthew T. Dearing, Yiheng Tao, Xingfu Wu, Zhiling Lan, Valerie Taylor
TL;DR
LASSI-EE addresses the gap in energy-aware parallel code generation by integrating runtime power profiling with an automated, multi-stage LLM workflow. It introduces energy-reduction@k to quantify expected energy savings when generating multiple code candidates, and leverages an LLM-as-a-Judge to filter functional equivalents at scale. Across 22 applications on NVIDIA A100 and AMD MI100 GPUs, LASSI-EE achieves substantial energy savings (up to ~48% at k=3) with high pass rates (≈97% at k=3), outperforming vanilla LLM prompting by up to 2.8× in single attempts. The framework demonstrates cross-platform robustness and a diverse set of optimization strategies mapped to memory hierarchy, algorithmic efficiency, device-specific tuning, and parallelism management, highlighting its potential to accelerate energy-efficient HPC code generation and guide future research.
Abstract
While large language models (LLMs) are increasingly used for generating parallel scientific codes, most efforts emphasize functional correctness, often overlooking performance, especially energy efficiency. We propose LASSI-EE, an automated LLM-based refactoring framework that generates energy-efficient parallel codes through a multi-stage, iterative approach integrating runtime power profiling, energy-aware prompting, self-correcting feedback loops, and an LLM-as-a-Judge agent for automated screening of code solutions. We introduce energy-reduction@k, a novel metric that quantifies expected energy reduction when generating k code candidates and selecting the most energy-efficient, enabling systematic evaluation of multi-attempt generation strategies. Evaluating 20 HeCBench applications and two miniApps on NVIDIA A100 and AMD MI100 GPUs, a single run (k=1) with LASSI-EE delivers refactored parallel codes with an average 29% expected energy reduction at an 81% pass rate, representing a 2.8x improvement over vanilla LLM prompting. Multiple runs (k=3) achieve an average 48% expected energy reduction at a 97% pass rate. These results are consistent across devices, demonstrating LASSI-EE's effectiveness across diverse hardware architectures.
