Towards Certificate-Driven Software Porting: A Self-Improving Agentic Harness for Scientific Program Optimization

Piyush Jha, Aishik Ghosh, Vijay GanesharXiv 2026

TL;DR

Researchers have developed Certificate-Driven Evolutionary Search (CDES), an agentic framework that uses Large Language Models (LLMs) to automatically port and optimize legacy scientific code for GPUs. By recording failures as enforceable "certificates" of what not to do, the system achieves up to 23.54x speedups and even outperforms expert-written GPU implementations by nearly 15%.

What Problem Does This Paper Address?

Scientific software, like the widely used Geant4 particle simulation toolkit, often consists of millions of lines of C++ code written over decades. As hardware evolves toward GPU acceleration, rewriting these massive codebases manually is a "herculean task."

While LLMs are surprisingly good at translating code, they suffer from a "memory" problem during optimization loops: even when told a specific approach failed, they often repeat the same errors in subsequent attempts. This paper addresses the need for a reliable, self-improving system that can port code without repeating mistakes, ensuring the resulting programs are both fast and physically accurate.

Methods

The authors introduce CDES, which builds on top of existing evolutionary search algorithms (like AlphaEvolve). The standard loop involves an LLM proposing code mutations, which are then tested. CDES adds a critical "control logic" layer:

  1. Certificate Database: When a candidate program fails a check, the system generates a "certificate"—a record of the conflicting choices and the violated requirement.
  2. Conflict Checker and Analyzer: Before the LLM even sees a new proposal, this component checks it against stored certificates. If the new code repeats a known mistake, it is rejected or sent for targeted repair.
  3. Rigorous Evaluation Harness: Instead of simple unit tests, the authors use a multi-layered validation suite:
  4. Formal Analysis: Using tools like the Lean theorem prover and CBMC to prove memory safety and work-assignment rules.
  5. Physics Checks: Ensuring conservation laws (like energy and momentum) are maintained.
  6. GPU Safety: Using NVIDIA’s Compute Sanitizer to catch race conditions and memory errors.
Figure 1. CDES extends evolutionary search with certificate-driven control. The certificate database supplies restrictions and feedback to the mutator LLM and evidence to the conflict checker and analyzer. CDES enforces validated restrictions during generation and repair. Gold highlights CDES additions.

Datasets

The study focuses on two critical functions from the Geant4 toolkit:

  • Compton: Computes particle scattering (photon-electron interaction). This served as a benchmark against Celeritas, an existing expert-written GPU implementation.
  • Fermi: Assigns energy and motion to nuclear fragments. This represented a "blind" test where no expert GPU implementation was previously available.

Evaluation was performed using approximately 250,000 inputs on an NVIDIA H100 GPU.

Key Insights and Ideas

  • Enforceable Memory Beats Prompting: Simply putting error messages in a prompt isn't enough for LLMs. By turning failures into hard logical constraints (certificates), the system increased the correctness pass rate from 55% to 90%.
  • AI Finds "Hidden" Optimizations: In the Compton function, the AI outperformed expert code by identifying that a specific value (the squared sine of an angle) was being recomputed unnecessarily. By reusing an earlier calculation, the AI squeezed out extra performance that human experts had overlooked.
  • Human-AI Collaboration: The best results came from a "Hybrid" approach—combining the expert's logic for energy selection with the AI's optimized direction calculations. This suggests that the future of scientific software isn't just "AI-written," but a collaborative refinement of expert kernels.

Key Results

The quantitative gains are significant, demonstrating that automated porting can rival or exceed manual effort:

  • Speedups: CDES-generated code achieved 13.78x (Compton) and 23.54x (Fermi) speedups over the original CPU versions.
  • Outperforming Experts: For the Compton function, the CDES implementation achieved a 14.9% higher throughput than the expert-written Celeritas implementation.
  • Hybrid Gains: Combining Celeritas and CDES components resulted in a 16.1% total throughput gain over the expert baseline.
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.

The ablation study highlights the efficiency of the certificate system. While it slightly increases the API cost per run, it drastically reduces the number of "wasted" candidates that fail basic correctness checks.

Table 3. Certificate feedback produces more proposals that pass correctness checks and improve performance. Costs cover this ablation’s Qwen3-Coder-Plus calls.

Limitations and Future Work

While successful, the authors note that this was a proof-of-concept on individual functions.

  • Scaling: The next step is to see if this "function-by-function" optimization translates to speedups for the entire simulation codebase, where data movement between functions becomes a bottleneck.
  • Complexity: Future work will explore how the cost and effectiveness of certificates change as the optimization tasks become more difficult or the functions become larger.
  • Integration: The team aims to incorporate these automated tools directly into production projects like Celeritas to assist human developers in real-time.

Summary updated

BibTeX
@misc{jha2026towards,
  author = {Piyush Jha and Aishik Ghosh and Vijay Ganesh},
  title = {{Towards Certificate-Driven Software Porting: A Self-Improving Agentic Harness for Scientific Program Optimization}},
  year = {2026},
  eprint = {2609.34069},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.34069},
}
Figure