Efficient model compression with Random Operation Access Specific Tile (ROAST) hashing

Aditya Desai, Keren Zhou, Anshumali ShrivastavaarXiv 2022

Abstract

Advancements in deep learning are often associated with increasing model sizes. The model size dramatically affects the deployment cost and latency of deep models. For instance, models like BERT cannot be deployed on edge devices and mobiles due to their sheer size. As a result, most advances in Deep Learning are yet to reach the edge. Model compression has sought much-deserved attention in literature across natural language processing, vision, and recommendation domains. This paper proposes a model-agnostic, cache-friendly model compression approach: Random Operation Access Specific Tile (ROAST) hashing. ROAST collapses the parameters by clubbing them through a lightweight mapping. Notably, while clubbing these parameters, ROAST utilizes cache hierarchies by aligning the memory access pattern with the parameter access pattern. ROAST is up to $\sim 25 \times$ faster to train and $\sim 50 \times$ faster to infer than the popular parameter sharing method HashedNet. Additionally, ROAST introduces global weight sharing, which is empirically and theoretically superior to local weight sharing in HashedNet, and can be of independent interest in itself. With ROAST, we present the first compressed BERT, which is $100\times - 1000\times$ smaller but does not result in quality degradation. These compression levels on universal architecture like transformers are promising for the future of SOTA model deployment on resource-constrained devices like mobile and edge devices.

Introduction

Deep learning models are experiencing an "explosion" in size. State-of-the-art architectures like BERT and GPT-2 require gigabytes of memory, making them nearly impossible to deploy on resource-constrained edge devices such as smartphones or IoT sensors. Furthermore, these large models create massive communication bottlenecks during distributed training.

While techniques like pruning and quantization are common, parameter sharing (specifically hashing) offers a powerful alternative by collapsing model weights into a small, shared pool. However, existing methods like HashedNet suffer from non-coalesced memory access. Because weights are mapped randomly, hardware must perform scattered memory reads, leading to significant latency. ROAST (Random Operation Access Specific Tile) hashing bridges this gap by aligning high compression ratios with real-world hardware efficiency.

Methods: ROAST Hashing

ROAST introduces two primary innovations to overcome the limitations of traditional hashing-based compression:

1. Operation-Specific Tiling

Instead of hashing individual weights to random locations, ROAST hashes "tiles" or blocks of weights. It employs 1D tiles for lookups (like embeddings) and 2D tiles for matrix multiplications, which are central to Transformer architectures. By mapping a block of model weights to a contiguous block in compressed memory, ROAST ensures that hardware fetches neighboring weights simultaneously, utilizing cache hierarchies effectively.

ROAST architecture showing 1D and 2D tiling mapping to a shared parameter memory.

2. Global Memory Sharing (GMS)

Unlike most methods that share weights locally within a single layer, ROAST shares a single pool of weights across the entire model. To maintain stability, a module-specific scaling factor ($\lambda$) is used to ensure each layer receives weights at an appropriate initialization scale (e.g., Xavier initialization). Theoretical analysis shows that GMS reduces the variance of inner-product estimations and increases model expressivity compared to local sharing.

Experimental Setup

The researchers evaluated ROAST by training BERT-base from scratch on five text-classification datasets: tweet-eval, ag-news, yelp-polarity, and amazon-polarity. The implementation utilized Triton to ensure custom tiled kernels were as efficient as vendor-optimized libraries like cuBLAS.

Key Results

ROAST achieved unprecedented compression levels for BERT models, reaching 100× to 1000× reductions in size (e.g., from ~400MB to ~4MB) without sacrificing accuracy.

Accuracy vs. training iterations on the Amazon-polarity dataset, comparing original BERT with various ROAST compression levels.
  • Performance Gains: ROAST is up to 50× faster for inference and 25× faster for training compared to HashedNet. On large workloads, its inference latency is only ~1.34× slower than uncompressed PyTorch-MM, demonstrating the effectiveness of its cache-friendly design.
  • Implicit Regularization: Interestingly, 100× compressed models often matched or exceeded the accuracy of the original BERT. This suggests that the weight-sharing mechanism acts as an implicit regularizer, preventing overfitting.

Discussion and Future Work

While ROAST significantly reduces memory footprint, it does not yet reduce the total number of floating-point operations (FLOPs). Future work will focus on skipping computations to further improve speed. Additionally, while results on text classification are promising, further research is needed to evaluate ROAST on complex generative tasks or high-resolution computer vision. Finally, extreme compression (1000×) may require more training iterations to reach optimal convergence.

Summary updated

BibTeX
@misc{desai2022efficient,
  author = {Aditya Desai and Keren Zhou and Anshumali Shrivastava},
  title = {{Efficient model compression with Random Operation Access Specific Tile (ROAST) hashing}},
  year = {2022},
  eprint = {2207.10702},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2207.10702},
}
Figure