TinyTTA: Efficient Test-time Adaptation via Early-exit Ensembles on Edge Devices

Hong Jia, Young Kwon, Alessio Orsino, Ting Dang, Domenico Talia, Cecilia MascoloNeurIPS 2024

TL;DR

Deploying deep learning on tiny edge devices like microcontrollers is challenging, but adapting those models on the fly to changing real-world environments is even harder due to severe memory limits. TinyTTA solves this by introducing a novel early-exit ensemble strategy and a custom on-device backpropagation engine. It is the first framework to enable efficient Test-Time Adaptation (TTA) on devices with as little as 512 KB of memory, boosting accuracy while slashing memory usage by up to 6x compared to existing methods.

The Challenge of Edge Adaptation

Internet of Things (IoT) devices—like wearables or remote sensors—increasingly rely on Microcontroller Units (MCUs) to run deep neural networks locally. This preserves privacy and reduces latency. However, real-world data is messy. A sensor might degrade, or a camera might encounter fog, causing a "distribution shift" that degrades the model's accuracy.

Test-Time Adaptation (TTA) is a popular solution that updates a pre-trained model on the fly using unlabeled test data. Unfortunately, standard TTA is practically impossible on MCUs for three main reasons:

  1. Memory Overhead: Updating a model requires backpropagation, which means storing massive activation maps in memory. MCUs typically have less than 1 MB of SRAM.
  2. Batch Size Constraints: MCUs process data one sample at a time (batch size of 1). Standard TTA relies heavily on Batch Normalization, which fails completely without large batches to calculate statistics.
  3. Lack of Software Support: Existing MCU inference libraries (like TensorFlow Lite Micro) do not support on-device training or normalization layers.
Memory and accuracy limitations of standard Test-Time Adaptation (Tent) on edge devices, highlighting out-of-memory errors and poor batch-size-1 performance.

Introducing TinyTTA

To make TTA viable on the extreme edge, the authors propose a hardware-aware framework called TinyTTA, supported by a custom software library called the TinyTTA Engine.

TinyTTA enables on-device continuous adaptation for single-sample data streams experiencing varying levels of corruption.

Self-Ensemble & Early Exits

Instead of running and updating the entire network, the authors partition the pre-trained model into sequential "submodules." During inference, if the model is highly confident (low entropy) after a few submodules, it "exits" early. Crucially, the model only backpropagates and updates the layers up to that exit point, drastically reducing the memory needed to store activations.

Weight Standardization (WS)

To solve the batch size problem, TinyTTA strips out traditional normalization layers and replaces them with Weight Standardization at the exit branches. WS normalizes the weights rather than the activations, making the adaptation completely batch-agnostic so it works perfectly with a batch size of 1.

TinyTTA Engine

The authors built a custom C/C++ extension on top of TensorFlow Lite Micro (TFLM). It introduces floating-point backpropagation and dynamic memory allocation to MCUs, allowing the device to actually compute gradients and update weights at runtime.

Key Insights

  • Activation memory is the real bottleneck: Profiling memory usage during TTA reveals that storing activations for backpropagation is what exhausts MCU memory, not the weights themselves. By freezing the deep submodules and only updating the shallow "early-exit" heads, TinyTTA bypasses massive activation storage.
  • Not all distribution shifts are equal: In the real world, some test samples are heavily corrupted while others are mostly clean. TinyTTA's early-exit strategy naturally handles this mixed distribution. "Easy" samples exit early (saving compute and memory), while "hard" samples traverse deeper into the network for more robust processing.
  • Batch-agnostic normalization unlocks the edge: Existing memory-efficient TTA methods still rely on batch statistics, causing them to collapse when forced to process one sample at a time. Shifting to Weight Standardization is a simple but vital architectural tweak for edge deployment.

Experimental Results

The authors evaluated TinyTTA on several benchmark datasets known for distribution shifts, including image corruption (CIFAR10C, CIFAR100C), domain generalization (OfficeHome, PACS), and audio keyword spotting.

  • The MCU Milestone: TinyTTA is the only framework capable of running TTA on an STM32H747 MCU (which has a strict 512 KB SRAM limit). On CIFAR10C, it improved the base model's accuracy from 60.2% to 64.3% while using only 123 KB of SRAM and adding just ~50 KB of flash storage overhead.
  • Massive Memory Reduction: On Microprocessors like the Raspberry Pi Zero 2W, TinyTTA used up to 6x less memory than standard fine-tuning methods (CoTTA) and 2.2x less than state-of-the-art memory-efficient methods (EATA).
  • Accuracy Boosts: Despite using less memory and a batch size of 1, TinyTTA outperformed baseline TTA methods by massive margins—achieving up to 57.6% higher accuracy than the next best method (ECoTTA) on the PACS dataset.
  • Speed and Energy: Because many samples exit early, TinyTTA actually reduces overall latency and energy consumption compared to standard inference and other TTA methods.

Limitations and Future Work

While groundbreaking, TinyTTA cannot be applied to an off-the-shelf model instantly. The model must be retrained offline to learn the self-ensemble submodules and early-exit branches before it is deployed to the MCU. Future work aims to expand the TinyTTA Engine to handle video and Inertial Measurement Unit (IMU) time-series data, which are highly relevant for wearable health and robotics applications.

Summary updated

BibTeX
@inproceedings{jia2024tinytta,
  author = {Hong Jia and Young Kwon and Alessio Orsino and Ting Dang and Domenico Talia and Cecilia Mascolo},
  title = {{TinyTTA: Efficient Test-time Adaptation via Early-exit Ensembles on Edge Devices}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=XIcBCBe6C3},
}
Figure