Reinforcement Learning for Code Optimization
Pierre Chambon, Kunhao Zheng, Juliette Decugis, Benoît Sagot, Gabriel Synnaeve
NeurIPS page · OpenReview · alphaXiv · Open on the map
Category: LLM Agents, Evals & Benchmarks › LLM-Driven Tool-Use and Planning · Type: new method · Keywords: reinforcement learning for code, code optimization, reward design, GRPO adaptation, benchmark construction
Areas: Code & Coding Agents › Code Generation and Optimization › Code Generation; Evaluation & Benchmarks › Language Model and Agent Benchmarks › Code Generation Benchmarks; RL for LLMs & Agents › Language Model Agents › Language Model Optimization
Summary
The paper addresses the difficulty of using reinforcement learning to optimize code execution speed, proposing a three-stage solution that creates a calibrated benchmark, designs a combined correctness-and-speed reward, and adapts RL training to handle noisy, sparse timing signals, achieving significant speedups while preserving correctness.
Explained to a 5-year-old
We want computers to write code that runs fast. Usually, computers learn to write correct code, but making them fast is hard because the reward (speed) is noisy. The paper builds a big collection of code problems and a safe testing area. It changes how the computer learns to focus on speed, and it gets much faster code while still being correct.
Explained to a 5-year-old, longer
A computer program can be written to solve problems, but we also want it to run quickly. Existing learning methods only care about whether the answer is right, not how fast it is. When we try to add speed to the learning signal, the feedback becomes noisy and hard to understand. The paper creates a large set of coding challenges and a safe environment where speed can be measured accurately. It then designs a new way to give the computer a reward that includes both correctness and speed. The learning algorithm is adjusted to handle this new, trickier reward. As a result, the computer learns to produce code that is both correct and much faster. The improvements are tested on two big collections of problems, showing big gains in speed while keeping the code correct. This makes programming tools more useful in real-world situations where performance matters.
For a technical reader
The work identifies that timing rewards in RL for code generation are plagued by noise and sparsity, which hampers optimization. It constructs a purpose-built benchmark (DMC-Optim) with a calibrated sandbox to reliably measure execution time. By combining correctness and speed into a unified reward and using an offline simulator to pre-select promising configurations, the authors adapt GRPO to the noisier signal. Empirical results on DMC-Optim and LCB show substantial speedups (e.g., up to 130% over baseline) while preserving correctness, demonstrating a practical pathway to performance-aware code generation.
Problem
Reinforcement learning for code generation currently focuses on correctness, but adding execution time to the reward is unreliable because measurement noise, sparse feedback, and instability in RL algorithms obscure the speed signal, preventing effective optimization.
Method
The approach builds a large-scale optimization benchmark with a calibrated sandbox, composes correctness and speed into a unified reward using an offline simulator, and adapts GRPO training to cope with the sparser, noisier timed-execution feedback.
Results
The approach raises top-decile pass@1 on DMC-Optim from 18.1% to 27.7% (Qwen 2.5 7B) and from 28.7% to 42.4% (CWM 32B), yields up to 130% improvement over baseline under noisy sandbox conditions, and on LCB achieves a 70.3% speed-win rate versus baseline while reaching 14% of human-level complexity-class improvement.
Contributions
It identifies the core challenges of timing rewards in RL for code, introduces a three-stage framework to make execution time learnable, and demonstrates substantial speed gains on two benchmarks while preserving correctness.
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction