Dynamic Quadtree Tokenization for Autoregressive PDE Forecasting

Yilin Zhuang, Noah Zambrano, Karthik DuraisamyNeurIPS 2026

TL;DR

Simulating violent physical phenomena—like shockwaves or detonations—with standard Vision Transformers wastes massive compute on empty, quiet space where nothing is happening. WAMRViT teaches Transformers to think like classical physics solvers: it dynamically zooms in on moving action using an evolving quadtree mesh while leaving calm regions coarse. For the first time, an AI surrogate can natively ingest and forecast multi-level Adaptive Mesh Refinement (AMR) data without flattening it onto a memory-crushing uniform grid.

What Problem Does This Paper Address?

Vision Transformers (ViTs) make great physics surrogates because self-attention easily captures long-range spatial interactions. The catch? Self-attention scales quadratically with the number of tokens, $\mathcal{O}(N^2)$. If you want fine-grained accuracy, you need tiny patches, which blows up your memory and compute budgets—especially over long, multi-step forecasts.

Yet in fluid dynamics and combustion, the real drama—shock fronts, chemical reactions, material boundaries—usually happens in tiny, shifting slivers of the domain, while 90% of the space sits relatively still. Classical numerical solvers solved this decades ago with Adaptive Mesh Refinement (AMR), placing fine grid cells only where needed. Existing adaptive ViTs have dabbled in variable patch sizes, but they typically freeze the grid, enforce rigid token budgets, or require uniform-grid inputs. None could ingest native multi-resolution simulator data and dynamically re-mesh on the fly as a shockwave travels across the screen.

Methods

WAMRViT bridges adaptive tokenization and true AMR practice through three core mechanisms:

Overview of WAMRViT adaptive tokenization and autoregressive regridding
  • 2:1-Balanced Quadtree Tokenization: Instead of slicing an image into uniform squares, the domain is recursively split into four child cells wherever local value ranges exceed a wavelet-inspired threshold (or directly initialized from a simulator's native AMR tree). The tree enforces a "2:1 balance"—adjacent leaves differ by at most one refinement level—ensuring smooth transitions. Every leaf becomes a single token.
  • 3D Rotary Positional Embeddings (RoPE): Because tokens live at different positions and scales, standard 2D coordinates aren't enough. The authors extend RoPE to 3D coordinates $(x, y, \ell)$, where $\ell$ is the refinement level. Rather than masking out interactions between coarse and fine cells, $\ell$ acts as a soft geometric bias so information flows naturally across resolution boundaries.
  • Uniform vs. Multi-Scale Variants: On a standardparallel-attention Transformer backbone, the uniform-patch variant block-averages coarse regions before the model (or samples native AMR hierarchies directly). For uniform-grid inputs, a multi-scale variant preserves every pixel of a coarse leaf, using learned convolutional "shrink" encoders and "expand" decoders per level alongside level-conditioned normalization (AdaLN).
  • In-Cell-Space Regridding: Every $R$ autoregressive steps, WAMRViT pauses time to update the grid topology based on its own predictions—splitting cells where gradients sharpen, adding a protective buffer around active fronts so features don't outrun the fine mesh, and merging quiet siblings.

Datasets

The authors test across three 2D benchmarks spanning different sparsity regimes:

  • PLI (from HEAT): 1,000 trajectories of multimaterial shockwaves on a $1120 \times 400$ uniform grid—lots of quiet ambient air surrounding sharp shocks.
  • TRL (from The Well): 90 trajectories of radiative turbulent mixing on a $128 \times 384$ uniform grid, featuring dense, widespread filaments with very little quiet space.
  • AMReX Combustion: A massive 264 GB native-AMR simulation of $\text{H}_2$/air detonation with 17 chemical/thermodynamic channels across multiple refinement levels (effective finest grid $4096 \times 24576$). A dense uniform grid here isn't even stored.

Key Insights and Ideas

  • Don't throw away sub-patch detail too early: On uniform grids, block-averaging coarse leaves before feeding them to the Transformer hurts full-field accuracy. Letting a lightweight learned encoder compress coarse regions (the multi-scale variant) slashes full-field error at the exact same token count.
  • Unconstrained token counts follow the physics: Rather than forcing a fixed "top-$k$" token budget, WAMRViT lets the token count breathe naturally as physical structures expand or dissipate.
  • Equal leaf weighting has a subtle blind spot: Training uniform-patch WAMRViT by weighting every leaf equally means tiny shockfront cells get huge attention, while massive coarse cells covering 84% of the domain make up just 6% of the tokens—leading to slight drift in broad, post-shock regions.

Key Results

  • PLI (Uniform Grid): Using only ~37% of the tokens of a finest-patch ViT, multi-scale WAMRViT cuts first-step full-field VRMSE by 27.7% and 20-step rollout-averaged finest-level VRMSE by 20.1%, while running 2.57$\times$ faster end-to-end (3.03$\times$ faster for uniform-patch).
  • TRL (Dense Mixing): Using ~50% of the tokens, both variants stay within ~1% of ViT-finest on full-field VRMSE and run ~1.21$\times$ faster. Because turbulence fills the domain, adaptive compression offers smaller accuracy gains here.
  • AMReX Detonation (Native AMR): A finest-grid ViT is intractable (~98k tokens). Compared to a feasible coarser ViT-mid baseline (which still uses 14% more tokens), WAMRViT slashes first-step finest-level RMSE by 60.8% and sustains a >50% error reduction across 20 rollout steps, cleanly reproducing delicate diamond-like detonation cellular structures ("soot foils").
Full-domain temperature prediction on AMReX combustion

Limitations and Future Work

Because every sample has a different number of tokens, training currently requires a micro-batch size of one. Furthermore, CPU-involved regridding takes 5.4%–17.2% of inference time—making WAMRViT 8.6% slower end-to-end than ViT-mid on AMReX, and slower than shifted-window SwinV2 across all datasets (though far more accurate). Finally, refinement thresholds are hand-tuned rather than learned, experiments are strictly 2D, and AMReX is evaluated on a single chronological trajectory. Moving topology updates entirely onto the GPU with packed variable-length attention and scaling to 3D octrees are clear next steps.

Summary updated

Abstract

The quadratic attention cost of Vision Transformers (ViTs) forces a trade-off between spatial resolution and rollout horizon, particularly for fine-scale PDEs where shocks, reaction fronts, and material interfaces occupy small, evolving regions of the domain. Conventional neural surrogates also lack mechanisms to adapt resolution dynamically. We propose WAMRViT, a ViT that tokenizes inputs as balanced quadtrees using a wavelet-inspired refinement criterion, jointly encodes position and refinement level with 3D rotary positional embeddings, and regrids in cell space during inference for stable long-horizon rollouts. A multi-scale variant retains each leaf at its native source resolution and lets the model learn across resolution levels. Unlike fixed-budget adaptive-tokenization methods, WAMRViT imposes no predetermined token count and supports fully adaptive topology throughout autoregressive rollout. To our knowledge, it is the first machine-learning surrogate to natively tokenize multi-level Adaptive Mesh Refinement (AMR) data. On uniform-grid benchmarks, uniform-patch WAMRViT improves finest-level region-of-interest VRMSE over a finest-patch uniform ViT while using substantially fewer tokens. The multi-scale variant achieves the lowest first-step full-field RMSE and VRMSE on both benchmarks and improves rollout-averaged full-field and refined-region accuracy at long horizons. With parallelized regridding, its end-to-end rollout cost lies between finest-patch and approximately token-matched coarser-patch ViTs. On a complex AMR combustion problem whose finest features cannot be represented natively by the evaluated uniform-grid baselines, WAMRViT operates on adaptive cells built from the simulator hierarchy and substantially reduces finest-level error at matched transformer capacity. Code: https://github.com/tonyzyl/wamrvit
BibTeX
@inproceedings{zhuang2026dynamic,
  author = {Yilin Zhuang and Noah Zambrano and Karthik Duraisamy},
  title = {{Dynamic Quadtree Tokenization for Autoregressive PDE Forecasting}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=QEBPUFXUHr},
}
Figure