TL;DR
The paper introduces RLVP (Reinforcement Learning with Verifiable Physics), a post-training framework that teaches Large Language Models (LLMs) to generate accurate code for solving partial differential equations (PDEs). By replacing traditional binary pass/fail code rewards with continuous physics-based rewards—measuring trajectory accuracy and residual consistency—RLVP allows smaller models to significantly outperform massive frontier LLMs and demonstrate zero-shot compositionality on unseen physical systems.
What Problem Does This Paper Address?
Writing reliable numerical solvers for partial differential equations (PDEs) is a cornerstone of climate modeling, aerospace engineering, and physics, but it typically requires deep human expertise to balance discretization schemes, stability constraints (like the CFL condition), and boundary conditions.
While LLMs have shown promise in code generation, existing approaches rely heavily on inference-time prompting, multi-agent debugging loops, or self-refinement rather than fundamentally adapting the model's weights. Furthermore, standard Reinforcement Learning from Verifiable Rewards (RLVR) typically uses binary feedback: Does the code compile? Do the unit tests pass?
In scientific computing, correctness is a spectrum, not a binary. Two different solver programs can both compile and run without errors, yet one might introduce massive artificial diffusion or explode numerically, while the other provides a highly accurate solution. Traditional binary rewards completely throw away this graded structure of scientific accuracy.
Methods
RLVP bridges this verifiability gap using a two-stage post-training pipeline:
- Solver-Bank Supervised Fine-Tuning (SFT): The base model is warm-started on a curated dataset of high-quality "teacher" solver implementations to establish a strong prior for numerical code structures.
- Reinforcement Learning with a Hybrid Verifier: The model is optimized using Group-Relative Policy Optimization (GRPO). Instead of a learned reward model, RLVP uses a deterministic, hybrid binary-continuous verifier environment.
The complete reward function is multiplicative: $$R(y, c) = V(y, c) \cdot R_{\text{traj}}(y, c) \cdot R_{\text{phys}}(y, c)$$
- Validity Gate ($V$): A binary check ensuring the code executes without error, outputs the correct array shapes, and contains no
NaNor infinite values. - Physical Accuracy Reward ($R_{\text{traj}}$): A continuous score derived from the normalized space-time $L^2$ error between the model's generated solver output and a hidden numerical reference solution.
- Residual Consistency Reward ($R_{\text{phys}}$): A continuous penalty based on the mathematical PDE residual, ensuring the generated solution physically satisfies the underlying governing equations.
Datasets
The authors curated a diverse training and evaluation suite:
- Multi-PDE Solver Bank (Seen Tasks): Spans 8 distinct PDE families and 71 standard numerical schemes (including finite-difference stencils, conservative updates, sparse linear solves, and projection steps). It includes 1D Advection, 1D Burgers, 1D/2D Reaction-Diffusion, 1D Diffusion-Sorption, 2D Darcy Flow, 2D Incompressible Navier-Stokes, and 2D Shallow Water equations.
- Held-Out PDEs (Unseen Tasks): 10 entirely unseen PDE families (e.g., 2D Advection, 1D/2D Advection-Diffusion, Cahn-Hilliard, Gray-Scott, and Korteweg-De Vries) used to rigorously test zero-shot cross-PDE generalization.
Key Insights and Ideas
- Continuous Physics Rewards are Essential: Ablation studies showed that training with binary validity alone helps models write executable code but fails to refine physical accuracy. Dense, continuous rewards are necessary to guide the model toward numerically stable and accurate zones.
- Emergent Compositionality: Rather than memorizing rigid code templates, the post-trained models learn to treat numerical methods as modular primitives. When faced with an unseen PDE, the model can flexibly recombine stencils, time-stepping schemes (like Runge-Kutta), and boundary-handling logic learned from different training equations.
- Post-Training Beats Scale: Aligning smaller models (3B to 14B parameters) directly with physical verification feedback yields better domain-specific performance than simply prompting massive, static frontier models.
Key Results
- Outperforming Frontier Models: On seen PDEs, RLVP raised pass@1 rates from near-zero to 0.63–0.89 across 3B, 7B, and 14B scales. Notably, the RLVP-trained 7B model achieved a 0.68 pass@1 rate, soundly beating Claude Sonnet 4.5 (0.24 pass@1) under the same direct-generation protocol.
- Zero-Shot Transfer: On the 10 held-out PDE tasks, the 7B model's pass@8 rate jumped from 0.28 (after SFT) to 0.57 (after RLVP), while dropping the median best-of-8 error by two orders of magnitude. For instance, it successfully synthesized a fourth-order operator for the unseen Cahn-Hilliard equation by chaining together lower-order Laplacian primitives learned during training.
Limitations and Future Work
While RLVP represents a major step forward for scientific AI agents, the authors note several limitations:
- Structured Environments: The current setup is restricted to structured grids, relatively simple geometries, and clean boundary conditions.
- Scope of Physics: The framework has not yet been tested on highly complex settings like adaptive mesh refinement, stochastic PDEs, or multi-physics systems.
- Inference Scaffolding: The paper focuses purely on direct code generation. The authors suggest that combining RLVP's post-trained models with inference-time scaffolding—such as agentic debugging loops or verifier-guided tree search—could unlock even higher reliability.
Summary updated