ConceptioArchivearXiv CS
arXiv CSopen access

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series

Unknown · 2026 · arxiv_cs
arXiv CS · Papers · License: Open Access · 2026
Open Source ↗Direct PDF ↓
neuralnetworks
machine learning, deep learning, neural networks

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series Yunhua Pei† , Zixing Song‡ , Jin Zheng‡ , John Cartlidge‡ † School of Computer Science, University of Bristol, Bristol, UK ‡ School of Engineering Mathematics, University of Bristol, Bristol, UK

{ge22472,zixing.song,jin.zheng,john.cartlidge}@bristol.ac.uk

arXiv:2605.23744v1 [cs.LG] 22 May 2026

Abstract

The core challenges in MTS anomaly detection center on the inherent structural complexity and non-stationary nature of highdimensional data [7, 16], which are known as (i) dynamic intervariable dependencies and (ii) feature entanglement and spectral noise. Existing studies have made progress in different directions. Specifically, Transformer-based methods use self-attention to capture long-range temporal dependencies [54, 58]. Frequency-domain methods attempt to untangle the overlapping periodic patterns and background noise across variables by filtering spectral noise and extracting dominant periodic components [4, 48]. To better understand structural patterns, recent graph-based methods have also tried to address both challenges by representing variables as nodes and modeling their dependencies through graph structures [9, 56]. However, detections that are based on temporal forecasting objectives combined with topological reconstruction priors are insufficient. Firstly, these models often reconstruct anomalies as accurately as normal data [13, 47], thereby weakening their detection capability. Secondly, treating all training batches as equally reliable assumes the stationarity structure of data, even though relational patterns may drift over time as system states evolve [23, 27]. Thirdly, in real-world settings, the sparsity of anomaly labels [39] limits the practical applicability of manually supervised methods. To address these challenges in a label-free setting, we augment reconstruction-based learning with a graph contrastive objective that enhances geometric discrimination in the latent space, separating sparse anomalies from dominant normal patterns. Moreover, real-world MTS are inherently non-stationary [27], with intervariable dependencies evolving over time, making static graph assumptions prone to false positives caused by structural drift [7, 41]. We therefore advance to a dynamic graph contrastive framework that learns structural evolution across batches, enabling robust distinction between benign temporal shifts and genuine topological deviations. Based on this motivation, we propose ContrastAD, an unsupervised anomaly detection framework with three components: (1) a Multi-Perspective Embedder (MPE) that jointly encodes temporal, attribute-wise, and structural representations; (2) a Frequency-Aware Attention Mixer (FAM) that processes the unified embedding using temporal and frequency-aware attention for adaptive fusion; and (3) a Dynamic Graph Contrastive Learner (DGCL) that aligns naturally evolving graph snapshots. By measuring structural drift between windows, it regularizes training to avoid the rigid invariance constraints of traditional contrastive methods. Our main contributions are summarized as follows:

Anomaly detection in multivariate time series (MTS) is hindered by dynamic inter-variable dependencies and feature entanglement under spectral noise, and in practice, is further complicated by the absence of anomaly labels. Existing reconstruction-based detectors tend to recover anomalies as faithfully as normal patterns, while prevailing graph contrastive methods enforce invariance across views and thus assume a stationary relational structure, an assumption that breaks under structural drift in real systems. We propose ContrastAD, an unsupervised framework that turns structural evolution itself into a learning signal rather than suppressing it. A MultiPerspective Embedder encodes inputs from temporal, attribute, and structural perspectives. A Frequency-Aware Attention Mixer then performs spectral top-K filtering before attention, preventing noise from leaking into query-key similarities. The core component, a Dynamic Graph Contrastive Learner, builds power-law-inspired sparse graph snapshots from batch-level DTW distances and contrasts the most divergent pair against a stable anchor, regularizing the latent space without imposing rigid invariance. Across five realworld benchmarks, ContrastAD attains the highest mean F1 on all five datasets and the highest AUC on three (SWaT 93.60, SMD 98.66, PSM 97.79), with statistically significant F1 and AUC margins over the strongest baseline on SWaT and PSM. On MSL and SMAP, it trails the AUC leader by under 0.7 points while still leading on F1. Ablation and sensitivity studies further confirm that the contrastive objective works best as a soft regularizer, supporting our claim that strict invariance is suboptimal under non-stationary dynamics. Code and demo data are available online.1

CCS Concepts • Computing methodologies → Anomaly detection; • Information systems → Data stream mining; • Theory of computation → Dynamic graph algorithms; Unsupervised learning and clustering.

Keywords Multivariate Time Series Anomaly Detection, Graph Contrastive Learning, Dynamic Graph Learning, Unsupervised Representation Learning, Non-stationary Time Series

1

Introduction

With the increasing complexity of modern infrastructures such as industrial control networks [20, 51] and smart grids [53], reliable anomaly detection in multivariate time series (MTS) has become essential for safe and stable system operation.

• We propose ContrastAD, an unsupervised anomaly detection framework that integrates multi-perspective embeddings, frequency-aware attention, and dynamic graph contrastive learning for MTS anomaly detection.

1 https://anonymous.4open.science/r/CIKM26-ContrastAD-D29A

1

,,

Pei, Song, Zheng, Cartlidge

• We introduce a dynamic graph contrastive regularization strategy in ContrastAD that regularizes evolving relational patterns by leveraging divergence between consecutive graph snapshots to guide latent space optimization, rather than enforcing static invariance across views. • We evaluate the framework on five public datasets against eight state-of-the-art baselines. ContrastAD achieves the highest mean F1 on all five datasets, with statistically significant F1 and AUC gains on SWaT and PSM, demonstrating robustness to sparse anomalies, class imbalance, and structural non-stationarity.

A less explored aspect is that structural change in a graph can itself serve as an anomaly signal. When inter-variable dependencies shift due to cyber-physical attacks or workload changes, the topology reorganises in ways that static or infrequently updated models are unable to detect, which motivates approaches that explicitly track and contrast successive graph states rather than treating the graph as a fixed input.

2.3

Contrastive learning has become a prominent self-supervised approach for learning meaningful representations without labeled data. Initial works like AD-GCL [40] and GraphCL [50] introduced graph-specific contrastive objectives leveraging data augmentations to enhance embedding quality. For time series, methods such as TS2Vec [52] and TimesURL [19] extend contrastive learning to capture temporal dependencies at multiple scales. In anomaly detection, graph contrastive methods like FedCAD [17] and GCLAD [21] improve robustness and generalization by learning discriminative representations of normal pattern. However, most approaches rely on static graphs or fixed augmentations and rarely consider structural evolution as a direct learning signal, despite known degree bias and hard-negative effects in graph contrastive learning [11], which limits their effectiveness in dynamic environments. Moreover, anomalies in MTS are typically sparse and localized, affecting only a small subset of variables or inter-variable relations [7, 13, 39], which makes it difficult for models to reliably capture such subtle patterns under static or globally invariant contrastive objectives. Closely related, GraphTNC [55] contrasts temporal neighborhoods on dynamic graphs under a piecewise-stationarity assumption, and CGSTA [32] aligns cross-scale graph views with a stability-aware anchor. DGCL differs by selecting the maximally divergent snapshot pair and using its divergence as the regularization signal, without assuming local stationarity or enforcing cross-view alignment. A fundamental limitation of most contrastive methods is the view-invariance assumption, which trains the encoder to suppress cross-view differences and can therefore discard genuine structural change signals in non-stationary settings. Treating the contrastive objective as a soft regularizer rather than a primary learning signal offers an alternative, where a small negative weight gently separates embeddings of structurally divergent snapshots without enforcing global invariance across all views.

2 Related Work 2.1 Multi-Perspective Anomaly Detection Multivariate time series (MTS) anomaly detection often requires capturing dependencies across time, variables, and latent representations. Traditional approaches typically focus on a single perspective, such as temporal modeling [54, 58] or statistical reconstruction [13], which limits their ability to generalize under complex or evolving conditions. To address this limitation, recent studies have explored multi-view learning and multimodal feature integration. For example, DAGMM [60] combines autoencoding with probabilistic estimation, while OmniAnomaly [39] leverages stochastic latent variables to improve generalization. More recent models, such as InterFusion [18], employ hierarchical inter-metric and temporal embeddings to jointly model multi-perspective dynamics. Although these approaches improve representation capacity, challenges related to adaptive fusion and signal domain conversion noise remain, particularly when robustness is required [24]. Recent frequency-domain methods [4, 48] demonstrate that many anomalies disrupt spectral patterns rather than signal magnitudes, motivating selective filtering before feature fusion [47]. However, naively incorporating all frequency components into attention mechanisms introduces high-frequency noise that masks subtle relational deviations, underscoring the need for selective spectral filtering when integrating multiple perspectives.

2.2

Contrastive Unsupervised Learning

Graph-Based Anomaly Detection

Graph-based methods have been widely adopted to model intervariable dependencies in MTS. Early approaches construct static graphs and apply message passing using GNNs for anomaly detection [7]. To better capture temporal variation, spatial-temporal extensions introduce multi-scale graph structures [29]. Dynamic graph learning has also been explored to adaptively model changing correlations over time [57, 59], often benefiting from non-uniform or asymmetric graph structures [38]. In addition, sparse latent graph representations have been shown to improve robustness, interpretability, and computational efficiency [10]. Despite these advances, many methods still rely on fixed or infrequently updated graphs, limiting their flexibility and effectiveness under rapidly evolving conditions. More recent detectors enhance graph attention with topological features [22] or combine dynamic graph attention with Informer-style temporal modeling [12]. Even when the graph evolves over time, these methods use it as an input for message passing, not as successive states whose divergence drives detection.

3 Methodology 3.1 Problem Definition A multivariate time series (MTS) is defined as a sequence of timestamps X = {𝑥 1, 𝑥 2, . . . , 𝑥𝑡 } ∈ R𝑁 ×𝑇 , where 𝑇 is the length of the series, 𝑁 is the number of variables, and 𝑥𝑡 ∈ R𝑁 represents the observation vector at time 𝑡. Given a training sequence assumed to be free of labels, the goal is to learn a model that captures the normal temporal dependencies and inter-signal relationships in an unsupervised manner, without using any anomaly labels. At inference time (test data), the ′ model receives an unseen test sequence X ′ ∈ R𝑁 ×𝑇 , which may contain anomalies. The task is to predict a binary label sequence b = {b Y 𝑦1, 𝑦b2, . . . , 𝑦b𝑡 ′ } , where 𝑦b𝑡 ′ ∈ {0, 1} indicates whether the 2

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series

,,

Figure 1: Overall framework of ContrastAD. The Multi-Perspective Embedder (MPE) encodes a multivariate time-series window from temporal, attribute-wise, and structural views. The Frequency-Aware Attention Mixer (FAM) applies spectral top-𝐾 filtering before multi-head attention to suppress noise. In parallel, batch-level DTW distances build 𝑆 power-law-inspired sparse graph snapshots that feed the Dynamic Graph Contrastive Learner (DGCL). The three modules are trained jointly with forecasting and reconstruction losses and a graph-contrastive regularizer. The anomaly scores are derived from the residuals. observation at time 𝑡 ′ is anomalous (1) or normal (0). The predicted sequence is evaluated against the ground-truth label sequence Y.

3.2

where 𝑘 is the amount of DCN layers. 𝑟𝑘 denotes the dilation rate, (𝑘 ) ⊙ indicates element-wise multiplication, and Wres is the weight matrix of residual connection. To produce both temporal and attribute embeddings, we apply Eq. (1) along two orthogonal axes of the input. The temporal pass takes X as input and yields 𝑧 seq , encoding how each variable evolves over time. The attribute pass takes the transposed input X ⊤ and yields 𝑧 fea , encoding cross-variable patterns at each time step.

Overview of ContrastAD

The overall architecture of ContrastAD is illustrated in Fig. 1. The model first employs a Multi-Perspective Embedder (MPE) to encode input sequences from temporal, attribute-wise, and structural perspectives, producing a unified representation that captures both temporal dynamics and inter-variable interactions. This representation is further refined by a Frequency-Aware Attention Mixer (FAM) to suppress spectral noise and enhance feature disentanglement. To handle structural drifts, the Dynamic Graph Contrastive Learner (DGCL) constructs sparse graph views from consecutive time windows and applies contrastive regularization to regularize evolving relational patterns. Finally, the learned embeddings are used for forecasting, reconstruction, and systematic consistency modeling, and anomaly scores are derived from the residuals of these tasks. A detailed block-wise illustration of FAM is provided in the supplementary material.

3.3

Structural Temporal Graph Attention. To model dynamic relational dependencies across features over time, we further employ a temporal graph attention module inspired by [44]. Each feature is treated as a node in a fully connected graph, and pairwise attention scores are computed after linear projection: ⊤ ¯  ¯ 𝐴𝑖,𝑗 = Softmax LeakyReLU 𝑎 ⊤ (2) srcℎ𝑖 + 𝑎 dstℎ 𝑗 , where 𝑎 src and 𝑎 dst are learnable attention vectors, and ℎ¯ is the node feature embedding. The attention-weighted representations are then aggregated via convolution: ¯ 𝑧 gat = Conv1D(𝐴 · ℎ).

Multi-Perspective Embedder (MPE)

Finally, representations from the three perspectives 𝑧 seq , 𝑧 fea , 𝑧 gat are concatenated to form the unified embedding Z. Unlike prior encoders that span at most two perspectives, such as the structural-only view in GDN [7] or the temporal-attribute view in DTrans [33], MPE fuses all three within a single forward pass, so downstream layers can mix evidence from any of them without an extra alignment stage.

Temporal and Attribute Dilated Causal Convolutions. Following WaveNet-style architectures [25, 33, 42], we adopt dilated causal convolutions (DCN) to efficiently capture long-range dependencies in MTS. The input sequence X ∈ R𝑁 ×𝑇 is first projected via a learnable linear transformation to Z (0) , and then processed through a stack of gated residual convolutional layers:    (𝑘 ) Z (𝑘 ) = Z (𝑘 −1) + Wres tanh Conv1D𝑟(𝑘𝑘 ) (Z (𝑘 −1) )   ⊙ Sigmoid Conv1D𝑟(𝑘𝑘 ) (Z (𝑘 −1) ) ,

(3)

3.4 (1)

Frequency-Aware Attention Mixer (FAM)

Let Z ∈ R𝐿×𝑑 denote the input sequence at encoder layer 𝑙, where 𝐿 is the sequence length and 𝑑 is the embedding dimension. Following 3

,,

Pei, Song, Zheng, Cartlidge

Figure 2: Structure of different blocks in FAM. standard Transformer architectures [8, 43], we first add positional encodings to obtain 𝑍˜ . To suppress spectral noise and emphasize dominant temporal patterns, we apply a frequency selection step prior to attention. Specifically, a real-valued FFT [6] is performed along the temporal axis, and only the top-𝐾 frequency components are retained before inverse FFT reconstruction:   𝐻𝑙 = IFFT Topk(|FFT(𝑍˜ )|) . (4)

Figure 3: Example of power-law-inspired sparse graph construction in ContrastAD. Feature slices are extracted from multivariate time-series segments (Step 1), and nodes are initialized for each dimension (Step 2). A target degree distribution following Zipf’s law (Step 3) defines the expected power-law connectivity pattern T𝐾 . Pairwise Dynamic Time Warping (DTW) distances are computed among dimensions (Step 4), and the top-𝐾 largest DTW scores are selected under the power-law edge budget (Step 5). Edges are then formed based on these selected pairs to produce a sparse adjacency graph (Step 6), which is used by DGCL.

Placing top-𝐾 selection before the query and key projections removes spectral noise from the attention mechanism itself, rather than from its outputs after the fact. The Topk(·) operator here acts as a hard spectral mask. In each forward pass, it zeros the real and imaginary parts of all but the 𝐾 highest-magnitude Fourier bins before the inverse FFT. Gradients flow through the retained bins via FFT and IFFT, then vanish on the masked bins, which is equivalent to a straight-through estimator on a binary frequency mask. The filtered representation 𝐻𝑙 is then fed into a multi-head attention layer. For each attention head ℎ, query, key, and value matrices are computed as: 𝑄

𝑄ℎ = 𝐻𝑙 Wℎ ,

𝐾ℎ = 𝐻𝑙 Wℎ𝐾 ,

𝑉ℎ = 𝐻𝑙 W𝑉ℎ

the query-key similarities that drive feature mixing, which we find essential for stable detection under non-stationary inputs.

3.5

Sparse Graph Construction with a Power-Law Edge Budget. We represent the dynamic system as a sequence of graphs constructed within each sliding window X𝑤 ∈ R𝑁 ×𝑊 of window size 𝑊 , where each feature is treated as a node. To capture batch-level temporal dynamics, the time series is partitioned into 𝑆 non-overlapping snapshots of equal length 𝛿 = 𝑊 /𝑆. For node 𝑖 at snapshot 𝑠, the corresponding time series segment is denoted as x𝑖(𝑠 −1)𝛿:𝑠𝛿 ∈ R𝛿 . We compute pairwise Dynamic Time Warping (DTW) distances between these node segments to measure their temporal dissimilarity. The adjacency matrix A𝑠 ∈ {0, 1}𝑁 ×𝑁 for snapshot 𝑠 is then constructed by selecting edges corresponding to the top-𝐾 DTW distances, i.e., the 𝐾 most dissimilar node pairs:

(5)

and the scaled dot-product attention is given by:   𝑄ℎ 𝐾 ⊤ Attentionℎ = Softmax √ ℎ 𝑉ℎ . 𝑑𝑘 The outputs of all heads are concatenated and projected:

(6)

MHA(𝐻𝑙 ) = Concat(Attention1, . . . , Attention𝐻 )𝑊 𝑂

(7)

Each encoder layer further includes a position-wise feed-forward network with residual connections and layer normalization: FFN(𝑥) = W2 (ReLU(W1𝑥 + 𝑏 1 )) + 𝑏 2

Dynamic Graph Contrastive Learner (DGCL)

(8)

The final embedding is obtained by a gated combination of the two FFN outputs with a residual connection. Finally, trend and seasonal components are aggregated through linear projections and combined via a gating mechanism:  𝑔 = Sigmoid W𝑔 (FFN1 + FFN2 ) (9)

( 𝐴𝑖𝑠 𝑗 =

1,

  if DTW x𝑖(𝑠 −1)𝛿:𝑠𝛿 , x 𝑗(𝑠 −1)𝛿:𝑠𝛿 ∈ T𝐾

0,

otherwise

(10)

where T𝐾 is the set of the 𝐾 largest DTW distances within snapshot 𝑠 (here 𝐾 is the per-snapshot edge budget, set in Tab. 1, distinct from the spectral 𝐾 used in FAM). The top-𝐾 DTW edge selection used here follows the powerlaw-inspired sparse graph construction strategy adopted in prior multivariate time-series work [31, 37]. Under this strategy, the persnapshot edge budget follows a power-law degree prior, in which the node-degree probability decays as:

The final embedding is a gated sum of two processed FFN results, plus a residual connection and gating weights W𝑔 . The overall structure of FAM is illustrated in Fig. 2: spectral filtering (Eq. 4) precedes multi-head attention, so the attention operates on a denoised, periodicity-dominant representation rather than the raw signal. This ordering is deliberate—placing FFT-based selection before attention prevents spectral noise from leaking into

𝑃 (𝑛) ∼ 𝑛 −𝛾 4

(11)

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series

where 𝑃 (𝑛) is the probability that a node has degree 𝑛, and 𝛾 is the degree exponent [2]. This aligns with Zipf’s law [28], where the degree probability is given by: 𝑛 −𝛾 𝑃 (𝑋 = 𝑛) = Í𝑁 (12) −𝛾 𝑖=1 𝑖

where the first two terms align each graph embedding with the anchor, while the third term explicitly separates embeddings of structurally dissimilar snapshots. This contrastive tension prevents representational collapse and enhances discrimination across evolving graph structures. 𝐵 denotes the mini-batch size of nodes. The overall objective combines the graph contrastive regularizer with the forecasting and reconstruction losses:

and 𝑁 is the total number of nodes. Consequently, the expected degree of a node under this distribution is: 𝐸 (𝑋 ) =

𝑁 ∑︁

𝑛 · 𝑃 (𝑋 = 𝑛)

L = Lforecast + 𝛽 · Lreconstruction + 𝜆 · Lgraph

We set the per-snapshot edge budget to 𝐾 = ⌊𝑁 · 𝐸 (𝑋 )/2⌋, the expected edge count under a power-law degree prior. This prior fixes a compact, hub-aware budget but does not enforce an exact powerlaw degree distribution. The edges themselves are selected by DTW dissimilarity, which keeps the graphs sparse without imposing a hard topology.

Theoretical Motivation of DGCL. We interpret DGCL through the alignment and uniformity view of contrastive learning [45]. In the score form of Eq. (17), the first two terms grow when the two divergent snapshots stay compatible with the anchor, and the third term grows when they stay separated from each other. Maximizing the score therefore keeps each divergent snapshot compatible with the anchor while preventing the two from collapsing together, the contrastive tension DGCL relies on. Since the total objective in Eq. (18) is minimized, this maximization requires a negative coefficient 𝜆, whose small magnitude |𝜆| ≤ 1 keeps the term auxiliary to the forecasting and reconstruction losses. Standard InfoNCE objectives maximize a mutual-information lower bound [30, 46], but DGCL departs from that setting, since the objective pairs two anchor-alignment terms with a snapshot-separation term and does not follow the standard InfoNCE positive and negative structure. The power-law-inspired sparse graph construction further introduces a principled inductive bias consistent with many realworld systems, where node connectivity follows power-law distributions [2]. Moreover, graph edges are constructed using the top-𝐾 highest DTW distances, connecting variables that exhibit highly dissimilar temporal behaviors. This design introduces structural diversity analogous to hard negative sampling, complementing the selection of the most dissimilar graph pair (𝐺 𝑝 , 𝐺𝑞 ) in the contrastive objective. Together, DTW-based hard relational edges and graph-level hard negatives enlarge the decision margin in representation space, preventing representational collapse and enhancing discrimination under temporal variation [14, 34]. Recent theoretical analyses further suggest that optimizing InfoNCE with diverse and informative views improves downstream prediction and anomaly detection performance [36, 41].

Contrastive Learning Objective. Given the set of snapshot graphs G = {𝐺 1, 𝐺 2, . . . , 𝐺𝑆 }, we identify the most structurally dissimilar pair (𝐺 𝑝 , 𝐺𝑞 ) by maximizing the symmetric Kullback-Leibler (KL) divergence between their normalized degree distributions: ∑︁

𝑑𝑎 (𝑘) log

𝑑𝑏 (𝑘) 𝑑𝑎 (𝑘) + 𝑑𝑏 (𝑘) log , 𝑑𝑏 (𝑘) 𝑑𝑎 (𝑘)

(14)

𝑘

where 𝑘 indexes the degree values, and 𝑑 (𝑘) denotes the normalized frequency of degree 𝑘 in graph 𝐺. The most dissimilar pair is then selected as: (𝑝, 𝑞) = arg max 𝐷 sym (d𝑎 , d𝑏 ) (15) We summarize per snapshot with a graph convolutional network (GCN) encoder. As the DTW graph connects the most temporally divergent variables, this GCN acts as a relational readout over a structural-contrast graph rather than a homophily-based smoother over a similarity graph. The embeddings are computed as: 𝑆 ª © 1 ∑︁ 𝐺𝑖 ® , z𝑎 = GCN­­ 𝑆 − 2 𝑖=1 ® (16) 𝑖≠𝑝,𝑞 ¬ « z𝑝 = GCN(𝐺 𝑝 ), z𝑞 = GCN(𝐺𝑞 ) where z𝑝 and z𝑞 are the embeddings of the two maximally divergent snapshots 𝐺 𝑝 and 𝐺𝑞 (see Theoretical Motivation below). Let 𝜏 > 0 denote the temperature hyperparameter. We now define an InfoNCE-style graph contrastive regularizer. It is written in score form, and the subscripts 𝑝 and 𝑞 index the two most divergent snapshots rather than positive or negative samples. Formally, Lgraph is given by:

Lgraph = +

4

Experiments

The supplementary material includes the demo code used in our experiments. Due to space constraints, we focus on reporting F1score and AUC in the main paper, with full Precision and Recall results as well as architectural efficiency and scalability analyses provided in the supplementary material.

⊤ z /𝜏) 𝐵 exp(z𝑝,𝑖 𝑎,𝑖 1 ∑︁ log Í𝐵 ⊤ z /𝜏) 𝐵 𝑖=1 exp(z 𝑗=1 𝑝,𝑖 𝑎,𝑗

⊤ z /𝜏) 𝐵 exp(z𝑞,𝑖 𝑎,𝑖 1 ∑︁ log Í𝐵 + ⊤ z /𝜏) 𝐵 𝑖=1 exp(z 𝑗=1 𝑞,𝑖 𝑎,𝑗

(18)

where 𝛽 weights the reconstruction loss and 𝜆 the graph contrastive regularizer.

(13)

𝑛=1

𝐷 sym (d𝑎 , d𝑏 ) =

,,

4.1

Datasets

We evaluate our proposed framework on five real-world MTS datasets: • SWaT [26] is collected from a real-world industrial water treatment testbed that simulates a fully operational plant. It consists of 51 sensor and actuator signals sampled at onesecond intervals. Anomalies correspond to cyber-attacks affecting control logic and physical processes.

(17)

⊤ z /𝜏) 𝐵 exp(z𝑝,𝑖 𝑞,𝑖 1 ∑︁ log Í𝐵 ⊤ z /𝜏) 𝐵 𝑖=1 exp(z 𝑗=1 𝑝,𝑖 𝑞,𝑗

5

,,

Pei, Song, Zheng, Cartlidge

Table 1: Dataset statistics and graph construction. Description

Dataset SWaT SMD MSL PSM SMAP

Year

Domain

Source

2016 2019 2018 2021 2018

Industrial control Server systems Spacecraft Server systems Satellite

Water treatment plant Cloud servers Mars rover Application servers Earth-observing satellite

Statistics Train

Test

Features (𝑁 )

Anomaly (%)

Edges

Density (%)

475,200 708,405 58,317 132,481 135,183

449,919 708,420 73,729 87,841 427,617

51 38 55 25 25

12.14 4.16 10.72 27.76 13.13

16 13 17 10 10

1.25 1.85 1.14 3.33 3.33

• SMD [39] contains multivariate system telemetry from 28 independent server machines, each monitored for 10 days with 38 performance metrics such as CPU usage, memory consumption, and I/O throughput. Anomalies are sparse and localized, resulting in a low anomaly ratio (4.16%). • MSL [13] is a spacecraft telemetry dataset collected from NASA’s Mars Science Laboratory rover. It contains a 55dimensional time series reflecting sensor and actuator readings. Anomalies are rare and often manifest as subtle deviations in system dynamics rather than abrupt signal changes. • PSM [1] originates from eBay’s application server infrastructure and includes 25 system-level performance metrics. The dataset exhibits frequent but diverse anomaly patterns caused by workload fluctuations and system faults. • SMAP [13] is a satellite telemetry dataset from NASA’s Soil Moisture Active Passive mission. It contains a 25-dimensional time series of sensor readings from an satellite.

• MTG [59] (TKDE 2024): A label-free framework that combines multivariate temporal graphs with flow-based density estimation for anomaly detection. • MSHTrans [5] (KDD 2025): A multi-scale hypergraph Transformer that decomposes time series into trend and seasonal components and models inter-variable relationships via learnable hyperedges. Non-Graph-Based Methods. • DTrans [33] (BigData 2022): A Transformer-based model that decomposes MTS into trend and seasonal components with frequency attention and dilated causal convolutions. • MemStr [3] (WWW 2022): A memory-augmented streaming framework that maintains a dynamically updated bank of prototypical normal patterns without retraining. • Catch [47] (ICLR 2025): A channel-aware reconstruction model that patches the frequency spectrum per channel and fuses cross-channel representations via attention for anomaly detection.

Tab. 1 summarizes the detailed statistics of each dataset and the power-law-inspired constructed sparse graphs. Notably, the training data is unlabeled. For all five datasets, the training data contains no anomalies, and anomalies appear only in the test data. Training on data that also contains anomalies is left for future work. Among them, SMD exhibits a relatively sparse anomaly distribution, with only 4.16% anomalous samples, which poses additional challenges for unsupervised anomaly detection. The undirected graph den2 × Edge sity is computed as , where Node denotes the Node × (Node − 1) number of features.

4.2

Graph

4.3

Evaluation Metrics

Following prior work [7, 10, 57, 59], we adopt Precision (P), Recall (R), F1-score, and AUC-ROC for evaluation, where TP, FP, and FN denote true positives, false positives, and false negatives, respectively: TP TP 2·𝑃 ·𝑅 , 𝑅= , 𝐹1 = . (19) TP + FP TP + FN 𝑃 +𝑅 AUC-ROC measures the area under the Receiver Operating Characteristic curve, which plots the true positive rate TPR = TP/(TP + FN) against the false positive rate FPR = FP/(FP + TN) across all decision thresholds: ∫ 1  AUC = TPR FPR −1 (𝑡) d𝑡 . (20) 𝑃=

Baselines

We compare ContrastAD with eight representative baselines spanning graph-based and non-graph-based paradigms. Graph-Based Methods.

0

Following standard practice in MTS anomaly detection [7, 49], we apply point adjustment uniformly to all methods before computing metrics: if any time step within a contiguous anomaly segment is correctly detected, all time steps in that segment are counted as true positives. Following recent evaluation work [15], the thresholdindependent AUC-ROC serves as a complementary metric.

• GDN [7] (AAAI 2021): A GNN-based method that dynamically constructs feature correlation graphs and detects anomalies via node-level deviations. • CSTGL [57] (TNNLS 2023): A correlation-aware spatialtemporal graph model that captures intra- and inter-variable dependencies using hierarchical attention. • FuSAG [10] (KDD 2022): A graph learning model that infers sparse latent graphs across temporal and feature dimensions to capture multiscale dependencies under structured sparsity constraints.

4.4

Experimental Setup

All experiments are conducted on an Nvidia GeForce RTX 3090 GPU with CUDA 11.5. Following prior works [7, 10, 33], the data is 6

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series

,,

Table 2: Performance comparison (P: Precision, R: Recall, F1: F1-score, AUC: AUC-ROC) reported as mean ± std over 𝑛=5 seeds. Best results are in red, second best are blue. ★ indicates statistically significant improvement of ContrastAD over the second-best method (non-overlapping 95% confidence intervals, F1 and AUC only). Dataset

Metric

GDN

CSTGL

FuSAG

MTG

DTrans

MemStr

Catch

MSHTrans

ContrastAD

SWaT

P R F1 AUC

93.97±0.51 71.38±1.27 81.17±1.09 88.75±0.41

40.16±1.14 33.12±1.33 36.29±1.23 62.25±0.93

98.63±0.24 71.79±1.20 83.11±1.02 87.35±0.35

45.24±0.88 53.50±1.09 49.03±0.99 84.46±0.46

64.03±0.78 71.42±0.88 67.55±0.84 85.56±0.48

97.94±0.27 64.30±1.18 77.63±0.98 82.41±0.43

96.29±2.00 74.99±2.34 84.27±1.11 91.94±0.17

98.15±1.83 72.89±3.26 83.57±1.37 91.78±0.89

91.32±0.46 71.72±0.50 88.24±0.51★ 93.60±0.22★

SMD

P R F1 AUC

86.39±0.27 3.41±0.20 6.55±0.33 68.09±0.61

17.30±0.56 18.55±0.65 17.91±0.53 68.22±0.60

11.91±0.38 32.96±0.50 17.50±0.46 67.92±0.45

18.86±0.57 23.63±0.65 20.98±0.55 72.85±0.51

77.17±0.50 57.38±0.61 65.87±0.57 65.73±0.56

11.40±0.41 26.47±0.51 15.93±0.47 60.23±0.58

69.58±5.90 78.06±5.75 73.57±5.82 97.60±1.42

78.53±1.72 79.23±2.31 78.83±0.97 98.50±0.16

81.54±0.41 76.39±0.45 78.87±0.43 98.66±0.15

MSL

P R F1 AUC

80.23±0.91 75.56±0.76 77.82±0.67 55.77±0.82

80.52±0.83 99.44±0.14 88.98±0.57 57.49±0.66

82.49±0.89 97.19±0.27 89.21±0.51 67.23±0.62

94.29±0.21 16.92±0.36 28.70±0.41 61.68±0.62

85.75±0.72 87.43±0.61 86.58±0.63 87.87±0.53

84.76±0.82 95.56±0.31 89.84±0.55 83.35±0.50

70.28±6.46 85.25±3.73 76.93±4.82 95.36±1.10

89.37±1.21 86.52±1.11 87.91±0.20 98.01±0.05

90.33±0.47 87.50±0.43 89.95±0.45 97.85±0.04

PSM

P R F1 AUC

59.17±0.97 28.61±0.56 38.55±0.62 66.90±1.04

27.77±0.48 99.95±0.02 43.46±0.78 55.08±0.87

52.57±0.76 76.70±0.60 62.38±0.65 76.41±0.42

73.47±0.61 29.07±0.51 41.64±0.58 72.83±0.57

76.78±0.62 77.55±0.58 77.16±0.56 74.86±0.55

49.41±0.65 66.97±0.58 56.86±0.62 69.37±0.56

80.40±15.43 82.87±14.48 78.78±0.38 94.22±0.25

95.82±1.46 85.88±1.64 90.56±0.16 96.26±0.14

96.87±0.40 86.21±0.35 91.17±0.11★ 97.79±0.06★

SMAP

P R F1 AUC

8.09±0.38 14.73±0.48 10.43±0.27 35.88±0.51

17.30±0.60 48.53±0.74 25.50±0.55 52.43±0.63

17.14±0.47 82.43±0.25 28.37±0.50 54.90±0.45

20.58±0.48 56.69±0.55 30.20±0.46 57.21±0.52

14.39±0.45 55.01±0.51 22.91±0.48 58.26±0.52

24.94±0.53 64.62±0.60 36.00±0.51 65.30±0.47

93.43±4.51 54.96±2.16 69.08±0.60 84.36±4.34

88.86±2.61 57.74±1.21 69.95±0.24 89.50±1.17

95.63±0.51 55.26±0.41 70.04±0.02 88.87±0.50

split into training, validation, and test sets. Specifically, 80% of the training set for training and the remaining 20% for validation. For MPE, we stack four DCN layers with dilation rates 𝑟𝑘 (1, 2, 4, 8) to capture long-range dependencies from both temporal and attribute dimensions following [33]. For spatial modeling, we apply a temporal GAT with the same feature dimensionality, followed by a 1D convolution (kernel size 3, 32 output channels, dropout 0.1). For FAM, we stack two attention layers with 128 channels and 4 heads, using an embedding size of 128. The 𝐾 in Eq. 4 TopK(·, 𝑘) is 6. For DGCL, we apply a sliding window of size 100 and step size 1, the window size of 100 matches the standard choice on these five datasets [49] and 10 snapshots of length 10, balancing contrastive pair diversity against DTW cost. The contrastive temperature 𝜏 is 0.1. The forecasting loss Lforecast and reconstruction loss Lreconstruction are both RMSE-based. We set 𝛽 = 0.1 to balance the losses. Anomaly thresholds are selected by clustering validation scores as in [49]. The contrastive loss weight 𝜆 in Lgraph is fixed per dataset prior to evaluation through pilot experiments on the training and validation splits, without consulting any test labels. The selected values are 𝜆 = −0.1 for SWaT and MSL, 𝜆 = −0.9 for SMD, 𝜆 = −1.0 for PSM, and 𝜆 = −0.4 for SMAP. Tab. 4 reports a post-hoc sensitivity sweep over 𝜆 ∈ [−1.0, +1.0] at intervals of 0.1 demonstrating that performance is robust around these chosen values; this sweep does not participate in 𝜆 selection. For each baseline, we report the hyperparameters used as follows. GDN [7]: sliding window 15 with stride 5, batch size 128, embedding dimension 𝑑 = 64, top-𝑘 = 20, one output layer with intermediate dimension 256, validation ratio 0.1, and 100 training epochs (no weight decay). CSTGL [57]: input sequence length 5, batch size 4, learning rate 3 × 10−4 , weight decay 10−4 , dropout 0.1,

5 training epochs, propagation 𝛼 = 0.1, tanh 𝛼 = 20, 3 graph splits, node embedding dimension 256, subgraph size 𝑘 = 5, GCN depth 2, (conv, residual, skip, end) channels of (16, 16, 32, 64), 2 stacked layers, with 5 PCA components and a normalization window of 200. FuSAG [10]: sliding window 5 with stride 1, batch size 32, embedding dimension 𝑑 = 64, top-𝑘 = 15, output intermediate dimension 64, validation ratio 0.2, learning rate 10−3 , forecasting loss weight 𝛼 = 0.5, and sparse loss weight 𝛽 = 1.0. MTG [59]: window size 60 with stride 10, batch size 128, learning rate 2 × 10−3 , weight decay 5×10−4 , MAF architecture with 1 block, 1 hidden layer of size 32, and 1 Gaussian component. MSHTrans [5]: temporal scales (1, 2, 4), model dimension 𝑑 = 64, 16 learnable hyperedges, 4 attention heads, and dropout 0.1. DTrans [33]: window size 100, batch size 128, learning rate 10−4 , dropout 0.2, kernel size 3, 1 GRU layer, 1 forecast layer with hidden dimension 150, and reconstruction/anomaly weights 𝜆 = 𝛽 = 1. MemStr [3]: memory length 2048, autoencoder pre-training for 5000 epochs with learning rate 10−2 , and threshold 𝛽 = 0.1. Catch [47]: patch size 10, model dimension 𝑑 = 64, 4 attention heads, 2 encoder layers, and dropout 0.1. All baselines are evaluated under identical point-adjustment settings and the five-seed protocol as ContrastAD {0, 1, 2, 3, 42}.

4.5

Results and Analysis

4.5.1 RQ1. Performance Comparison. Tab. 2 summarizes results across eight baselines and five datasets. ContrastAD attains the highest mean F1 on all five datasets and the highest AUC on three of them(SWaT, SMD, and PSM), with statistically significant F1 and AUC margins on SWaT and PSM, while MSHTrans leads on AUC for MSL and SMAP. The pattern of F1 leadership across every dataset paired with AUC leadership on three out of five supports 7

,,

Pei, Song, Zheng, Cartlidge

Table 3: Ablation study results are reported as mean ± std over 𝑛=5 seeds. We evaluate the full model (ContrastAD) and its variants by ablating the MPE (\M), the FAM (\F), and the DGCL (\D). Best results are in red, second best are blue. ★ indicates statistically significant improvement over the best variant (non-overlapping 95% confidence intervals). SWaT

Variant

SMD

MSL

PSM

SMAP

F1

AUC

F1

AUC

F1

AUC

F1

AUC

F1

AUC

ContrastAD\M ContrastAD\F ContrastAD\D

80.77±0.70 77.65±0.68 73.84±0.73

90.22±0.38 88.81±0.36 81.90±0.42

38.01±0.51 47.11±0.48 50.01±0.47

62.73±0.46 72.60±0.43 69.51±0.45

79.46±0.62 89.03±0.55 84.65±0.58

77.81±0.41 76.15±0.37 69.95±0.40

73.85±0.58 81.17±0.57 80.84±0.52

73.92±0.53 74.93±0.52 70.33±0.48

28.17±0.46 30.79±0.41 46.43±0.43

59.13±0.48 61.97±0.45 60.69±0.46

ContrastAD

88.24±0.51★

93.60±0.22★

78.87±0.43★

98.66±0.15★

89.95±0.45

97.85±0.04★

91.17±0.11★

97.79±0.06★

70.04±0.02★

88.87±0.50★

Table 4: Sensitivity of the contrastive weight 𝜆 on F1 and AUC-ROC (mean±std, 𝑛 =5, values×100). Each column is independently shaded from worst to best . The shaded row (𝜆 =0) removes DGCL. SWaT

𝜆 F1

−1.0 82.64±1.47 −0.9 75.42±12.77 −0.8 82.28±0.80 −0.7 81.63±3.81 −0.6 81.05±0.95 −0.5 81.31±0.75 −0.4 83.26±1.64 −0.3 79.22±7.08 −0.2 84.60±12.38 −0.1 88.24±5.00 0

73.84±0.73

+0.1 85.53±2.21 +0.2 76.70±4.69 +0.3 77.33±8.69 +0.4 73.90±16.41 +0.5 82.55±2.28 +0.6 83.39±1.44 +0.7 82.23±1.55 +0.8 82.89±1.90 +0.9 80.61±4.63 +1.0 81.71±1.47

SMD

MSL

PSM

SMAP

AUC

F1

AUC

F1

AUC

F1

AUC

F1

AUC

90.68±0.97 86.46±6.02 88.50±1.53 89.23±2.47 88.68±1.93 89.68±1.39 90.02±1.63 88.92±3.46 87.62±5.70 93.60±0.22

78.01±0.68 78.87±1.12 77.73±0.60 78.47±0.78 77.71±0.32 78.09±0.37 77.76±0.59 78.12±0.86 74.06±0.40 76.81±0.45

98.55±0.14 98.66±0.15 98.55±0.15 98.59±0.15 98.56±0.11 98.55±0.10 98.58±0.10 98.53±0.12 98.33±0.14 98.36±0.15

88.81±0.25 88.31±0.79 88.21±0.32 88.58±0.19 88.62±0.13 88.47±0.32 88.73±0.71 88.41±0.37 89.13±0.44 89.95±0.18

98.15±0.07 98.08±0.12 98.08±0.06 98.10±0.07 98.12±0.02 98.11±0.09 98.16±0.06 98.11±0.12 97.70±0.08 97.85±0.04

91.17±0.11 90.20±1.23 90.60±0.99 90.04±1.13 90.03±0.32 90.08±1.08 90.69±1.03 90.39±0.63 90.95±0.93 90.41±1.35

97.79±0.06 97.72±0.30 97.72±0.20 97.67±0.12 97.65±0.18 97.75±0.15 97.75±0.24 97.82±0.12 97.79±0.28 97.68±0.31

70.01±0.06 70.03±0.07 70.03±0.07 70.00±0.05 70.01±0.02 70.02±0.04 70.04±0.02 70.03±0.03 48.05±0.03 49.08±0.05

89.43±1.02 89.21±1.04 89.27±0.66 89.03±0.52 89.11±0.65 88.77±0.51 88.87±0.50 88.78±0.40 88.24±0.61 87.85±0.57

81.90±0.42 50.01±0.47 69.51±0.45 84.65±0.58

69.95±0.40 80.84±0.52 70.33±0.48 46.43±0.43

60.69±0.46

89.39±1.34 88.68±2.00 87.22±3.23 85.95±8.27 89.49±1.34 90.21±0.67 89.11±1.76 89.33±0.67 88.83±2.86 88.69±1.89

98.16±0.11 98.06±0.13 98.17±0.05 98.05±0.15 98.10±0.05 98.16±0.07 98.09±0.09 98.10±0.07 98.11±0.07 98.10±0.11

88.20±0.45 88.22±0.48 88.22±0.65 87.76±0.49 87.78±0.57 87.51±0.78 87.67±0.62 87.62±0.78 87.44±1.38 87.26±1.34

72.63±0.44 68.88±0.48 78.52±0.52 78.34±0.70 77.94±0.61 78.30±0.45 78.06±0.31 78.30±0.45 78.25±0.52 78.40±0.34

98.40±0.10 98.70±0.14 98.62±0.11 98.58±0.14 98.62±0.09 98.60±0.10 98.58±0.13 98.56±0.10 98.60±0.11 98.64±0.09

86.65±0.38 80.58±0.54 88.71±0.12 88.22±0.91 88.72±0.12 88.86±0.17 88.78±0.79 88.65±0.22 88.56±0.28 88.85±0.19

DGCL’s role as a boundary-shaping regularizer that improves both operating-threshold quality and global score separation. On SWaT, ContrastAD reaches F1 88.24% (★, +3.97 over Catch) and AUC 93.60% (★, +1.66 over Catch). The wider F1 margin relative to the AUC margin indicates that DGCL’s main contribution on coordinated multi-variable attacks is sharpening the operating threshold rather than uniformly widening score separation. On SMD (4.16% anomaly ratio), ContrastAD edges out MSHTrans on both F1 (+0.04) and AUC (+0.16), showing that DGCL’s relational regularizer remains effective on sparse anomalies even when the margin to the strongest baseline is tight. On PSM, ContrastAD achieves both the best F1 (★, 91.17%) and AUC (★, 97.79%), suggesting that diverse anomaly patterns benefit especially from relational evolution modelling. Several baselines collapse to degenerate precision-recall tradeoffs. GDN on SMD yields F1 of only 6.55% despite 86.39% Precision (Recall 3.41%), and CSTGL on PSM yields 43.46% F1 despite 99.95% Recall (Precision 27.77%). ContrastAD avoids both

88.45±1.09 86.13±0.94 91.14±1.03 89.69±1.16 89.72±1.23 90.43±1.33 90.41±0.33 89.77±0.37 90.45±1.13 90.69±1.11

97.76±0.17 97.87±0.16 97.81±0.19 97.58±0.48 97.64±0.29 97.73±0.14 97.72±0.12 97.59±0.22 97.74±0.16 97.79±0.18

47.34±0.06 39.39±0.06 70.01±0.05 70.03±0.03 70.03±0.04 65.47±0.06 70.03±0.05 63.22±0.04 70.03±0.03 68.18±0.10

failure modes on every dataset, which is the direct result of DGCL tightening the normal manifold without over-committing to either detection direction. 4.5.2 RQ2. Ablation Study. To assess the contribution of each core component, we replace MPE (\M) with a linear projection, FAM (\F) with standard multi-head attention, and exclude DGCL (\D) entirely. Results are in Tab. 3. Every ablation degrades performance consistently across datasets. Removing DGCL (\D) causes the most striking single-module drop on SWaT, where F1 falls from 88.24 to 73.84, equal to the 𝜆 = 0 sensitivity baseline, confirming that DGCL’s contribution cannot be recovered by the reconstruction objective alone. Removing MPE (\M) produces the largest absolute drop on SMD (from 78.87 to 38.01), suggesting that multi-perspective representation is especially critical when anomalies are sparse and non-stationary structural shifts provide the primary detection signal. Replacing FAM (\F) with standard attention degrades performance on SMAP and 8

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series

,,

Table 5: Architectural and computational characteristics of different anomaly detection methods on the SWaT dataset. 𝑁𝐿 denotes test-sequence length. Performance tiers use ✓ (low), ✓✓ (medium), and ✓✓✓ (high) based on aggregate average F1 and AUC across all datasets. Complexities are reported under the fixed sliding window (𝐿 = 100). Type

Method

Train Parallel

Inference Cost

Memory Complexity

Train Time (s/epoch)

Perf. Tier

Graph-based

GDN [7] CSTGL [57] FuSAG [10] MTG [59] MSHTrans [5]

✓ ✓ ✓ ✓ ✓

O (1) O (1) O (1) O (1) O (1)

O (𝑁𝐿 ) O (𝑁𝐿 ) O (𝑁𝐿 ) O (𝑁𝐿 ) O (𝑁𝐿2 )

9.53 384.53 156.22 2.80 634.72

✓✓ ✓ ✓✓ ✓ ✓✓✓

Non-graph-based

DTrans [33] MemStr [3] Catch [47]

✓ – ✓

O (𝑁𝐿 ) O (1) O (1)

O (𝑁𝐿2 ) O (𝑁𝐿 ) O (𝑁𝐿2 )

141.64 96.39 190.49

✓✓ ✓✓ ✓✓✓

Ours

ContrastAD

O (1)

O (𝑁𝐿 )

132.16

✓✓✓

SMD most noticeably, indicating that frequency-aware filtering before attention is not interchangeable with generic mixing. Taken together, the ablation reveals that the three modules address complementary failure modes rather than redundant functions, which explains why their gains are additive rather than overlapping.

parallel training with linear memory but either incur high cost (CSTGL at 384.53s, FuSAG at 156.22s, MSHTrans at 634.72s) or fall short on detection (MTG). DTrans achieves competitive accuracy but requires O (𝑁𝐿2 ) memory due to global attention, and MemStr sacrifices parallelism for streaming efficiency. Catch and MSHTrans reach the high performance tier but both require O (𝑁𝐿2 ) memory due to self-attention, which limits their applicability as the window length 𝑁𝐿 grows. ContrastAD is the only method in the high performance tier that simultaneously supports parallel training, O (1) inference, and O (𝑁𝐿 ) memory. This favourable profile arises from a design choice that may not be immediately obvious. DGCL operates on sparse graph snapshots with a fixed number of nodes, so its memory footprint scales with the variable count 𝑁 rather than the window length 𝑁𝐿 , unlike attention-based approaches that must materialise an 𝑁𝐿 × 𝑁𝐿 similarity matrix at every layer. The pairwise DTW used for graph construction adds a per window cost of 𝑁2 comparisons on 𝛿-length snapshots, bounded by 1485 calls at our largest variable count 𝑁 =55 with 𝛿 =10, and the resulting graphs stay sparse at 1.14–3.33% density (Tab. 1). For larger 𝑁 , Sakoe-Chiba banding [35] reduces each DTW call from O (𝛿 2 ) to O (𝛿𝑤) with 𝑤 ≪ 𝛿, keeping the construction cost linear in the band width and well within the per-epoch budget.

4.5.3 RQ3. Hyperparameter Sensitivity. Tab. 4 reports F1 and AUC across 𝜆 ∈ [−1.0, +1.0] at 0.1 intervals. Setting 𝜆 =0 removes DGCL entirely and uniformly produces the lowest F1 on every dataset, with drops as large as 28.86 points on SMD, establishing that the contrastive signal is indispensable and cannot be absorbed by the reconstruction loss. Any non-zero 𝜆 substantially restores performance, and negative values outperform their positive counterparts on average across all five datasets. For SWaT and MSL, performance peaks at 𝜆 =−0.1, while SMD and PSM favour larger magnitudes (−0.9 and −1.0 respectively), reflecting how the degree of structural non-stationarity varies across domains. The key insight from this table is that performance remains largely stable across the full nonzero range, with F1 standard deviations well below 2 points on most datasets outside the 𝜆 =0 singularity. This robustness confirms that DGCL acts as a soft regularizer whose benefit does not depend on precise tuning, and that the critical design choice is the sign of 𝜆 rather than its magnitude. The sign of 𝜆 follows directly from this score form and the alignment-uniformity view of contrastive learning [45]. A negative 𝜆 maximizes the graph contrastive regularizer and produces the contrastive tension above, whereas a positive 𝜆 minimizes it, collapses the divergent snapshots, and recovers the static invariance the model is designed to avoid. Tab. 4 matches this picture on three fronts. AUC at 𝜆 =0 stays below 71 on SMD, MSL, PSM, and SMAP and recovers above 87 once any non-zero 𝜆 is added, the best F1 on every dataset sits at a negative 𝜆, and the datasets with the strongest structural non-stationarity prefer the largest magnitudes (SMD F1 rises 28.86 points and AUC rises from 69.51 to 98.66 between 𝜆 =0 and −0.9). The take-away is that the sign flip restores separability, and magnitude only tunes how aggressively diversity is preserved.

4.5.5 RQ5. Case Study on SWaT. Quantitative metrics aggregate performance across an entire test set but do not reveal whether a model reacts promptly at anomaly onset or maintains stable baseline scores during normal operation. Fig. 4 shows anomaly score curves from ContrastAD and all eight baselines over a 10,000-step SWaT interval containing three annotated cyber-physical attack periods. GDN and CSTGL produce near-zero scores throughout, missing the first two attacks and responding only weakly to the third. FuSAG fires a spurious peak around index 1500 in a normal window, a false alarm from sparse latent graph estimation. MTG stays near 0.5 across the interval with no separation between normal and anomalous windows, a sign of unstable density estimation. DTrans rises only in the third attack and largely misses the first two. MemStr holds a step-like elevated score throughout, indistinguishable from its normal baseline and unreliable for threshold-based detection.

4.5.4 RQ4. Architectural Efficiency and Scalability Analysis. Tab. 5 compares training parallelism, inference cost, memory complexity, and per-epoch training time. Most graph-based baselines support 9

,,

Pei, Song, Zheng, Cartlidge

Figure 4: Case study on the SWaT dataset comparing anomaly score responses of ContrastAD and baseline methods. Anomalies correspond to cyber-physical attacks annotated in the SWaT test set. The dashed red vertical line indicates the anomaly onset. All anomaly scores are independently min-max normalized to the range [0, 1] for visualization. The x-axis shows a sequence of 10,000 timestamp indices selected from the full test dataset. Catch responds clearly only to the third attack, as its frequencypatch reconstruction error rises only for sustained, magnitudedominant anomalies. MSHTrans detects the first onset quickly but recovers slowly, staying elevated well after each attack ends. ContrastAD is the only method that spikes sharply at all three onset markers, recovers to a low baseline between attacks, and stays noise-free during normal operation. The SWaT attacks here override actuator setpoints while the paired sensors still report a steady physical state, breaking the normal sensor-actuator coupling and producing a structural rather than a magnitude anomaly. DGCL contrasts the most divergent graph snapshot against a stable anchor at every window, so the score tracks this relational deviation directly, rising at onset and falling once the inter-variable structure returns to normal. The reconstruction-based baselines Catch and MemStr score by raw-signal error and respond only to magnitude shifts, consistent with Catch missing the first two short attacks and MemStr’s permanently elevated baseline in Fig. 4.

5

contrastive learning, ContrastAD effectively captures both temporal dynamics and structural evolution in non-stationary systems. A key contribution of this work is the DGCL, which regularizes evolving graph structures through contrastive learning. Instead of enforcing strict invariance across snapshots, DGCL aligns stable relational patterns while accommodating structural drifts inherent in non-stationary systems. This approach ensures that the learned embeddings remain sensitive to the relational changes necessary for anomaly detection. Experimental results across five real-world benchmarks demonstrate that ContrastAD achieves the highest mean F1 on all five datasets, with statistically significant F1 and AUC improvements on SWaT and PSM against eight competitive baselines, while ablation results further indicate that contrastive learning is most effective when used as a soft regularizer, highlighting that rigid invariance for a static graph is suboptimal in dynamic environments. In future work, we plan to explore adaptive contrastive weighting strategies that respond to structural stability over time, compare alternative time-series-to-graph constructions such as correlationbased or learnable adjacency against the current DTW-based snapshot graph, investigate more expressive snapshot-divergence measures such as spectral distances beyond the current degree-distribution KL, and apply the proposed framework to other domains with

Conclusion

We present ContrastAD, an unsupervised anomaly detection framework for multivariate time series that explicitly models evolving inter-variable dependencies. By integrating multi-perspective embeddings, frequency-aware attention fusion, and dynamic graph 10

Contrast to Detect: Dynamic Graph Contrastive Regularization for Unsupervised Anomaly Detection in Multivariate Time Series

dynamic relational patterns, such as financial systems and network security.

,,

[19] Jiexi Liu and Songcan Chen. 2024. Timesurl: Self-supervised contrastive learning for universal time series representation learning. In AAAI Conference on Artificial Intelligence, Vol. 38. 13918–13926. [20] Jiaqi Liu, Guoyang Xie, Jinbao Wang, Shangnian Li, Chengjie Wang, Feng Zheng, and Yaochu Jin. 2024. Deep industrial image anomaly detection: A survey. Machine Intelligence Research 21, 1 (2024), 104–135. [21] Yixin Liu, Zhao Li, Shirui Pan, Chen Gong, Chuan Zhou, and George Karypis. 2021. Anomaly detection on attributed networks via contrastive self-supervised learning. IEEE Transactions on Neural Networks and Learning Systems 33, 6 (2021), 2378–2392. [22] Zhe Liu, Xiang Huang, Jingyun Zhang, Zhifeng Hao, Li Sun, and Hao Peng. 2024. Multivariate time-series anomaly detection based on enhancing graph attention networks with topological analysis. In Proceedings of the 33rd ACM International Conference on Information and Knowledge Management. 1555–1564. [23] Jie Lu, Anjin Liu, Fan Dong, Feng Gu, Joao Gama, and Guangquan Zhang. 2018. Learning under concept drift: A review. IEEE transactions on knowledge and data engineering 31, 12 (2018), 2346–2363. [24] Hongnan Ma, Yiwei Shi, Guanxiong Sun, Mengyue Yang, and Weiru Liu. 2025. TriShGAN: Enhancing Sparsity and Robustness in Multivariate Time Series Counterfactuals Explanation. arXiv preprint arXiv:2511.06529 (2025). [25] Stefano Mariani, Quentin Rendu, Matteo Urbani, and Claudio Sbarufatti. 2021. Causal dilated convolutional neural networks for automatic inspection of ultrasonic signals in non-destructive evaluation and structural health monitoring. Mechanical Systems and Signal Processing 157 (2021), 107748. [26] Aditya P Mathur and Nils Ole Tippenhauer. 2016. SWaT: A water treatment testbed for research and training on ICS security. In 2016 International Workshop on Cyber-Physical Systems for Smart Water Networks (CySWater). IEEE, 31–36. [27] Youngeun Nam, Susik Yoon, Yooju Shin, Minyoung Bae, Hwanjun Song, JaeGil Lee, and Byung Suk Lee. 2024. Breaking the time-frequency granularity discrepancy in time-series anomaly detection. In ACM Web Conference 2024. 4204–4215. [28] Mark EJ Newman. 2005. Power laws, Pareto distributions and Zipf’s law. Contemporary physics 46, 5 (2005), 323–351. [29] Zefei Ning, Zhuolun Jiang, Hao Miao, and Li Wang. 2022. MST-GNN: A multiscale temporal-enhanced graph neural network for anomaly detection in multivariate time series. In Asia-Pacific Web (APWeb) and Web-Age Information Management (WAIM) Joint International Conference on Web and Big Data. Springer, 382–390. [30] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. 2018. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748 (2018). [31] Yunhua Pei, Jin Zheng, and John Cartlidge. 2025. Dynamic Graph Representation with Contrastive Learning for Financial Market Prediction: Integrating Temporal Evolution and Static Relations. In 17th International Conference on Agents and Artificial Intelligence - Volume 2: ICAART. INSTICC, SciTePress, 298–309. doi:10. 5220/0013154700003890 [32] Zhongpeng Qi, Jun Zhang, Wei Li, and Zhuoxuan Liang. 2026. CGSTA: CrossScale Graph Contrast with Stability-Aware Alignment for Multivariate TimeSeries Anomaly Detection. arXiv preprint arXiv:2602.20468 (2026). [33] Shuxin Qin, Jing Zhu, Dan Wang, Liang Ou, Hongxin Gui, and Gaofeng Tao. 2022. Decomposed transformer with frequency attention for multivariate time series anomaly detection. In 2022 IEEE International Conference on Big Data (Big Data). IEEE, 1090–1098. [34] Joshua Robinson, Ching-Yao Chuang, Suvrit Sra, and Stefanie Jegelka. 2020. Contrastive learning with hard negative samples. arXiv preprint arXiv:2010.04592 (2020). [35] Hiroaki Sakoe and Seibi Chiba. 1978. Dynamic programming algorithm optimization for spoken word recognition. IEEE transactions on acoustics, speech, and signal processing 26, 1 (1978), 43–49. [36] Nikunj Saunshi, Orestis Plevrakis, Sanjeev Arora, Mikhail Khodak, and Hrishikesh Khandeparkar. 2019. A theoretical analysis of contrastive unsupervised representation learning. In International conference on machine learning. PMLR, 5628–5637. [37] Ramit Sawhney, Shivam Agarwal, Arnav Wadhwa, and Rajiv Shah. 2021. Exploring the scale-free nature of stock markets: Hyperbolic graph learning for algorithmic trading. In Web Conference 2021. 11–22. [38] Zixing Song, Yifei Zhang, and Irwin King. 2023. Optimal block-wise asymmetric graph construction for graph-based semi-supervised learning. Advances in Neural Information Processing Systems 36 (2023), 71135–71149. [39] Ya Su, Youjian Zhao, Chenhao Niu, Rong Liu, Wei Sun, and Dan Pei. 2019. Robust anomaly detection for multivariate time series through stochastic recurrent neural network. In 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. 2828–2837. [40] Susheel Suresh, Pan Li, Cong Hao, and Jennifer Neville. 2021. Adversarial graph augmentation to improve graph contrastive learning. Advances in Neural Information Processing Systems 34 (2021), 15920–15933. [41] Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. 2020. What makes for good views for contrastive learning? Advances in Neural Information Processing Systems 33 (2020), 6827–6839.

Acknowledgments This work was supported by UK Research and Innovation (UKRI) Engineering and Physical Sciences Research Council (EPSRC) [grant number EP/Y028392/1]: AI for Collective Intelligence (AI4CI).

References [1] Ahmed Abdulaal, Zhuanghua Liu, and Tomer Lancewicki. 2021. Practical approach to asynchronous multivariate time series anomaly detection and localization. In 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining. 2485–2494. [2] Albert-László Barabási and Réka Albert. 1999. Emergence of scaling in random networks. Science 286, 5439 (1999), 509–512. [3] Siddharth Bhatia, Arjit Jain, Shivin Srivastava, Kenji Kawaguchi, and Bryan Hooi. 2022. MemStream: Memory-Based Streaming Anomaly Detection. In The Web Conference (formerly WWW). [4] Ziwei Chen, Jianjian Jiang, Xiangmin Luo, Fangyuan Lei, Xiaochen Yuan, and Jin Zhan. 2025. Dual-channel hypergraph networks in the time-frequency domain for learning advanced spatiotemporal dependencies in multivariate time series. Neurocomputing (2025), 130600. [5] Zhaoliang Chen, Zhihao Wu, William K Cheung, Hong-Ning Dai, Byron Choi, and Jiming Liu. 2025. MSHTrans: Multi-Scale Hypergraph Transformer with Time-Series Decomposition for Temporal Anomaly Detection. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 2. 274–285. [6] William T Cochran, James W Cooley, David L Favin, Howard D Helms, Reginald A Kaenel, William W Lang, George C Maling, David E Nelson, Charles M Rader, and Peter D Welch. 1967. What is the fast Fourier transform? Proc. IEEE 55, 10 (1967), 1664–1674. doi:10.1109/PROC.1967.5957 [7] Ailin Deng and Bryan Hooi. 2021. Graph neural network-based anomaly detection in multivariate time series. In AAAI Conference on Artificial Intelligence, Vol. 35. 4027–4035. [8] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Vol. 1. 4171–4186. doi:10.18653/v1/ N19-1423 [9] Chaoyue Ding, Shiliang Sun, and Jing Zhao. 2023. MST-GAT: A multimodal spatial–temporal graph attention network for time series anomaly detection. Information Fusion 89 (2023), 527–536. [10] Siho Han and Simon S Woo. 2022. Learning Sparse Latent Graph Representations for Anomaly Detection in Multivariate Time Series. In 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining. 2977–2986. [11] Jingyu Hu, Hongbo Bo, Jun Hong, Xiaowei Liu, and Weiru Liu. 2025. Mitigating Degree Bias Adaptively with Hard-to-Learn Nodes in Graph Contrastive Learning. arXiv preprint arXiv:2506.05214 (2025). [12] Xiangheng Huang, Ningjiang Chen, Ziyue Deng, and Suqun Huang. 2024. Multivariate time series anomaly detection via dynamic graph attention network and Informer. Applied Intelligence 54, 17 (2024), 7636–7658. [13] Kyle Hundman, Valentino Constantinou, Christopher Laporte, Ian Colwell, and Tom Soderstrom. 2018. Detecting spacecraft anomalies using lstms and nonparametric dynamic thresholding. In 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. 387–395. [14] Yannis Kalantidis, Mert Bulent Sariyildiz, Noe Pion, Philippe Weinzaepfel, and Diane Larlus. 2020. Hard negative mixing for contrastive learning. Advances in Neural Information Processing Systems 33 (2020), 21798–21809. [15] Siwon Kim, Kukjin Choi, Hyun-Soo Choi, Byunghan Lee, and Sungroh Yoon. 2022. Towards a rigorous evaluation of time-series anomaly detection. In Proceedings of the AAAI conference on artificial intelligence, Vol. 36. 7194–7201. [16] Taesung Kim, Jinhee Kim, Yunwon Tae, Cheonbok Park, Jang-Ho Choi, and Jaegul Choo. 2021. Reversible instance normalization for accurate time-series forecasting against distribution shift. In International Conference on Learning Representations. [17] Xiangjie Kong, Wenyi Zhang, Hui Wang, Mingliang Hou, Xin Chen, Xiaoran Yan, and Sajal K Das. 2024. Federated graph anomaly detection via contrastive self-supervised learning. IEEE Transactions on Neural Networks and Learning Systems 36, 5 (2024), 7931–7944. [18] Zhihan Li, Youjian Zhao, Jiaqi Han, Ya Su, Rui Jiao, Xidao Wen, and Dan Pei. 2021. Multivariate time series anomaly detection and interpretation using hierarchical inter-metric and temporal embedding. In 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining. 3220–3230. 11

,,

Pei, Song, Zheng, Cartlidge

[42] Aaron Van Den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew Senior, Koray Kavukcuoglu, et al. 2016. Wavenet: A generative model for raw audio. arXiv preprint arXiv:1609.03499 12 (2016), 1. [43] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In 31st Conference on Neural Information Processing Systems, Vol. 30. 6000–6010. [44] Petar Veličković, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio. 2017. Graph attention networks. arXiv preprint arXiv:1710.10903 (2017). [45] Tongzhou Wang and Phillip Isola. 2020. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In International conference on machine learning. PMLR, 9929–9939. [46] Mike Wu, Chengxu Zhuang, Milan Mosse, Daniel Yamins, and Noah Goodman. 2020. On mutual information in contrastive learning for visual representations. arXiv preprint arXiv:2005.13149 (2020). [47] Xingjian Wu, Xiangfei Qiu, Zhengyu Li, Yihang Wang, Jilin Hu, Chenjuan Guo, Hui Xiong, and Bin Yang. 2025. Catch: Channel-aware multivariate time series anomaly detection via frequency patching. In International conference on learning representations, Vol. 2025. 17017–17045. [48] Zhichao Wu, Li Zhu, Zitao Yin, Xirong Xu, Jianmin Zhu, Xiaopeng Wei, and Xin Yang. 2025. MAFCD: Multi-level and adaptive conditional diffusion model for anomaly detection. Information Fusion 118 (2025), 102965. [49] Jiehui Xu, Haixu Wu, Jianmin Wang, and Mingsheng Long. 2022. Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy. In International Conference on Learning Representations. [50] Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. 2020. Graph contrastive learning with augmentations. Advances in Neural Information Processing Systems 33 (2020), 5812–5823. [51] Xiang Yu, Xianfei Yang, Qingji Tan, Chun Shan, and Zhihan Lv. 2022. An edge computing based anomaly detection method in IoT industrial sustainability.

Applied Soft Computing 128 (2022), 109486. [52] Zhihan Yue, Yujing Wang, Juanyong Duan, Tianmeng Yang, Congrui Huang, Yunhai Tong, and Bixiong Xu. 2022. Ts2vec: Towards universal representation of time series. In AAAI Conference on Artificial Intelligence, Vol. 36. 8980–8987. [53] Jiuqi Elise Zhang, Di Wu, and Benoit Boulet. 2021. Time series anomaly detection for smart grids: A survey. In 2021 IEEE Electrical Power and Energy Conference (EPEC). IEEE, 125–130. [54] Wenxin Zhang and Cuicui Luo. 2025. Decomposition-based multi-scale transformer framework for time series anomaly detection. Neural Networks 187 (2025), 107399. [55] Yitian Zhang, Florence Regol, Antonios Valkanas, and Mark Coates. 2022. Contrastive learning for time series on dynamic graphs. In 2022 30th European Signal Processing Conference (EUSIPCO). IEEE, 742–746. [56] Hang Zhao, Yujing Wang, Juanyong Duan, Congrui Huang, Defu Cao, Yunhai Tong, Bixiong Xu, Jing Bai, Jie Tong, and Qi Zhang. 2020. Multivariate timeseries anomaly detection via graph attention network. In 2020 IEEE International Conference on Data Mining (ICDM). IEEE, 841–850. [57] Yu Zheng, Huan Yee Koh, Ming Jin, Lianhua Chi, Khoa T. Phan, Shirui Pan, Yi-Ping Phoebe Chen, and Wei Xiang. 2023. Correlation-aware Spatial-Temporal Graph Learning for Multivariate Time-series Anomaly Detection. IEEE Transactions on Neural Networks and Learning Systems (2023). [58] Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. 2021. Informer: Beyond efficient transformer for long sequence time-series forecasting. In AAAI Conference on Artificial Intelligence, Vol. 35. 11106–11115. [59] Qihang Zhou, Shibo He, Haoyu Liu, Jiming Chen, and Wenchao Meng. 2024. Label-Free Multivariate Time Series Anomaly Detection. IEEE Transactions on Knowledge and Data Engineering (2024). [60] Bo Zong, Qi Song, Martin Renqiang Min, Wei Cheng, Cristian Lumezanu, Daeki Cho, and Haifeng Chen. 2018. Deep autoencoding Gaussian mixture model for unsupervised anomaly detection. In International Conference on Learning Representations.

12

Record · ID 222591 · SHA-256 ffe354d8dfe13885
Retrieved via Conceptio — every document is proof-bundled with source, license, and retrieval metadata.