AI summaryⓘ
The authors point out that current code models mainly focus on making code work correctly, not on how much energy the code uses. They created Green Tea, a large dataset using a consistent simulation method to measure energy use in C++ programs without relying on unreliable hardware tests. Using this, they trained a new model that learns to write code that saves energy without breaking functionality and introduced a metric (CARET) to check both correctness and energy savings. Their method improved energy efficiency significantly compared to previous approaches and outperformed human experts on many problems, showing that traditional shortcuts like IPC don't reliably reflect true energy use. They also shared their data and tools to help others make energy-efficient code models more easily.
code modelsenergy efficiencyarchitectural simulationsupervised fine-tuningreinforcement learningC++ programmingInstructions-Per-Cycle (IPC)energy simulationcorrectnessGreen Tea dataset
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.