Robust Code RL via Faulty-Code-Driven Test case Synthesis and Dense Reward Shaping
Organizations: Zhejiang University · Ant Group
Abstract
Reinforcement Learning from Verifiable Rewards (RLVR) is pivotal for enhancing LLM code generation, yet its efficacy is often hindered by insufficient test case coverage, leading to reward hacking and policy degradation. To address this, we propose RobustTests, a framework featuring a faulty-code-driven test case synthesis strategy. By leveraging "near-correct" faulty codes, RobustTests captures latent logical discrepancies and employs validator agents with behavioral feature clustering to filter invalid or redundant test cases. Additionally, a stepwise dense reward function based on pass rates is introduced to mitigate false negatives and enhance training robustness. Using this pipeline, we construct an augmented version of the CodeContests+ dataset with superior diagnostic utility. Experimental results show that RL fine-tuning of Qwen3-32B via RobustTests achieves a 3% absolute gain on LiveCodeBench, demonstrating its effectiveness in advancing LLM code generation proficiency. Codes and data are available at https://huggingface.co/datasets/sid6/RobustTests.
Figures & tables
| Method | Livecodebench | Codeforces | ||
| Score | Score | Rating | Percentile | |
| Naive LLM Generation | 65.75 | 35.41 | 83.36 | 91.70 |
| HardTests | 65.25 | 35.65 | 83.58 | 91.35 |
| CodeContests + | 65.41 | 35.56 | 83.96 | 91.45 |
| CodeContests-O | 66.21 | 36.43 | 84.35 | 91.81 |
| RobustTests(Ours) | 68.39 | 38.50 | 85.99 | 94.67 |
| Method | Livecodebench | Codeforces | ||
| Score | Score | Rating | Percentile | |
| RobustTests*(Ours) | 67.84 | 38.47 | 85.16 | 93.97 |
| w/o Test case Synthesis | 66.91 | 36.41 | 84.4 | 92.12 |
| w/o Diversity-Driven Selection | 66.82 | 36.23 | 84.12 | 91.96 |
| w/o Both Module | 65.41 | 35.56 | 83.96 | 91.45 |
| Dataset | Method | LiveCodeBench | Codeforces | ||
| Score | Score | Rating | Percentile | ||
| Sparse Reward | 65.41 | 83.96 | 35.56 | 91.45 | |
| Dense Reward | 66.30 | 84.24 | 37.74 | 92.05 | |
| RobustTests* | Sparse Reward | 67.84 | 85.16 | 38.47 | 93.97 |
| Dense Reward | 68.39 | 85.99 | 38.50 | 94.67 | |
| RobustTests* w/o validator | Sparse Reward | 66.02 | 83.82 | 35.91 | 91.28 |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Parameter | Value |
| Optimizer | AdamW |
| Learning Rate ( ) | |
| Adam | |
| Weight Decay | |
| Gradient Clipping | |
| Global Batch Size |
RL for Code Generation
Reinforcement learning for code generation trains models to write, repair, and optimize programs using execution-based and other task-specific feedback.
See all 150 papers