arXiv:2607.04577cs.LGcs.SE2026-07

用模拟反馈训练代码模型,让生成的程序更省电。

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

论文配图:Beyond the Need for Speed: Energy-Aware Code Generation via Simulation-Guided Reinforcement Learning
图 1 · 摘自论文原文
  • 用确定性仿真代替硬件测量,获取稳定能耗反馈
  • 在143个测试问题上实现12.63%的能效提升,超人工专家58.4%
  • 揭露主流指标误判真实能效,强调直接模拟必要性

代码模型通常只关注功能正确性,忽视能效优化。训练生成节能代码需要可复现的大规模反馈,但物理硬件测量因波动难以满足。本文用确定性架构仿真替代硬件采样,构建了包含350万次评估、覆盖1474个C++问题的Green Tea数据集。通过监督微调能量对比样本,再结合仿真闭环强化学习(GRPO)进行训练。为严格评估部署可行性,提出新指标CARET,显式惩罚牺牲功能换取效率的代码。在143个保留问题上,该流程达成12.63% CARET,接近微调方法的三倍,且58.4%的有效输出优于人类专家。分析还揭示‘IPC陷阱’:标准吞吐代理如指令/周期(IPC)在67.8%的问题上错误排序真实能效,证明直接能耗模拟不可或缺。通过开源数据集与基础设施,避免重复消耗26.3万CPU小时,推动社区构建原生节能代码生成模型。

原文摘要 · Abstract (English)

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.

代码生成能效优化强化学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。