TQCompressor: Improving Tensor Decomposition Methods in Neural Networks Via Permutations

Ivan Oseledets, Vadim Abronin, Aleksei Naumov, Denis Mazur, Dmitriy Bystrov, Katerina Tsarova, Artem Melnikov, Sergey Dolgov, Reuben Brasher, Michael PerelshteinMipr 2024

Abstract

Large Language Models (LLMs) pose significant deployment challenges due to their immense computational and memory requirements. While tensor decomposition techniques like Kronecker factorization offer a path toward compression, they often suffer from a substantial "expressivity tax." This paper introduces TQCompressor, a method that mitigates this loss by applying optimal row and column permutations to weight matrices before decomposition. By reordering neurons to maximize Kronecker-friendliness, TQCompressor produces a compressed GPT-2 model that is 35% smaller yet more accurate than established baselines like DistilGPT-2, utilizing only a fraction of the original training data.

Introduction

The deployment of state-of-the-art LLMs on edge devices is frequently hindered by their scale. Traditional compression methods, such as pruning or standard matrix factorization, often struggle to maintain model performance without extensive retraining. Kronecker decomposition is theoretically efficient but practically limited because standard weight matrices are not naturally structured for such factorization. TQCompressor addresses this by treating weight matrix arrangement as an optimization problem, shuffling neurons to create a more compressible structure without altering the layer's underlying function.

Methodology: The TQCompressor Pipeline

The core innovation of TQCompressor is the addition of a permutation step prior to factorization. The process follows an iterative loop designed to minimize approximation error.

Optimal Permutation and Kronecker Decomposition

Before a weight matrix $W$ is decomposed, TQCompressor identifies optimal permutation matrices $P$ and $C$ to reorder its rows and columns. This "shuffling" is framed as an assignment problem and solved using the Hungarian algorithm to minimize the mean squared error (MSE) between the original matrix and its Kronecker approximation.

The TQCompressor pipeline: Iterative row-column permutation followed by Kronecker decomposition.

Once permuted, the matrix is decomposed into smaller factors $A$ and $B$ using rank-1 Singular Value Decomposition (SVD). This process is repeated iteratively to refine the approximation until the desired accuracy is achieved.

Architectural Implementation and Distillation

The method is applied across the Transformer architecture, targeting embedding layers, multi-head attention, and feed-forward networks. To recover performance lost during compression, a multi-step knowledge distillation (KD) process is employed. A "student" model (TQCompressedGPT-2) is trained to mimic the "teacher" (GPT-2 Small) using a small subset (~3.1%) of the OpenWebText dataset.

Comparison of Transformer blocks in the original GPT-2 Small vs. the TQCompressedGPT-2 model.

Experimental Results

The authors evaluated TQCompressor by compressing GPT-2 Small (124M parameters) into TQCompressedGPT-2 (81M parameters), representing a 35% reduction in size.

Performance Benchmarks

TQCompressedGPT-2 was tested against DistilGPT-2 and KnGPT-2 on several language modeling benchmarks. In all cases, TQCompressor achieved superior perplexity (lower scores indicate better performance):

Dataset TQCompressedGPT-2 DistilGPT-2
Wikitext-103 40.28 44.53
Wikitext-2 32.25 36.47
Lambada 64.72 75.99

Data Efficiency

A key finding is the extreme data efficiency of the distillation process. While many compression techniques require the full original dataset, TQCompressor achieved state-of-the-art results using only ~250k texts from OpenWebText. This suggests that the permutation-based initialization provides a superior starting point for the student model.

Discussion and Conclusion

TQCompressor demonstrates that the spatial arrangement of weights is a critical, yet often overlooked, factor in model compression. By leveraging permutations, the "expressivity tax" of tensor decomposition is significantly reduced.

While the current implementation shows clear benefits in parameter reduction and accuracy, future work will focus on hardware-level optimizations. Current GPUs are primarily optimized for dense matrix operations; specialized kernels for Kronecker products could further unlock the latency benefits of this approach. Additionally, exploring the scalability of TQCompressor to larger architectures like Llama-3 remains a promising avenue for research.

Summary updated

BibTeX
@inproceedings{oseledets2024tqcompressor,
  author = {Ivan Oseledets and Vadim Abronin and Aleksei Naumov and Denis Mazur and Dmitriy Bystrov and Katerina Tsarova and Artem Melnikov and Sergey Dolgov and Reuben Brasher and Michael Perelshtein},
  title = {{TQCompressor: Improving Tensor Decomposition Methods in Neural Networks Via Permutations}},
  booktitle = {Mipr},
  year = {2024},
}
Figure