ChatPaper.aiChatPaper

コード最適化のための強化学習

Reinforcement Learning for Code Optimization

July 28, 2026
著者: Pierre Chambon, Kunhao Zheng, Juliette Decugis, Benoit Sagot, Gabriel Synnaeve
cs.AI

要旨

コードの正確性に対する強化学習(RL)は確立されつつある。つまり、モデルにプログラムを生成させ、隠されたテストケースに対して実行し、合格した解に報酬を与える手法である。これをコード最適化に拡張することは一見単純に見える。すなわち、実行時間を報酬に加えればよい。しかし実際には、実行時間が報酬の主軸となると、測定ノイズ、報酬の疎性、GRPOの不安定性といった小さな問題が信号を圧倒し、RLを失敗に導く。生成された解はほとんど速度が向上せず、失敗する解が増えるのである。我々は実行時間を学習可能にするため、3段階のアプローチをとる。(1)コードのテスト方法:大規模な最適化テストと較正済みサンドボックスを備えたDMC-Optimを構築する。(2)速度を報酬に変換する方法:RL環境において正確性と速度を組み合わせ、オフラインシミュレータを用いて最も有望な設定を予測する。(3)モデルがその報酬から学習する方法:より疎でノイズの多いタイムド実行環境に適応するようGRPOと評価を調整する。DMC-Optimにおいて、最も強い最適化対応設定は、Qwen 2.5 7Bではstrict top-50% pass@1を18.0%から31.3%に、CWM 32Bでは30.7%から50.4%に改善する。これらの向上はtop-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%).