arXiv:2609.09135cs.LGSep 2026

Manuscript Offprint

arXiv:2609.09135

Entropy-Regularized Rank-Masked Policy Optimization for Test-Time Reinforcement Learning in Code Generation

Jiacheng Xu, Feng Chen, Xiuneng Xu, Bo An

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Existing methods for test-time reinforcement learning (TTRL) derive rewards from answer-level self-voting on unlabeled test-time tasks with canonical answers, but this breaks down for code generation because programs cannot be compared by surface form and therefore do not directly provide a usable training signal. To make TTRL applicable to code generation, we propose probe-driven TTRL, which constructs output-free probe inputs from the problem statement, executes candidate programs on these probes, and defines a Probe Consensus Reward (PCR) from the resulting behavioral agreement. PCR provides a behavioral training signal for open-vocabulary programs, but it is not a fully reliable verifier and remains susceptible to reward hacking through spurious consensus. We therefore introduce Entropy-Regularized Rank-Masked Policy Optimization (ERPO), which converts low PCR into conservative negative updates through rank masking and controls policy drift with an entropy ceiling. On coding benchmarks, ERPO substantially improves pass@1 and pass@k in both in-domain adaptation and zero-shot transfer.

1 Introduction

As large language models are increasingly trusted with critical tasks, deployment-time response qual-

ity has become a central concern (Aghazadeh-Chakherlou et al., 2026). A common way to improve quality at test time is inference-time scaling, which spends additional computation without changing model parameters, typically by sampling multiple solutions and selecting one through voting, verification, or search (Wang et al., 2023; Shi et al., 2022; Li et al., 2025). Such search can be effective, but it is expensive and increases response latency when high-quality answers require many samples. Test-time reinforcement learning (TTRL) offers a complementary direction: it converts test-time signals into rewards and adapts the model on unlabeled test-time tasks, aiming to improve single-pass response quality at deployment time (Zuo et al., 2025; Liao et al., 2026; Zhou et al., 2025). This setting is most natural for tasks such as mathematical reasoning, where sampled solutions can be reduced to directly comparable canonical answers and the majority answer can serve as a pseudo-label (Wang et al., 2023; Zuo et al., 2025).

For code generation, however, model outputs are open-vocabulary programs rather than canonical final answers, so exact-match voting cannot be directly used to construct a reward (Li et al., 2022; Shi et al., 2022). Prior training-free inference-time search methods avoid exact matching by comparing execution behavior rather than program text, using

Figure

Figure 1: Performance overview. Left: Qwen3-8B per-step LCB results. Middle: Qwen3-4B mean transfer performance across three target benchmarks. Right: Qwen3-4B LCB inference-time scaling.

execution traces or functional consensus to compare candidate programs (Shi et al., 2022; Chen et al., 2023; Launer et al., 2026). Turning this behavioral comparison into a TTRL reward is non-trivial because test-time adaptation lacks the inputs needed to evaluate generated programs. The model must therefore construct inputs itself and turn the resulting outputs into a reward signal suitable for reinforcement learning. A further challenge is that existing TTRL objectives often emphasize pass@1, which can improve single-pass performance and reduce the need for costly training-free search, but can also weaken the pass@k frontier when the gain comes from reduced solution diversity (Zhou et al., 2025). This trade-off is especially undesirable in quality-sensitive applications, where pass@k serves as a practical upper bound on what training-free inference-time scaling can extract from the model (Yue et al., 2025; Snell et al., 2025).

To make TTRL applicable to code generation while improving both single-pass accuracy and the pass@k frontier, we propose probe-driven test-time reinforcement learning. For each coding problem, the model constructs a set of problem-specific, output-free probe inputs from the problem statement. It then executes sampled programs on these inputs and defines a Probe Consensus Reward (PCR) from the induced output distributions. PCR turns open-vocabulary programs into comparable training samples without relying on oracle outputs. However, because PCR is built from generated inputs and consensus over candidate outputs, it is not a fully reliable verifier. High consensus may reflect a correct solution, but it may also arise from a common bug or from probes that miss the decisive corner case (Tambon et al., 2025; He et al., 2025). Directly optimizing PCR can therefore trigger reward hacking and degrade the pass@k frontier while improving pass@1.

Motivated by this observation, we propose Entropy-Regularized Rank-Masked Policy Optimization (ERPO). Our analysis shows that the PCR signal is asymmetric: low-consensus programs are easier to identify as poor candidates than high-consensus programs are to certify as correct. Rather than treating high-PCR programs as positive labels, ERPO uses PCR mainly as a negative signal. Within each candidate group, it masks out the high-ranked half. The remaining lower-ranked samples typically have negative group-normalized advantages, so the update reduces the likelihood of low-consensus programs while avoiding direct

reinforcement of potentially spurious majorities. A fixed entropy-ceiling regularizer further controls upward entropy drift and preserves stable sampling behavior for pass@k.

We summarize our contributions as follows:

  1. We formulate probe-driven TTRL for code generation, where output-free inputs generated from the problem statement provide a behavioral interface for rewards without oracle tests or oracle outputs.

  2. We analyze the noise pattern of probe-based PCR rewards and show why direct optimization can be brittle: behavioral consensus is more reliable as a negative signal than as a correctness certificate.

  3. We propose ERPO, a policy optimization algorithm that combines negative rank-masked PCR updates with fixed entropy-ceiling control, improving both pass@1 and pass@k with gains that transfer across coding benchmarks.