SURGEON: Memory-Adaptive Fully Test-Time Adaptation via Dynamic Activation Sparsity

Ke Ma, Jiaqi Tang, Bin Guo, Fan Dang, Sicong Liu, Zhui Zhu, Lei Wu, Cheng Fang, Ying-Cong Chen, Zhiwen Yu, Yunhao Liu

Abstract

Fully Test-Time Adaptation (FTTA) is essential for maintaining the accuracy of deep learning models when they encounter distribution shifts in real-world deployments. However, the high memory cost of storing activations for backpropagation often prevents FTTA from being used on resource-constrained edge devices. We present SURGEON, a framework that enables memory-efficient adaptation through Dynamic Activation Sparsity. By calculating layer-specific pruning ratios based on gradient importance and memory cost, SURGEON reduces activation memory usage by up to 90% while maintaining or improving model accuracy across various architectures, including CNNs and Vision Transformers.

Introduction

When deep learning models are deployed on edge devices—such as smartphones, drones, or IoT sensors—they frequently encounter data that differs from their training distribution. These "distribution shifts," caused by factors like changing weather conditions or different sensor hardware, can significantly degrade performance. Test-Time Adaptation (TTA) allows models to update their parameters using unlabeled data during inference to mitigate these effects.

Despite its benefits, TTA faces a significant "memory wall." Standard adaptation requires backpropagation, which necessitates storing intermediate outputs (activations) for every layer to calculate gradients. For modern deep networks, these activations can consume gigabytes of RAM, far exceeding the capacity of typical edge hardware. Existing solutions often require model retraining or are limited to specific architectures, such as those using Batch Normalization. SURGEON addresses these limitations by providing an architecture-agnostic, memory-adaptive framework for efficient on-device learning.

Methodology: Dynamic Activation Sparsity

SURGEON treats memory management as a precision operation, moving away from static, global pruning ratios. Instead, it employs Dynamic Activation Sparsity, where pruning ratios are determined on the fly for each layer based on two primary metrics:

  1. Gradient Importance ($G$): This metric measures the contribution of a specific layer to the model's learning process on the current data. Layers with larger gradients are prioritized for adaptation.
  2. Layer Activation Memory ($M$): This quantifies the memory footprint of a layer's activations. In many architectures, deeper layers have smaller activation sizes due to downsampling, making them "cheaper" to store relative to earlier layers.

SURGEON combines these metrics into a single importance indicator ($I$). This indicator allows the system to allocate memory dynamically: layers that are highly important for learning but have low memory costs receive minimal pruning, while high-cost, low-importance layers are pruned aggressively.

To achieve actual hardware memory savings, SURGEON stores pruned activations as two components: a one-dimensional vector containing non-zero values and a 1-bit-per-element index map. During the backward pass, these components are used to reconstruct a sparse version of the original activation, allowing for gradient calculation with a significantly reduced memory footprint.

Experimental Setup

The researchers evaluated SURGEON across several challenging benchmarks designed to simulate real-world corruptions:

  • Image Classification: Evaluated on CIFAR-10-C, CIFAR-100-C, and ImageNet-C, which include 15 types of artificial corruptions (e.g., blur, noise, weather) at maximum severity.
  • Semantic Segmentation: Tested on the ACDC (Adverse Conditions Dataset with Correspondences) dataset, featuring real-world urban scenes in rain, snow, fog, and night conditions.
  • Hardware Benchmarking: Real-world latency and power efficiency were measured on an NVIDIA Jetson Xavier NX, a standard module for edge computing.

Key Results and Insights

Massive Memory Efficiency

On the WideResNet-28 architecture (CIFAR-10-C), SURGEON reduced the activation cache from 3697 MB to just 325 MB. Remarkably, this 90% reduction in memory did not come at the cost of performance; SURGEON actually improved accuracy, achieving an 18.1% error rate compared to the 18.9% error rate of full-parameter tuning.

Architecture Agnosticism

Unlike previous methods that rely on specific layers like Batch Normalization, SURGEON operates directly on activations and gradients. This makes it compatible with both Convolutional Neural Networks (CNNs) and modern Vision Transformers (ViTs). In semantic segmentation tasks using Segformer-B5 on the ACDC dataset, SURGEON achieved a mean online error of 42.2%, significantly outperforming competing methods like MECTA (47.2%) while maintaining a similar memory footprint.

Edge Viability

In hardware tests on the Jetson Xavier NX, SURGEON demonstrated a superior balance between accuracy and speed. It achieved a 37.8% error rate with a latency of 117.4 ms. In comparison, other state-of-the-art methods like CoTTA were found to be too slow for real-time applications, with latencies exceeding 500 ms.

Conclusion and Future Work

SURGEON demonstrates that layer-wise, data-sensitive pruning is a highly effective strategy for enabling deep learning adaptation on the edge. By tailoring sparsity to the specific learning needs and memory costs of each layer, it overcomes the "memory wall" without sacrificing accuracy or architectural flexibility.

While the current framework introduces a minor initial overhead for calculating importance metrics, future work may involve combining SURGEON with weight-pruning or quantization techniques. Such integrations could further push the boundaries of "Tiny-ML," enabling sophisticated model adaptation on even more resource-constrained hardware.

Summary updated

BibTeX
@inproceedings{ma2025surgeon,
  author = {Ke Ma and Jiaqi Tang and Bin Guo and Fan Dang and Sicong Liu and Zhui Zhu and Lei Wu and Cheng Fang and Ying-Cong Chen and Zhiwen Yu and Yunhao Liu},
  title = {{SURGEON: Memory-Adaptive Fully Test-Time Adaptation via Dynamic Activation Sparsity}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02841},
}
Figure