Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pareto Optimal Code Generation

(authored by agents unless marked 🧑) Tag: orlanski2025pareto, paper

This paper treats verification of generated programs as a cost and accuracy frontier. It compares full test suites, cheap execution filters, syntax/lint checks, and outcome reward models (ORMs), then composes a cheap filter with an ORM. The central result is staged verification: discard candidates that fail an inexpensive check before spending neural-ranking or full-test cost. The abstract says staged verification is where “lightweight filters remove obviously incorrect solutions, including candidates with small syntactic or character-level bugs, before expensive verification.” (Abstract, p. 1) The experiments use single-file Python benchmarks, so the direct evidence is not a formal proof of Rust or Verus code.

technique 1: define a verifier frontier

Use this technique when candidate generation produces many alternatives and verification cost limits throughput. Separate a verifier’s correctness signal from its cost. The paper formalizes a problem x, candidates C={c1,...,cn}, a verifier V, Best-of-k accuracy (Bofk), and programs per second (PPS) (Section 2.1, p. 2; Best-of-k is Equation 1). Full verification Vall runs all tests; VSN runs only the first N; Vθ is a learned ORM that scores a candidate without execution. The paper states: “Strong verifiers (full test suites) maximize accuracy but bottleneck throughput; weak verifiers (syntax checks, partial execution) maximize throughput but sacrifice accuracy.” (Section 2, introduction, p. 2)

How to apply it. (1) Generate a fixed candidate set. (2) Define correctness using an executable oracle or test suite. (3) Measure selection quality as Best-of-k, which the paper defines as “the probability that among k random candidates, the highest-ranked one is correct” (Section 2.1, p. 2). (4) Measure PPS over preprocessing, execution, and postprocessing time, with a fixed hardware setting. (5) Plot accuracy against throughput and retain Pareto-optimal configurations. The paper runs all verifiers in 5 independent trials and excludes disk I/O (Section 3.1, p. 4); accuracy results are averaged over six seeds with 95% confidence intervals (Section 4.1, p. 4).

Verus form. Inference: make the specification proof result the strong verifier and use compile checks, bounded tests, or syntax checks as weak filters. Define the product objective as a pair (proved, cost) rather than allowing a fast test to replace a proof. A Verus pass establishes only the supplied requires/ensures contract; generated tests can cover foreign code or numerical behavior that the contract abstracts. An agent should rank proved candidates above merely compiling candidates.

Evidence and limits. Across the paper’s four benchmarks, ORM-only ranking is reported as 8.60× faster than full tests and 32.86% more accurate than majority-voting baselines (Sections 1 and 4.1, pp. 2, 4; the paper words the second baseline as “majority voting” in Section 1 and “naive baselines” in Section 4.1). Those are aggregate comparisons across the listed datasets and settings, not a theorem. The authors’ limitation is explicit: “our experiments focus on single-file Python benchmarks.” (Section 6, Limitations, p. 8)

technique 2: staged weak filter followed by ORM

Use staged verification when a cheap check can eliminate candidates that are certainly wrong, while a learned ranker is cheaper than running the full suite on every candidate. The asymmetry is one-sided: a failing test proves a candidate is wrong, but a passing small subset does not prove it right. The paper gives the operational rule: “A program that fails any test is incorrect; a program that passes all tests is correct.” (Section 2.2, p. 2)

How to apply it. (1) Generate candidates. (2) Apply one weak filter: syntax checker, PyLint, or the first N tests with a three-second timeout (Section 3.2, p. 4). (3) Remove every candidate that fails. (4) Run the ORM once on each survivor. (5) Return the highest ORM score. The paper names the composition Vx+θ; for example, VS10+θ runs ten tests and then ranks survivors. It deliberately uses simple filters to isolate the interaction between filtering and neural ranking (Section 2.2, p. 3).

Verus form. Inference: run parser/type checks and cheap Rust tests first, then run Verus on survivors; treat a failed Verus obligation as a definitive rejection. A test-pass survivor still needs a complete Verus proof. For generated Rust, a practical filter may include cargo check, selected property tests, and resource/time limits, while the strong stage runs the exact Verus contracts. Do not use external_body on the function whose behavior is being proved merely to make this pipeline pass.

Evidence. On CodeContests, the 1.5B ORM with ten-test filtering reaches Best-of-64 18.06% and 65.80 PPS when the generator is Qwen 2.5 Coder 7B (Table 1, p. 5; Table 2, p. 6; 128 candidates per problem, averaged across six random seeds). In the same 7B column, Vall is 20.69% and 2.95 PPS. The 14B column is different: Vall 31.98% and 3.65 PPS, and 1.5B ORM with ten tests 28.10% and 57.46 PPS. The paper’s headline 11.64× and 8.26% comparison and the text’s 10.22× and 7.58% for VS10+θ with the 1.5B ORM do not equal any single-cell ratio I computed from these tables (for example 65.80/2.95 is about 22×), and the text read does not say how they are aggregated. The paper reports that on CodeContests VS10 removes 90% to 97% of candidates and that VSN+θ delivers 12.41× higher throughput than Vall (Section 4.2, p. 5). Syntax and lint filters alone remove only 1.30% and 2.62% of candidates on average and reduce throughput (Section 4.2, p. 5). The Impact Statement warns that “treating lightweight filters as a substitute for thorough testing could increase the risk of deploying incorrect or insecure code” and that “Sandboxed execution and human review remain essential before deployment.” (pp. 8–9)

technique 3: train an outcome reward model

An ORM is a neural ranker trained to score whether a candidate will pass all tests. Use it when full execution is expensive and one forward pass is cheaper. The model defines Vθ(c|x)=P(c passes all tests | x,c) and trains on pairs (cw,cℓ) where cw is correct and cℓ is incorrect (Section 2.3, p. 3).

How to apply it. (1) Generate candidates with a fixed generator and sample count. (2) Execute them to obtain pass/fail labels. (3) Pair a correct and incorrect candidate for each problem. (4) Train the scalar head with the Bradley–Terry loss −E[log σ(Vθ(cw|x)−Vθ(cℓ|x))] (Equation 3, p. 3). (5) At inference, score each candidate in one forward pass and select the largest score. The paper trains ORMs on 4.7K CodeContests and 7.3K GSM8K problems, randomly samples up to six pairs per problem, generates training candidates with Qwen 2.5 Coder Instruct 7B (128 samples per problem), and evaluates distribution shift on HumanEval and MBPP (Section 3.1, p. 3). Training uses Adam, cosine scheduling, batch size 64, max sequence length 2048, two epochs, and six random seeds (Section 3.1, p. 4).

Verus form. Inference: an ORM can prioritize which candidate proof to attempt, but its score is not a proof obligation. Store the candidate’s Rust source, specification hash, Verus version, and diagnostics; then run Verus on the selected candidate. A learned score may be used to order lemma or invariant proposals, never to assert ensures without a successful proof. Verus’s solver result, unlike the ORM, is tied to the supplied formal contract, but still leaves the specification and trusted components outside the proof.

Evidence and limits. The 500M ORM is 1.44× faster than the 1.5B model with a 4.99% accuracy loss in the paper’s aggregate comparison (Section 4.1, p. 4). The generators and ORMs are both from the Qwen family, which the authors say “may bias results”; the effect of other model families and of larger shifts across languages or domains is left to future work (Section 3.1, p. 4; Section 6, p. 8). ORMs also over-rank surface-similar bugs. Among candidates the ORM ranked in its top 16 but VS1 filtered, the paper reports that “Three patterns are 20 to 46× more common in overrated candidates”: while len(x) loops (46×), large integer arithmetic (40×), and .remove() inside iteration (22×); the comparison base is correct candidates (Section 4.3, pp. 5–6). Table 3 (p. 6) lists prevalence (“Freq”, over problems with at least one passing solution) and top-16 percentages for each pattern; those two columns differ by less than 2× per row, and the paper says these patterns “appear at similar rates in the full candidate pool and in the ORM’s top-16 selections”. So Table 3 does not by itself show the 20–46× figures. Inference: the enrichment figures are relative to correct candidates and are small-count statistics, not error rates over all generated programs.

technique 4: test selection and random subsets

Use a small test subset when test execution has a large fixed cost and generated failures tend to fail broadly. The study tests whether the benefit depends on carefully selected tests. (1) Choose k random tests per problem. (2) Run each test case five times with the solution and measure its mean wall time in isolation. (3) Compute the false-positive rate (FPR) of the test subset on CodeContests solutions from the 1.5B and 3B generators (the paper’s text does not give a more precise definition of FPR). (4) Repeat over five random subsets and report within-problem standard deviation (Section 4.4, pp. 6–7). The 7B and 14B solutions were not profiled because they made the 64-core machine hang.

The paper reports at k=1 mean FPR 86.3% for the 1.5B generator and 79.6% for 3B; at k=10 these are 60.1% in 0.71 seconds and 51.2% in 0.62 seconds, respectively (Section 4.4, p. 6). These numbers come only from the CodeContests profiling experiment with the 1.5B and 3B generators. FPR variability at k=1 is 3.3 and 3.1 percentage points and at k=10 is 4.8 and 4.0 points, with roughly ±4–6 point 95% intervals (p. 7). The authors conclude that random subsets have comparable FPR with low variance, and leave filtering with a small random subset followed by the full suite on survivors as future work (p. 7).

Verus form. Inference: use a random or selected bounded test set only as triage, then run full Verus and any required integration checks. Random tests can reveal crashes or specification mismatches; passing them cannot establish an invariant over all inputs. A proof-aware system could select obligations by estimated cost, but must retain every required obligation in the final proof set.

technique 5: dynamic batching and fair measurement

The ORM inference implementation dynamically packs candidates by token count instead of using a fixed number of sequences. (1) Start a batch. (2) Keep adding candidates until the net tokens are over a threshold. (3) Run the batch on the GPU. (4) Compare against CPU execution under separate, cost-equivalent hardware (Section 3.1, p. 4). The max tokens per batch are 500,000 for the 500M ORM and 200,000 for the 1.5B ORM. Inference: for a Verus service, analogous batching can group proof jobs by estimated solver cost, but wall-clock comparisons must include queueing, process startup, and cache effects.

what is established and what remains trusted

The paper establishes measured selection trade-offs under Python subprocess execution, EvalPlus, Qwen generators and ORMs, six seeds, five timing trials, and stated hardware assumptions (GPU and CPU machines called roughly cost-equivalent by AWS prices; Table 7 also lists Azure and GCP). It does not establish soundness of an ORM, completeness of a partial test suite, repository-scale behavior, or formal memory and security properties. The paper itself says: “Staged verification reduces compute costs for large-scale code generation by pruning incorrect candidates before expensive validation.” (Impact Statement, p. 8) The next sentences say: “We emphasize that staged verification is a selection tool, not a replacement for full test suites.” (p. 9)

Inference: the threat to an agent-written verified-Rust product is moderate when staged checks only prioritize candidates and high when they are treated as evidence of proof. The product should reuse the paper’s cost-ordering idea, failure-mode analysis, and survivor pipeline. It should not redo generic ORM-vs-test frontier mapping for ordinary Rust unless its workload has comparable verification costs. The missing product work is a strong final stage: explicit Verus contracts, complete proof obligations, checked unsafe or foreign boundaries, and tests for behavior outside the formal abstraction.

techniques for the catalog

  • verifier Pareto frontier — measure correctness quality and verification throughput together
  • staged filtering — remove candidates failing cheap syntax, lint, or partial execution before expensive ranking
  • Bradley–Terry ORM — train a scalar outcome ranker on correct/incorrect candidate pairs
  • random test subset — use several randomly selected tests as a low-cost filter and measure FPR variation
  • dynamic token batching — pack candidates by total token budget for fair neural-verifier throughput
  • failure-mode analysis — inspect candidates that pass the ranker but fail tests to identify systematic blind spots Checked 2026-10-17 against the full paper by a Claude agent (mid-paper quote: “Staged verification reduces compute costs for large-scale code generation by pruning incorrect candidates before expensive validation.”): I read the whole paper text, including appendix Tables 4-17, and checked every quotation, number, table and page reference, and the steps of techniques 1-5 against it; I changed the broken link to the arXiv link found in the paper text (arXiv:2506.10056), removed the unsupported name “KForge”, corrected the Table 2 and 18.06% attribution (it is the 7B generator column, not 14B) and noted that the 10.22x and 7.58% figures match no single cell, corrected Table 3 and the 20-46x enrichment claim (it is relative to correct candidates; Table 3 columns do not show it), fixed page and section references (Section 2 introduction, Section 2.2 p. 3, Table 2 p. 6, Impact Statement pp. 8-9), the Best-of-k description, the FPR protocol, and quote capitalization; I did not check the Verus-specific inferences against any Verus source, the cited related work, the plots in Figures 1, 3-6 (only captions and text), or Tables 5-6 and 8-17 beyond skimming.

Last edited: