Training Transformers for Mesh-Based Simulations

Paul Garnier, Vincent Lannelongue, Jonathan Viquerat, Elie HachemarXiv 2025 · OpenReview

Abstract: Simulating physics using Graph Neural Networks (GNNs) is predominantly driven by message-passing architectures, which face challenges in scaling and efficiency, particularly in handling large, complex meshes. These architectures have inspired numerous enhancements, including multigrid approaches and $K$-hop aggregation, yet they often introduce significant complexity and suffer from limited in-depth investigations. In response to these challenges, we propose a novel Graph Transformer architecture that leverages the adjacency matrix as an attention mask. The proposed approach incorporates innovative augmentations, including Dilated Sliding Windows and Global Attention, to extend receptive fields without sacrificing computational efficiency. Through extensive experimentation, we evaluate model size, adjacency matrix augmentations, positional encoding and $K$-hop configurations using challenging 3D computational fluid dynamics (CFD) datasets. We also train over 60 models to find a scaling law between training FLOPs and parameters. The introduced models demonstrate remarkable scalability, performing on meshes with up to 300k nodes and 3 million edges. Notably, the smallest model achieves parity with MeshGraphNet while being $7\times$ faster and $6\times$ smaller. The largest model surpasses the previous state-of-the-art by $38.8$% on average and outperforms MeshGraphNet by $52$% on the all-rollout RMSE, while having a similar training speed.

Introduction: The Scaling Challenge in CFD

Simulating physical phenomena—such as blood flow in an aneurysm or air over a wing—traditionally requires solving complex partial differential equations (PDEs) on unstructured meshes. While Graph Neural Networks (GNNs) have become the standard machine learning tool for this, they rely heavily on Message-Passing (MPS) architectures.

MPS faces two major hurdles in high-fidelity physics simulations:

  1. Scaling: As meshes grow to millions of edges, the computational cost of passing messages across the graph becomes prohibitive.
  2. Efficiency: MPS often struggles to capture long-range dependencies without becoming overly complex, often requiring multi-grid hierarchies.

This research introduces a novel Graph Transformer architecture designed to bring the efficiency and scaling advantages of Transformers to unstructured 3D meshes, which typically lack the sequence or grid structure Transformers were originally designed for.

Methodology: Masked Graph Transformers

The core innovation is a Masked Graph Transformer that follows an Encode-Process-Decode architecture. Instead of the standard Transformer's "all-to-all" attention (which is $O(n^2)$ and computationally impossible for large meshes), the model uses the graph's adjacency matrix as a sparse mask. In this setup, nodes only "attend" to their immediate neighbors.

Visualization of the graph adjacency matrix augmentations including dilated connections (blue), random "jumper" edges (red), and global tokens (green).

To ensure information travels across the mesh efficiently, the authors introduce three key receptive field augmentations:

  • Dilated Adjacency: Similar to dilated convolutions, this allows nodes to attend to neighbors $K$ hops away without processing every intermediate node.
  • Random Connections: Small numbers of random "jumper" edges are added at each step, creating shortcuts for information flow.
  • Global Attention: Specific critical nodes (e.g., inlets or obstacles) are designated as "global tokens" visible to every other node.

By ignoring edge features and focusing on node features and positions, the model significantly reduces memory overhead compared to previous state-of-the-art (SOTA) models like MeshGraphNet.

Scaling Laws and Performance

Through the training of over 60 models, the researchers identified a scaling law for physics-based Transformers: $N \propto C^{0.75}$, where $N$ is the number of parameters and $C$ is training FLOPs. This suggests that physics-based models follow predictable performance improvements as they scale, similar to Large Language Models.

Comparison of model performance (RMSE) vs. speed (it/sec), alongside a breakdown of parameters and vRAM usage for the proposed models (S, M, L, XL) against standard baselines.

Key Results

  • Accuracy: The largest model (XL/1) surpassed the previous SOTA by an average of 38.8% across all datasets. On challenging 3D Aneurysm rollouts, it outperformed MeshGraphNet by 52%.
  • Efficiency: The smallest model (500k parameters) matched MeshGraphNet's performance while being 7x faster and 6x smaller.
  • Speed: The model achieved a 500x speed-up over classical CFD solvers for 3D aneurysm simulations.
  • Scalability: The architecture successfully handled meshes with 300k nodes and 3 million edges, a scale where traditional MPS-GNNs often hit memory limits on single GPUs.

Limitations and Future Work

While the model shows remarkable generalization, it faced challenges on specific datasets like PLATE, where it performed slightly worse than specialized multi-grid GNNs. This is likely due to the lack of "world edges" (connections between non-adjacent objects) in the current sparse mask. Additionally, the model currently uses raw 3D coordinates, meaning it is not naturally invariant to rotations or translations. Future work will focus on restoring geometric invariance and improving the handling of complex boundary interactions.

Summary updated

BibTeX
@misc{garnier2025training,
  author = {Paul Garnier and Vincent Lannelongue and Jonathan Viquerat and Elie Hachem},
  title = {{Training Transformers for Mesh-Based Simulations}},
  year = {2025},
  eprint = {2508.18051},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.18051},
}
Figure