Mamba Flow Matching Neural Processes: Linear-Time Inference for Irregularly Observed Spatial Fields

Cosmo Nazzareno Santoni, Giovanni Charles, Timothy James Hitge, Oliver John Watson, Elizaveta SemenovaNeurIPS 2026

TL;DR

Predicting continuous physical maps—like continental temperatures—from scattered weather stations usually forces an ugly choice: either ignore how nearby predictions correlate with each other, or suffer a quadratic compute explosion that crashes your GPU after a few thousand points. MambaFlowNP sidesteps this dilemma by weaving observations and target locations into a single 1D thread along space-filling curves, scanning them in linear time with a Mamba-2 state-space model, and generating coherent whole-field maps in a single forward pass. The result scales to a million spatial points in under a second while running hundreds of times faster than Transformer-based equivalents.

What Problem Does This Paper Address?

Imagine looking at temperature readings from a few hundred scattered weather stations and trying to fill in the entire map in between. The classic statistical hammer for this—Gaussian-process kriging—requires solving an $O(N^3)$ system from scratch every single day.

Neural Processes (NPs) amortize this work: trained on historical maps, they predict a new field in one forward pass. Better yet, joint-predictive NPs sample entire, spatially coherent maps rather than treating neighboring towns as statistically independent islands. The catch? State-of-the-art joint NPs rely on Transformer self-attention across all $K$ observed ("context") and target ("query") points. That $O(K^2)$ compute and memory scaling hits a brick wall at just a few thousand points—well short of large, real-world sensor networks.

Switching to linear-time state-space models (like Mamba) seems like an obvious fix. However, a naive translation reads all the context stations, squashes the entire continent's weather into a single fixed-size vector, and hands that summary to a decoder. Unsurprisingly, cramming complex 2D geography through a tiny bottleneck blurs out local detail.

Methods

The authors introduce MambaFlowNP (MFNP), combining establish building blocks—Mamba-2, Hilbert space-filling curves, conditional flow matching, and reflow distillation—around a clever shared context–query sequence architecture:

  • Spatial Routing via Hilbert Curves: Because state-space models read 1D sequences, 2D coordinates must be ordered so nearby stations stay close in line. MFNP threads both context and query points together along space-filling Hilbert curves (using four directional scans with random grid offsets to smooth out artificial boundary seams).
  • Read-Only Queries in a Distance-Aware Scan: As Mamba-2 scans the shared sequence, context tokens write their observations into the recurrent hidden state (modulated by physical distance to the previous context point). Query tokens enter with zero step size: they read the rich local hidden state right where they sit in space without altering it. No single-vector bottleneck!
  • One-Step Flow Matching: Instead of starting from pure white noise, MFNP initializes queries using a spatially smooth random-function draw, then learns a velocity field to transport that guess into a realistic map. Using reflow distillation, a multi-step teacher trains a student model to make that leap in a single Euler step (1 network evaluation), followed by Continuous Ranked Probability Score (CRPS) fine-tuning on real-world tasks.

Datasets

  • Synthetic Gaussian Processes: Standard 1D ($K \le 128$) and 2D ($K \le 256$) benchmarks using RBF, Matérn-$3/2$, and Matérn-$5/2$ kernels with randomized lengthscales and amplitudes per episode.
  • NOAA Temperature Interpolation: Daily maximum temperatures (2005–2024) from irregular weather station networks across three geographic scales: Utah ($K=222$), California ($K=486$), and the continental US ($K=5{,}580$). Models train on pre-2017 dates and infill randomly masked stations on 2020–2024 test dates.

Key Insights and Ideas

  • Quantifying the Compression Bottleneck: Forcing context into a single terminal state degrades MSE by 10–17% on synthetic tasks and a massive 58–65% on NOAA weather data, proving why reading directly from local scan positions matters.
  • Free Mathematical Consistency: Because query tokens never write to the scan state, adding, removing, or chunking target locations doesn't alter predictions elsewhere—preserving strict stochastic-process (Kolmogorov) consistency that several recent efficient Transformer NPs have had to sacrifice.
  • Distillation vs. Architecture: At small scales ($K \le 1{,}024$), GPU dispatch overhead dominates, meaning MFNP's early speedups come primarily from 1-step reflow distillation. Beyond a few thousand points, linear-time $O(K)$ Mamba scans take over as quadratic Transformer baselines choke on memory.

Key Results

  • Continental Accuracy & Speed: Across all three NOAA tiers, MFNP achieves the lowest RMSE and CRPS, near-ideal 95% calibration coverage (0.940–0.955), and runs 114–784$\times$ faster than the strongest Transformer joint-predictive baselines.
Figure 2: Per-episode latency vs. RMSE (left) and CRPS (right) on continental US NOAA (K=5,580). Means ±1 SE over 10 seeds at Nsamples=128; the hatched staircase is the empirical Pareto frontier. TNPA exceeds the per-cell budget (§5.3); Utah and California frontiers in Appendix F.
  • Million-Point Scaling: On a single NVIDIA L40S GPU, Transformer baselines run out of memory between $K=16{,}384$ and $65{,}536$ (with autoregressive TNPA taking ~2 hours at $16{,}384$ points). MFNP processes $10^6$ points in under one second.
  • Synthetic Parity: On 1D and 2D Matérn-$3/2$ GPs, MFNP matches or stays competitive with attention baselines while cutting inference latency by 25–42$\times$.
Figure 4: Continental US (K=5,580) posterior on a held-out date, 10%/90% context/query split. Top, truth and MFNP posterior mean (red dots are context stations), interpolated for display. Bottom, MFNP absolute error averaged over the query stations in each ∼110 km hexagon (grey hexagons hold none), with the per-station histogram as legend and the RMSE dashed. Population-averaged accuracy in Figure 5.

Limitations and Future Work

  • Irregular vs. Gridded Domains: If your data already lives on a neat pixel grid, convolutional NPs and FFT-based solvers remain better tools; at small point counts ($K \lesssim 10^3$), simple factorised NPs are also faster due to per-call overhead.
  • Training Overhead: Reflow distillation requires generating teacher couplings, adding training steps that single-stage baselines skip.
  • Scope of Real-World Validation: Real-world testing covers a single variable (temperature) evaluated across new dates on fixed stations—leaving zero-shot spatial transfer to unseen regions, 3D space-time $(x, y, t)$ Hilbert curves, and predictive accuracy at the $10^6$-point scale as open territory for future work.

Summary updated

Abstract

Interpolating a spatial field, such as daily maximum temperature, from sparse and irregularly located observations is a recurring task across the environmental and health sciences. The standard tool, Gaussian-process kriging, refits hyperparameters and solves an $O(N^3)$ system for every new field. When many related fields are observed, such as daily maps from one sensor network, neural processes (NPs) instead learn the interpolation map from past fields and predict a new field in a single forward pass. Joint-predictive variants, which sample whole fields rather than independent values at each location, typically rely on self-attention over context and query points, incurring $O(K^2)$ compute in the combined point count $K$ and capping practical use at a few thousand points. State-space models offer a linear-time alternative, but a direct state-space adaptation compresses the context into a single hidden state before reading queries, reducing the information available to the decoder. We propose MambaFlowNP, a joint-predictive NP with linear compute, trained with a conditional flow-matching objective. A multi-directional Mamba-2 scan reads context and query tokens in a single shared sequence, so each query's velocity is read from its own scan position rather than from a compressed context summary, and because queries only read the scan state, predictions are consistent across query sets. MambaFlowNP is competitive with the strongest attention-based joint-predictive baselines on synthetic Matérn Gaussian-process benchmarks, and across regional and continental-scale NOAA temperature interpolation tasks it attains the lowest RMSE, the lowest CRPS and near-nominal coverage on every tier, while running $114$–$784\times$ faster than the strongest joint-predictive baseline. A single forward pass scales to $10^6$ points on one NVIDIA L40S GPU in under a second. This makes joint prediction computationally feasible for continental-scale, irregularly sampled sensor networks, with predictive quality evaluated up to $K = 5{,}580$.
BibTeX
@inproceedings{santoni2026mamba,
  author = {Cosmo Nazzareno Santoni and Giovanni Charles and Timothy James Hitge and Oliver John Watson and Elizaveta Semenova},
  title = {{Mamba Flow Matching Neural Processes: Linear-Time Inference for Irregularly Observed Spatial Fields}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=fVeT6lAKvN},
}
Figure