Structure-Preserving Weak-Form Loss
- Structure-preserving weak-form loss is a family of learning objectives that replaces pointwise residuals with integral formulations to maintain key governing relations.
- It leverages variational principles by integrating against test functions, enabling conservation laws and energy balances to be preserved during learning.
- This approach enhances robustness to noise and discontinuities, making it effective in scientific machine learning, Hamiltonian learning, and numerical PDE solvers.
Taken together, these works suggest that structure-preserving weak-form loss is best understood as a family of learning objectives that enforce governing relations in weak, variational, or otherwise non-pointwise form while preserving problem-specific structure. In scientific machine learning, this usually means replacing pointwise strong-form residuals by integral residuals against test functions, often with integration by parts, domain decomposition, and explicit regularization by initial or boundary conditions (Xu et al., 2020). In adjacent literatures, the same design principle appears as energy-preserving or Lyapunov-preserving losses, thermodynamically constrained weak-form estimators, Hamiltonian regression restricted to vector fields of the form , equality-constrained mixed-form surrogates, and differentiable geometric penalties that preserve panel and seam structure in garment models (Gao et al., 2024, Chu et al., 2024, Park et al., 3 Apr 2026, Hu et al., 2024, Zhang et al., 10 Jun 2026, Chen et al., 2022).
1. Weak-form foundations and the shift away from pointwise residuals
Before weak-form losses became common in learned models, weak formulations were already the standard route for preserving structure in numerical discretization. In port-Hamiltonian systems, a weak formulation of the underlying geometric Stokes-Dirac structure, combined with mixed Galerkin discretization and power-preserving linear maps, yields a family of structure-preserving schemes that allows trade-offs between centered approximations and upwinding (Kotyczka et al., 2017). In finite element compilation, TSFC was explicitly designed to maintain the structure of the input weak form as long as possible, separating the lowering of finite element constructs to tensor algebra from the scheduling of tensor operations (Homolya et al., 2017).
Within learning systems, the main contrast is between strong-form and weak-form enforcement. Strong-form losses penalize PDE residuals at collocation points, but they are reported to deteriorate when high-order derivatives are present or when the solution contains strong discontinuities (Xu et al., 2020). Weak-form constructions multiply the governing equation by test functions and integrate over the domain or subdomains, so that integration by parts can move derivatives from the learned field to analytically chosen test functions (Xu et al., 2020). A closely related argument appears in weak-form PINNs and quantum PINNs: weak forms impose a global condition on the solution and prioritize good average behavior instead of “overfitting” select points (Paine et al., 9 Feb 2026).
This shift is not only numerical. It changes what the loss treats as primary: not pointwise exactness, but preservation of a variational identity, a conservation law, an energy balance, or a topological assembly relation.
2. Canonical constructions of weak-form loss
A standard template appears in theory-guided neural networks. For a PDE , TgNN-wf defines, on each collocation subdomain ,
and then combines the weak residual with data, initial-condition, and boundary-condition terms as
The method uses domain decomposition with locally defined test functions, and Gauss-Legendre quadrature is used for numerical evaluation of the integrals (Xu et al., 2020).
A second template is the self-test loss for operators linear in unknown parameters. With self-testing functions satisfying linearity, symmetry, and positivity, the loss is
Because both and are linear in , the loss is quadratic; the paper emphasizes identifiability, well-posedness, and efficient regression algorithms, and shows that the construction conserves energy for gradient flows and coincides with the expected log-likelihood ratio for stochastic differential equations (Gao et al., 2024).
A third template is hybridization. In weak-form PI and PI-QML, local collocation and global weak-form terms are combined as
0
with the explicit goal of exploiting the advantages and mitigating the weaknesses of both local and global formulations (Paine et al., 9 Feb 2026).
For PDE discovery, Weak-PDE-LEARN uses a neural approximation 1 of the solution and a trainable coefficient vector 2, with total loss
3
where 4 is built from the weak form after transferring derivatives to weight functions by repeated integration by parts (Stephany et al., 2023).
3. What is being preserved
The “structure” in structure-preserving weak-form loss is not uniform across domains. It can refer to conservation, dissipation, symplecticity, thermodynamic admissibility, divergence constraints, topology, or manufacturing relations.
In gradient-flow settings, the preserved quantity is often energy dissipation. The self-test construction uses the first variation of the energy as the test function, and at the minimizer the data’s energy change equals the modeled dissipation (Gao et al., 2024). In SP-PINN, the Allen–Cahn equation is augmented with a structure-preserving loss
5
where 6 is a discrete global energy; the loss penalizes increases of energy and enforces 7 (Chu et al., 2024).
In thermodynamic modeling, WGFINNs preserve the GENERIC degeneracy and symmetry conditions exactly by construction while replacing strong-form fitting by weak-form fitting. The paper states that strong-form estimators diverge as the time step decreases in the presence of noise, whereas weak-form estimators can remain accurate if test functions satisfy certain conditions (Park et al., 3 Apr 2026).
In Hamiltonian learning, structure preservation means restricting the learned vector field to Hamiltonian form. The kernel estimator solves
8
so every learned vector field is Hamiltonian by construction (Hu et al., 2024).
In mixed finite element surrogates, structure preservation can be a hard equality constraint. Structure-preserving neural surrogates with tractable uncertainty quantification enforce the discrete conservation law
9
in compatible 0–1 spaces built from Raviart–Thomas and 2 elements, and pose training as an optimal recovery problem with equality constraints (Zhang et al., 10 Jun 2026).
In optimal control of Maxwell’s equations, the preserved structure includes the de Rham structure, a discrete Gauss law, and a per-time-step energy balance, inherited by a discrete optimization scheme built on the weak form of the forward problem (Antil et al., 30 Apr 2026).
| Setting | Mechanism | Preserved structure |
|---|---|---|
| TgNN-wf | Weak residual on subdomains | PDE consistency under discontinuities |
| Self-test loss | Parameter-dependent test functions | Energy dissipation, likelihood structure |
| WGFINNs | Weak-form loss + GENERIC architecture | Degeneracy and symmetry conditions |
| Kernel Hamiltonian learning | Loss on 3 | Hamiltonian vector-field form |
| Mixed FEM surrogate | Equality-constrained ORP | Discrete conservation law |
| Neural Sewing Machine | Inner/inter-panel losses | Panel isometry and seam topology |
This variety indicates that weak-form loss is less a single formula than a design pattern: structural constraints are encoded at the level where the governing model is naturally variational, integral, or relational.
4. Representative implementations
A particularly direct implementation appears in differentiable finite element correction. Instead of adding a black-box strong-form source term, the correction is inserted directly into the variational form through learned bilinear operators. For incompressible Navier–Stokes, the corrected weak form modifies the viscosity, convection scaling, and grad-div stabilization coefficients; for the 1D convection–diffusion equation, the correction is applied to the flux. The paper argues that this aligns the learned model with the finite element discretization, preserves key numerical structure, and better respects the fundamental properties of incompressible flow (Jung et al., 27 Jan 2026).
In weak-form PDE discovery, the central implementation choice is to never differentiate the learned solution or the noisy data directly. Instead, all derivatives are transferred to smooth weight functions, and the learning problem becomes simultaneous approximation of the solution 4 and the PDE coefficients 5 from the linear system 6 induced by the weak form (Stephany et al., 2023).
For PI and PI-QML, implementation details emphasize test-function choice, numerical integration, and boundary handling. The weak form may be evaluated by quadrature or Monte Carlo; integration by parts introduces boundary terms; and collocation is identified as the special case 7, which turns the weak form back into a local point test (Paine et al., 9 Feb 2026).
Outside PDE learning, Neural Sewing Machine provides a geometrically explicit example of weak-form, differentiable structure preservation. Its inner-panel structure-preserving loss
8
encourages local isometry within each panel, while its inter-panel structure-preserving loss
9
penalizes discrepancies along stitched edges. The full training loss is
0
The paper describes these constraints as enforcing structural relationships in a weak-form, differentiable manner (Chen et al., 2022).
5. Empirical behavior and comparative evidence
Across the literature, weak-form losses are repeatedly associated with improved robustness under high-order derivatives, discontinuities, or noisy data. TgNN-wf reports higher accuracy than strong-form TgNN in both hydraulic head prediction for unsteady-state 2D single-phase flow and saturation profile prediction for 1D two-phase flow, with the advantage becoming especially pronounced when strong discontinuity is present. It also trains faster than TgNN when the number of integration subdomains is not too large, specifically below 1, and is reported to be more robust to noises (Xu et al., 2020).
Hybrid weak-form plus collocation losses are motivated by an empirical asymmetry: collocation only can fit the DE at sampled points but may fail to propagate boundary conditions and may converge to trivial solutions; weak-form only captures global behavior but may miss local features; the combined loss is reported to outperform both, particularly with domain decomposition (Paine et al., 9 Feb 2026).
Weak-PDE-LEARN reports recovery of Burgers’ equation and the KdV equation with up to 2 noise and the Kuramoto–Sivashinsky equation with up to 3 noise, with graceful degradation under increasingly limited or noisy measurements (Stephany et al., 2023). WGFINNs similarly report that weak-form training consistently outperforms strong-form GFINNs at varying noise levels while retaining exact satisfaction of the GENERIC constraints (Park et al., 3 Apr 2026).
In differentiable finite element correction, the quantitative gap between weak-form and strong-form augmentation is explicit. For the 1D convection–diffusion equation, the time-averaged relative error is reported as 4 for weak-form correction, compared with 5 for strong-form correction and 6 for the baseline, at similar speedups of about 7. For 2D incompressible Navier–Stokes, the weak-form correction achieves 8 for short-term prediction and 9 for long-term prediction, whereas the strong-form correction degrades to 0 on the long horizon; both methods retain a speedup of about 1, and the weak-form correction reaches a minimum training loss about 2–3 lower than strong-form correction (Jung et al., 27 Jan 2026).
Neural Sewing Machine provides a structurally different but instructive ablation. Using only 4 yields MGLE 5 cm; adding 6 alone gives MGLE 7 cm; adding 8 reduces MGLE to 9 cm; and adding 0 further improves MGLE to 1 cm. The paper emphasizes that Chamfer and P2S change little, which indicates that those pointwise geometric metrics do not reflect structural preservation or topology correctness (Chen et al., 2022).
6. Misconceptions, limitations, and active directions
One recurrent misconception is that weak-form loss is simply a smoothed version of collocation. In the PI-QML formulation, collocation is instead characterized as the special case of the weak form with Dirac-delta test functions, so the distinction is structural rather than cosmetic (Paine et al., 9 Feb 2026).
A second misconception is that weak-form loss is automatically structure-preserving. The self-test paper makes the opposite point: the construction of loss functions for weak-form operators is itself a major challenge, particularly because test functions must be selected appropriately. Traditional weak-form losses use a pre-selected family of test functions and do not, in general, guarantee preservation of structures such as energy or likelihood; the self-test construction was introduced precisely to address that gap (Gao et al., 2024).
A third misconception is that weak-form enforcement alone is always sufficient. Several papers argue for combinations with data terms, initial and boundary regularization, or local residual terms. TgNN-wf adds data, initial-condition, and boundary-condition penalties to the weak residual (Xu et al., 2020). Hybrid PI-QML explicitly combines local and global losses because weak-form loss may miss local features while pure collocation may fail globally (Paine et al., 9 Feb 2026).
These works also show that “structure-preserving” may be realized in different ways: by soft penalty, as in SP-PINN or Neural Sewing Machine; by hard equality constraint, as in mixed-form neural surrogates; or by architectural construction, as in WGFINNs and Hamiltonian kernel regression (Chu et al., 2024, Chen et al., 2022, Zhang et al., 10 Jun 2026, Park et al., 3 Apr 2026, Hu et al., 2024). A plausible implication is that the field is moving toward losses that are not merely weak-form in the variational sense, but also aligned with the underlying thermodynamic, geometric, topological, or manufacturing structure of the problem.