TransAxx: Efficient Transformers With Approximate Computing

Dimitrios Danopoulos, Georgios Zervakis, Dimitrios Soudris, Jörg HenkelIEEE Transactions on Circuits and Systems for Artificial Intelligence 2024

TL;DR

This paper introduces TransAxx, a novel framework for efficiently evaluating approximate computing in Vision Transformers (ViTs). By enabling fast emulation and approximate-aware retraining, TransAxx allows researchers to explore significant power savings in ViTs without substantial accuracy loss, paving the way for their deployment on resource-constrained devices.

What Problem Does This Paper Address?

Vision Transformers (ViTs) have emerged as powerful alternatives to Convolutional Neural Networks (CNNs) for computer vision tasks, achieving state-of-the-art performance. However, their computational demands, particularly due to the self-attention mechanism, are very high, limiting their practical application on devices with limited power and computational resources. Approximate computing, which trades a small amount of accuracy for significant gains in speed and power efficiency by using inexact arithmetic, has shown promise for CNNs. Yet, its application and impact on ViT models remained largely unexplored. This paper addresses this gap by providing a framework to systematically investigate and exploit approximate computing for ViTs.

Methods

The core contribution is TransAxx, a PyTorch-based framework designed for fast emulation of approximate ViT models. Key features include:

  • Seamless Integration: TransAxx acts as a PyTorch plugin, allowing users to enable approximate computing without altering their existing DL workflow. It automatically swaps standard PyTorch layers with custom approximate versions during model compilation, leveraging Just-In-Time (JIT) compilation for flexibility.
  • Approximate Multiplier Emulation: TransAxx supports arbitrary approximate multipliers by modeling their behavior at a high level. It uses Look-Up Tables (LUTs) to store precomputed approximate multiplication results, significantly speeding up emulation. For very large bitwidths where LUTs become impractical, it can dynamically switch to functional-based emulation.
  • Approximate-Aware Retraining: To recover accuracy lost due to approximation, TransAxx incorporates an approximate-aware finetuning strategy. This process simulates the noise introduced by approximate multipliers during retraining, leading to more robust models.
  • Hardware-Driven Monte Carlo Tree Search (MCTS): To efficiently explore the vast design space of approximate configurations (i.e., which approximate multiplier to use for each layer), the authors propose a hardware-driven MCTS algorithm. This algorithm uses a custom policy that incorporates layer sensitivity to approximation and power consumption, guiding the search towards Pareto-optimal accuracy-power trade-offs.

Datasets

The primary dataset used for evaluation is ImageNet-1K. The paper also mentions using a standard Stochastic Gradient Descent (SGD) algorithm for training and finetuning.

Key Insights and Ideas

  • ViTs are Sensitive to Approximation: The paper demonstrates that ViTs, like CNNs, can be sensitive to approximation, but also that approximate-aware retraining can effectively recover lost accuracy.
  • LUTs are Crucial for Speed: Using LUTs for approximate multipliers drastically reduces emulation time, making the exploration of approximate ViTs feasible.
  • MCTS is Effective for Design Space Exploration: The hardware-driven MCTS approach is shown to be highly effective in navigating the complex accuracy-power trade-off space for approximate ViTs, outperforming simpler baseline approaches.
  • Layer-wise Approximation Matters: The sensitivity analysis reveals that different layers within a ViT model have varying sensitivities to approximation, highlighting the importance of per-layer optimization.

Key Results

  • Significant Power Savings: The MCTS-optimized solutions achieve, on average, ~21% lower power consumption compared to baseline approximate solutions with similar accuracy (within ~1% difference).
  • Fast Emulation: TransAxx provides significantly faster emulation times compared to existing frameworks, especially when using LUT-based multiplication. For example, ViT-S emulation time is reduced from 121 minutes (functional) to 6 minutes (LUT-based).
  • Accuracy Recovery: Approximate-aware retraining successfully recovers accuracy loss, with retrained models showing performance close to their initial (pre-approximation) state. Table IV shows that for the mul8s_1KV9 multiplier, retrained accuracy is often within a few percentage points of the initial accuracy.
  • Pareto-Optimal Solutions: The MCTS algorithm effectively identifies a set of Pareto-optimal solutions, offering designers a flexible range of choices for balancing accuracy and power consumption.

Limitations and Future Work

  • Not a Multiplier Design Tool: TransAxx is designed for evaluating existing approximate multipliers, not for designing new ones. The authors suggest that their framework can inform the design of new multipliers by revealing sensitivities.
  • VOS Approximation Limitations: TransAxx natively supports logic and algorithmic approximations. While it can handle Voltage Over-Scaling (VOS) approximations through its functional-based mode or by integrating VOS-approximated multiplier outputs into LUTs, it doesn't directly emulate VOS timing violations.
  • Application-Dependent Quality: The acceptable level of approximation is highly application-dependent and needs to be explored by the user.
  • Future Work: The authors suggest that further research is needed for ViT models and dedicated approximate multipliers to achieve even higher power savings for similar accuracy loss. They also note that their MCTS objective function can be extended to include other metrics like latency and area.

Summary updated

BibTeX
@misc{danopoulos2024transaxx,
  author = {Dimitrios Danopoulos and Georgios Zervakis and Dimitrios Soudris and Jörg Henkel},
  title = {{TransAxx: Efficient Transformers With Approximate Computing}},
  year = {2024},
  eprint = {2402.07545},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.07545},
}
Figure