Integrating Locality-Aware Attention with Transformers for General Geometry PDEs

Minsu Koh, Beom-Chul Park, Heejo Kong, Seong-Whan LeearXiv 2025

TL;DR

The Locality-Aware Attention Transformer (LA2Former) is a novel neural operator designed to solve partial differential equations (PDEs) across complex and irregular geometries. By combining efficient linear attention for global context with a dynamic, K-nearest neighbors (KNN) pairwise attention for local interactions, it reduces predictive error by over 50% compared to existing linear attention methods without incurring the prohibitive quadratic computational costs of standard Transformers.

What Problem Does This Paper Address?

Partial differential equations (PDEs) are the mathematical backbone of fluid dynamics, materials science, and weather forecasting. Traditional numerical solvers (like the Finite Element Method) are highly accurate but computationally grueling for real-time applications. While deep learning alternatives like Fourier Neural Operators (FNOs) offer massive speedups, they are notoriously rigid, requiring uniform grids and struggling with complex, irregular real-world geometries.

To handle irregular meshes, researchers recently turned to Transformers. However, standard self-attention scales quadratically ($O(N^2)$) with the number of mesh points, making high-fidelity simulations too expensive. "Linear attention" variants solve this scaling problem ($O(N)$), but they do so by flattening the attention matrix into a global summary. In doing so, they lose the ability to capture fine-grained, localized physical interactions—such as boundary layer turbulence or localized stress concentrations—which are absolutely vital for accurate PDE modeling.

LA2Former bridges this gap by introducing an attention mechanism that is both computationally efficient and highly sensitive to local physics.

Methods

LA2Former introduces a hybrid architecture that processes global and local features in parallel within a Global-Local Attention (GLA) module.

Schematic overview of the proposed LA2Former layer, combining global linear attention and local neighborhood attention branches.

The core innovations include:

  1. Instant KNN Patchifying: Instead of dividing an irregular mesh into rigid, contiguous spatial patches (like in computer vision), the model dynamically identifies the $K$-nearest neighbors for every single point based on Euclidean distance. This allows it to construct neighborhood "patches" regardless of how warped or irregular the underlying geometry is.
  2. Dynamic Soft Mask: To avoid the pitfalls of a hard-coded neighborhood size, the authors introduce a learnable soft-weighting mask ($W_K$). This mask uses a sigmoid-based decay curve to adaptively tune the effective number of neighbors per layer.
  3. Dual-Branch Attention:
  4. Global Branch: Uses linear attention to capture long-range dependencies across the entire domain with a complexity of $O(N \times C^2)$.
  5. Local Branch: Uses standard pairwise attention restricted only to the dynamically masked KNN neighborhood, keeping its complexity down to $O(N \times K \times C)$.

Datasets

The authors evaluated LA2Former across six industry-standard PDE benchmarks spanning different geometric types:

  • Point Clouds: Elasticity (predicting inner stress distributions).
  • Structured Meshes: Plasticity (mesh displacement), Airfoil (Mach number over an aerodynamic wing), and Pipe (fluid velocity).
  • Regular Grids: Darcy Flow (fluid pressure in porous media) and Navier-Stokes (2D fluid equations over time).

These datasets represent a mix of solid mechanics and fluid dynamics in both 2D and (2+1)D settings.

Key Insights and Ideas

  • The "Sweet Spot" of Locality: One of the most striking findings is that restricting attention to a local neighborhood can actually outperform full, unconstrained pairwise attention. As shown in the paper's window-size experiments, letting a model look at everything introduces distant "noise" that degrades PDE prediction accuracy. Filtering this out via KNN acts as a powerful inductive bias.
  • Hierarchical Specialization: By visualizing the learnable parameters across layers, the authors discovered that shallow layers naturally learn to use tight, compact local windows to resolve sharp boundary conditions and local perturbations. Deeper layers automatically expand their receptive fields to integrate these fine details into a cohesive global representation.
Visualization of parameter changes across layers during training, showing distinct behaviors between shallow (blue) and deep (red) layers.

Key Results

LA2Former achieved state-of-the-art (SOTA) performance on four out of the six benchmarks, significantly outperforming both Fourier-based and other efficient Transformer-based operators.

Compared to the baseline Galerkin Transformer (a popular linear attention model), LA2Former achieved massive relative $L_2$ error reductions:

  • 77.5% reduction on Elasticity
  • 86.7% reduction on Plasticity
  • 52.5% reduction on Airfoil
  • 46.4% reduction on Darcy Flow
Performance comparison showing relative L2 error and epoch time vs. attention window size for Elasticity and Darcy datasets.

Crucially, as shown in Figure 4, LA2Former achieves these lower error rates while maintaining a fraction of the computational runtime (epoch time) required by standard full-attention Transformers.

Limitations and Future Work

While LA2Former excels on complex geometries, it hit a bottleneck on the Navier-Stokes benchmark. Because this dataset uses a perfectly uniform grid with symmetric boundary conditions and no internal obstacles, the global flow patterns are highly consistent. In this specific scenario, the local attention branch provided little benefit and instead introduced redundant computational overhead.

Additionally, while the neighborhood size $K$ is adaptively masked, finding the optimal maximum value for $K$ still requires manual tuning based on mesh density. The authors note that scaling the KNN computation to extremely large, multi-million-node PDE domains remains a challenge. Future work will focus on developing fully learnable weighting mechanisms to balance the global and local branches and exploring hybrid models that merge adaptive patching with spectral (Fourier) operators.

Summary updated

BibTeX
@misc{koh2025integrating,
  author = {Minsu Koh and Beom-Chul Park and Heejo Kong and Seong-Whan Lee},
  title = {{Integrating Locality-Aware Attention with Transformers for General Geometry PDEs}},
  year = {2025},
  eprint = {2504.13480},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.13480},
}
Figure