[NeurIPS 2025 Spotlight] Co-Evolving LLM Coder and Unit Tester via Reinforcement Learning
See the code
We propose CURE, a novel reinforcement learning framework that co-evolves LLM coder and unit tester to improve the overall coding ability of large language models. Trained on just 4.5 K samples, our ReasonFlux-Coder models outperform similarly sized Qwen Coder, DeepSeek Coder and Seed Coder. Also, we make everything publicly available—including models, comprehensive evaluation benchmarks, training and testing datasets, and training codes!
Our reinforcement learning framework co-evolves the LLM’s coding and unit-test generation abilities simultaneously, thereby improving its overall coding performance. As shown in the table above, after training on Qwen2.5-7B/14B-Instruct or Qwen3-4B, the models excel at one-shot coding, unit-test generation, and Best-of-N accuracy. Crucially, the unit tester requires no ground-truth code in the training data—it automatically learns from the coder’s mistakes during the RL rollout process.
The unit tester can be applied to test‐time scaling, agentic coding (iterative debugging and refinement), and even serve as a reward model for your coding LLM’s RL training (refer to our paper)!
conda create --name CURE python=3.10
source activate CURE
pip install torch
pip install -r requirements.txt
pip install --no-cache-dir \
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/\
flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
You can also install FlashAttention based on your version of PyTorch and CUDA.
We provide datasets in the Stdio format, including CodeContests, LiveBench, LiveCodeBench, CodeForces, and MBPP. You can also add your own evaluation dataset, detailed instructions are in ./data.
Download the evaluation data LiveBench (can also choose CodeContests, LiveCodeBench, CodeForces and MBPP)
cd data
python download_dataset.py --dataset LiveBench
Download the training data CodeContests_train
cd data
python download_dataset.py --dataset CodeContests_train
After downloading the dataset, you can perform a comprehensive evaluation using our benchmark, which includes one-shot coding, unit test generation, and Best-of-N (BoN) evaluation, supported by both API-based and vLLM-based inference. Detailed instructions are in ./evaluation; you can modify ./evaluation/evaluation_config.py then to evaluate your model's coding ability by python eval.py. We have two simple examples here:
cd evaluation
python eval.py \
--use_api False \
--pretrained_model Qwen/Qwen2.5-7B-Instruct \
--single_eval False \
--dataset CodeContests \
--k_code 4 \
--k_case 4 \
--scale_tuple_list "[(2, 2), (4, 4)]" \
--gpu_groups "[[0,1],[2,3],[4,5],[6,7]]"
pretrained_model is the model to evaluate;
dataset is the evaluation dataset;
k_code and k_case is the number of codes and unit tests the LLM generates to conduct BoN;
scale_tuple_list is the BoN setting list you want to report: (number of codes, number of unit tests);
gpu_groups is the GPU usage, [[0]] represents only one engine with one GPU; [[0, 1], [2, 3]] represents two engines each with 2 GPUs, each engine loads a model to do inference concurrently.
cd evaluation
python eval.py \
--use_api True \
--api_key API_KEY \
--base_url BASE_URL \
--api_model_name gpt-4o-mini \
--single_eval True \
--dataset CodeContests \
--rpm_limit 100
api_key is your API key;
base_url is your base url;
api_model_name is the model to evaluate;
dataset is the evaluation dataset;
rpm_limit the the request per minute you can set.
To start training, simply set the configurations in ./optimization/optimization_config.py, run the following command to CURE your coding model!
python run.py
See instructions about configuration details and how to monitor the results in ./optimization.
@article{wang2025cure,
title={Co-Evolving LLM Coder and Unit Tester via Reinforcement Learning},
author={Wang, Yinjie and Yang, Ling and Tian, Ye and Shen, Ke and Wang, Mengdi},
journal={arXiv preprint arXiv:2506.03136},
year={2025}
}
This code is heavily based on the amazing work of Open-Reasoner-Zero and OpenRLHF!
Please do not hesitate to report any issues or difficulties you encounter.
11 commits
2 commits
Python
93.7%
Jupyter Notebook
6.3%
[NeurIPS 2025 Spotlight] Co-Evolving LLM Coder and Unit Tester via Reinforcement Learning
See the code
We propose CURE, a novel reinforcement learning framework that co-evolves LLM coder and unit tester to improve the overall coding ability of large language models. Trained on just 4.5 K samples, our ReasonFlux-Coder models outperform similarly sized Qwen Coder, DeepSeek Coder and Seed Coder. Also, we make everything publicly available—including models, comprehensive evaluation benchmarks, training and testing datasets, and training codes!
Our reinforcement learning framework co-evolves the LLM’s coding and unit-test generation abilities simultaneously, thereby improving its overall coding performance. As shown in the table above, after training on Qwen2.5-7B/14B-Instruct or Qwen3-4B, the models excel at one-shot coding, unit-test generation, and Best-of-N accuracy. Crucially, the unit tester requires no ground-truth code in the training data—it automatically learns from the coder’s mistakes during the RL rollout process.
The unit tester can be applied to test‐time scaling, agentic coding (iterative debugging and refinement), and even serve as a reward model for your coding LLM’s RL training (refer to our paper)!
conda create --name CURE python=3.10
source activate CURE
pip install torch
pip install -r requirements.txt
pip install --no-cache-dir \
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/\
flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
You can also install FlashAttention based on your version of PyTorch and CUDA.
We provide datasets in the Stdio format, including CodeContests, LiveBench, LiveCodeBench, CodeForces, and MBPP. You can also add your own evaluation dataset, detailed instructions are in ./data.
Download the evaluation data LiveBench (can also choose CodeContests, LiveCodeBench, CodeForces and MBPP)
cd data
python download_dataset.py --dataset LiveBench
Download the training data CodeContests_train
cd data
python download_dataset.py --dataset CodeContests_train
After downloading the dataset, you can perform a comprehensive evaluation using our benchmark, which includes one-shot coding, unit test generation, and Best-of-N (BoN) evaluation, supported by both API-based and vLLM-based inference. Detailed instructions are in ./evaluation; you can modify ./evaluation/evaluation_config.py then to evaluate your model's coding ability by python eval.py. We have two simple examples here:
cd evaluation
python eval.py \
--use_api False \
--pretrained_model Qwen/Qwen2.5-7B-Instruct \
--single_eval False \
--dataset CodeContests \
--k_code 4 \
--k_case 4 \
--scale_tuple_list "[(2, 2), (4, 4)]" \
--gpu_groups "[[0,1],[2,3],[4,5],[6,7]]"
pretrained_model is the model to evaluate;
dataset is the evaluation dataset;
k_code and k_case is the number of codes and unit tests the LLM generates to conduct BoN;
scale_tuple_list is the BoN setting list you want to report: (number of codes, number of unit tests);
gpu_groups is the GPU usage, [[0]] represents only one engine with one GPU; [[0, 1], [2, 3]] represents two engines each with 2 GPUs, each engine loads a model to do inference concurrently.
cd evaluation
python eval.py \
--use_api True \
--api_key API_KEY \
--base_url BASE_URL \
--api_model_name gpt-4o-mini \
--single_eval True \
--dataset CodeContests \
--rpm_limit 100
api_key is your API key;
base_url is your base url;
api_model_name is the model to evaluate;
dataset is the evaluation dataset;
rpm_limit the the request per minute you can set.
To start training, simply set the configurations in ./optimization/optimization_config.py, run the following command to CURE your coding model!
python run.py
See instructions about configuration details and how to monitor the results in ./optimization.
@article{wang2025cure,
title={Co-Evolving LLM Coder and Unit Tester via Reinforcement Learning},
author={Wang, Yinjie and Yang, Ling and Tian, Ye and Shen, Ke and Wang, Mengdi},
journal={arXiv preprint arXiv:2506.03136},
year={2025}
}
This code is heavily based on the amazing work of Open-Reasoner-Zero and OpenRLHF!
Please do not hesitate to report any issues or difficulties you encounter.
11 commits
2 commits
Python
93.7%
Jupyter Notebook
6.3%