Skip to content

Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMs

Sep 2026 · 2 citations · 43 references
Computer Science

TL;DR

This work proposes Test Cases Scaling (TCS), a two-stage RL framework for effective test generation that improves both pass@1 and inference-time answer selection according to generated tests across TACO and LiveCodeBench.

Abstract

Reinforcement learning (RL) has substantially advanced code generation with large language models (LLMs) through executable feedback. The feedback for coding problems mainly comes from specific test cases, where high-quality test cases are often scarce since they should be both sound and discriminative. We thus turn to study the auto-generation of test cases using the learned model. We find this is naturally an adversarial RL problem: the model is expected to generate effective test cases as counterexamples, depending on the solver's current failure modes. We propose Test Cases Scaling (TCS), a two-stage RL framework for effective test generation. Both stages train a test generator from a rolling policy-aligned buffer: Stage 1 generates tests consistent with the reference solution, and Stage 2 restricts the buffer to current failure modes and learns counterexample tests. Across TACO and LiveCodeBench, TCS improves both pass@1 and inference-time answer selection according to generated tests. We find the learned test generator also enables effective selection among other LLM outputs.

View source

Similar papers

Preprint Aug 2026

CHORUS: Complementary Experts for High-Coverage Testbench Stimulus Generation

CHORUS is presented, a post-training framework that pushes performance beyond what a conventional supervised fine-tuning (SFT)-to-reinforcement learning (RL) pipeline achieves, and consolidates the resulting specialists into a single 4B model.

He-Jia Zhang, Sheng Lu, Zhongming Yu et al. · 0 citations
Preprint Aug 2026

Robust Code RL via Faulty-Code-Driven Test case Synthesis and Dense Reward Shaping

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.

Yiwen Zhang, Xiaodong Yan, Zhen-Yu Huang et al. · 0 citations
Open access Aug 2026

RL–LLMfuzzer: reinforcement learning–guided dual–model differential fuzzing for compiler testing

RL-LLMfuzzer, a reinforcement learning and LLM-based differential fuzzing framework that has successfully unearthed 28 officially confirmed vulnerabilities in GCC and LLVM/Clang, establishing a highly efficient and scalable paradigm for LLM-driven compiler validation.

Dong-Hui Li, Ying-Ying Li, Bo Zhao et al. · 0 citations
Preprint Sep 2026

TIPCODER: Reinforcement Learning Boosted Test-time Instruction Proposer for Code Generation

Test-time scaling for code generation typically explores the solution space by sampling multiple programs from a fixed instruction. We study a complementary direction: instance-level instruction-space exploration. Our observation is that many coding failures stem from missing constraints, overlooked edge cases, or misl...

Minyu Chen, Si-Hao Wu, Ling-I Wu et al. · 0 citations
#natural language process... Preprint Sep 2026

CovR: Coverage-Aware Hardware Verification via Reasoning-Guided Reinforcement Learning

CovR is presented, an agentic framework for automated testbench generation that combines self-reflection loops with simulation-based feedback to maximize coverage and a reinforcement learning (RL) framework tailored for coverage-driven testbench generation, leveraging tool-derived rewards from simulation and coverage f...

Manar Abdelatty, Maryam Nouh, Sherief Reda · 0 citations

Related blog posts

MIT News · Artificial Intelligence Aug 27, 2026

Looking beyond natural sequences

A new machine-learning framework aims to improve the success rate of computational protein design while moving away from results that reproduce sequences found in nature.

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.