NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ACECode: A Reinforcement Learning Framework for Aligning Code Efficiency and Correctness in Code Language Models

Chengran Yang, Hong Jin Kang, Jieke Shi, David LoarXiv 2024 · DOI

Introduction: The Efficiency Gap in CodeLLMs

Modern Code Large Language Models (CodeLLMs) have become adept at generating functionally correct code. However, they frequently overlook efficiency, often producing code that is 3 to 13 times slower than human-written counterparts. This "computational debt" poses significant challenges for deployment in resource-constrained environments like mobile devices or high-scale cloud infrastructures where every millisecond translates to energy and cost.

Existing optimization methods often involve trade-offs. Techniques like SOAP require complex execution environments during inference, while standard instruction tuning (e.g., PIE) can inadvertently degrade functional correctness while attempting to improve speed. ACECode addresses this by optimizing for both speed and correctness simultaneously during the fine-tuning phase.

Methodology: Reinforcement Learning from Execution Feedback

ACECode adapts the principles of Reinforcement Learning from Human Feedback (RLHF) but replaces subjective human labeling with objective "Execution Feedback."

The standard RLHF pipeline, which ACECode replaces with an automated execution-based feedback loop.

The framework utilizes an Actor-Critic architecture. The "Actor" generates code, while the "Critic" estimates the value of these generations. The core innovation is the Training-Free Rewarder:

  1. Execution-Based Rewards: Instead of a separate reward model, ACECode runs generated code against unit tests.
  2. Scoring Logic: Code that fails tests receives a negative reward. Successful code receives a base reward for correctness plus an efficiency bonus based on its runtime relative to a high-quality human reference.
  3. PPO Optimization: The model is updated using Proximal Policy Optimization (PPO), encouraging the exploration of faster coding patterns.
The ACECode framework, illustrating the Actor-Critic architecture and the unit-test based reward system.

To ensure stability against CPU noise, the researchers employed Python’s timeit module with repeated execution strategies for accurate reward signals.

Data: EffiBench+ and the Search for the "Gold Standard"

The authors developed EffiBench+, an enhanced version of the EffiBench dataset. While the original dataset provided a single human reference per task, the authors found these were not always the most efficient. EffiBench+ incorporates up to 15 top-voted human solutions for each of its 797 tasks, selecting the absolute fastest as the "gold standard" for the rewarder. This ensures the model is always pushed toward state-of-the-art efficiency.

Results: Simultaneous Gains in Correctness and Speed

Testing across four state-of-the-art models (CodeQwen1.5, DeepSeekCoder, WaveCoder, and Magicoder) revealed significant improvements:

  • Correctness Boost: pass@1 scores increased by 1.84% to 14.51%. Interestingly, optimizing for efficiency encouraged deeper logical exploration, improving overall accuracy.
  • Efficiency Gains: ACECode-tuned models produced faster code in 65% to 72% of cases. The Geometric Execution Time (GET) improved by up to 10.86% over base models and up to 23.18% over standard instruction-tuned models.
  • Scaling Exploration: Performance correlated positively with the number of responses generated during training, suggesting that increased exploration leads to better optimization, similar to neural scaling laws.

Conclusion and Future Directions

ACECode demonstrates that execution-grounded reinforcement learning can effectively bridge the gap between code correctness and efficiency. While currently focused on Python and open-weight models under 10B parameters, future work aims to extend this framework to low-level languages like C++ and Rust, where performance is even more critical, and to scale the approach to larger frontier models.

Summary updated

BibTeX
@misc{yang2024acecode,
  author = {Chengran Yang and Hong Jin Kang and Jieke Shi and David Lo},
  title = {{ACECode: A Reinforcement Learning Framework for Aligning Code Efficiency and Correctness in Code Language Models}},
  year = {2024},
  eprint = {2412.17264},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.17264},
}
Figure