AI agent ports 250k-line weather sim to GPU with 5.1x speedup
A new arXiv paper shows an AI agent modernizing one of the hardest kinds of legacy code — a 250,000-line Fortran weather model — and the validation-first workflow that kept the port trustworthy.
Researchers used an AI agent to port CReSS, a legacy Fortran weather simulation code with more than 250,000 lines, to run on GPUs — and the ported version ran a real typhoon simulation 5.1x faster while staying numerically faithful to the original.
The workflow, described in a paper submitted to the AgenticAI4HPC 2026 workshop, treats code generation as the easy part and proof as the hard part. The agent pulled the parallel regions out of the old OpenMP code, built benchmark kernels from physically meaningful simulation states, and applied OpenACC offloading so the heavy loops run on GPU. Then came the part that makes this worth reading: every kernel was validated element-by-element against reference data dumped from the original CPU runs, plus full application-level checks on top.
Of the 162 target kernels, the agent produced numerically validated GPU implementations for all of them. It also caught genuine bugs in the process — numerical discrepancies in five kernels caused by floating-point and intrinsic-function differences, including threshold-sensitive branch divergence and cancellation effects that the team fed back to the model's developers. That is the payoff of the validation-centric design: the agent did not just make the code faster, it found problems the existing test regime had missed.
The paper's broader argument is that legacy scientific software is not merely old code — it is a credibility asset, refined against observations and cited in published science for years. Porting it to new hardware is a correctness problem before it is a performance problem, which is why the authors say practical AI-assisted porting demands workflow design, not just code generation: agents need session-spanning context, runtime-state reconstruction, and the ability to recover cheaply when small static-analysis omissions derail a port. We've seen LLMs get good at writing fresh code; this is the harder second act — taking code that already works and proving an AI can move it to new hardware without breaking the science.
What to watch: whether this dump-and-validate pattern becomes the default scaffold for agentic HPC modernization, and whether the 5.1x speedup holds up outside the typhoon test case.
If your team has legacy code waiting for an AI port, does this validation-first approach match what you'd need? Tell us in the comments.
Sources: arXiv paper · Hacker News discussion