arXiv:2608.30532cs.AIAug 2026

Manuscript Offprint

arXiv:2608.30532

DiffPDE: Masked Diffusion Language Models as PDE Solver

Wenxuan Guo, Yuyang Hong, Lubin Fan, Zhaojin Fu, Lin Chen, Kun Ding, Shiming Xiang

Abstract

Existing approaches for synthesizing Partial Differential Equation (PDE) solvers predominantly rely on autoregressive models, yet their global left-to-right decoding incurs substantial redundancy when addressing inherently localized bugs. In this work, we challenge this inefficient paradigm and propose DiffPDE, a framework leveraging discrete diffusion language models for targeted code repair. By introducing a localized re-masking and infilling strategy, DiffPDE regenerates only erroneous regions while preserving correct context, naturally aligning generation with the sparse nature of PDE errors. Furthermore, to handle coupled bugs requiring sequential interventions, we present Iterative Debugging GRPO (ID-GRPO), a reinforcement learning scheme that enables multi-round debugging within single trajectories via intermediate rewards. Experiments on PDEBench show that DiffPDE achieves competitive accuracy, outperforms same-scale AR models, and significantly accelerates repair. The project repository is available at https://github.com/GU0vvx/DiffPDE.

1 Introduction

Partial Differential Equations govern a broad range of physical phenomena, from fluid dynamics to reaction-diffusion processes, and serve as a cornerstone of computational science (Cao et al., 2024; Li et al., 2024; Meuris et al., 2023). Despite their centrality, implementing correct and efficient numerical solvers remains a significant challenge, requiring deep domain expertise in discretization schemes, boundary condition handling, and solver stability. Recent advances in large language models (LLMs) have opened new avenues toward automating this process through code generation (Jiang et al., 2025; Soroco et al., 2025), yet reliable solver synthesis in practice demands not just initial gener-

Figure

Figure 1: Comparison of debugging paradigms. AR models repair buggy solvers by sequential full-context regeneration, while DiffPDE re-masks only the erroneous region and repairs it through infilling under full surrounding context.

ation, but also iterative debugging under real execution feedback.

Existing LLM-based (Li et al., 2025b; Chen et al., 2023; Jiang et al., 2025) approaches predominantly adopt autoregressive (AR) architectures for both generation and repair. While powerful, AR models are fundamentally constrained by left-to-right decoding: when an execution error is localized to a specific code span, the model must nonetheless consume the full preceding context and regenerate subsequent tokens sequentially. As repair rounds accumulate, this full-context sequential decoding introduces substantial redundant computation, since large portions of the surrounding code are already correct and need not be reconsidered. As shown in Figure 1, the mismatch between the locality of most debugging actions and the global nature of AR generation represents a core inefficiency in iterative code repair.

However, as shown in Figure 2, discrete diffusion language models (dLLMs) (Li et al., 2025a; Austin et al., 2021; Sahoo et al., 2024; Nie et al., 2026) overcome this limitation through their inherent bidirectional decoding. Unlike AR models, dLLMs utilize all unmasked tokens to predict masked tokens simultaneously at each reverse step. Therefore, leveraging dLLMs, we propose a novel debugging strategy termed localized re-

†^{\dagger}Corresponding authors.

masking and infilling. Specifically, this strategy entails masking only the suspected erroneous regions for parallel regeneration, while retaining the surrounding correct code as conditional context. Such localized editing is highly effective for debugging PDE solvers, where errors often manifest as sparse anomalies within otherwise correct logic. Based on this alignment, we propose DiffPDE, a framework for PDE solving tasks. DiffPDE uses dLLMs to identify and infill erroneous code segments. It substantially accelerates debugging while maintaining accuracy comparable to autoregressive models.

Furthermore, authentic PDE solver failures often involve coupled bugs that require multiple sequential repairs, making reinforcement learning difficult due to sparse feedback. At the same time, effective training must bridge from-scratch generation and localized infilling within a unified process. To address these challenges, we propose Iterative Debugging GRPO (ID-GRPO), which combines a task allocation and dynamic buffer mechanism with a multi-round reward design. These design choices not only improve training stability, but also translate into competitive empirical behavior in both solver generation and iterative repair. Extensive experimental results validate the effectiveness of DiffPDE with ID-GRPO, showing that localized infilling supports high-quality solver synthesis and more efficient, robust debugging than same-scale autoregressive baselines. In summary, our main contributions are as follows:

• We propose DiffPDE, a framework for PDE solver synthesis and repair that employs a localized re-masking and infilling strategy to regenerate only erroneous regions while preserving correct context.

• We introduce ID-GRPO, an RL training scheme that addresses sparse feedback in coupled bug repair via multi-round debugging trajectories and dense intermediate rewards.

• Comprehensive experiments on benchmark PDE tasks show that DiffPDE with ID-GRPO achieves competitive accuracy, stronger robustness than same-scale AR baselines, and lower repair latency.