Flow+Diff: Unifying Flow and Diffusion Representations for Multivariate Time Series Anomaly Detection

Van Koh Kwan Zhi, Songnan Lin, Zhiping Lin, Bihan WenNeurIPS 2026

TL;DR

Catching subtle glitches in complex sensor networks is notoriously hard because standard deep learning models get too good at reconstructing data, accidentally smoothing over tiny errors or letting healthy signals drown out a single faulty sensor. Flow+Diff solves this by pairing two distinct generative models—a deterministic normalizing flow and a stochastic diffusion model—inside a shared latent space. When an anomaly strikes, the two models fundamentally disagree on how to represent it, turning their divergence into a sharp, reliable alarm bell.

What Problem Does This Paper Address?

Imagine monitoring a water treatment plant or a spacecraft using hundreds of simultaneous sensor streams—a task known as Multivariate Time Series Anomaly Detection (MTSAD). Because real-world anomalies are rare, we usually train models exclusively on "normal" data to compress and reconstruct the input. The assumption is simple: when something breaks, the model won't know how to reconstruct the weird data, and the resulting spike in time-domain reconstruction error will trigger an alarm.

Here is the catch: when anomalies are subtle—say, just two out of a hundred sensors drift slightly off-course—most features are still reconstructed accurately. That tiny error gets washed out in the overall average, making subtle failures look completely normal.

Figure 1: Challenges of reconstruction-based methods (left) versus our approach (right). Subtle anomalies, such as small deviations and sparse feature anomalies, yield low reconstruction errors and are difficult to detect. Moreover, reconstructions may remain accurate in anomalous segments, resulting in reconstruction errors indistinguishable from normal data. In contrast, our approach quantifies anomaly scores by transforming input time series into a shared latent space via normalizing flow and diffusion models, where the resulting representations diverge for anomalous inputs.

Methods

Instead of measuring errors in the raw time series, the authors move the detective work into a shared latent space, pitting two complementary generative paradigms against each other:

  1. Localized Mean Augmentation (LMA): Before hitting the neural networks, each time window is split into its local temporal mean and its centered residuals, then concatenated back together. This simple trick keeps local scales intact while stabilizing latent representations.
  2. Normalizing Flow (The Honest Witness): A normalizing flow (NF) is a sequence of invertible, deterministic mathematical mappings (built here with REALNVP layers and Transformer encoders). Crucially, the authors introduce temporal-preserving feature-wise masking, hiding subsets of features at each layer while keeping the timeline intact so the flow learns how different sensors relate to one another. Because the NF is strictly bijective (one-to-one), it cannot throw away information; if you feed it an anomaly, it faithfully maps that anomaly into a weird, low-probability corner of the latent space.
  3. Diffusion Model (The Optimist): Instead of forcing the NF to map data to a rigid, standard Gaussian prior, Flow+Diff replaces the NF's base distribution with a conditional 1D U-Net diffusion model. Trained jointly via maximum likelihood, the diffusion model learns the distribution of normal latent representations through iterative denoising.
Overview of Flow+Diff training and inference procedures

During inference (FlowDiff-AS), both models look at the input window. If the data is normal, their latent representations align. If the data is anomalous, the NF faithfully maps it out to the fringes, while the diffusion model—conditioned on normal dynamics—pulls its generated samples back toward familiarity. The squared $L_2$ distance between the NF's representation and the mean of $K$ diffusion samples becomes the anomaly score. Finally, because the NF is invertible, you can pass the diffusion samples backward through the flow to estimate a healthy reconstruction distribution in the time domain, pinpointing exactly which sensor went rogue.

Datasets

The authors evaluate Flow+Diff on six standard, publicly available MTSAD benchmarks (no new datasets are introduced):

  • SMD (Server Machine Dataset)
  • SMAP (Soil Moisture Active Passive satellite) & MSL (Mars Science Laboratory rover) — Note: discrete variables were zeroed out following recent best practices.
  • SWaT (Secure Water Treatment) & WADI (Water Distribution)
  • PSM (Pooled Server Metrics)

Importantly, they ditch the controversial "point-adjustment" evaluation metric (which artificially inflates scores if a model catches even a single timestamp of an anomaly) in favor of strict ROC, F1, and Volume Under the Precision-Recall Surface (V-PR) metrics.

Key Insights and Ideas

  • Latent Disagreement Beats Time-Domain Error: Evaluating the exact same trained Flow+Diff model using standard time-domain reconstruction error (MSE(X̂)) causes performance to plummet (e.g., WADI F1 drops from 0.626 to 0.249). The magic genuinely lies in measuring the clash between deterministic and stochastic latent spaces.
  • Fast Inference Without Sampling: Diffusion sampling at test time is computationally heavy. In a clever ablation, the authors replaced inference-time diffusion sampling with a single precomputed mean latent representation derived from training data. Detection accuracy stayed virtually identical! This means you can run lightweight, diffusion-free inference in production, and only spin up the diffusion sampler to reconstruct features when an operator needs to diagnose why an alarm went off.
  • Bounded Spaces Matter: Wrapping the final latent outputs in an affine-sigmoid (Asig) function to bound values between $(-1, 1)$ proved critical; removing it caused the largest performance collapse across all ablations, showing how touchy joint NF-diffusion training is without aligned scales.

Key Results

Tested against 12 baselines—from classical Isolation Forests to modern reconstruction heavyweights like NSPR and CrossAD—Flow+Diff achieves state-of-the-art ROC and F1 scores on four of the six datasets (MSL, SMAP, PSM, and WADI) and top V-PR on three.

On the complex, high-dimensional WADI dataset, Flow+Diff leaps ahead with a 0.809 ROC and 0.629 F1, whereas deep learning baselines struggle to break 0.51 ROC and 0.27 F1. Qualitatively, on the 25-feature PSM dataset, the model cleanly isolates subtle single-feature deviations against its estimated reconstruction confidence bands, avoiding the constant baseline offsets that plague deterministic reconstructors.

Limitations and Future Work

While the main text does not include a dedicated "Limitations and Future Work" section, the experimental results surface a few clear trade-offs:

  • Not a Universal Winner: Flow+Diff trails behind NSPR and CrossAD on the SMD dataset (achieving 0.224 F1 vs. NSPR's 0.375 F1).
  • Detection vs. Interpretability Trade-off: Removing the LMA module actually improves raw detection metrics slightly on WADI (F1 ticks up to 0.638), even though it visibly degrades time-domain reconstruction quality—suggesting tension between optimizing latent separability and maintaining crisp reconstructions.

Summary updated

Abstract

Many existing multivariate time series anomaly detection methods formulate anomaly detection as a reconstruction problem, where detections are derived from reconstruction errors in the time domain. While effective for large deviations, reconstruction-based scoring struggles with subtle anomalies where only a small subset of features deviates slightly. In such cases, most features are well reconstructed, causing the overall reconstruction error to remain low and indistinguishable from normal data. To address these challenges, we propose Flow+Diff, a novel framework that detects anomalies via discrepancies in a latent space, where two complementary representations, induced by distinct modeling paradigms, diverge under anomalous inputs. One representation is obtained via a normalizing flow, which provides an invertible mapping that preserves temporal dependencies and captures inter-feature dependencies. The other is produced by a diffusion model that learns the distribution of normal samples in the latent space via a stochastic denoising process. When given anomalous inputs, the normalizing flow maps the inputs to latent representations that lie in low-probability regions of the learned latent distribution, while the diffusion model generates representations aligned with normal data distributions, resulting in a pronounced discrepancy between the two. We compute the anomaly score based on this latent space discrepancy, thereby shifting anomaly detection from the time domain to the latent space. Finally, the invertibility of the normalizing flow enables reconstruction in the time domain, facilitating interpretation of anomalous features. Extensive experiments across six benchmark datasets show that Flow+Diff achieves state-of-the-art performance on four datasets against competitive baselines. The code is publicly available at https://github.com/vanerkz/FlowPlusDiff
BibTeX
@inproceedings{zhi2026flow,
  author = {Van Koh Kwan Zhi and Songnan Lin and Zhiping Lin and Bihan Wen},
  title = {{Flow+Diff: Unifying Flow and Diffusion Representations for Multivariate Time Series Anomaly Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=SsSjmffHDW},
}
Figure