arXiv:2609.30966cs.LGSep 2026

Manuscript Offprint

arXiv:2609.30966

Gradient Surgery for Physics-Informed Neural Networks

Thomas Borsani, Giuseppe Di Fatta

ABSTRACT

Physics-Informed Neural Networks (PINNs) are trained by optimising a composite objective that combines data fitting with physics-based constraints, typically resulting in a highly imbalanced multi-task optimisation problem. Under these conditions, existing optimisation strategies are affected by conflicting task gradients, leading to slow convergence and unstable training, particularly for stiff and high-frequency partial differential equations. We analyse gradient conflicts throughout training of PINNs with standard optimiser and investigate Multi-Task Deep Learning (MTDL) optimisation methods. In our analysis across four benchmark problems we observed that PINN optimisation exhibits three distinct phases in which angle- and magnitude-based gradient conflicts alternate, with only one present at a time. Building on these observations, we propose PAM-GS, a physics-aware gradient surgery method that adaptively mitigates task interference during training according to the observed conflict types. Experiments on four representative PDE benchmarks demonstrate that PAM-GS combines competitive solution accuracy with consistently strong task-balanced performance, outperforming existing methods on most problems. Code is available at https://github.com/ThomBors/gs_pinn

Keywords Physics-Informed Neural Networks · Multi-Task Deep Learning · Gradient Surgery

Recent advances in deep learning have driven growing interest in neural networks models for solving partial differential equations (PDEs) [1, 2]. PDEs arise across diverse scientific disciplines, including fluid dynamics, electromagnetics, and financial mathematics [3, 4, 5]. However, solving nonlinear and high-dimensional PDEs efficiently remains a fundamental challenge for traditional numerical methods due to stability and computational constraints. Physics-Informed Neural Networks (PINNs) address this challenge by formulating PDE solving as the optimisation of a neural network constrained by the governing physical laws [6, 7]. Specifically, PINNs employ an implicit neural representation, where a neural network parametrises the solution field as a continuous, differentiable function, enabling spatial and temporal derivatives to be computed efficiently via automatic differentiation. The governing PDE residuals are enforced at collocation points within the computational domain, while boundary and initial conditions are included as additional terms in the training objective.

Despite its simplicity, this formulation gives rise to a challenging multi-objective optimisation problem [8, 7, 9, 10, 11]. Competing objectives can result in gradient imbalances caused by numerical stiffness [11], heterogeneous convergence rates between loss components [10], the soft enforcement of physical constraints [8], poor initialisation [12], and inefficient collocation sampling strategies. These factors often lead to slow convergence, optimisation stagnation, and reduced solution accuracy. Consequently, adaptive weighting schemes have been proposed to balance the loss functions for PDE residuals, boundary conditions, and initial conditions [13], although no consensus exists on an optimal strategy.

In parallel, Multi-Task Deep Learning (MTDL) addresses analogous issues via gradient surgery methods, which mitigate inter-task interference by modifying conflicting gradients during joint optimisation [14]. Such conflicts arise from misaligned gradient directions (angle-based) and/or disproportionate magnitudes that dominate shared updates (magnitude-based) [15]. Similar phenomena are expected in PINNs [16], where PDE residual gradients can dominate boundary and initial condition gradients [11], and where the residual loss landscape is often highly non-convex due to underdetermined PDE constraints [17]. However, a systematic study of gradient conflicts and a comprehensive evaluation of gradient surgery methods in this setting remains limited.

This work studies the training dynamics of PINNs, with a focus on the emergence of gradient conflicts [15] across canonical PDE benchmarks. Specifically, we consider problems that capture a range of behaviours, including non-linear convection, dispersion, and incompressible fluid dynamics, making them suitable testbeds for analysing optimisation behaviour in PINNs. We perform a systematic evaluation of modern gradient surgery methods to assess their impact on optimisation behaviour. Our empirical analysis reveals a distinct temporal structure in gradient conflicts: task-angle-based gradient conflict dominates early training, while later stages are primarily affected by magnitude gradient conflicts. Based on these findings, we propose Physics-Aware Momentum Gradient Surgery (PAM-GS), a conflict-aware gradient method for PINNs that outperforms existing optimisers in most cases. Our main contributions are summarised as follows:

• We study the emergence of gradient conflicts in PINNs across canonical 1D and 2D PDE benchmarks.

• We perform a systematic evaluation of modern gradient surgery methods and quantify their impact on optimisation behaviour.

• We propose Physics-Aware Momentum Gradient Surgery (PAM-GS), a conflict-aware optimisation method that improves performance over existing approaches.

1 Physics-Informed Neural Networks

Preliminaries. We consider the initial–boundary value problem for a general partial differential equation (PDE) defined over a scalar field u(x,t):Ω×(0,T]→Ru(x, t) : \Omega \times (0, T] \to \mathbb{R}:

N[u(x,t),x,t]:=N[u(x,t),x,t]+f(x,t)=0,x∈Ω,t∈(0,T],(1)\mathcal{N}[u(x,t),x,t]:=\mathcal{N}[u(x,t),x,t]+f(x,t)=0,\quad x\in\Omega,t\in(0,T], \tag{1} B[u(x,t),x,t]:=B[u(x,t),x,t]+g(x,t)=0,x∈∂Ω,t∈(0,T],(2)\mathcal{B}[u(x,t),x,t]:=\mathcal{B}[u(x,t),x,t]+g(x,t)=0,\quad x\in\partial\Omega,t\in(0,T], \tag{2} I[u(x,0),x,0]:=u(x,0)+h(x)=0,x∈Ω,(3)\mathcal{I}[u(x,0),x,0]:=u(x,0)+h(x)=0,\quad x\in\Omega, \tag{3}

where Ω⊂Rd\Omega \subset \mathbb{R}^d denotes the spatial domain with boundary ∂Ω\partial\Omega, and N\mathcal{N} and B\mathcal{B} are differential operators that encode the dynamics of PDE and the boundary conditions, respectively. The functions ff, gg, and hh represent the source terms.

PINN formulation. To solve this system, PINNs introduce a parametric neural approximation u^(x,t;θ)\hat{u}(x,t;\theta) of the solution u(x,t)u(x,t), where θ\theta denotes the network parameters. The spatial and temporal derivatives required by the operators N\mathcal{N} and B\mathcal{B} are calculated using automatic differentiation applied to u^(x,t;θ)\hat{u}(x,t;\theta). The PDE is then enforced by minimising the following composite loss:

L(θ)=1nN∑i=1nN∥N[u^(xi,ti;θ),xi,ti]∥⏟LPDE+1nB∑i=1nB∥B[u^(xi,ti;θ),xi,ti]∥⏟LBC+1nI∑i=1nI∥I[u^(xi,0;θ),xi,0]∥⏟LIC.(4)\mathcal{L}(\theta)=\underbrace{\frac{1}{n_{N}}\sum_{i=1}^{n_{N}}\|\mathcal{N}[\hat{u}(x_{i},t_{i};\theta),x_{i},t_{i}]\|}_{\mathcal{L}_{PDE}}+\underbrace{\frac{1}{n_{B}}\sum_{i=1}^{n_{B}}\|\mathcal{B}[\hat{u}(x_{i},t_{i};\theta),x_{i},t_{i}]\|}_{\mathcal{L}_{BC}}+\underbrace{\frac{1}{n_{I}}\sum_{i=1}^{n_{I}}\|\mathcal{I}[\hat{u}(x_{i},0;\theta),x_{i},0]\|}_{\mathcal{L}_{IC}}. \tag{4}

Optimisation structure. PINNs can be formulated as a MTDL problem, where a neural network with shared parameters ( θ∈Rm\theta \in \mathbb{R}^m) jointly optimises ( K≥2K \geq 2) physics-based objectives. Each physical constraint defines a task-specific loss, including the PDE residual ( LPDE\mathcal{L}_{\text{PDE}}), boundary conditions ( LBC\mathcal{L}_{\text{BC}}), and initial conditions ( LIC\mathcal{L}_{\text{IC}}). The resulting optimisation problem is given by θ∗=arg⁡min⁡θ∈RmL(θ)\theta^* = \arg \min_{\theta \in \mathbb{R}^m} \mathcal{L}(\theta).

The LPDEL_{PDE} enforces the governing equations at collocation points throughout the spatio-temporal domain, whereas the LBCL_{BC} and LICL_{IC} impose soft constraints on the solution at the spatial boundaries and the initial time, respectively. This decomposition explicitly exposes the multi-objective nature of PINN optimisation, where gradients interaction induced by different physical constraints may interfere, leading to conflicting optimisation directions.

References (38)