This repository includes implementations to reproduce the R1 pipeline for code generation:
Qwen2.5-7B-Instruct-1M beats Qwen2.5-Coder-7B-Instruct (even better w/ 12K samples).More results and findings to come...
# For training
pip install -e .
pip install vllm==0.7.3
pip install flash-attn --no-build-isolation
pip install wandb IPython matplotlib gpustat # utility
I tried multiple ways for sandboxing including calling code execution servers, running dockerized Python, calling paid services, etc.
firejail is the approach I found to meet all the three:
OSError), etc.sudo add-apt-repository ppa:deki/firejail
sudo apt-get update
sudo apt-get install firejail firejail-profiles
The current version has 12K RL samples (prompt + tests) at 🤗 ganler/code-r1-12k:
In general, it's suggesgted to test data & sandbox on every dataset & environment before training code RL. Directly using noisy data and mismatched envornments can lead to reward false positives, confusing the model. These noise could come from (i) wrong tests, (ii) unsolvable prompts (e.g., images tags), and (iii) execution environment mismatch.
To produce locally validated RL data:
python examples/data_preprocess/coder1.py
bash main_grpo.sh
[!NOTE]
The script was optimized for single-node 8x H200 setup. You might need to customize the settings for your own workstation.
We trained two models based on Qwen2.5-7B-Instruct-1M by pure R1 Zero:
| Model | LCB (v5) | HumanEval+ | MBPP+ | Average |
|---|---|---|---|---|
| Qwen2.5-7B-Instruct-1M | 24.0 | 80.5 | 66.7 | 57.1 |
| + Code-R1-Zero (2k - 1088s GRPO) | 28.6 | 84.8 | 70.1 | 61.2 |
| + Code-R1-Zero (12k - 832s GRPO) | 29.7 | 83.5 | 74.3 | 🌟62.5 |
Some existing models:
| Model | LCB (v5) | HumanEval+ | MBPP+ | Average |
|---|---|---|---|---|
| Qwen2.5-Coder-7B-Instruct | 31.1 | 82.3 | 69.6 | 61.0 |
| Eurus-2-7B-PRIME | 23.8 | 65.9 | 29.9 | 39.9 |
| Sky-T1-7B | 21.3 | 54.3 | 50.8 | 42.1 |
If you find this work helpful...
@article{code-r1,
title={Code-R1: Reproducing R1 for Code with Reliable Rewards},
author={Liu, Jiawei and Zhang, Lingming},
howpublished={\url{https://github.com/ganler/code-r1}},
year={2025}
}
Apache-2.0. See LICENSE.code-r1 for more details.
103 followers · starred Jan 2026
1,933 followers · starred Mar 2025
529 followers · starred Mar 2025
315 followers · starred Jul 2025
This repository includes implementations to reproduce the R1 pipeline for code generation:
Qwen2.5-7B-Instruct-1M beats Qwen2.5-Coder-7B-Instruct (even better w/ 12K samples).More results and findings to come...
# For training
pip install -e .
pip install vllm==0.7.3
pip install flash-attn --no-build-isolation
pip install wandb IPython matplotlib gpustat # utility
I tried multiple ways for sandboxing including calling code execution servers, running dockerized Python, calling paid services, etc.
firejail is the approach I found to meet all the three:
OSError), etc.sudo add-apt-repository ppa:deki/firejail
sudo apt-get update
sudo apt-get install firejail firejail-profiles
The current version has 12K RL samples (prompt + tests) at 🤗 ganler/code-r1-12k:
In general, it's suggesgted to test data & sandbox on every dataset & environment before training code RL. Directly using noisy data and mismatched envornments can lead to reward false positives, confusing the model. These noise could come from (i) wrong tests, (ii) unsolvable prompts (e.g., images tags), and (iii) execution environment mismatch.
To produce locally validated RL data:
python examples/data_preprocess/coder1.py
bash main_grpo.sh
[!NOTE]
The script was optimized for single-node 8x H200 setup. You might need to customize the settings for your own workstation.
We trained two models based on Qwen2.5-7B-Instruct-1M by pure R1 Zero:
| Model | LCB (v5) | HumanEval+ | MBPP+ | Average |
|---|---|---|---|---|
| Qwen2.5-7B-Instruct-1M | 24.0 | 80.5 | 66.7 | 57.1 |
| + Code-R1-Zero (2k - 1088s GRPO) | 28.6 | 84.8 | 70.1 | 61.2 |
| + Code-R1-Zero (12k - 832s GRPO) | 29.7 | 83.5 | 74.3 | 🌟62.5 |
Some existing models:
| Model | LCB (v5) | HumanEval+ | MBPP+ | Average |
|---|---|---|---|---|
| Qwen2.5-Coder-7B-Instruct | 31.1 | 82.3 | 69.6 | 61.0 |
| Eurus-2-7B-PRIME | 23.8 | 65.9 | 29.9 | 39.9 |
| Sky-T1-7B | 21.3 | 54.3 | 50.8 | 42.1 |
If you find this work helpful...
@article{code-r1,
title={Code-R1: Reproducing R1 for Code with Reliable Rewards},
author={Liu, Jiawei and Zhang, Lingming},
howpublished={\url{https://github.com/ganler/code-r1}},
year={2025}
}
Apache-2.0. See LICENSE.code-r1 for more details.
103 followers · starred Jan 2026
1,933 followers · starred Mar 2025
529 followers · starred Mar 2025
315 followers · starred Jul 2025