TL;DR
RLPF (Reinforcement Learning from Performance Feedback) is a novel training paradigm that teaches code generation LLMs to optimize for runtime efficiency rather than just functional correctness. By structuring execution feedback into a staged reward staircase—guiding the model from compilation progress to task-normalized speedups—RLPF dramatically improves both the success rate and execution speed of generated systems code.
What Problem Does This Paper Address?
Most state-of-the-art code models are trained using reinforcement learning from verification feedback (like unit tests), which treats functional correctness as the ultimate goal. However, for performance-critical systems code, simply passing tests is only half the battle. Two programs can be functionally identical while differing by orders of magnitude in execution speed or memory consumption.
Training LLMs to prefer faster code is notoriously difficult because runtime is a "fragile" reward signal. It can only be measured after a program successfully compiles and passes all tests, its absolute scale varies wildly across different tasks, and it provides zero feedback during early training phases when most model generations fail completely.
Methods
The authors introduce RLPF, which addresses reward sparsity and task heterogeneity by decomposing execution outcomes into a structured, two-regime reward staircase optimized via Group-Relative Policy Optimization (GRPO):
- The Failure Regime (Dense Progress Feedback): When a model's generated code fails, it isn't just given a zero reward. Instead, RLPF scores how far the code progressed through the execution pipeline: No extraction ($NX$) < No compilation ($NC$) < No execution/crash ($NR$) < Wrong output ($WO$). This teaches the model to climb the execution ladder toward valid code.
- The Success Regime (Relative Efficiency Feedback): Once a program passes all tests, its runtime is evaluated against a baseline implementation and an optimized human-expert reference. Rather than using raw execution time, RLPF uses CGRE (Closed Gap Ratio of Efficiency), which normalizes the runtime improvement against the task's specific optimization headroom. Small additional bonuses are awarded for beating the baseline or matching the expert reference.
Datasets
- PerfCodeBench: A heterogeneous performance benchmark consisting of 1,854 tasks across six languages (C, C++, CUDA, Go, Java, Python). It features low-level systems problems like SIMD string processing, bitmap filtering, and CUDA reductions. The authors train on ,1413 tasks and evaluate on a family-disjoint test split of 306 tasks.
- EffiBench-X: A multi-language benchmark used to evaluate out-of-distribution (OOD) transfer capability, ensuring the model's efficiency preference generalizes beyond the training environment.
Key Insights and Ideas
- Climbing the Ladder Prevents Collapse: Providing incremental rewards for failure modes prevents the policy from collapsing early in training when dealing with highly complex systems tasks.
- Task-Normalized Rewards are Essential: A 1-millisecond improvement on one task might represent a massive algorithmic breakthrough, while on another, it's negligible. Normalizing performance via CGRE provides a stable, task-agnostic optimization signal across highly diverse problems.
- Correctness and Speed are Coupled: Interestingly, training a model to optimize for performance also drastically inflates its correctness rate. By learning to prefer leaner code paths, the model naturally avoids complex, over-engineered, and error-prone implementations.
Key Results
- Massive Performance Gains: Fine-tuning a base Qwen3-32B model with RLPF on PerfCodeBench raised its Correct-and-Runnable Rate (CRR) from a weak 11.1% to 54.6%, while its relative efficiency (CGRE) jumped from 8.1% to 38.6%.
- RLPF vs. Correctness-Only (RLVR): While a correctness-only baseline (RLVR) achieved a high correctness rate (50.0% CRR), its relative efficiency lagged significantly at 28.98% CGRE. This confirms that test-passing models frequently generate slow, unoptimized code unless explicitly incentivized otherwise.
- Surpassing Stronger Models: The RLPF-tuned 32B model successfully outperformed larger general-purpose models like Qwen3.6-Plus and Gemini 3.1 Pro on efficiency metrics.
- Out-of-Distribution Transfer: The model demonstrated modest generalization on EffiBench-X, improving execution time by 3.9% on shared solved tasks without any fine-tuning on that dataset.
Limitations and Future Work
- Harness Dependency: RLPF relies heavily on a stable, low-noise execution environment and requires a meaningful performance gap between the baseline and expert reference to provide a useful signal.
- The Expert Ceiling: While RLPF is highly effective at local code cleanups (e.g., loop unrolling, eliminating redundant allocations), it struggles to discover entirely new algorithmic paradigms or hardware-specific parallelization layouts required to fully close the gap to human experts.
- Future Directions: The authors suggest exploring stricter format control to minimize syntax/compilation errors before execution, alongside more specialized performance supervision tailored to low-level hardware optimization domains.
Summary updated