코드 최적화를 위한 강화 학습
Reinforcement Learning for Code Optimization
July 28, 2026
저자: Pierre Chambon, Kunhao Zheng, Juliette Decugis, Benoit Sagot, Gabriel Synnaeve
cs.AI
초록
코드 정확성을 위한 강화학습(RL)은 이제 확립되었다: 모델이 프로그램을 생성하고, 이를 숨겨진 테스트 케이스에 대해 실행시킨 후 통과하는 해결책에 보상을 부여하는 방식이다. 이를 코드 최적화로 확장하는 것은 간단해 보인다: 실행 시간을 보상에 추가하기만 하면 된다. 그러나 실제로 시간이 보상을 결정하게 되면, 측정 노이즈, 보상 희소성, 또는 GRPO 불안정성과 같은 작은 문제들이 신호를 압도하여 RL을 실패하게 만든다: 생성된 해결책은 거의 더 빠르지 않으며, 더 많은 해결책이 실패할 수 있다. 우리는 실행 시간을 학습 가능하게 만들기 위해 세 단계를 거친다: (1) 코드가 어떻게 테스트되는지 - 대규모 최적화 테스트와 보정된 샌드박스를 갖춘 DMC-Optim을 구축; (2) 속도가 어떻게 보상으로 변환되는지 - RL 환경에서 정확성과 속도를 결합하고 오프라인 시뮬레이터를 사용하여 가장 유망한 구성을 예측; (3) 모델이 그 보상으로부터 어떻게 학습하는지 - GRPO와 평가를 더 희소하고 노이즈가 많은 시간 기반 실행 환경에 적응. DMC-Optim에서, 가장 강력한 최적화 인식 구성은 Qwen 2.5 7B에서 엄격한 상위 50% pass@1을 18.0%에서 31.3%로, CWM 32B에서 30.7%에서 50.4%로 향상시킨다. 이러한 이득은 상위 30%와 같은 더 엄격한 백분위수에서 더욱 증가하며, CWM 32B의 경우 125%의 상대적 개선을 보이면서 순수 정확성 점수는 유지한다. 시간 샌드박스가 저하되었을 때, 강건한 최적화 RL은 평가 기준에 따라 표준 RLVR 대비 100%에서 200%의 개선을 달성한다. LCB에서 CWM 32B는 표준 RLVR 대비 중간 표본 속도 비교에서 최대 83%의 승률을 기록한다. 문제당 가장 빠른 올바른 인간 제출과 비교할 때, 복잡성 클래스 개선에서 인간 비율의 약 절반에 도달한다(14% 대 28%).
English
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%).