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

StepCoder: Improving Code Generation with Reinforcement Learning from Compiler Feedback

Shihan Dou, Yan Liu, Haoxiang Jia, Enyu Zhou, Limao Xiong, Junjie Shan, Caishuang Huang, Xiao Wang, Xiaoran Fan, Zhiheng Xi, Yuhao Zhou, Tao Ji, Rui Zheng, Qi Zhang, Tao Gui, Xuanjing Huang

Abstract

Large Language Models (LLMs) often struggle with complex programming tasks due to the sparse rewards and credit assignment challenges inherent in Reinforcement Learning from Compiler Feedback (RLCF). We present StepCoder, a novel framework that addresses these issues through two key components: a Curriculum of Code Completion Subtasks (CCCS) and Fine-Grained Optimization (FGO). CCCS breaks down complex requirements into manageable completion tasks, while FGO utilizes execution traces to mask unexecuted code segments during optimization. Our results on the APPS+, HumanEval, and MBPP benchmarks demonstrate that StepCoder significantly outperforms existing baselines, particularly in handling high-complexity competitive programming problems.

Introduction

While LLMs have become remarkably proficient at generating simple code snippets, they frequently fail when faced with complex, multi-step programming requirements. Researchers typically use Reinforcement Learning from Compiler Feedback (RLCF) to bridge this gap, utilizing the pass/fail results of unit tests as a reward signal. However, RLCF faces two major hurdles: the Exploration Challenge, where the search space for correct code is vast and rewards are sparse, and the Credit Assignment Problem, where the entire code block is penalized for a single error, or model weights are updated based on code that was never even executed.

Methodology

The authors introduce StepCoder, which consists of two primary components designed to solve these issues:

Curriculum of Code Completion Subtasks (CCCS)

Instead of forcing the model to generate a complex program from scratch, CCCS breaks the task into a curriculum. Initially, the model is given a large portion of a "canonical" (correct) solution and asked to complete just the final segment. As the model's proficiency increases, the starting point moves backward toward the beginning of the file until the model can generate the entire solution from just the natural language prompt.

The StepCoder architecture vs. Vanilla RL, illustrating the CCCS process.

Fine-Grained Optimization (FGO)

This technique leverages the execution trace of the code. During RL training, the framework identifies which tokens were actually executed during the unit test. FGO then masks out the unexecuted tokens, ensuring the model's weights are only updated based on the code that actually contributed to the reward (or failure). This provides a much higher-fidelity signal to the model compared to standard RL, which is "blind" to the internal logic of the code.

Experimental Setup

The framework uses Proximal Policy Optimization (PPO) as the underlying RL algorithm and DeepSeek-Coder-Instruct-6.7B as the backbone model. To ensure high-quality training, the authors created APPS+, a refined version of the APPS dataset containing 7,413 instances, all manually verified to ensure unit test correctness and standardized I/O formats.

Key Results

StepCoder demonstrated clear superiority over vanilla PPO and other state-of-the-art RL methods across multiple benchmarks:

  • APPS+ Performance: StepCoder achieved an overall Pass@1 of 36.1%, outperforming the SFT baseline (29.8%) and other RL methods like RLTF (32.7%).
  • Generalization: On HumanEval, StepCoder reached 78.7%, and on MBPP, it reached 67.0%.
  • Complexity Handling: The CCCS component was particularly effective for "Competition" level problems, where the gap between StepCoder and other models was most pronounced.
  • Error Reduction: Analysis showed that StepCoder significantly reduced the rate of compilation and runtime errors compared to standard models, indicating a better grasp of syntax and structural requirements.
Comparison of compile and runtime error rates across Introductory, Intermediary, and Competition levels.

Conclusion and Future Work

StepCoder effectively addresses the core challenges of RLCF in code generation by combining curriculum learning with execution-aware optimization. While the model is better at passing tests, it still faces challenges with complex runtime failures that aren't easily solved by simple masking. Future work will involve deeper semantic analysis of test failures, increasing unit test density, and extending the framework to multi-language environments beyond Python.

Summary updated

BibTeX
@inproceedings{dou2024stepcoder,
  author = {Shihan Dou and Yan Liu and Haoxiang Jia and Enyu Zhou and Limao Xiong and Junjie Shan and Caishuang Huang and Xiao Wang and Xiaoran Fan and Zhiheng Xi and Yuhao Zhou and Tao Ji and Rui Zheng and Qi Zhang and Tao Gui and Xuanjing Huang},
  title = {{StepCoder: Improving Code Generation with Reinforcement Learning from Compiler Feedback}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.251},
}
Figure