NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CodeRL+: Improving Code Generation via Reinforcement with Execution Semantics Alignment

Xue Jiang, Yihong Dong, Mengyang Liu, Hongyi Deng, Tian Wang, Yongding Tao, Rongyu Cao, Binhua Li, Zhi Jin, Wenpin Jiao, Fei Huang, Yongbin Li, Ge Li · OpenReview

TL;DR

Large Language Models (LLMs) struggle with generating functionally correct code because they learn from text patterns, not execution logic. This paper introduces CodeRL+, a novel reinforcement learning approach that aligns code generation with execution semantics by inferring variable-level execution trajectories. This leads to significant improvements in code generation accuracy and generalization to related tasks.

What Problem Does This Paper Address?

LLMs are incredibly good at generating code that looks right, thanks to training on massive amounts of code from the internet. However, there's a fundamental disconnect between the "textual patterns" LLMs learn and the "execution semantics" that actually determine if code works correctly. Think of it like learning to speak a language fluently without understanding the grammar rules – you might sound good, but you'll make subtle, critical errors. Current methods like Reinforcement Learning with Verifiable Rewards (RLVR) try to fix this by rewarding code that passes tests. But this is like only getting a "pass/fail" grade on an exam; it doesn't tell you why you failed, especially for tricky logical errors. This paper tackles this "semantic gap" by proposing a way to teach LLMs not just to write code, but to understand how that code executes.

Methods

The core innovation of CodeRL+ is execution semantics alignment. Instead of just relying on the final "pass/fail" outcome of test cases, CodeRL+ actively tries to understand the intermediate steps of code execution. Here's how:

  • Inferring Execution Trajectories: When a generated code snippet fails a test, CodeRL+ doesn't just discard it. It uses this "failed rollout" to infer the execution trajectory – essentially, how variables change step-by-step. This is done by predicting the final value of each variable at its last definition point, which implicitly captures control flow and data dependencies.
  • Dual-Objective Training: CodeRL+ trains the LLM with two goals simultaneously: generating correct code and aligning with execution semantics. This is achieved by creating a mixed prompt distribution that includes both code generation prompts and prompts designed to elicit the inferred execution semantics.
  • On-Policy Alignment: The execution semantics alignment prompts are generated dynamically from the model's own failed rollouts during training. This means the alignment process evolves with the model's capabilities and doesn't require external datasets.
  • Reinforcement Learning Framework: The approach builds upon existing RLVR methods, specifically using Group Relative Policy Optimization (GRPO) for efficient advantage estimation. The final training objective is a composite of rewards for both code generation and execution semantics alignment.

Datasets

The paper uses several datasets for training and evaluation:

  • Training: APPS, CodeContests, TACO, and Codeforces (totaling 27K problems).
  • Evaluation:
    • Code Generation: HumanEval, LeetCode, LiveCodeBench.
  • Code Reasoning: LiveCodeBench-Reason.
  • Test Output Generation: LiveCodeBench-Test.
  • Additional Benchmarks: MBPP, LiveBench.

Key Insights and Ideas

  • The "Pass/Fail" Signal is Too Sparse: Relying solely on binary test outcomes is insufficient for teaching LLMs the nuances of execution semantics, especially for subtle logical errors.
  • Failed Rollouts are Valuable Training Data: Instead of discarding incorrect code, CodeRL+ repurposes it to learn why it failed, providing a richer learning signal.
  • Variable Trajectories are Key: Inferring how variables change step-by-step offers a direct and dense signal for understanding program behavior.
  • Alignment Improves Internal Representations: Probe analyses show that CodeRL+ trained models develop internal representations that better capture execution semantics, moving beyond mere textual pattern matching.
  • Generalization is Enhanced: The focus on execution semantics not only improves code generation but also boosts performance on related tasks like code reasoning.

Key Results

  • Code Generation: CodeRL+ achieves state-of-the-art (SOTA) performance on HumanEval, LeetCode, and LiveCodeBench, with an average relative improvement of 4.6% in pass@1 compared to baselines. For example, on HumanEval, it reached 90.9% pass@1, outperforming the base model (88.4%) and GRPO (87.2%).
  • Code Reasoning: It achieved the best performance on LiveCodeBench-Reason, with a 15.5% higher accuracy than the next best method.
  • Test Output Generation: It showed a 4.4% higher accuracy on LiveCodeBench-Test.
  • LLM and RL Algorithm Agnostic: CodeRL+ demonstrated consistent improvements across different LLM families (LLaMA-3.1, Qwen2.5) and sizes, as well as various RL algorithms (GRPO, PPO, REINFORCE++). For instance, it achieved an 11.2% average absolute improvement over GRPO on LLaMA-3.1-8B-Instruct.
  • Ablation Studies: The results confirmed the importance of using failed rollouts, on-policy alignment, and inferring fine-grained variable trajectories.

Limitations and Future Work

  • Computational Constraints: The study was limited to models up to 8B parameters due to computational costs. Evaluating on larger LLMs could reveal further generalizability.
  • Hyperparameter Tuning: Due to the high cost of RL post-training, extensive hyperparameter tuning was not performed.
  • Computational Overhead: The execution semantics alignment component adds computational overhead compared to standard RL algorithms, though the paper argues it leads to superior performance and higher ceilings.
  • Future Work: The paper suggests that the approach can be integrated with other RL algorithms and LLMs, and its effectiveness on larger models and more complex tasks could be explored. The authors also highlight the potential for this method to improve other code-related tasks.

Summary updated

BibTeX
@misc{jiang2025coderl,
  author = {Xue Jiang and Yihong Dong and Mengyang Liu and Hongyi Deng and Tian Wang and Yongding Tao and Rongyu Cao and Binhua Li and Zhi Jin and Wenpin Jiao and Fei Huang and Yongbin Li and Ge Li},
  title = {{CodeRL+: Improving Code Generation via Reinforcement with Execution Semantics Alignment}},
  year = {2025},
  eprint = {2510.18471},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.18471},
}
Figure