Co-Evolving Policy and Reward for Code Generation: A Mechanistic Study of Single-Adapter Drift
Organizations: Jarvis College of Computing and Digital Media, DePaul University, Chicago, IL, USA
Abstract
Reinforcement learning with verifiable rewards (RLVR) is particularly well suited to code generation because generated programs can be objectively evaluated through execution. Execution also provides behavioral information that can be reused as additional supervision. The Synergistic Policy and Reward Co-Evolving Framework (SPARK), originally proposed for reasoning tasks, exploits this idea by recycling training rollouts and their evaluation results to train a model not only to generate solutions but also to evaluate and improve them. We investigate whether this policy-reward co-evolution approach transfers effectively to code generation and whether execution-grounded reflection provides an additional source of self-improvement. We compare SPARK-style rollout recycling with execution-only Group Relative Policy Optimization (GRPO) using Qwen2.5-Coder-3B-Instruct. Our results do not support either hypothesis under the configuration tested. Although co-evolution improves training performance, these gains do not generalize to held-out problems. Compared at the same stage of training, rollout recycling produces roughly 34x greater KL divergence from the reference policy than execution-only GRPO. Over training, trained tokens per GRPO sequence fall from 185 to 86 as training pass rate increases, while held-out performance declines or fails to sustain early gains. We characterize these patterns as single-adapter policy drift: the shared trainable parameters increasingly depart from pretrained code-generation behavior without corresponding gains in generalization. The results show that higher training reward alone is not evidence of generalizable code self-improvement and highlight the importance of held-out evaluation and drift diagnostics.
Figures & tables
| Objective | Weight | Input | Supervised target |
|---|---|---|---|
| Pointwise | 0.00 | one candidate solution | correctness label (not used) |
| Pairwise | 0.05 | two candidate solutions | the better candidate |
| Reflection | 1.00 | failing code + execution trace | correct rollout, else canonical solution |
| Condition | HE@1 | HE@5 | MBPP@1 | MBPP@5 | Train Pass | Mean Reward | KL | Refl. Fix |
|---|---|---|---|---|---|---|---|---|
| Baseline | 0.7963 | 0.8537 | 0.6340 | 0.6800 | – | – | – | 0.1176 |
| A: Exec-only GRPO | 0.8049 | 0.8537 | 0.6360 | 0.6900 | 0.6385 | 0.6713 | 0.0011 | – |
| C-light: Naive Co-Evolve | 0.7732 | 0.8232 | 0.6580 | 0.6800 | 0.6577 | 0.6930 | 0.0941 | 0.1389 |
| C-reg: Regularized Co-Evolve | 0.8000 | 0.8537 | 0.6300 | 0.7200 | 0.6288 | 0.6578 | 0.0136 | 0.0968 |
| Model / Checkpoint | HE@1 | HE@5 | MBPP@1 | MBPP@5 | Train Pass | Mean Reward | KL | Refl. Fix |
|---|---|---|---|---|---|---|---|---|
| Baseline | 0.7963 | 0.8537 | 0.6340 | 0.6800 | – | – | – | 0.1176 |
| A-long best (iter 4) | 0.8159 | 0.8720 | 0.6380 | 0.7100 | 0.6486 | 0.6844 | 0.0023 | – |
| A-long matched (iter 5) | 0.7963 | 0.8537 | 0.6360 | 0.6900 | 0.6723 | 0.7086 | 0.0024 | – |
| C-reg2 best HE@1 (iter 1) | 0.7988 | 0.8476 | 0.6380 | 0.7000 | 0.5933 | 0.6237 | 0.0003 | 0.0606 |
| C-reg2 matched (iter 5) | 0.7707 | 0.8232 | 0.6280 | 0.6700 | 0.6574 | 0.6857 | 0.0822 | 0.0811 |
| C-reg2 final (iter 6) | 0.7744 | 0.8232 | 0.6320 | 0.6800 | 0.6962 | 0.7274 | 0.0957 | 0.0833 |
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