Drift-Calibrated Temporal Consistency for Streaming Test-Time Adaptation

When a video model is deployed and the world shifts under it (new lighting, sensor noise, compression, a different person wearing the sensor), its frame-by-frame predictions start to flicker. A popular fix is to adapt the model on the unlabeled test stream by asking consecutive frames to agree. But any "frames should agree" loss needs a rule for telling nuisance jitter apart from a real change of state, such as an action ending or an expression changing. Today that rule is a fixed scalar threshold or a symmetric median filter. The filter needs future frames, so it cannot run live. The fixed threshold stops fitting once drift changes how much, and in which directions, the model's internal features jitter.

We propose a strictly causal consistency loss for streaming adaptation. It uses no future frames. Each new frame's feature is compared with a running average of past features. The size of the difference is measured against a running estimate of the current jitter covariance, meaning the shape and orientation of recent frame-to-frame feature changes, rather than against a fixed number. A jump counts as a real transition only if it is unusual relative to how the stream is jittering right now. Keeping a drifting covariance of high-dimensional features current at frame rate is the practical obstacle. We handle it with a low-rank streaming sketch that forgets old data and costs time linear in feature dimension per frame. The sketch also gives, at no extra cost, a collapse monitor and a multivariate drift signal.

Core Claim

In streaming test-time adaptation, the jitter-versus-transition decision inside a truncated temporal consistency loss should be made in a metric that tracks the drifting covariance of frame-to-frame feature changes. We expect a causal loss of this kind to match or beat acausal median-filter adaptation on accuracy and flicker while adding no latency. We also expect it to beat a scalar-threshold loss and a per-dimension (diagonal) variance version, and the diagonal comparison is the ablation the covariance claim lives or dies by.

Concretely, let $z_t \in \mathbb{R}^d$ be the penultimate-layer feature at frame $t$. Let $m_{t-1}$ be an exponential moving average of past features, held fixed during the gradient step. Let $r_t = z_t - m_{t-1}$ be the residual. Let $\Sigma_t$ be a decayed estimate of the covariance of recent residuals. The loss is

$$\mathcal{L}_t = \min\!\left(\tfrac{1}{d}\, r_t^\top \Sigma_t^{-1} r_t,\; \tau\right),$$

where $\tau$ is a truncation level in whitened units. Frames whose normalized squared distance exceeds $\tau$ contribute no gradient, so the model is free to change state there. Because distances are measured relative to current jitter, $\tau$ keeps the same meaning as the stream drifts. It can be set once, for example from a chi-squared tail quantile. By contrast, the scalar $\tau$ of truncated MSE in MS-TCN++ has to be re-tuned whenever noise levels change.

We represent $\Sigma_t$ as $V S V^\top + c_t I$. Here $V$ holds the $\ell$ leading directions from a Frequent Directions sketch (a streaming SVD that keeps only an $\ell \times d$ summary matrix), and $c_t$ is the "escaped mass" the sketch has discarded, reinjected as an isotropic floor. Applying $\Sigma_t^{-1}$ to $r_t$ via the Woodbury identity then costs $O(\ell d)$ per frame. Forgetting is implemented by rescaling the sketch and the escaped mass by $\sqrt{\gamma}$ each frame, so old jitter statistics fade.

Relation to Prior Work

Three lines of work motivate the proposal. TempT adapts batch-norm parameters on facial-expression video by regressing raw logits onto a median-filtered version of themselves. It improves AffWild2 F1 and cuts decision flips, and it shows that entropy minimization degrades on correlated video frames. Its filter is symmetric in time, though, so adapting frame $t$ requires frames after $t$. It also operates on logits with no notion of feature geometry. We keep TempT's idea of using temporal coherence as the self-supervision signal but make it causal and covariance-calibrated.

ViTTA enforces agreement across resampled temporal views of a clip and aligns exponential-moving-average feature means and variances to source statistics. It works at batch size 1 but needs a buffered clip and tracks only per-dimension variances. Learning to Adapt to Online Streams with Distribution Shifts meta-learns per-sample updates driven by rotation prediction and uses no temporal signal at all. Our loss is frame-causal like the latter and temporal like the former, and it models off-diagonal structure that ViTTA discards.

The truncated smoothing loss of MS-TCN++, also used on wrist IMU streams in Wang et al., supplies our truncation operator. It constrains the design too: those papers show that untruncated smoothing erases real boundaries, so plain squared differences are ruled out. Their threshold is scalar, fixed, applied in training rather than at test time, and computed on log-probabilities.

FeCAM is the motivating evidence that class features are anisotropic and that Mahalanobis distances with shrinkage beat Euclidean ones in continual learning. It stores full per-class covariances over a frozen backbone and has no temporal component. We borrow its shrinkage intuition, which our escaped-mass floor plays the role of, but we estimate the covariance of temporal residuals rather than of classes.

The sketching machinery comes from Sketchy, which sketches gradient covariances with Frequent Directions and reinjects discarded mass as a diagonal, and from ADA-FD, which uses Woodbury updates in $O(\tau d)$ space. Neither decays old data or targets non-stationary streams, a gap the research file notes explicitly. Our forgetting variant is a simple rescaling, and we do not claim it as the contribution.

CODA is the closest work that joins covariance and drift. It forecasts feature correlation matrices with an LSTM to synthesize future training data offline, and only for $d \le 54$. We do not forecast; we track, online, in high dimension, and use the estimate inside a loss.

Research Program

The method has four pieces. First, a source model is frozen except for its normalization affine parameters, following TempT, so that the covariance of the frozen penultimate features stays interpretable. Second, a causal teacher: an exponential moving average of features, plus an exponential moving average of weights in the style of the mean teacher in CoTTA, used for prediction. Third, the decayed residual sketch with escaped-mass floor. Fourth, the truncated whitened loss above.

The same sketch provides two monitors we will analyze rather than tune. The first is the effective rank of $V S V^\top + c_t I$. A sustained drop signals that adaptation is collapsing features toward a constant, which is the failure mode any consistency loss invites. When it fires, we apply CoTTA-style stochastic restoration of the adapted parameters. The second is the energy of $r_t$ outside the span of $V$, relative to $c_t$. This is a multivariate drift statistic in $o(d^2)$ memory, addressing the univariate limitation of IKS. We use it only to shorten the forgetting horizon $\gamma$ after abrupt shifts.

The analysis questions are narrow. Does calibration keep the fraction of ground-truth state changes that fall above $\tau$ stable as corruption severity changes, when a scalar threshold does not? Does full covariance buy anything over diagonal? What sketch rank $\ell$ is needed before the sketch matches the full covariance? And how does that depend on how flat the residual spectrum is? The file warns that flat spectra are where low-rank sketches fail.

Baselines

The naive reference is the source model with no adaptation. We also run a pure-inference exponential moving average of predictions, to separate the gains from post-hoc smoothing from the gains from adaptation. Every method will see the same streams in the same order, adapt the same parameter subset where the method allows it, and receive the same hyperparameter search budget on a held-out stream that is disjoint from test.

The strongest existing competitor on the core question is TempT. It is the only cited method that turns temporal consistency into an adaptation signal, and its reported AffWild2 numbers are F1 0.307 → 0.323 with ResNet-18, 0.325 → 0.345 with SE-ResNext-101, and flips 0.15 → 0.043 per frame (TempT). We run it in its original acausal form and in a causal form whose median window covers only past frames. Beating TempT means matching its F1 within noise while being causal, and beating its causal version on both F1 and flips.

On corrupted action recognition the strongest competitor is ViTTA, reported at 78.20% accuracy on UCF101 with TANet, up from 51.35% source-only (ViTTA). On streaming segmentation it is Wu et al., reported at 66.67 mIoU on CamVid against 64.21 for CoTTA and 63.48 for the unadapted model (Wu et al.). We also run TENT and CoTTA, whose CIFAR-10-C continual error is reported as 16.2% against 20.7% for continual TENT (CoTTA), as general-purpose continual adaptation references.

The ablations that isolate the key ingredient all use the same causal teacher and truncation and change only the metric. The variants are a scalar threshold on logits (a test-time MS-TCN++ loss), a scalar threshold on features, per-dimension variance whitening, full exponential-moving-average covariance, and the sketch at several ranks. A further ablation removes the collapse monitor. The proposal succeeds only if full or sketched covariance beats diagonal beyond seed variance.

Why not just…?

Why not just make TempT causal and keep a scalar threshold on logits? This is the most serious threat. Logits live in a space with only 7 to 17 dimensions in these tasks, so a causal truncated MSE on logits may capture most of the benefit. We run exactly this as an ablation. If it matches our method on AffWild2 and the corrupted-video streams, the covariance component is unjustified, and the contribution shrinks to "causal truncated consistency works." We would report that honestly. Our prediction of a gap rests on one mechanism: drift inflates jitter unevenly across directions, and a scalar threshold then misfires in both directions, a failure the research file argues from FeCAM's anisotropy evidence but that no cited paper measures in a temporal setting. The boundary-recall analysis below tests the mechanism directly.

Why not just whiten each feature dimension by its running variance? This is ViTTA-style diagonal statistics, $O(d)$ and trivially cheap. FeCAM reports gains of over 4% from anisotropic over spherical modeling on CIFAR-100 (FeCAM), and ADA-FD reports higher regret for diagonal methods when features are correlated (ADA-FD). Neither result concerns temporal residuals under drift, however, so the diagonal-versus-full ablation is decisive rather than presumed.

Why not just store the full covariance, since $d$ = 512–2048 is small? For a single layer at this width, a full exponential-moving-average covariance fits easily in memory, and we include it as the upper-bound variant. The sketch is argued for on three grounds only. Per-frame inversion at $O(d^3)$ versus $O(\ell d)$ matters for frame-rate edge deployment. Multi-layer or wider ViT features multiply the cost. The low-rank-plus-floor form also yields the collapse and drift monitors directly. If the sketch at modest $\ell$ does not match the full-covariance version, we recommend full covariance for small $d$.

Why not just use CoTTA or TENT, which need no temporal structure? TempT reports that TENT degrades on correlated video frames. CoTTA's continual gains come with up to 32 augmentations per step. We compare accuracy at matched wall-clock cost per frame, so a heavier method cannot win by spending more compute.

Decisive Experiments

The primary benchmark is AffWild2 with ResNet-18 and SE-ResNext-101, scored by F1 and decision flips per frame against TempT's reported numbers, with latency reported in frames of lookahead. Ours is zero by construction. The second setting is UCF101 under the 12 corruption types at maximum severity at batch size 1 with TANet, against ViTTA's 78.20%. We extend it with a harder protocol in which corruptions switch mid-stream, for which we found no reported result on Lacuna. The third is CamVid streaming segmentation against Wu et al.'s 66.67 mIoU, applying the loss per pixel feature with one shared sketch.

To probe boundary preservation, we corrupt 50Salads test videos at test time and adapt an MS-TCN++ source model. We report F1@{10,25,50} and edit distance; no reported result was found on Lacuna for test-time adaptation on 50Salads. We also measure boundary recall, defined as the fraction of labeled action changes whose whitened residual exceeds $\tau$, together with the jitter false-transition rate, at each severity. The calibration claim predicts that both stay flat across severities for our metric and move for the scalar threshold.

For a real rather than synthetic shift, we train on the semi-controlled DX-I IMU data and adapt on the free-living DX-II data. For context, the same-domain segmental F1 on DX-II is reported as 0.900 (Wang et al.); no cross-dataset result was found on Lacuna.

The idea is refuted if either the causal logit-threshold ablation or the diagonal ablation matches the full method on AffWild2 and switching-corruption UCF101 across five seeds. It is also refuted if boundary recall under the whitened metric drifts with severity as much as under the scalar threshold. The sketching component is refuted if it needs $\ell$ close to $d$ to match full covariance. We will relate that outcome to the measured flatness of the residual spectrum.