Manuscript Offprint

arXiv:2610.06039

MercerFlow: Flow Matching in a Kernel-Induced Latent Space for Probabilistic Forecasting

Ilya Kuleshov, Egor Serov, Alexey Zaytsev

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

ABSTRACT

Recent work has shown that probabilistic flow matching for time series forecasting benefits from a data-matched prior. The resulting prior introduces local correlations, which a sequential architecture usually absorbs: a recurrent neural network (RNN), a structured state-space model (S4), or a Transformer. However, such a backbone costs GPU memory and time per epoch. A cheaper alternative is MLP-based latent-space flow matching: embed the time series via an invertible map to a single latent vector and learn the flow there, so a tabular MLP can treat the series as a set of features. The relationship between the prior and the choice of linear latent map is understudied in conditional flow matching (CFM) forecasting, yet we found it strongly affects performance. Fixed transforms such as Fourier or discrete cosine (DCT) are only well-conditioned for Ornstein–Uhlenbeck priors, while a principal-component (PCA) map fit to the data is a strong but training-set-dependent reference sensitive to train–test shift. Instead, we propose to use the Mercer eigenbasis of the prior kernel: it diagonalises the centred covariance exactly, decouples from training data, and adapts to non-stationary and periodic priors. On five GluonTS benchmarks (ETTh1, ETTh2, Weather, Electricity, Traffic) under a shared protocol with TSFlow, the resulting MLP matches or beats it on CRPS at about 4.7×4.7\times less training memory and 3.5×−4.4×3.5\times-4.4\times less time per epoch.

1 INTRODUCTION

The usual approach to probabilistic forecasting is to devise an algorithm which samples from a predictive distribution over future windows given the observed past. A sampler that is expressive, while staying cheap to train and cheap to run, is the practical target. Flow matching (Lipman et al., 2023; Tong et al., 2024) is a prominent modern way to build such samplers: one learns a velocity field along a probability path from a tractable prior to the data, and training is ordinary regression onto a known interpolant. Since each forecast requires numerically integrating this velocity during inference, the cost at test time is dominated by the backbone that evaluates the field; cheapness at training time matters too, since the backbone also dictates GPU memory and time per epoch. If the prior already matches the data, the flow starts closer to the target and needs less capacity to finish the trip. TSFlow (Kollovieh et al., 2025) commits to a Gaussian-process (GP) prior on the forecast window for that reason. However, under that prior, neighbouring time coordinates stay correlated, so a global multilayer perceptron (MLP) spends capacity on local smoothness the GP already encodes. TSFlow absorbs those correlations with a bidirectional state-space backbone (Gu et al., 2022), which is accurate on long smooth series but expensive in memory and time per epoch.

Orthonormal projections are a classical way to decorrelate coordinates in a latent space (Mercer, 1909; Karhunen, 1947; Gabor, 1946). Several recent generative models run denoising or score matching in orthonormal latents: DCTdiff (Ning et al., 2025) trains image diffusion in discrete cosine coordinates, Crabbé et al. (Crabbé et al., 2024) dualise time-series diffusion to the Fourier domain, and Phillips et al. (Phillips et al., 2022) score functional data along truncated Mercer eigen-

∗^{*}Equal contribution.

†^{\dagger}i.kuleshov@applied-ai.ru

Figure

Figure 1: Overview of MERCERFLOW. The joint context and horizon window is mapped into the decorrelated Mercer eigenbasis of the GP prior. A lightweight MLP learns conditional flow matching directly in this latent space, enabling fast and scalable probabilistic forecasting without sequential backbones.

functions. However, when we commit to a GP prior, as in TSFlow, the latent map must also decorrelate the resulting structure—not just the correlations in the data itself. To address this, we conduct a controlled comparison of five linear codecs for projection on a shared architecture and matched prior: Fourier (discrete Fourier transform), discrete cosine (DCT), principal components (PCA), the identity (Raw), and Mercer-based eigenbasis.

Mercer’s theorem supplies the orthonormal eigenbasis of the kernel one has already committed to (Mercer, 1909; Karhunen, 1947), so the coefficients are uncorrelated under the corresponding GP. Thus, that decorrelation is exact for the centred prior and approximate for the conditional law and for the interpolant on which the network trains. Across codecs, Mercer is the most versatile data-free choice: it works on data which requires a non-OU prior (Fourier and DCT best diagonalise OU-like priors, which are not always optimal for the data) and where PCA suffers from the train–test shift since it fits only the training path (§3.2).

That said, all five codecs are orthonormal projections, so a rotation-equivariant optimiser with an MSE loss should treat them as equivalent reparameterisations (Nesterov, 2004; Zhang et al., 2025). However, that equivalence is optimiser-specific: it holds for Euclidean SGD (Proposition 1), but fails under Adam because of the first-layer input geometry. Write A=E[xx⊤]A = \mathbb{E}[\mathbf{x}\mathbf{x}^\top] for a first-layer input x\mathbf{x} second-moment matrix and κ(A)=λmax⁡(A)/λmin⁡(A)\kappa(A) = \lambda_{\max}(A)/\lambda_{\min}(A) for the condition number of its spectrum. Orthonormal codecs leave the spectrum and κ(A)\kappa(A) unchanged, so Euclidean SGD cannot prefer one codec over another. Under Adam, however, per-coordinate rescaling is modelled by the Jacobi preconditioner D=diag(A)−1/2D = \text{diag}(A)^{-1/2}, after which the normalised second-moment matrix is DAD with the geometry conditioned by κ(DAD)\kappa(DAD). The rotation leaves κ(A)\kappa(A) fixed but changes diag(A)\text{diag}(A), which is what Jacobi reads, so κ(DAD)\kappa(DAD) is codec-dependent. Empirically, the decorrelating codecs exhibit both lower κ(DAD)\kappa(DAD) and better forecasting accuracy than Raw under Adam on challenging datasets, while their advantage disappears under SGD. Our experiments therefore examine how codec choice interacts with the optimiser and whether MercerFlow offers a favourable balance of predictive accuracy and computational cost relative to TSFlow and other baselines.

Contributions. Our contributions are as follows:

• A controlled five-codec study of conditional flow matching under matched architecture, prior, and protocol: Mercer, Fourier, DCT, PCA, and Raw on five GluonTS benchmarks with paired t-test ranks.

• A diagnostic of codec gaps under Adam versus SGD. First-layer κ(DAD)\kappa(DAD) separates Raw from the decorrelating codecs on hard sets under Adam, while the gaps vanish when the models are trained with SGD.

• MERCERFLOW: conditional flow matching carried out directly in the Mercer / Karhunen–Loève eigenbasis of the forecasting GP prior. Unlike fixed transforms such as DCT and

Fourier, the basis adapts directly to non-stationary and periodic priors, providing a data-free representation that remains robust across kernels without fitting the training path.

• An empirical comparison against TSFlow on multiple benchmarks. The MLP codecs are about 4.7×4.7\times cheaper in peak GPU memory and 3.5×−4.4×3.5\times-4.4\times cheaper in time per epoch at matched batch size, making MLP flow matching in linearly projected latents a practical alternative to sequential S4 backbones.

References (68)

  • Discrete cosine transform
  • Probabilistic and neural time series modeling in Python
  • Unitary equivalence: a new twist on signal processing
  • Dmamba: Decomposition-enhanced mamba for time series forecasting (opens arXiv in a new tab)
  • Time series diffusion in the frequency domain (opens arXiv in a new tab)
  • Toeplitz Forms and Their Applications
  • Efficiently modeling long sequences with structured state spaces
  • Shampoo: Preconditioned stochastic tensor optimization
  • Muon: An optimizer for hidden layers in neural networks
  • On the eigenvalues of certain Hermitian forms
  • Adam: A method for stochastic optimization
  • Flow matching with Gaussian process priors for probabilistic time series forecasting
  • Flow matching for generative modeling
  • Optimizing neural networks with Kronecker-factored approximate curvature
  • A Time Series is Worth 64 Words: Long-term Forecasting with Transformers
  • DCTdiff: Intriguing properties of image generative modeling in the DCT space
  • Spectral diffusion processes
  • Gaussian Processes for Machine Learning
  • Autoregressive denoising diffusion models for multivariate probabilistic time series forecasting
  • CSDI: Conditional score-based diffusion models for probabilistic time series imputation
  • Improving and generalizing flow-based generative models with minibatch optimal transport
  • SOAP: Improving and stabilizing Shampoo using Adam
  • Adam exploits $\ell_{\infty}$-geometry of loss landscape via coordinate-wise adaptivity
  • Are transformers effective for time series forecasting? In Proceedings of the AAAI conference on artificial intelligence, volume 37, pp. 11121–11128, 2023
  • Understanding Adam requires better rotation dependent assumptions
  • The target displacement in coefficient space is $\mathbf{u} = \mathbf{c}_1 - \mathbf{c}_0 = \Phi^\top (\mathbf{z}_1 - \mathbf{z}_0)$
  • The implemented MLP architecture satisfies this condition (Section C.3)
  • Consider an Identity network parameterised by $\theta_I = \{W_1, \mathbf{b}_1, W_2, \mathbf{b}_2, \theta_\psi\}$ and define the conjugated parameter set $\theta_\Phi = \{W_1^\Phi, \mathbf{b}_1^\Phi, W_2^\Phi, \mathbf{b}_2^\Phi, \theta_\psi^\Phi\}$ of the codec- $\Phi$ network by
  • if $\dot{\mathbf{c}} = \mathbf{v}_{\theta_{\Phi}}(t, \mathbf{c})$ and $\mathbf{y} = \Phi \mathbf{c}$, then by the chain rule
  • That is, the gradient step on the conjugated parameters matches the conjugation of the Euclidean gradient step on the original parameters
  • The SGD learning rate is untuned; the comparison is the matched-budget control that Proposition 1 predicts
  • All five codecs land within one standard deviation of each other on both datasets, in agreement with the equivariance claim
  • Evaluated at 20 NFE under the identical joint window ($L = 384$) and OU length scales as the AdamW runs
  • Under the standing model that Adam's input-side rescaling acts as this Jacobi preconditioner, the change of coordinates $\mathbf{x} \mapsto D\mathbf{x}$ leaves the residual Gram
  • The spectrum of $A$ is invariant under any orthogonal codec $\mathbf{x} \mapsto Q^{\top}\mathbf{x}$, since $Q^{\top}AQ$ is similar to $A$
  • The calculations below verify each row
  • Jitter gives $\lambda_i > 0$, so $D = \Lambda^{-1/2}$ and $G = I$, hence $\kappa(G) = 1$
  • When $\ell$ is large, the spectral mass concentrates at low frequencies, so $\min_k f$ shrinks rapidly
  • On the centred prior population of the proposition, PCA's basis is generally not aligned with K, and $\kappa(\text{DAD})$ is whatever that misalignment produces; Table 5 reports 8.15–46.98
  • This is the population the proposition's identity is proved against: Mercer hits $\kappa(\mathrm{DAD})=1$ on every dataset, with jitter only, by construction
  • Given the concatenated input vector $\mathbf{c} \in \mathbb{R}^L$ (joint sequence coefficients) and the sinusoidal flow-time embedding $\mathbf{e}_t \in \mathbb{R}^{d_e}$, the forward pass is defined as:
  • The bracketed operation
  • This strictly satisfies the structural condition required in the proof of Proposition 1 (Appendix B.1)
  • While DCT provides a competitive condition number under the OU prior ($\kappa(DAD)=712$), its condition number surges to $2.45\times 10^{4}$ under the periodic kernel, confirming that fixed harmonic bases cannot accommodate non-Toeplitz periodic correlations
  • Evaluated on the joint window ($L_p = 192$, $L_f = 192$, $L = 384$), last channel, random seed 42, standard scaler fit on the first 70%
  • MERCERFLOW achieves the best overall forecast (0.0821 CRPS)
  • Although Fourier captures periodic harmonic frequencies better than DCT on Traffic, it remains inferior to MERCERFLOW
  • Under the periodic prior, MERCERFLOW dynamically adapts and achieves top performance, whereas fixed harmonic codecs (DCT, Fourier) suffer from severe condition degradation and numerical instability under learning rate stress ($\eta = 10^{-1}$)
  • Each cell gives train/test
  • To verify the direct connection between first-layer AdamW preconditioning and final forecasting quality, Table 13 reports the mean within-dataset Spearman rank correlation $\rho$ between $\kappa(DAD)$ and test CRPS across the five MLP codecs
  • Each per-dataset $\rho$ ranks the five codecs on the two axes within that dataset; the column is the mean of those $\rho$'s across the listed datasets
  • Parenthetical values indicate the model's rank determined by pairwise two-sided $t$-tests on shared random seeds ($p < 0.2$) within the flow matching family
  • Among conditional flow matching models, MERCERFLOW consistently matches or outperforms all alternatives, securing rank 1 across all five benchmarks
  • Top: deterministic baselines; bottom: conditional flow matching models
  • Conversely, MERCERFLOW delivers competitive point accuracy across all datasets while simultaneously preserving well-calibrated prediction intervals, maintaining top rank (1.00) among generative models
  • Parenthetical values denote paired two-sided $t$-test rank ($p < 0.2$) among flow matching models on shared random seeds (42–48)
  • Table 16 provides the full test CRPS and MAE comparisons across all five benchmarks
  • Evaluated at matched mid-run EMA checkpoints $E^{*}$
  • MERCERFLOW converges rapidly and strictly monotonically
  • MERCERFLOW (solid blue) converges faster and strictly monotonically
  • The observation-space GP prior and the Mercer basis share this identical ground-truth kernel
  • Matched codecs share the OU prior at $\ell=32$; the wrong-$\ell$ arm uses a Mercer/GP model at $\ell=320$
  • Table 19 benchmarks MERCERFLOW against an equivalent score-based diffusion model formulated in the identical Mercer latent space (MERCERDIFF) across varying Numbers of Function Evaluations (NFE) at forecast horizon $L_{f}=192$
  • Due to straight probability paths, MERCERFLOW saturates within 4–10 steps, whereas diffusion (MERCERDIFF) suffers from severe discretization error
  • >Dataset</td><td rowspan=
  • $\kappa(DAD)$ is evaluated on conditional interpolants $\mathbf{c}_t$
  • >Metric</th><th rowspan=
  • A minimal jitter level ($\varepsilon\le 10^{-3}$) preserves exact alignment with the continuous analytical kernel, whereas excessive jitter forces the prior covariance toward isotropic white noise ($K\approx I_L$)