Abstract
Vision Transformers (ViTs) have achieved remarkable performance in various image classification tasks by leveraging the attention mechanism to process image patches as tokens. However, the high computational and memory demands of ViTs pose significant challenges for deployment in resource-constrained environments. This paper introduces ViT-1.58b, a novel 1.58-bit quantized ViT model designed to drastically reduce memory and computational overhead while preserving competitive performance. ViT-1.58b employs ternary quantization, which refines the balance between efficiency and accuracy by constraining weights to {-1, 0, 1} and quantizing activations to 8-bit precision. Our approach ensures efficient scaling in terms of both memory and computation. Experiments on CIFAR-10 and ImageNet-1k demonstrate that ViT-1.58b maintains comparable accuracy to full-precision Vit, with significant reductions in memory usage and computational costs. This paper highlights the potential of extreme quantization techniques in developing sustainable AI solutions and contributes to the broader discourse on efficient model deployment in practical applications.
Introduction
Vision Transformers (ViTs) have revolutionized computer vision, but they come with a heavy "computational tax." Their attention mechanisms scale quadratically with the number of image patches (tokens), leading to massive memory footprints and high latency. While techniques like pruning and knowledge distillation help, quantization—reducing the numerical precision of weights and activations—is often the most direct path to efficiency. However, traditional binary (1-bit) models often suffer from significant accuracy drops because they are too restrictive. ViT-1.58b aims to find the "sweet spot" between extreme efficiency and model expressiveness to make ViTs viable for resource-constrained environments like smartphones and IoT devices.
Methodology
The core innovation of ViT-1.58b is the use of ternary quantization, where weights are constrained to three values: $\{-1, 0, 1\}$. Mathematically, $\log_2(3) \approx 1.58$, giving the model its name. The inclusion of "0" is crucial; it allows for sparsity and a richer representation of data than binary weights.
The model replaces standard linear layers with a specialized BitLinear module. This module implements:
- Weight Quantization: Weights are scaled by their average absolute value and rounded to the nearest integer in $\{-1, 0, 1\}$.
- Activation Quantization: Activations are quantized to 8-bit precision using an
absmaxfunction to maintain a balance between numerical flow and efficiency. - Quantization-Aware Training (QAT): The model is trained from scratch using a Straight-Through Estimator (STE) to allow gradients to flow through non-differentiable rounding functions during backpropagation.
Key Results and Discussion
The model was evaluated on CIFAR-10 and ImageNet-1k. The results demonstrate a massive leap in efficiency with minimal performance degradation.
Efficiency Gains
- Memory Footprint: A full-precision ViT-Large (ViT-L) requires 1.14 GB of memory. ViT-1.58b-L slashes this to just 57 MB—a 20x reduction.
- Throughput: Computational performance (measured in TFLOPs) jumped from 0.692 for the full-precision model to 11.069 for the 1.58-bit version, indicating massive potential for real-time applications.
Accuracy Retention
On ImageNet-1k, ViT-1.58b achieved a 74.25% Top-1 accuracy. While slightly lower than the full-precision baseline (76.54%), it significantly outperformed the 4-bit post-training inference version (70.88%) and nearly matched the 8-bit version (74.11%). This suggests that training with quantization in mind (QAT) is more effective than high-bit post-training quantization.
Hardware Synergy
By using ternary weights, complex floating-point multiplications can be replaced by simple additions and subtractions. This shift is significantly faster and more energy-efficient on specialized hardware, facilitating real-time inference on mobile devices.
Conclusion and Future Work
ViT-1.58b demonstrates that extreme quantization is a viable path for deploying high-performance vision models on edge devices. However, the approach requires training from scratch, which is computationally intensive and currently shows lower "learning efficiency" (requiring more epochs to stabilize). Future work will focus on scaling ViT-1.58b to larger architectures and investigating its integration into broader computer vision pipelines beyond classification.
Summary updated