Abstract
This paper introduces CURE (Co-evolving Coder and Unit Tester via Reinforcement Learning), a framework designed to enhance the coding and verification capabilities of Large Language Models (LLMs) through mutual self-play. By training a single model to simultaneously generate code and discriminative unit tests, CURE creates a self-improving loop that reduces reliance on expensive human-labeled data. The resulting ReasonFlux-Coder models demonstrate significant performance improvements over state-of-the-art open-weights models, achieving superior accuracy in competitive programming benchmarks and enhanced efficiency in long-Chain-of-Thought (CoT) reasoning.
Introduction
Training LLMs for high-quality code generation typically requires massive amounts of human-labeled or ground-truth code, which is expensive and difficult to scale. Furthermore, while LLMs are becoming better at writing code, they often struggle to verify their own work. Traditional verification methods, such as using a separate reward model, often introduce quadratic computational complexity during "Best-of-N" sampling.
CURE addresses the need for a scalable, self-improving system where the model learns to write better code by learning to write better tests, and vice versa. This approach effectively uses unit tests as a lightweight and reusable reward signal, allowing the model to bootstrap its own performance through execution-based feedback.
Methodology: The CURE Framework
The core of the proposed method is the co-evolution of the coder and the unit tester. The process follows an iterative cycle of interaction and optimization:
- Self-Play Interaction: For a given task, the model generates multiple candidate code solutions and multiple candidate unit tests.
- Execution Table: Every code candidate is run against every generated unit test, creating a binary pass/fail matrix that serves as the basis for evaluation.
- Mutual Supervision:
- The Coder is rewarded based on its ability to pass ground-truth unit tests.
- The Unit Tester is rewarded based on its "reward precision"—its ability to pass correct code while failing incorrect code. A specific reward formula is derived to penalize "trivial" tests (which pass everything) and "impossible" tests (which fail everything).
- Iterative Optimization: The model is updated using Group Relative Policy Optimization (GRPO), alternating between improving its coding and testing policies.
- Response-Length-Guided Reward: For models utilizing Chain-of-Thought (CoT), the authors introduce a reward transformation that penalizes unnecessarily long reasoning paths. This forces the model to become more concise and efficient during inference without compromising accuracy.
Experimental Results
The researchers developed three models: ReasonFlux-Coder-4B, 7B, and 14B, trained on a small set of 4.5K coding problems from CodeContests. Evaluation across major benchmarks including LiveBench, MBPP, and LiveCodeBench revealed several key findings:
Performance and SOTA Comparison
The ReasonFlux-Coder-14B outperformed similarly sized specialized models, including Qwen-Coder-14B-Instruct and DeepSeek-Coder-V2-Lite, across almost all benchmarks. The 7B and 14B models improved one-shot code generation accuracy by 5.3% and Best-of-N (BoN) accuracy by 9.0% over the Qwen2.5-Instruct base.
Agentic Coding and Self-Correction
When integrated into agentic workflows (such as AlphaCodium), the model achieved an 8.1% improvement over the base model. This suggests that the co-evolution process significantly enhances the model's ability to self-correct and reason about code logic through its improved testing capabilities.
Inference Efficiency
By rewarding shorter reasoning chains, the ReasonFlux-Coder-4B (long-CoT) achieved 64.8% inference efficiency compared to the base Qwen3-4B. This optimization allowed the model to slash inference costs by nearly 35% while maintaining higher accuracy than the original base model.
Discussion and Key Insights
A primary insight of this work is that generating a valid unit test is often computationally simpler for an LLM than solving the entire coding problem, yet a high-quality test provides a high-fidelity signal for correctness. The "Mutual Supervision" loop ensures that the coder's mistakes become the tester's best training data; by observing where the coder fails, the tester learns to write more discriminative tests.
Furthermore, the unit tester trained via CURE can act as a standalone reward model to fine-tune other base models, achieving performance gains comparable to using human-labeled ground-truth tests. This demonstrates the potential for label-free reinforcement learning in the coding domain.
Limitations and Future Work
While CURE reduces the need for ground-truth code, it still utilizes a small set of ground-truth unit tests to bootstrap the reward signal during the initial training phase. Additionally, the current focus is on competitive programming-style tasks. Future research will explore how this co-evolution scales to complex, multi-file software engineering projects and move toward truly autonomous self-supervision using execution-based consistency as the sole starting signal.
Conclusion
CURE represents a significant step toward self-improving LLMs for software engineering. By aligning the development of coding and testing skills, the framework produces models that are not only more accurate but also more efficient and capable of sophisticated self-verification.
Summary updated