KV cache has become a de facto technique for the inference of large language models (LLMs), where tensors of shape (layer number, head number, sequence length, feature dimension) are introduced to cache historical information for self-attention. As the size of the model and data grows, the KV cache can quickly become a bottleneck within the system in both storage and memory transfer. To address this, prior studies usually focus on the first three axes of the cache tensors for compression. This paper supplements them, focusing on the feature dimension axis, by utilizing low-rank projection matrices to transform the cache features into spaces with reduced dimensions. We begin by investigating the canonical orthogonal projection method for data compression through principal component analysis (PCA). We observe the issue with PCA projection where significant performance degradation is observed at low compression rates. To bridge the gap, we propose to directly tune the orthogonal projection matrices with a distillation objective using an elaborate Matryoshka training strategy. After training, we adaptively search for the optimal compression rates for various layers and heads given varying compression budgets. Compared to previous works, our method can easily embrace pre-trained LLMs and hold a smooth tradeoff between performance and compression rate. We empirically witness the high data efficiency of our training procedure and find that our method can sustain over 90% performance with an average KV cache compression rate of 60% (and up to 75% in certain extreme scenarios) for popular LLMs like LLaMA2-7B-base and Mistral-7B-v0.3-base.
Break Through the Compression Bottleneck: From Theory to Practice
Institute of Automation, Chinese Academy of Sciences(中国科学院自动化研究所);University of Chinese Academy of Sciences(中国科学院大学);Beijing Academy of Artificial Intelligence(北京人工智能研究院)
Maestro: Uncovering Low-Rank Structures via Trainable Decomposition
Mohamed bin Zayed University of Artificial Intelligence (MBZUAI)(穆罕默德·本·扎耶德人工智能大学(MBZUAI));Brave Software(Brave软件公司);DataBricks(Databricks公司);Carnegie Mellon University(卡内基梅隆大学)
Parameter-Efficient Orthogonal Finetuning via Butterfly Factorization
Max Planck Institute for Intelligent Systems(马克斯·普朗克智能系统研究所);University of Cambridge(剑桥大学);ETH Zürich(苏黎世联邦理工学院);University of Tübingen(蒂宾根大学);Mila(米拉研究所);Université de Montréal(蒙特利尔大学);The Alan Turing Institute(艾伦·图灵研究所)
Fast Trainable Multilinear Bases for Image Compression
Institute of Science Tokyo(东京科学大学);Center for Advanced Intelligence Project (AIP), RIKEN(理化学研究所先进智能项目中心);The Hong Kong University of Science and Technology (Guangzhou)(香港科技大学(广州))
Deep Orthogonal Hypersphere Compression for Anomaly Detection
School of Data Science, The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳)数据科学学院);Shenzhen Research Institute of Big Data(深圳大数据研究院);School of Computing, National University of Singapore(新加坡国立大学计算机学院);Institute of Data Science, National University of Singapore(新加坡国立大学数据科学研究院)