Towards Certificate-Driven Software Porting: A Self-Improving Agentic Harness for Scientific Program Optimization
Authors: Piyush Jha, Aishik Ghosh, Vijay Ganesh
Organizations: School of Computer Science, Georgia Institute of Technology, USA · School of Physics, Georgia Institute of Technology, USA · Lawrence Berkeley National Laboratory, USA
The upgrade and rewriting of large scientific codebases has traditionally been a major challenge. While evolutionary search with large language models (LLMs) can port and accelerate legacy code, repair feedback in prompts alone does not prevent subsequent candidates from repeating the same errors. We introduce Certificate-Driven Evolutionary Search (CDES), which extends evolutionary search with enforceable restrictions derived from failed candidates, recorded as certificates of assumptions, checker evidence, and justified restrictions. Its control logic enforces these restrictions through rejection, backtracking, and targeted repair while preserving compatible edits. We apply CDES to CPU-to-GPU translation of two particle-simulation functions from the Geant4 toolkit, evaluated with a harness that goes beyond unit tests to combine formal checks, numerical comparisons, physics checks, and GPU safety tests. Generated implementations achieve 13.78x and 23.54x function-level speedups over CPU code, including data conversion and transfers; for one function, GPU throughput exceeds an expert implementation by 14.9%, reaching 16.1% when complementary components are combined. In an ablation over execution settings, certificate feedback increases the fraction of candidates passing required correctness checks from 55% to 90%.
Figures & tables
Function
Geant4 CPU
CDES-generated CUDA
Speedup
Compton
30.162
2.189
13.78 ×
Fermi
340.090
14.447
23.54 ×
Table 1: Generated CUDA achieves 13.78 × and 23.54 × speedups over standalone CPU functions under the stated timing protocol. Times are in milliseconds. GPU times sum separately measured conversion, transfers, and computation, not full-simulation runtime.
Version
Execution time
GPU time
GPU throughput gain
vs. Celeritas
vs. CDES
Celeritas
2.4753
0.5093
CDES-generated
2.4000
0.4433
14.9%
Hybrid
2.3905
0.4387
16.1%
1.2%
Table 2: Combining Celeritas components with generated code gives the highest GPU throughput. Times are medians in milliseconds over six paired timing rounds. Throughput gains are medians of per-round time ratios, not ratios of displayed median times. Execution time directly measures transfers, computation, and completion waits in the shared benchmark. Settings are selected separately for each timing metric. Celeritas and the hybrid use a shared direction correction.
Without certificates
With certificates
Proposals passing correctness checks
55%
90%
Passing with throughput gain >10%
50%
80%
Passing with throughput gain >20%
30%
35%
Best throughput gain on withheld inputs
66.5%
68.6%
Model-call cost (USD)
$0.0535
$0.0782
Table 3: Certificate feedback produces more proposals that pass correctness checks and improve performance. Costs cover this ablation’s Qwen3-Coder-Plus calls.
Recent work has demonstrated the potential of large language models (LLMs) for program optimization, a key challenge in programming languages. We propose a blackbox adaptation method called Retrieval Augmented Search (RAS) that performs beam search over candidate optimizations; at each step, it retrieves in-context examples from a given training dataset of slow-fast program pairs to guide the LLM. Critically, we find that performing contextual retrieval based on an LLM-generated natural language description significantly outperforms retrieval based on the source code. We also propose AEGIS, a method for improving interpretability by decomposing training examples into ''atomic edits'' that are significantly more incremental in nature. We show that RAS performs up to 2.06× better than prior state-of-the-art blackbox adaptation strategies on optimizing C++ programs, and that AEGIS performs up to 1.37× better while making significantly smaller edits. We also show that using RAS improves the mean runtime percentile of Python programs by 10.27 compared to baselines.
Test-time scaling is an important mechanism for improving large language models, especially on tasks with deterministic verifiers. Code translation is a canonical example: the source program constrains valid outputs, while compilers, type check- ers, and behavioral checks provide exact pass/fail feedback. Existing approaches typically apply these verifiers only after generation, which is inefficient because early errors corrupt the autoregressive context and are rarely corrected later. We introduce Decoding Time Verification (DTV), a framework that treats structural boundaries as meta steps for verifier-guided decoding. DTV interleaves generation with verifier calls under a state-machine controller that enforces valid prefixes, using structural-boundary checks and structure-aware rollback to prevent error propagation while reducing wasted tokens. We evaluate DTV on C-to-Rust and JavaScript-to-TypeScript translation. Using Qwen3-4B as the primary generator under matched token budgets, DTV improves pass rates from 72.3% to 82.0% on C-to-Rust and from 33.3% to 46.0% on JavaScript-to-TypeScript relative to matched self-refinement baselines, while using fewer tokens per case; the same trend largely transfers to Gemma-4-E4B. In the evaluated cost-matched grid, DTV achieves a more favorable pass-rate-cost tradeoff than post-hoc verification or sampling-based scaling. These results show that verifier-guided decoding is an effective use of inference-time compute for code translation.
Tianyang Zhou, Somesh Jha, Mihai Christodorescu +2
University of Illinois Urbana-Champaign · University of Wisconsin–Madison and Google · Google
Recent large language model (LLM) agents have shown promise in using execution feedback for test-time adaptation. However, robust self-improvement remains far from solved: most approaches still treat each problem instance independently, without accumulating reusable knowledge. This limitation is particularly pronounced in domain-specific languages such as Triton, which are underrepresented in LLM pretraining data. Their strict constraints and non-linear optimization landscape further make naive generation and local refinement unreliable. We propose AdaExplore, an agent framework that enables self-improvement via accumulated execution feedback for performance-critical kernel code generation through two complementary stages: failure-driven adaptation and diversity-preserving search, jointly improving correctness and optimization performance without additional fine-tuning or external knowledge. In the adaptation stage, the agent synthesizes tasks and converts recurring failures into a reusable memory of validity rules, helping subsequent generations remain within the feasible set. In the search stage, the agent organizes candidate kernels as a tree and alternates between small local refinements and larger structural regeneration, allowing it to explore the optimization landscape beyond local optima. Experiments on kernel runtime optimization benchmarks validate these gains: AdaExplore achieves 3.12x and 1.72x speedups on KernelBench Level-2 and Level-3, respectively, within 100 steps, and continues to improve with additional computation.
Weihua Du, Jingming Zhuo, Yixin Dong +9
1Carnegie Mellon University · University of Washington · 3Arm Ltd.