arXiv:2611.26355cs.LGNov 2026

Manuscript Offprint

arXiv:2611.26355

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

Cosmo Santoni, Giovanni Charles, Timothy James Hitge, Oliver Watson, Elizaveta Semenova

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

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(N3)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(K2)O(K^{2}) compute in the combined point count KK 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 114114–784×784{\times} faster than the strongest joint-predictive baseline. A single forward pass scales to 10610^{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,580K{=}5{,}580.

1 Introduction

Modelling continuous spatial fields from discrete, scattered sensor data remains a fundamental challenge in spatial statistics and probabilistic machine learning. Examples include inferring temperature from weather stations (Vaughan et al., 2022), disease prevalence from sentinel sites (Weiss et al., 2025), and rainfall between rain gauges (Li et al., 2023). Gaussian-process kriging is the standard approach, but it refits hyperparameters and solves an O(N3)O(N^{3}) system for every new field. When many related fields are observed, as with daily readings from a fixed sensor network, neural processes (Garnelo et al., 2018b, NPs;) cast this as amortised inference, in which the network is trained on many datasets drawn from a data-generating process and, given a new dataset, performs inference in a single forward pass without further optimisation. An episode is one dataset together with a random split into context observations and query locations at which values are to be predicted. Factorised NPs infer the parameters of an independent Gaussian distribution at each query (Garnelo et al., 2018a), whilst latent-variable NPs introduce a global latent variable (Garnelo et al., 2018b) through which all cross-query dependence passes. In contrast, a fully joint-predictive NP directly models the conditional distribution of the values at all query locations together, via autoregressive (Nguyen and Grover, 2022), diffusion (Dutordoir et al., 2023) or flow (Abu Hamad and Rosenbaum, 2025) parametrisations. Most existing fully joint-predictive instances employ self-attention over the concatenation of NN context and MM query locations, with compute scaling as O(K2)O(K^{2}), where K=N+MK=N+M. Flow Matching NP (FNP) (Abu Hamad and Rosenbaum, 2025) and Transformer NP (TNPA) (Nguyen and Grover, 2022) are representative, and FNP exhausts GPU memory at 16,38416{,}384 points and TNPA at 65,53665{,}536 (Table 8). As an alternative to self-attention transformers, state-space models (SSMs) such as Mamba-2 (Dao and Gu, 2024) run a recurrent scan in O(K)O(K) time, FLOPs, and activation memory. However, a naive adaptation of these models compresses the context into a single hidden state, a bottleneck that we show degrades accuracy on synthetic and NOAA tasks (§6.4).

MambaFlowNP (MFNP) avoids this compression by maintaining a hidden state at every token position throughout a multi-directional state-space scan (Figure 1). Context and query tokens share a single sequence, and the model predicts a flow-matching (Lipman et al., 2023; Liu et al., 2023) velocity at each query location. A single joint-predictive draw for all the query locations requires batched ODE integration of the velocity, which typically entails tens of network function evaluations (NFE) (Table 13). MFNP mitigates this cost via a single round of reflow distillation (Liu et al., 2023) to enable inference with only one NFE. As in latent-variable NPs, dependence between queries is carried by a shared latent, here a random-function initial condition transported by the learned flow (§4.3).

  1. Tokenisation2. Hilbert routing3. Distance-aware scan4. Fusion & outputFlow timettCoordinatesXC,XQ\mathbf{X}_{C},\mathbf{X}_{Q}ContextYC\mathbf{Y}_{C}Noisy queriesYt\mathbf{Y}_{t}Time embeddinget\mathbf{e}_{t}TokeniseE ⁣∈ ⁣R(N+M)×d\mathbf{E}\!\in\!\mathbb{R}^{(N+M)\times d}Sort π1\pi_{1}Sort π1rev\pi_{1}^{\mathrm{rev}}Sort π2\pi_{2}Sort π2rev\pi_{2}^{\mathrm{rev}}Mamba-2 (×L)(\times L)Mamba-2 (×L)(\times L)Mamba-2 (×L)(\times L)Mamba-2 (\times L)$$\delta_{d}$$\delta_{d}$$\delta_{d}$$\delta_{d}UnsortUnsortUnsortUnsortLinearmergeOutputprojectionvθ(Yt,t,c)v_{\theta}(\mathbf{Y}_{t},t,\mathbf{c})

Figure 1: MFNP parametrises the velocity field vθ(Yt,t,c)v_{\theta}(\mathbf{Y}_{t},t,\mathbf{c}) of §2.2 in four stages. The stages are tokenisation of context values and the noisy query slice Yt\mathbf{Y}_{t} with frozen Random Fourier Feature (RFF) coordinate embeddings; multi-directional Hilbert routing under Π={π1,π1rev,π2,π2rev}\Pi=\{\pi_{1},\pi_{1}^{\mathrm{rev}},\pi_{2},\pi_{2}^{\mathrm{rev}}\}; distance-aware Mamba-2 scans modulated by an adaLN-Zero flow-time embedding et\mathbf{e}_{t}; and inverse-permutation fusion to per-query velocities. Trained with LCFM\mathcal{L}_{\mathrm{CFM}}, reflow-distilled to a one-step Euler student, and CRPS fine-tuned. Full pipeline in Appendix B, Algorithm 1.