Papers
Topics
Authors
Recent
Search
2000 character limit reached

Pass@k: Evaluating LLM Code and Reasoning

Updated 3 July 2026
  • Pass@k is a metric that measures the probability that at least one of k generated outputs passes a verifier, essential for LLM applications in code and reasoning tasks.
  • It drives research into methods like Coordinated Pass@k Policy Optimization, which segments solution generation into planning and solving stages to enhance diversity.
  • Analytical trade-offs between pass@k and pass@1 reveal gradient interference issues, leading researchers to adopt blended objectives to balance reliability and diversity.

Pass@kk (commonly styled as pass@k) is a fundamental metric and optimization target in evaluating LLMs for verifiable, open-ended tasks such as code generation, mathematical reasoning, and short-answer question answering. The metric quantifies the probability that, out of kk independently sampled model outputs for a given input, at least one output passes a programmatic verifier or test suite. Pass@kk has shaped both benchmarks and learning objectives in LLM research, giving rise to policy optimization methods explicitly targeting multi-sample verification. The metric, its formalism, empirical observed trade-offs, and algorithmic specialization are central to current LLM evaluation and training regimes (Li et al., 26 May 2026, Barakat et al., 24 Feb 2026).

1. Formal Definition and Analytical Properties

Pass@kk is defined with respect to a distribution D\mathcal{D} over prompts xXx\in\mathcal{X} and a stochastic LLM policy πθ(yx)\pi_\theta(y\mid x). For each prompt xx, the single-sample success probability is

pθ(x):=Eyπθ(x)[r(x,y)][0,1],p_\theta(x) := \mathbb{E}_{y\sim\pi_\theta(\cdot\mid x)}[r(x,y)] \in [0,1],

where r(x,y){0,1}r(x, y)\in\{0,1\} indicates verifier-confirmed correctness.

For kk0 i.i.d. samples kk1, the canonical pass@kk2 reward is

kk3

The population-level pass@kk4 objective is

kk5

The pass@kk6 value captures the complementary failure probability: under i.i.d. sampling,

kk7

If kk8,

kk9

The metric is monotonically increasing in kk0, and kk1 where kk2 is concave and increasing.

2. Standard Inference Protocols and Limitations of IID Sampling

The prevailing protocol for code and reasoning task evaluation samples kk3 continuations per prompt and declares success if any candidate passes the verifier. This approach is computationally straightforward but can be highly sample-inefficient at nontrivial kk4, especially with modern overconfident LLMs. When the model “collapses” onto a single dominant solution mode, i.i.d. sampling yields numerous near-duplicate outputs—leading to wasted computational budget without true exploration of alternative strategies or algorithms.

This redundancy is particularly detrimental in problem domains—such as competitive programming—where a multiplicity of fundamentally distinct algorithmic ideas may exist, and a single working attempt suffices for pass@kk5 success (Li et al., 26 May 2026).

3. Coordinated Pass@K Policy Optimization (CPPO) and Algorithmic Advances

To address the inefficiency of i.i.d. sampling, the Coordinated Pass@kk6 Policy Optimization (CPPO) framework recasts pass@kk7 solution generation as a joint exploration process over a structured strategy space. The approach factors generation into a two-stage policy:

  • Planner kk8 emits a tuple kk9 of high-level strategies, autoregressively enforcing novelty across kk0.
  • Shared solver kk1 generates a complete solution kk2 from each kk3.

The resulting trajectory is kk4, with joint probability

kk5

Reward assignment incorporates:

  • Branch-level verifier rewards kk6
  • Tuple-level outcome reward kk7, directly matching pass@kk8
  • Plan-validity reward kk9, gating credit to tuples that are valid (distinct, code-free outlines, minimal topicality)
  • Combined planner reward D\mathcal{D}0

CPPO is trained with Gradient Regularized Proximal Policy Optimization (GRPO) and a split-region advantage scheme: token-level solvers use normalized within-tuple advantages; planners use normalized advantages across sampled tuples.

Empirical results show CPPO consistently outperforms direct sampling and competitive pass@D\mathcal{D}1-oriented RL baselines across APPS, CodeContests, and LiveCodeBench-v6, achieving statistically significant improvements in six of nine (model, dataset) cells (Li et al., 26 May 2026). As a concrete example, CPPO delivers a gain of D\mathcal{D}2 (from D\mathcal{D}3 to D\mathcal{D}4) on LiveCodeBench-v6 with Qwen3.5-9B compared to PKPO.

4. Analytical Trade-Offs: Pass@K vs Pass@1 and Gradient Interference

Post-training LLMs to maximize pass@D\mathcal{D}5 has revealed a recurring trade-off: as D\mathcal{D}6 increases, pass@D\mathcal{D}7 improves but pass@1 degrades (Barakat et al., 24 Feb 2026). This is operationally significant, given that single-shot inference often remains necessary due to resource or latency constraints.

Analytically, pass@D\mathcal{D}8 optimization amplifies gradients for “hard” prompts (i.e., those with lower base success probability), via the weighting D\mathcal{D}9 in the chain-rule expansion of xXx\in\mathcal{X}0. This non-uniform reweighting can result in a global gradient that is anti-aligned with the pass@1 direction, especially in the presence of prompts exhibiting negative interference. For prompt xXx\in\mathcal{X}1, the agreement xXx\in\mathcal{X}2 quantifies its gradient’s alignment with the population mean.

If negatively-interfering, low-success prompts are sufficiently amplified by xXx\in\mathcal{X}3, the overall optimization step for xXx\in\mathcal{X}4 can perversely harm xXx\in\mathcal{X}5, as formalized in Proposition 3.1 and explored empirically. For sufficiently large xXx\in\mathcal{X}6, a phase transition can occur where further increase in xXx\in\mathcal{X}7 guarantees gradient conflict and pass@1 decline.

Empirical validation on mathematical reasoning tasks with LLMs (DeepSeek-R1-Distill-Llama-8B and DeepSeek-R1-Distill-Qwen-7B) confirms that agreement scores stratify by difficulty and that pass@xXx\in\mathcal{X}8 weighting can upweight hard, negatively interfering prompts with power-law disparity—yielding persistent negative gradient inner products and pass@1 regression during pass@xXx\in\mathcal{X}9 optimization (Barakat et al., 24 Feb 2026).

5. Practical Recommendations and Mitigation Strategies

Operational workflows should consider the following:

  • When only single-sample inference (pass@1) is feasible, direct pass@πθ(yx)\pi_\theta(y\mid x)0 optimization without constraint may degrade real-world reliability.
  • One can blend the pass@πθ(yx)\pi_\theta(y\mid x)1 and pass@1 objectives (e.g., interpolate πθ(yx)\pi_\theta(y\mid x)2 with πθ(yx)\pi_\theta(y\mid x)3) to regularize training and retain single-sample fidelity.
  • Capping extreme values of πθ(yx)\pi_\theta(y\mid x)4 or employing alternative risk-sensitive objectives (e.g., log-sum-exp over rewards, tuning exponents replacing πθ(yx)\pi_\theta(y\mid x)5) can smooth the optimization landscape and mitigate outlier prompt amplification.
  • Gradient-surgery or prompt-level trust-region methods can be used to remove or limit the influence of strongly negatively interfering prompts.
  • Monitoring the gradient inner product πθ(yx)\pi_\theta(y\mid x)6 can offer a diagnostic signal: if it turns negative, switching to a reduced πθ(yx)\pi_\theta(y\mid x)7 or incorporating explicit pass@1 regularization is recommended (Barakat et al., 24 Feb 2026).

6. Empirical Benchmarking and Impact

Across major code reasoning benchmarks—APPS, CodeContests, LiveCodeBench-v6—pass@πθ(yx)\pi_\theta(y\mid x)8 is the primary evaluation metric. The empirical superiority of coordinated policies (as in CPPO) demonstrates that optimizing diversity in attempted solution strategies, rather than naively increasing πθ(yx)\pi_\theta(y\mid x)9 for i.i.d. model samples, directly translates to higher pass@xx0—with the incremental benefit most pronounced on harder benchmarks and larger models. Gains of up to xx1 in pass@xx2 have been documented for Qwen3.5-4B on LiveCodeBench-v6 compared to direct sampling. This suggests that structured, reward-gated diversification substantially advances the state of the art for verifiable LLM-assisted code synthesis (Li et al., 26 May 2026).

7. Open Challenges and Future Directions

A persistent open problem is maximizing pass@xx3 without incurring excessive cost to pass@1, especially as LLMs are deployed in settings with heterogeneous inference budgets and risk tolerances. Further research into adaptive, prompt-level trade-offs, refined reward shaping, and population-wide agreement-aware optimizers is ongoing. A plausible implication is that dynamically balancing exploration (diversity) and exploitation (single-shot robustness) will remain central to the next generation of LLM post-training strategies and benchmark design.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (2)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Pass@o.