arXiv:2608.12279cs.CVAug 2026

Manuscript Offprint

arXiv:2608.12279

Curvature-Aware Zeroth-Order Optimization for Memory-Efficient Test-Time Adaptation

Junming Zhang, Shuyu Yin, Peilin Liu, Rendong Ying, Fei Wen

Abstract

Test-time adaptation (TTA) aims to enhance the cross-domain performance of pre-trained models by adapting to unlabeled test data. While most existing TTA methods rely on backpropagation (BP) for finetuning, BP-free methods such as zeroth-order (ZO) methods are more desired in practical on-device scenarios. ZO methods rely only on forward computation, which can largely reduce the complexity and memory overhead of on-device deployment. However, ZO methods suffer from much higher variance compared with first-order methods in estimating the gradient. To address this, we propose an improved ZO method to substantially boost the performance of ZO optimization based TTA. First, we provide an observation to reveal the persistent low-rank Hessian structure of the loss during the adaptation process. Based on this insight, we then propose a loss-landscape curvature-aware zeroth-order (CAZO) method, which leverages a sliding-average estimation of the diagonal Hessian to construct a covariance matrix for anisotropic‌ perturbation sampling. CAZO operates by freezing pretrained weights and optimizing minimal adapter parameters via forward-only passes based gradient estimation, which can substantially reduce the memory overhead compared to BP-based methods. Extensive experiments demonstrate that CAZO significantly outperforms existing TTA methods, achieving state-of-the-art performance while maintaining an excellent balance between accuracy and memory efficiency. Code is available at https://github.com/Hollyming/CAZO.

1 Introduction

Deep neural networks have demonstrated remarkable performance across various tasks, primarily due to extensive pretraining on large-scale datasets. However, when deployed in real-world applications, these models often suffer from performance degradation due to domain shifts between training and test distributions [24, 25]. This issue is particularly critical in edge device applications, where data is collected in dynamic and uncontrolled environments, leading to a substantial mismatch between the pretrained model’s training domain and incoming data. Such distribution shifts can significantly degrade model performance, making it challenging to achieve reliable real-world performance.

To mitigate these issues, test-time adaptation (TTA) has emerged as a promising paradigm that allows models to adapt to out-of-distribution (OOD) test data without requiring full retraining [51, 61]. Prior TTA methods predominantly rely on BP-based optimization, using unsupervised objectives such as entropy minimization or self-supervised losses. While these methods have shown effectiveness, they incur significant computational and memory overhead, making them impractical for some resource-constrained applications, e.g., on edge devices. Recently, BP-free TTA methods[1, 23, 38] have been explored to reduce memory usage. These works illustrate the potential of BP-free TTA in resource-limited scenarios.

In this work, we explore zeroth-order (ZO) methods for TTA. ZO methods estimate gradients through function evaluations alone and require forward-only computation, which makes them ideal for memory-constrained on-device TTA. However, vanilla ZO methods suffer from notorious drawbacks: their gradient estimates exhibit high variance due to random perturbations [33] which leads to slow convergence in high-dimensional problems. It has been shown that naive ZO stochastic gradient descent may need O(d)O(d) more iterations (where dd is the parameter dimension) to reach comparable accuracy as first-order methods [36]. This poor efficiency makes naive ZO methods ineffective for TTA. Consequently, reducing the variance of ZO gradient estimators is crucial to unlock their potential for fast and effective TTA.

To reduce the variance of ZO methods for effective and efficient forward-only TTA, in this work we propose a curvature-aware zeroth-order (CAZO) optimization method for memory-efficient TTA. CAZO leverages ZO optimization to estimate gradients from forward-pass finite differences [36, 12], and cuts memory footprint by roughly 70% while retaining competitive adaptation accuracy. Specifically, based on the observation that the Hessian matrix has a low-dimension structure during the adaptation process, we replace the isotropic random perturbation in the vanilla ZO with a low-cost curvature-aware update to efficiently exploit curvature information of local loss-landscape, making the adaptation more efficient and robust.

The main contributions are summarized as follows:

  • We analyze the curvature of the loss landscape in TTA and reveal that the Hessian admits a low-dimensional subspace that is both prominent and slowly varying throughout adaptation. This observation lays the foundation for variance reduction in ZO optimization for TTA.
  • Building on this observation, we propose a Curvature-Aware Zeroth-Order (CAZO) method, a forward-pass-only approach that utilizes a sliding-average diagonal Hessian estimation to encode the low-rank and slowly varying curvature into ZO gradient sampling. By making the ZO updates curvature-aware, CAZO substantially reduces the variance of gradient estimates and improves adaptation performance. Furthermore, we provide nonconvex convergence guarantees under standard smoothness assumptions.
  • Through extensive experiments on benchmarks like ImageNet-C and ImageNet-R/V2/Sketch, we demonstrate that CAZO achieves new state-of-the-art performance. Notably, it significantly outperforms previous methods while substantially reducing memory overhead by more than 70% compared to BP-based methods. Our method achieves both high accuracy and high memory efficiency, which enables practical TTA on devices with limited memory resources.

Figure

Figure 1: Illustration of CAZO and the used model architecture. A lightweight adapter is updated in TTA.

References (38)