Dancing along Battery: Enabling Transformer with Run-time Reconfigurability on Mobile Devices

Yuhong Song, Weiwen Jiang, Bingbing Li, Panjie Qi, Qingfeng Zhuge, Edwin Hsing-Mean Sha, Sakyasingha Dasgupta, Yiyu Shi, Caiwen Ding

Abstract

Large Transformer models have set new benchmarks in Natural Language Processing (NLP), yet their deployment on battery-powered mobile devices remains a significant challenge due to high energy consumption and strict latency requirements. This paper introduces RT$^3$ (Run-Time Re-configurable Transformer), a novel AutoML framework that enables dynamic model adaptation to hardware power states. By combining hardware-aware Dynamic Voltage and Frequency Scaling (DVFS) with a two-stage software pruning strategy—Block-Structured Pruning and Reinforcement Learning-based Pattern Pruning—RT$^3$ allows Transformers to maintain real-time performance even as battery levels drop. Our evaluation shows that RT$^3$ can improve battery life by nearly 5x with minimal accuracy loss (less than 1%), enabling seamless run-time reconfiguration in under 45 milliseconds.

Introduction

The massive scale of Transformer models makes them difficult to deploy on resource-constrained mobile devices. To conserve energy, mobile operating systems frequently employ Dynamic Voltage and Frequency Scaling (DVFS), which reduces the processor's clock speed as battery levels decline. However, this hardware-level power saving causes inference latency to spike, often violating the real-time constraints necessary for interactive applications.

Existing model compression techniques, such as static pruning, do not account for these fluctuating hardware states. This paper addresses the need for a co-designed software-hardware approach, asking: How can a Transformer dynamically adjust its complexity to maintain real-time speeds across different hardware power modes?

Methodology: The RT$^3$ Framework

The authors propose RT$^3$, a two-level optimization framework that integrates hardware states with software reconfiguration.

Overview of the RT$^3$ framework, illustrating the two-level pruning process and the RL-based pattern selection for different power modes.

Level 1: Block-Structured Pruning (BP)

The framework first applies coarse-grained Block-Structured Pruning to the original Transformer model ($M$). This process removes entire rows or columns of weights to create a compressed "backbone" model ($C$). While BP is hardware-friendly due to regular memory access patterns, aggressive pruning can significantly degrade accuracy.

Level 2: Pattern Pruning (PP) via Reinforcement Learning

To further increase compression without sacrificing accuracy, RT$^3$ applies fine-grained Pattern Pruning on top of the backbone. Given the vast search space of potential patterns, the framework uses the structural importance identified in Level 1 as a "hot start" for an RNN-based Reinforcement Learning (RL) controller. This controller searches for optimal sparsity patterns tailored to specific DVFS levels (e.g., F-Mode for full power, N-Mode for normal, and E-Mode for energy-saving).

Run-Time Reconfiguration

During inference, the backbone model remains fixed in memory. As the device's battery state changes and triggers a shift in hardware frequency, RT$^3$ dynamically swaps the lightweight pattern masks. This approach avoids the high overhead of swapping entire models, enabling near-instantaneous adaptation.

Experimental Setup

The framework was evaluated using the following benchmarks and hardware:

  • Models & Datasets: A standard Transformer was tested on WikiText-2 for next-word prediction, and DistilBERT was evaluated across nine tasks in the GLUE Benchmark.
  • Hardware Platform: Real-world latency and energy profiling were conducted on an Odroid-XU3 mobile platform (ARM Cortex A7).

Results and Analysis

RT$^3$ demonstrates a superior balance between energy efficiency and model performance.

Performance evaluation showing Pareto frontiers for different latency constraints and accuracy vs. sparsity comparisons.

Efficiency and Battery Life

The framework achieved a 4.96x improvement in the total number of inferences possible on a single energy budget compared to an unoptimized baseline. Crucially, RT$^3$ successfully met strict real-time deadlines (94ms and 104ms) across all power states, whereas standard models failed as hardware frequency decreased.

Accuracy and Switching Performance

Accuracy remained robust, with only a 0.95% loss for the standard Transformer and a 1.5% average decrease for DistilBERT. Furthermore, the context-switching speed between different pattern sets was recorded at under 45 milliseconds. This is over 1000x faster than swapping distinct sub-models, which typically requires over a minute due to memory constraints.

Conclusion

RT$^3$ provides a practical solution for deploying large-scale Transformers on mobile devices by bridging the gap between hardware power management and software model compression. By utilizing a shared backbone and dynamic pattern masks, the framework enables high-performance, real-time NLP applications that can "dance" along with the device's battery life. Future research may extend this methodology to other architectures, such as Vision Transformers, or explore its synergy with dynamic quantization techniques.

Summary updated

BibTeX
@inproceedings{song2021dancing,
  author = {Yuhong Song and Weiwen Jiang and Bingbing Li and Panjie Qi and Qingfeng Zhuge and Edwin Hsing-Mean Sha and Sakyasingha Dasgupta and Yiyu Shi and Caiwen Ding},
  title = {{Dancing along Battery: Enabling Transformer with Run-time Reconfigurability on Mobile Devices}},
  booktitle = {DAC},
  year = {2021},
  url = {https://openreview.net/forum?id=qeYiZ35Z0ok},
}
Figure