Skip to main content
Back

Argonne's petscagent-bench Exposes How Frontier Models Memorize Deprecated HPC Code

A new benchmark from Argonne shows frontier LLMs can write clean scientific code but fumble the library conventions that matter in real HPC work.

Pro

Paper, Full Access
  • Argonne released petscagent-bench, an agents-evaluating-agents framework for scientific code generation using PETSc.
  • A Green evaluator agent and Purple model-under-test agent communicate via A2A and MCP protocols for black-box evaluation.
  • Pipeline runs 14 evaluators across 5 categories: correctness, performance, code, appropriateness, and library-specific conventions.
  • Gemini 2.5 Pro scored 46.4, Claude Opus 4.6 hit 42.4, GPT-5.2 came in at 39.9.
  • Models write clean code but universally fail on PETSc-specific conventions like the current PetscCall() error macro.
  • Code, benchmark suite, and MCP server available at github.com/petsc/petscagent-bench.

Writing a conjugate gradient solver from scratch is a nice interview problem. Writing production-grade HPC code means calling into libraries like PETSc, choosing the right preconditioner, wrapping every call in the current error-handling macro, and making sure the whole thing scales across MPI ranks. A team at Argonne National Laboratory just released a benchmark arguing that essentially none of today's code-generation evaluations measure that skill, and built an agentic framework to fix it.

The framework is called petscagent-bench, and its central idea is agents evaluating agents. Instead of a static test harness, the evaluator is itself a tool-using LLM agent that compiles, runs, profiles, and judges code produced by a separate model-under-test.

Why pass@k falls apart for HPC libraries

Traditional code-generation benchmarks follow a simple pipeline: present a prompt, collect the generated code, and run it against test cases. That works for self-contained Python snippets. It breaks for scientific code that must link against MPI, compile against a specific library installation, and be judged on solver choice as much as output correctness.

PETSc is a good stress test for exactly this reason. It exposes over 6,000 functions spanning time integrators, nonlinear solvers, linear solvers, data management, and optimization, and the difference between a working solution and a broken one often lies in whether the model picked the right module, not whether it can write a loop.

Two agents, one MCP server, fourteen evaluators

The architecture separates responsibilities cleanly. A Green agent orchestrates evaluation. A Purple agent is the model under test. They talk over Google's Agent-to-Agent (A2A) protocol, while the Green agent reaches for tooling through Anthropic's Model Context Protocol (MCP).

Bar chart of per-problem composite scores for Claude Opus 4.6, Gemini 2.5 Pro, and GPT-5.2

The MCP server exposes two primary tools: a compile tool that builds uploaded code against PETSc, and a run tool that executes the binary with specified MPI ranks and command-line arguments. It is deployed for free public access at mcp.petsc-ai.org. Because both agents speak standardized protocols, any coding agent can be plugged in as a black box, no source access required.

Evaluation runs in three sequential stages, gating expensive work behind cheap checks:

  1. Gates (deterministic): compilation, execution, memory safety via Valgrind or PETSc's tracker, and API usage patterns. Fail any and the run scores zero.
  2. Metrics (runtime): numerical accuracy against reference outputs using exponential decay on relative error, plus execution time scored on a piecewise linear curve.
  3. Quality (LLM-as-judge plus static analysis): readability, documentation, algorithm appropriateness, solver choice, best-practice compliance, error handling, and parallel awareness.

Scores are aggregated with confidence weighting inside each of five categories, then combined into a 0–100 composite. Default weights are correctness 0.35, performance 0.15, code 0.15, library-specific 0.20, appropriateness 0.15.

The benchmark itself

The suite contains six curated problems spanning PETSc modules and difficulty levels, including a stiff Robertson ODE, 1D advection, Rosenbrock optimization, Darcy flow, 2D Navier–Stokes, and a Vec/MPI Scatter task. To fight data contamination, the authors changed initial conditions, boundary conditions, or discretizations from anything resembling PETSc's public tutorials. For example, PETSc's tutorial suite solves Darcy flow with finite differences; their specification requires a finite-element formulation instead, forcing the model to use higher-level abstractions such as PETSc's DMPLEX module for mesh management and element assembly.

How frontier models actually did

Three agents were tested, each backed by a frontier LLM and given one shot per problem, three times. Gemini 2.5 Pro leads at 46.4, followed by Claude Opus 4.6 at 42.4 and GPT-5.2 at 39.9. Across 54 total attempts, 21 score zero due to gate failures, while 17 exceed 80.

The failure modes are more interesting than the leaderboard. On Navier–Stokes, all three models tanked but for different reasons. Gemini 2.5 Pro fails at compilation in all three runs, passing incorrect argument types to DMStagCreate2d, for example supplying NULL where PETSc expects a PetscInt stencil width, indicating a fundamental misunderstanding of the DMStag API. Claude Opus 4.6 and GPT-5.2 both compile successfully but then crash at runtime.

Compilation, not runtime, is the dominant bottleneck. Gate pass rates are 67% for Claude, 61% for Gemini, and 56% for GPT-5.2. Every program that compiles passes all the subsequent gates, indicating that the primary bottleneck is generating code that compiles against PETSc rather than subtle memory or API-compliance errors.

The real signal: training data is stale

The most useful finding is buried in the qualitative section. Error handling scores are especially low (0.30 in 27 of 33 gate-passed attempts) since most models do not wrap PETSc calls in PetscCall(). That macro replaced the older CHKERRQ() style back in PETSc 3.17, meaning the frontier models have essentially memorized a deprecated idiom. Code and appropriateness scores land at 76–82 and 71–80 respectively, indicating agents tend to generate readable, well-structured code with reasonable choices of numerical method and solvers. Library-specific scores are consistently low at 52–59.

What's useful about this if you build agents

Two things travel beyond PETSc. First, the A2A-plus-MCP setup is a reusable pattern for black-box evaluation of any coding agent, including proprietary ones you can't peek inside. Second, the three-stage gate/metric/quality pipeline is a template for scoring code in domains where compilation and runtime behavior matter as much as string matching. The authors explicitly suggest multi-turn agents with compile–fix loops could substantially improve pass rates, as compiler diagnostics are often informative enough to guide corrections, and that retrieval augmentation over current library docs is the obvious next lever for anyone shipping a scientific coding assistant.

Full source, problem specs, and configuration files are on GitHub, with a live leaderboard hosted through AgentBeats. The benchmark does not yet cover GPU kernels or multiphysics, but the JSON-based problem format is designed so new tests slot in without touching the evaluator.