COMCAT: Towards Efficient Compression and Customization of Attention-Based Vision Models

Jinqi Xiao, Miao Yin, Yu Gong, Xiao Zang, Jian Ren, Bo Yuan

Vision Transformers (ViTs) have taken the computer vision world by storm, often outperforming traditional convolutional networks. However, their massive appetite for parameters and compute makes them difficult to deploy on mobile devices or edge hardware. While researchers have spent years pruning these models (cutting out redundant connections), another powerful technique—low-rank factorization—has largely struggled to show its worth in the world of attention mechanisms.

A new paper from researchers at Rutgers and Snap Inc., titled COMCAT, changes that. By rethinking how we look at the "rank" of an attention layer, they’ve unlocked a way to compress these models that actually beats state-of-the-art pruning.

TL;DR

COMCAT introduces a "head-level" low-rank compression strategy for Vision Transformers that outperforms state-of-the-art pruning methods. By factorizing the combined products of attention matrices rather than individual ones, it achieves higher accuracy with fewer parameters and slashes the storage cost of customizing diffusion models by over 1900$\times$.

What Problem Does This Paper Address?

The standard way to compress a model using low-rank factorization is to take a large weight matrix and decompose it into two smaller ones (like turning a $100 \times 100$ matrix into a $100 \times 10$ and a $10 \times 100$ pair). In CNNs, this works wonders. In ViTs, it often fails.

Singular value distributions of individual attention matrices, illustrating a lack of strict low-rankness.

The authors observed a critical bottleneck: individual weight matrices in Multi-Head Attention (MHA) layers—specifically the Query ($W^Q$), Key ($W^K$), Value ($W^V$), and Output ($W^O$) matrices—don't always exhibit "low-rankness." If you try to force them into a low-rank format individually, you lose too much information, and accuracy plummets.

Methods

The core innovation of COMCAT is Head-Level Low-Rankness.

Instead of looking at $W^Q$ or $W^V$ in isolation, the authors look at the functional combinations within the attention mechanism. Mathematically, the attention operation involves products like $W^Q W^{K^T}$ (to compute scores) and $W^V W^O$ (to produce the final output).

  1. Combined Factorization: COMCAT factorizes these products directly. This is mathematically more efficient; factorizing the product $AB$ requires half the parameters of factorizing $A$ and $B$ separately to achieve the same rank.
Parameter comparison demonstrating that combined factorization requires fewer parameters than individual matrix factorization.
  1. Automatic Rank Selection: Since every layer and every head in a transformer has different importance, you can't just pick one rank for the whole model. The authors treat rank selection as a "Neural Architecture Search" (NAS) problem. They use a differentiable sampling-based search to automatically find the best rank for every component given a specific "budget" (e.g., "reduce parameters by 50%").
  2. Diffusion Customization: They applied this same logic to text-to-image models (like Stable Diffusion). Instead of fine-tuning the whole model to learn a new concept (like your pet dog), they add tiny, low-rank "head-level" adapters to the cross-attention layers.

Datasets

The authors validated their approach on:

  • ImageNet-1K: The gold standard for image classification, using DeiT-small and DeiT-base architectures.
  • CustomDiffusion Dataset: A set of 6 objects (plus one new one) used to test how well the model learns specific user-defined concepts.
  • MS-COCO: Used to evaluate the quality and diversity of images generated by the customized diffusion models via the FID (Fréchet Inception Distance) metric.

Key Insights and Ideas

  • The "Aha" Moment: The authors realized that while a single matrix might be full-rank, the interaction between two matrices in the attention pipeline is often low-rank. By targeting the pipeline rather than the individual weights, they bypassed the fundamental limitation of previous low-rank methods.
  • Relaxed Constraints: Head-level factorization is more "forgiving." As long as either $A$ or $B$ is low-rank, the product $AB$ is low-rank. This opens up many more opportunities for compression that matrix-level methods miss.
  • Storage is the New Bottleneck: For personalized AI (like having a model that knows what your house looks like), storing a full 2GB model for every concept is impossible. COMCAT shows that by only saving the tiny low-rank "delta" weights, you can store thousands of concepts in the space usually taken by one.

Key Results

  • Better than Pruning: On ImageNet, COMCAT achieved 0.45% to 0.76% higher top-1 accuracy than state-of-the-art pruning methods, even while using fewer parameters.
  • Hardware Speedups: The compressed models aren't just smaller on paper; they are faster. They achieved a 2.52$\times$ speedup on a Snapdragon 855 mobile processor for the DeiT-base model.
  • Diffusion Efficiency: When customizing Stable Diffusion, COMCAT was 2.6$\times$ faster to train and required 1927.5$\times$ less extra storage than DreamBooth, all while producing higher-quality images (lower FID scores).

Limitations and Future Work

While the results are impressive, the paper primarily focuses on Vision Transformers. The authors note that while the logic should hold for Large Language Models (LLMs) like GPT, they haven't yet published results for that domain. Additionally, the "search" phase for automatic rank selection adds an extra step to the training pipeline, though the authors argue this is a one-time cost that pays off during deployment.

Future work could involve extending this "head-level" insight to other transformer-based architectures in speech and multi-modal tasks.

Summary updated

BibTeX
@inproceedings{xiao2023comcat,
  author = {Jinqi Xiao and Miao Yin and Yu Gong and Xiao Zang and Jian Ren and Bo Yuan},
  title = {{COMCAT: Towards Efficient Compression and Customization of Attention-Based Vision Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=LrDkno4B3u},
}
Figure