ExecVerify: White-Box RL with Verifiable Stepwise Rewards for Code Execution Reasoning

Lingxiao Tang, He Ye, Zhaoyang Chu, Muyang Ye, Zhongxin Liu, Xiaoxue Ren, Lingfeng Bao

TL;DR

ExecVerify is a novel post-training framework that teaches code LLMs to truly understand program execution rather than just mimic textual explanations. By combining constraint-based data synthesis with white-box reinforcement learning (RL) that rewards correct intermediate control- and data-flow predictions, it elevates a 7B model to match or exceed the code reasoning performance of 32B models while significantly boosting downstream code generation.

What Problem Does This Paper Address?

While Large Language Models (LLMs) excel at writing code, they frequently struggle to reason about how code actually executes step-by-step. Existing methods attempt to bridge this gap using Supervised Fine-Tuning (SFT) on teacher-generated execution traces or input-output (I/O) chains.

However, SFT only optimizes for token-level text matching; it cannot explicitly verify whether the model actually computed the correct variable values or followed the right control flow during training. This often leads to "hallucinated" execution steps where the model mimics the style of an explanation without understanding the underlying logic. Additionally, existing training datasets are typically mined passively without explicit control over structural diversity or task difficulty, resulting in data that is either trivial or completely unsolvable.

Comparison between SFT and white-box RL.

Methods

The authors introduce ExecVerify, a framework that shifts the training objective from text imitation to semantic execution understanding via a two-part strategy:

  1. Constraint-Based Data Synthesis: Instead of passively collecting code, ExecVerify actively synthesizes Python programs by enforcing structural constraints (e.g., nesting depth, specific method calls) to build a curriculum from simple to complex. It mutates inputs to create diverse execution paths and filters out trivial cases by keeping only programs that a baseline model struggles to solve.
  2. Two-Stage Post-Training via White-Box RL:
  3. Stage I (Code Reasoning): After a brief SFT warm-up, the model is trained using Group Relative Policy Optimization (GRPO). Instead of just predicting the final output, the model must answer "white-box" questions generated directly from an interpreter trace. These include control-flow questions (predicting the exact next line of code) and data-flow questions (predicting variable values and types). The reward function balances final I/O correctness and intermediate step accuracy.
  4. Stage II (Code Generation): The reasoning-enhanced model is further optimized using RL with unit-test feedback, translating its execution understanding into functional code generation capabilities.
Overview of the ExecVerify approach.

Datasets

  • Synthesized Dataset: A newly curated dataset containing 119,358 non-trivial, structurally diverse Python training examples derived from constraint-based synthesis and difficulty filtering.
  • Reasoning Evaluation Benchmarks: Evaluated on standard execution reasoning benchmarks including CRUXEval, LiveCodeBench-Exec, and REval (which measures fine-grained coverage, state, path, and output tracking). It was also tested on CRUXEval-X (multilingual) and a custom library-involved benchmark derived from BigCodeBench.
  • Code Generation Benchmarks: HumanEval, MBPP, LiveCodeBench, and BigCodeBench.

Key Insights and Ideas

  • Verification Over Imitation: Rewarding semantic correctness at the interpreter level prevents the model from faking its way through reasoning chains. Tracking internal states explicitly forces true program simulation.
  • Control Flow and Data Flow are Complementary: Ablation studies revealed that only scoring control-flow questions hurts variable state accuracy, and vice versa. Training on both yields the best balanced performance.
  • Reasoning Transfers to Generation: Better execution reasoning directly translates to fewer logical bugs during code generation. For example, the model learns to correctly implement subtle constraints (such as distinguishing "at least one" from "for all") by accurately simulating how loops and conditional guards behave at runtime.

Key Results

  • Punching Above Its Weight: A 7B model trained with ExecVerify achieved an average score of 80.8 across code reasoning benchmarks, significantly outperforming its base model (60.8) and matching or beating the much larger Qwen2.5-Coder-32B-Instruct (77.9).
  • Generation Boost: Incorporating Stage I white-box RL before code generation RL (Stage II) led to a consistent upward trend, improving pass@1 by up to 5.9% over pure unit-test RL baselines.
  • Cross-Language & Library Generalization: Despite being trained only on Python built-ins, the execution reasoning capabilities successfully generalized to five other programming languages (Java, C++, C#, Go, JavaScript, PHP) on CRUXEval-X and transferred well to code involving external libraries.

Limitations and Future Work

  • Language and Scope Constraints: The synthesized data is currently limited to Python and primarily focuses on built-in types and functions. Real-world code often relies heavily on complex third-party libraries.
  • Granularity: The approach operates at the function or snippet level. Extending it to multi-file, project-level code remains an open challenge.
  • Compute Overhead: The white-box RL pipeline requires running code through an interpreter and generating dense intermediate questions, which incurs higher computational and engineering overhead than standard SFT.

Summary updated

BibTeX
@inproceedings{tang2026execverify,
  author = {Lingxiao Tang and He Ye and Zhaoyang Chu and Muyang Ye and Zhongxin Liu and Xiaoxue Ren and Lingfeng Bao},
  title = {{ExecVerify: White-Box RL with Verifiable Stepwise Rewards for Code Execution Reasoning}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.631},
}
Figure