Skip to content

Reinforcement Learning for Code Optimization

Jul 2026 · arXiv.org · Vol abs/2607.25970 · 0 citations
Computer Science

TL;DR

This work makes execution time learnable through three stages: how code is tested, by building DMC-Optim with large optimization tests and a calibrated sandbox; how speed is turned into reward, by composing correctness and speed in the RL environment and using an offline simulator to predict the most promising configurations.

Abstract

RL for code correctness is now established: have the model generate a program, run it against hidden test cases, and reward solutions that pass. Extending this to code optimization seems straightforward: just add execution time to the reward. But in practice, once timing drives the reward, small problems in measurement noise, reward sparsity, or GRPO instability overwhelm the signal and make RL fail: generated solutions are barely faster, and more of them can fail. We make execution time learnable through three stages: (1) how code is tested, by building DMC-Optim with large optimization tests and a calibrated sandbox; (2) how speed is turned into reward, by composing correctness and speed in the RL environment and using an offline simulator to predict the most promising configurations; and (3) how the model learns from that reward, by adapting GRPO and evaluation to the sparser, noisier timed-execution setting. On DMC-Optim, the strongest optimization-aware configurations improve strict top-50% pass@1 from 18.0% to 31.3% on Qwen 2.5 7B and from 30.7% to 50.4% on CWM 32B. These gains further increase at stricter percentiles such as top-30%, with 125% relative improvement for CWM 32B, while preserving pure-correctness scores. When the timing sandbox is degraded, robust optimization RL reaches 100% to 200% improvement over standard RLVR, depending on the evaluation criterion. On LCB, CWM 32B wins up to 83% of median-sample speed comparisons against standard RLVR. Relative to the fastest correct human submissions per problem, it reaches about half the human rate of complexity-class improvements (14% vs. 28%).

View source

Similar papers

Jul 2026

RLPF: Reinforcement Learning from Performance Feedback for Code Generation

This work proposes RLPF, reinforcement learning from performance feedback, which turns execution outcomes into a staged reward, and suggests that code agents can be trained not only to pass tests, but also to optimize the programs they write.

Huihao Jing, Hao-Zhe Cui, Wenbin Hu et al. · 0 citations
Preprint Aug 2026

TaPR: Test-Aware Policy Refinement for Feedback-Conditioned Code Generation

This work proposes Test-aware Policy Refinement (TaPR), a framework that transforms execution feedback into a dense per-turn test-pass-ratio reward under a consistent multi-turn interaction protocol and a turn-aware evaluation protocol that decouple first-shot generation quality from multi-turn repair competence.

Ao-Fan Liu, Jing Meng, Fangxin Liu et al. · 1 citation
Jul 2026

Multi-turn RL with Structural and Performance Aware Rewards for CUDA Kernel Generation

Empirical findings suggest that CudaPerf significantly outperforms strong baselines, including Qwen-3-32B and CUDA Agent by achieving up to 5X and 3.32X improvements in speedup, and 17%&7% improvements in correctness, respectively.

Q. I. Mahmud, Nesreen K. Ahmed, Ali Jannesari · 0 citations
Review

A Closer Look at the Use of Reinforcement Learning for Speeding Up Runtime Verification of Software Tests (Experience Paper)

Valg aims to probabilistically monitor most unique traces—sequences of spec-related events like method calls—and monitor fewer redundant ones and has plenty of room to improve, but only two of 11 RL algorithms that are feasible for RV during continuous integration are feasible.

Unknown authors · 0 citations
Review Open access Oct 2026

A Closer Look at the Use of Reinforcement Learning for Speeding Up Runtime Verification of Software Tests (Experience Paper)

Valg aims to probabilistically monitor most unique traces—sequences of spec-related events like method calls—and monitor fewer redundant ones and has plenty of room to improve, but only two of 11 RL algorithms that are feasible for RV during continuous integration are feasible.

Shinhae Kim, Saikat Dutta, Owolabi Legunsen · 0 citations
Jul 2026

WarmTuner: Program-Specific Warm Starts for Compiler Autotuning via Offline-to-Online Reinforcement Learning

WarmTuner is an offline-to-online reinforcement learning framework that turns historical records into a program-conditioned policy that predicts each flag's setting over the full flag space and remains adaptable on the target program and significantly outperforming the compared techniques.

Tianlu Qiao, Mingxuan Zhu, Ze-Yu Sun et al. · 0 citations

Related blog posts

Microsoft Research Blog Oct 12, 2026

Simulating student learning for better AI tutoring

StudentSim is a research system for evaluating and improving AI tutoring tools before they are tested with learners. It models how individuals may engage with tutors, giving feedback to improve tutor performance across subjects like chess, writing, and mathematics. The post Simulating student learning for better AI tutoring appeared first on Microsoft Research.

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.