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

Self-Execution Simulation Improves Coding Models

Gallil Maimon, Ori Yoran, Felix Kreuk, Michael Hassid, Gal Cohen, Pierre Chambon, Yossi AdiarXiv 2026

TL;DR

Code LLMs often struggle to accurately predict the runtime behavior of the code they generate. This paper demonstrates that models can be trained to simulate program execution step-by-step using natural language traces and reinforcement learning. This "internal simulator" allows models to effectively verify and iteratively fix their own code, yielding substantial performance gains on competitive programming benchmarks without relying on an external sandbox or interpreter.

What Problem Does This Paper Address?

Traditional code LLMs treat code as static text blocks, frequently failing to understand the dynamic runtime behavior of their own programs. While executing code in a real environment (like a Python interpreter) provides a reliable feedback loop during training or inference, doing so at scale introduces massive practical headaches: complex environment setups, dependency management, security sandboxing, and high computational overhead.

To bypass these bottlenecks, this paper explores whether an LLM can act as its own "world model" for code. The authors tackle a key question: Can we teach an LLM to faithfully simulate code execution internally, and can this capability be leveraged to improve its code-generation performance?

Methods

The authors introduce a two-stage training pipeline to build and exploit this internal simulation capability:

  1. Natural Language Execution Tracing (NLEX) via SFT: The authors collect Python programs and record their line-by-line execution states. They use a strong teacher model to translate these raw, structured execution traces into free-form natural language explanations. The base models are then subjected to Supervised Fine-Tuning (SFT) on these conversational execution traces.
  2. Multi-Task Reinforcement Learning with Verifiable Rewards (RLVR): The model is further optimized using RLVR on two alternating objectives:
  3. Output Prediction: Given a code snippet and standard input (stdin), the model must reason step-by-step to predict the correct standard output (stdout).
  4. Code Optimization: Solving competitive programming tasks directly.
Figure 2. The two parts of our training pipeline. 1) Supervised fine tuning on natural language execution traces (NLEX), 2) Multi-task reinforcement learning on output prediction and competitive programming (optionally with multi-turn feedback and fixing).

At inference time, this simulation capability is deployed in two ways:

  • Self-Execution for Verification (best@k simulate): The model generates multiple candidate solutions, internally simulates their execution on public test cases, and selects the candidate predicted to pass the most tests.
  • Self-Execution for Fixing (Self-RLEF): A multi-turn framework where the model generates code, simulates its execution to generate its own feedback, and iteratively refines the code based on that simulated feedback.

Datasets

  • NLEX Dataset: A newly compiled dataset featuring ~30M functions from basic code sources and 115k complex competitive programming solutions from CodeContests, all paired with natural language execution traces.
  • Bootstrapping Datasets: OpenMathReasoning and OpenCodeReasoning to establish baseline reasoning capabilities.
  • Evaluation Benchmarks:
  • CruxEval-O: For evaluating short Python function execution and input/output prediction.
  • LCB-IO: A subset of LiveCodeBench-v6 focusing strictly on standard I/O problems.
  • DMC: Validation and test splits derived from CodeContests.

Key Insights and Ideas

  • Natural Language over JSON: Unlike prior work that relied on rigid, structured formats (like JSON) to track variable states, this paper uses free-form natural language. This allows the model to inject semantic context (e.g., explaining a matrix update within a dynamic programming algorithm) and abstract away tedious details like character-by-character loops.
  • Overcoming "Self-Blindness": Previous literature suggested that LLMs are inherently blind to flaws in their own code. This work proves otherwise: with targeted NLEX and RLVR training, models can reliably simulate and debug their own generations.
  • A Narrow Simulation Gap: The performance gap between using the model's internal simulation versus a real Python interpreter oracle (the "simulation gap") is remarkably small, demonstrating that internal world-modeling of code is highly effective.

Key Results

  • Massive Output Prediction Gains: On the CruxEval-O benchmark, adding NLEX data caused a massive surge in pass@1 accuracy, with Qwen2.5-3B jumping from 37.5% to 68.0% and Qwen2.5-7B improving from 48.5% to 75.5%.
  • Effective Self-Verification: When using the best@k setup, filtering solutions via internal simulation provided a 2 to 8 point absolute boost in competitive programming pass rates compared to standard sampling.
  • Iterative Self-Fixing Success: Under the Self-RLEF framework on the DMC dataset, the model successfully fixed 17.0% of initially failing solutions based purely on simulated feedback, boosting the final pass rate to 63.2% (up from the 49.0% official baseline).
Figure 4. Best@k performance of self-verification with self-simulation. Solutions and output predictions are produced by the same model - based on Qwen2.5-7B or CWM, trained for both solving and output prediction. Even though the tests used for filtering are in the solve prompt, there is still room for notable gains from simulating them.

Limitations and Future Work

  • Complex Computational Operations: The internal simulator struggles with heavy numerical or complex algorithmic math, such as multiplying massive numbers or calculating precise logarithms.
  • Single-File Constraints: The approach is currently limited to single-file competitive programming problems. Scaling this internal simulation to full multi-file software repositories (like SWE-bench) remains an open challenge.
  • RL Instability with Rich Feedback: While providing the model with full textual explanations of execution errors during the fixing phase is ideal, the authors noted that training with such rich textual feedback currently presents significant training stability challenges.

Summary updated

BibTeX
@misc{maimon2026self,
  author = {Gallil Maimon and Ori Yoran and Felix Kreuk and Michael Hassid and Gal Cohen and Pierre Chambon and Yossi Adi},
  title = {{Self-Execution Simulation Improves Coding Models}},
  year = {2026},
  eprint = {2604.03253},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.03253},
}
Figure