学习用于神经网络压缩的函数子空间

·

研究论文 · 2026/10/08

现代Transformer在展现强大能力的同时,也带来了巨大的内存和计算需求。低秩权重分解能在保持矩阵稠密的同时减少这两者,从而在标准硬件上高效运行。然而,现有方法通过局部闭式准则(如激活能量、逐层重建误差或损失的二次近似)来选择每个权重矩阵中要移除的子空间。这些准则忽略了误差如何在网络中传播,因此在高压缩率下,误差会随深度累积,导致性能崩溃。我们提出了可学习子空间投影(LSP),它端到端地学习要丢弃的子空间。每个线性层或读取相同激活的绑定层组被分配一个正交投影器。所有投影器针对全局目标(与稠密模型输出分布的KL散度或模型原始训练损失)联合优化,同时预训练权重保持冻结。投影器从白化SVD截断初始化,秩根据每个投影器每节省一个参数所诱导的输出KL来分配。训练后,投影器合并为标准低秩因子,每个绑定组共享一个因子。在注意力中,这还允许模型缓存一个窄潜在表示来代替完整的键和值。在LLM(OPT-125M/1.3B、Qwen3-4B、Llama-2-7B)和ViT-B/16上,LSP优于基线,且随着压缩增加,其优势扩大。在-70%压缩下,LSP将Llama-2-7B的WikiText-2困惑度降至10.9,平均零样本准确率达到42.2%,而最强基线分别为13.3和36.0%。在小批量大小下,分解模型解码速度比稠密模型快达1.6倍,并且在128k令牌上下文下,缓存共享潜在表示将权重和KV缓存的组合内存减少13.5倍,而未绑定基线分解最多减少6.5倍。

LSP通过端到端学习子空间,解决了现有低秩分解方法在高压缩下误差累积的问题,在多个大模型上实现了更优的压缩效果和推理加速,且能显著减少内存占用,对高效部署大模型具有重要意义。

Modern transformers pair impressive capabilities with substantial memory and compute demands. Low-rank weight factorization reduces both while keeping the matrices dense, and thus efficient on standard hardware. Existing methods, however, choose the subspace to remove from each weight matrix with local closed-form criteria: activation energy, layer-wise reconstruction error, or a quadratic approximation of the loss. These criteria ignore how errors propagate through the network, so at high compression the errors compound with depth and performance collapses. We introduce Learnable Subspace Projections (LSP), which instead learns the subspaces to discard end-to-end. Each linear layer, or tied group of layers that read the same activations, is assigned an orthogonal projector. All projectors are optimized jointly against a global objective--the KL divergence to the dense model's output distribution or the model's original training loss--while the pretrained weights remain frozen. Projectors are initialized from a whitened SVD truncation, and ranks are allocated by the output KL each projector induces per parameter saved. After training, the projectors merge into standard low-rank factors, with each tied group sharing one factor. In attention, this also lets the model cache one narrow latent in place of full keys and values. Across LLMs (OPT-125M/1.3B, Qwen3-4B, Llama-2-7B) and ViT-B/16, LSP outperforms baselines, and its advantage widens as compression increases. At -70% compression, LSP brings Llama-2-7B to 10.9 WikiText-2 perplexity and 42.2% mean zero-shot accuracy, versus 13.3 and 36.0% for the strongest baseline. The factorized model decodes up to 1.6x faster than the dense model at small batch sizes, and aching the shared latent shrinks the combined memory of weights and KV cache by 13.5x at a 128k-token context, versus at most 6.5x for untied baseline factorizations.

阅读原文

参与讨论