Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Attention as an input-dependent integral
In a transformer every token looks at every other token and decides how much to borrow from each. If the tokens are points of a physical field, that is a weighted integral over the field, like the kernel integrals of a neural operator, except that the weights are recomputed for each new input. A steep front can then draw on different places than a gentle wave would. The price is cost: comparing every point with every other grows with the square of the number of points, so PDE transformers use cheaper forms of attention or group points into patches.
Transformer models trained on many kinds of simulation, such as Poseidon and DPOT, are being explored as foundation models for PDEs, much as language models are pretrained on large text collections.
- 1. Attention computes for each token…
- 2. Standard attention on n points costs about…
- 3. PDE transformers reduce cost by…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Attention: z_i = Σ_j softmax_j(q_i · k_j/√d) v_j with q, k, v linear maps of the tokens; the weights form an n × n matrix.
- As a kernel integral: z(x) ≈ ∫ κ(x, y; u) v(y) dy with κ built from queries and keys; because q and k depend on u, the kernel depends on the input, unlike FNO or GNO layers with fixed kernels.
- Galerkin attention (Cao, 2021): z = Q(KᵀV)/n without softmax. KᵀV/n is a d × d average over tokens, an approximation of ∫ k(y) v(y)ᵀ dy, so the layer is resolution independent and costs O(nd²) instead of O(n²d).
- Tokens: grid points, mesh nodes (Transolver, GNOT) or patches of a field (ViT-style models, used in weather); position features or coordinates are part of each token.
- Time dependence: many PDE transformers predict the next state from recent states and are rolled out autoregressively, so one-step errors compound.
- Pretraining: models such as Poseidon (Herde et al., 2024) and DPOT (Hao et al., 2024) are trained on many PDE families and fine-tuned for new ones.
- 1. Galerkin attention costs…
- 2. Unlike an FNO layer, an attention kernel…
- 3. Autoregressive rollout means…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Attention mechanics and resolution independence
Exercise 1.
- Standard softmax attention and Galerkin attention Q(KᵀV)/n.
- Checks: softmax weights average the values; Galerkin attention equals (QKᵀ)V/n without forming the n × n matrix.
- Tokens with Fourier position features and u-weighted features; their Galerkin summary is the same on 64 and 256 points.
Practice.
- Choose tokens to fit the budget: points for small 1-D problems, patches or a latent grid for large 2-D and 3-D fields, mesh nodes or learned slices for irregular geometry.
- Use linear or efficient attention (Galerkin, Fourier-type, FlashAttention for softmax) when n is large.
- Give tokens positions: coordinates or Fourier features; the model is otherwise blind to where points are.
- For time stepping, train with multi-step rollouts or noise injection to limit error growth, and report errors over the whole rollout.
- Tools: PyTorch, neuraloperator, PDEBench and The Well data, NVIDIA PhysicsNeMo; pretrained Poseidon and DPOT checkpoints.
import numpy as np
# Galerkin attention layer as a regression: query features e_i, keys p(x_j), values (1, u_j, u_j^2)
P = position_features(x, Ke) # n × (2Ke + 1)
E = np.concatenate([P, u[:, None] * P], axis=1) # tokens (queries)
summary = np.concatenate([[1], P.T @ u / n, P.T @ u**2 / n]) # K^T V / n: one pass over the tokens
features = np.einsum("ia,b->iab", E, summary).reshape(n, -1) # z_i = e_i^T T summary, linear in T
# T is fitted by least squares over all tokens of all training pairs; cost per layer O(n d^2)- 1. Pretrained PDE transformers include…
- 2. For large 3-D fields, tokens are usually…
- 3. To limit rollout error growth, one can…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why input-dependent kernels help. In Burgers’ equation the solution at x depends on u(x) times the slope of u there: a product of a local value and information spread over the field. A fixed kernel integral is linear in u and cannot form this product. In the attention layer the query e_i contains u(x_i)·p(x_i), and the summary KᵀV/n contains the averages of p·u and p·u², so their products include u(x)·û_k·p(x), which is what u u_x needs within the resolved frequencies.
Why Galerkin attention is grid-free. (1/n) Σ_j k(x_j) v(x_j)ᵀ is a quadrature for ∫ k(y) v(y)ᵀ dy. On uniform periodic grids it is exact once the grid resolves the integrand, so the 64-point and 256-point summaries agree to machine precision and a model trained on one grid can be used on the other. Softmax attention also averages, but its weights are normalised per query and depend on how many points fall in each region.
Results in the exercise. On the Burgers data of J4-3 (300 pairs on 64 points), the fixed-kernel model stayed at 0.2 for Ke = 2 and 3, while the Galerkin attention layer reached 0.09 and 0.06, with the same errors on 256 points. With one position frequency both were poor (0.3 and 0.2). For comparison, the one-layer random-feature Fourier model of J4-3 reached 0.03 on the same data; neither toy model is tuned, so this says nothing general about which architecture is better.
- 1. A fixed kernel integral is…
- 2. (1/n) Σ_j k(x_j) v(x_j)ᵀ approximates…
- 3. The 64- and 256-point summaries agreed because…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Does an attention kernel that depends on the input beat a fixed kernel on a nonlinear PDE, and is it independent of the grid?
History.
- A. Vaswani et al. (2017) introduced the transformer.
- S. Cao (2021) introduced Galerkin and Fourier-type linear attention for operator learning, linking attention to Petrov–Galerkin projection.
- Z. Hao et al. (2023) introduced GNOT for irregular meshes; H. Wu et al. (2024) introduced Transolver, which attends over learned physical slices.
- Pretrained models followed: Poseidon (Herde et al., 2024), DPOT (Hao et al., 2024), and multiple-physics pretraining (McCabe et al., 2023).
Exercise 2. The Burgers data of J4-3: u(·, 0) ↦ u(·, 0.5), ν = 0.01, 300 training pairs on 64 points, 100 test pairs on 64 and 256 points. Fixed kernel: p(x)ᵀ M (1/n) Σ_j p(x_j) u_j plus pointwise terms. Galerkin attention: queries (p, u p)(x_i), keys p(x_j), values (1, u_j, u_j²), output weights by ridge least squares. Median relative L2 error (64 / 256 points).
| position frequencies Ke | fixed kernel | Galerkin attention |
|---|---|---|
| 1 | 0.3 / 0.3 | 0.2 / 0.2 |
| 2 | 0.2 / 0.2 | 0.09 / 0.09 |
| 3 | 0.2 / 0.2 | 0.06 / 0.06 |
- The input-dependent kernel helped: about three times lower error than the fixed kernel at Ke = 3.
- Resolution transfer held for both models, as the Galerkin summary is a quadrature.
- Seeds 1 and 2: the same table, except 0.1 / 0.08 for attention at Ke = 2 on seed 2.
Transformers for PDEs in practice
- Weather: Pangu-Weather uses a 3-D Earth-specific transformer on patches; many current models mix attention with graph or Fourier layers (J8-2).
- Engineering geometry: Transolver and GNOT predict fields on irregular meshes of cars, airfoils and structures.
- Foundation models: Poseidon, DPOT and multiple-physics pretraining are fine-tuned to new PDEs with little data.
- Plasma and turbulence: autoregressive transformers emulate time-dependent simulations, with rollout stability as the main challenge.
References
- A. Vaswani et al. (2017). “Attention is all you need.” NeurIPS.
- S. Cao (2021). “Choose a transformer: Fourier or Galerkin.” NeurIPS.
- Z. Hao et al. (2023). “GNOT: a general neural operator transformer for operator learning.” ICML.
- H. Wu, H. Luo, H. Wang, J. Wang and M. Long (2024). “Transolver: a fast transformer solver for PDEs on general geometries.” ICML.
- M. Herde et al. (2024). “Poseidon: efficient foundation models for PDEs.” NeurIPS.