arxiv.org·2026/10/26
为什么重要 LLM 代码优化未必节能,执行能耗可大幅上升;解码与架构选择影响可持续性。
大语言模型(LLM)正被越来越多地用于优化代码性能。这种做法通常假设执行速度的提升会自然转化为整体更低的能耗。我们通过实证方式挑战这一假设,衡量由 LLM self-refinement pipelines 生成的性能优化代码相对于 canonical human reference solutions 是否也具备能效,以及优化过程的能耗是否能被后续执行时间节省所抵消。
我们在 11 个开源模型、4 种解码配置上,对性能基准 EffiBench 的全部 1,000 个问题进行评估,并在整个过程中收集 per-process、hardware-level 的能耗测量。跨模型变体对的推理能耗为 0.79 到 8.68 MJ,大致相当于 250 到 2800 次 GPT-4.1 查询的能量。限制最大输出 token 数的影响最大,相比默认配置可将能耗降低最多 69%。
在执行侧,44 个配置中有 42 个生成的代码每个问题能耗高于 canonical human reference,开销范围为 +4% 到 +886%。仅有的两个例外也只取得边际收益,其 break-even points 约为 106 到 107 次执行。Mixture-of-Experts 架构在不牺牲正确性的情况下,比同等规模的 dense 模型消耗显著更少的推理能耗,使架构选择成为比解码参数更有影响的可持续性杠杆。
性能优化与能效并不总是对齐的目标:相对于人类工程师编写的代码,LLM self-refinement 一致地产生追求更快但更耗能的代码。所有 artifacts 可在 https://doi.org/10.5281/zenodo.23598170 获取。
Large Language Models (LLMs) are increasingly used to optimize code for performance.
This practice often assumes that improvements in execution speed naturally translate into overall lower energy consumption.
We challenge this assumption empirically by measuring whether performance-optimized code produced by LLM self-refinement pipelines is also energy-efficient relative to canonical human reference solutions, and whether the energy cost of the optimization process can be offset by subsequent execution-time savings.
We evaluate 11 open-source models across four decoding configurations on all 1,000 problems of EffiBench, a state-of-the-art performance benchmark, while collecting per-process, hardware-level energy measurements throughout.
Inference energy spans 0.79 to 8.68 MJ across model-variant pairs, which is roughly equivalent to the energy of 250 to 2800 GPT-4.1 queries.
Limiting the maximum number of output tokens has the largest impact, reducing energy use by up to 69% compared to the default configuration.
On the execution side, 42 of 44 configurations produce code that consumes more energy per problem than the canonical human reference, with overheads ranging from +4% to +886%.
The two exceptions achieve only marginal gains, with break-even points on the order of 106 to 107 executions.
Mixture-of-Experts architectures consume substantially less inference energy than equivalently-sized dense models without sacrificing correctness, making architectural choice a more consequential sustainability lever than decoding parameters.
Performance optimization and energy efficiency are not always aligned goals: LLM self-refinement consistently produces faster-seeking but energy-heavier code relative to what a human engineer would write.
All artifacts are available at https://doi.org/**10.5281**/zenodo.23598170.
原版排版与图表 · 手机无法内嵌时可在浏览器打开。PDF 插件内选文不能传给网页助手。