Zebra: In-Context and Generative Pretraining for Solving Parametric PDEs

Louis Serrano, Armand Kassaï Koupaï, Thomas X. Wang, Pierre Erbacher, Patrick Gallinari · DOI

Abstract

Solving parametric Partial Differential Equations (PDEs) is a cornerstone of science and engineering, yet traditional numerical methods and current neural surrogates often struggle with efficiency and generalization. We introduce Zebra, a framework that treats physical trajectories as sequences of discrete tokens to enable In-Context Learning (ICL) for PDEs. By providing a few example trajectories as a prompt, Zebra adapts to varying physical parameters—such as viscosity or wave speed—without requiring gradient-based fine-tuning. Our experiments show that Zebra achieves state-of-the-art accuracy on 2D fluid dynamics benchmarks while being orders of magnitude faster than existing adaptive methods.

Introduction

The primary challenge in developing neural PDE solvers is generalization. A model trained on a specific set of physical coefficients often fails when applied to a system with different underlying rules. Current approaches typically rely on either knowing these coefficients explicitly (parameter-conditioning) or performing slow, gradient-based "meta-learning" at test time.

Zebra proposes a paradigm shift: treating physics as a language. By leveraging the same "few-shot" capabilities found in Large Language Models (LLMs), Zebra can "sense" the underlying physics from a small context window of examples and predict future states immediately.

Methodology: Physics as a Sequence

Zebra utilizes a two-stage pipeline to bridge the gap between continuous physical fields and discrete sequence modeling.

  1. Discretization via VQ-VAE: Continuous 2D physical fields are compressed into a discrete "vocabulary" of spatial codes using a Vector Quantized Variational Auto-Encoder (VQ-VAE).
  2. Generative Transformer: A causal transformer, based on the Llama architecture, is trained to predict the next token in a sequence. The input sequence includes "Context Trajectories" (examples of the system's behavior) and a "Query Initial Condition."
The Zebra pipeline: Tokenizing physical trajectories into discrete codes for auto-regressive generation in a transformer.

To address the latency of autoregressive generation, the authors also introduce a Zebra + UNet hybrid. In this configuration, Zebra acts as a context encoder to extract a dynamics embedding, which a UNet then uses to predict entire frames in a single forward pass.

Experiments and Benchmarks

The model was evaluated on a diverse set of 1D and 2D benchmarks, including Advection, Burgers, and Wave equations, as well as complex 2D fluid turbulence (Vorticity). The training set was scaled to include up to 1,200 unique physical environments to ensure robust in-context capabilities.

Results and Discussion

Zebra demonstrates significant improvements over baseline methods like CODA and CAPE in both accuracy and inference speed.

  • Accuracy: On the 2D Vorticity benchmark, Zebra achieved a relative L2 error of 0.119, significantly lower than the best baseline (0.173).
  • Speed: The Zebra + UNet hybrid provides a massive speedup, generating trajectories in 0.14 seconds, compared to nearly 30 seconds for gradient-based adaptation methods.
  • Generative Robustness: Unlike deterministic solvers, Zebra models the distribution of possible futures, providing built-in uncertainty quantification and improved stability over long-term rollouts.
Qualitative results on 2D Vorticity: Zebra's predictions (Pred) accurately capture the evolution of turbulence compared to the Ground Truth (GT).

Conclusion

Zebra proves that the next-token prediction objective is a powerful tool for modeling spatio-temporal dynamics. By enabling zero-shot adaptation through in-context learning, it bypasses the computational bottlenecks of traditional meta-learning. Future work will focus on overcoming the reconstruction limits of VQ-VAEs and extending the model to irregular grids and 3D simulations.

Summary updated

BibTeX
@inproceedings{serrano2025zebra,
  author = {Louis Serrano and Armand Kassaï Koupaï and Thomas X. Wang and Pierre Erbacher and Patrick Gallinari},
  title = {{Zebra: In-Context and Generative Pretraining for Solving Parametric PDEs}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=22kNOkkokU},
}
Figure