Beyond the Need for Speed: Energy-Aware Code Generation via Simulation-Guided Reinforcement Learning

πŸ“… 2026-07-05
πŸ“ˆ Citations: 0
✨ Influential: 0
πŸ“„ PDF
πŸ€– AI Summary
This work addresses the neglect of energy efficiency in existing code generation models and the impracticality of large-scale, reproducible hardware-based energy feedback. To bridge this gap, the authors propose the first simulation-based framework for energy-efficient code generation, featuring Green Teaβ€”a deterministic architectural simulator enabling 3.5 million energy evaluations of C++ code snippets. They train energy-aware models via supervised fine-tuning followed by closed-loop reinforcement learning with a novel algorithm (GRPO), and introduce the CARET metric to jointly assess functional correctness and energy efficiency. Experiments on 143 held-out problems demonstrate a 12.63% CARET improvement over baselines, with generated code outperforming human expert implementations in energy efficiency by 58.4%. The study also reveals the misleading nature of traditional throughput-oriented metrics like IPC for energy ranking. The open-sourced dataset and infrastructure eliminate approximately 263,000 CPU hours of reproduction costs.
πŸ“ Abstract
Code models strictly prioritize functional correctness, leaving software energy efficiency as an unoptimized byproduct. Training models to generate energy-efficient code requires reproducible feedback at scale, which physical hardware measurement cannot reliably provide due to variance. In this paper, we replace hardware profiling with a deterministic architectural simulation harness to build Green Tea, a corpus of $3.5$ million evaluations across $1{,}474$ C++ problems. We train an energy-aware code model via supervised fine-tuning on energy-contrastive pairs, followed by closed-loop reinforcement learning (GRPO) using simulation-in-the-loop feedback. To rigorously evaluate deployment readiness, we introduce the Correctness-Adjusted Reduction in Energy Total (CARET), a metric that explicitly penalizes code that sacrifices functionality for efficiency. On $143$ held-out problems, our simulation-in-the-loop pipeline achieves $12.63\%$ CARET, nearly tripling the gain of fine-tuning alone, and successfully beats the energy efficiency of human-expert references on $58.4\%$ of its valid outputs. Furthermore, our analysis exposes the IPC trap: standard throughput proxies like Instructions-Per-Cycle (IPC) actively misrank true energy efficiency on $67.8\%$ of problems, proving the absolute necessity of direct energy simulation. By releasing our dataset and infrastructure, we bypass the $263{,}000$ CPU-hours required for reproduction, structurally empowering the community to deploy inherently energy-efficient code generation models.
Problem

Research questions and friction points this paper is trying to address.

energy-efficient code generation
code model
hardware measurement variance
energy simulation
functional correctness
Innovation

Methods, ideas, or system contributions that make the work stand out.

energy-aware code generation
simulation-guided reinforcement learning
architectural simulation
CARET metric
Green Tea dataset