用DCT系数压缩Transformer线性层,参数减半仍保持接近原模型性能。
Training Transformers in Cosine Coefficient Space
- 将线性层权重转为存储DCT系数,前向传播时重建矩阵
- 参数量减半时验证损失仅上升0.024,优于低秩方法的0.221
- DCT基支持快速重构,节省内存带宽,适合部署优化
线性层占Transformer绝大部分参数。本文将每个线性层替换为仅存储每权重矩阵mn个二维DCT系数中的K个,并在每次前向传播时通过逆DCT重构完整矩阵,其中K个系数为可训练参数。在字符级莎士比亚文本上从零训练一个4层、128维的Transformer,在K = mn/2时达到验证损失1.604,而标准稠密基线为1.580,参数减半下仅损失0.024,处于稠密模型末期波动范围内;相同参数量下,秩48的LoRA仅达1.801(损失+0.221)。在匹配参数数下,稀疏系数表示相较低秩参数化具明显结构优势,其根源在于秩灵活性。随机正交基在K = mn/2时与DCT性能相近,压缩实验显示:能容纳高秩矩阵的子空间维持低损失,而退化为低秩块的子空间(如锯齿选择变体)则同步收敛至秩48 LoRA的损失水平。在所有正交基中,DCT最优,因其可分离快速变换支持融合重建核,使权矩阵始终驻留片上内存,参数节省直接转化为带宽节省。
原文摘要 · Abstract (English)
Linear layers hold most of a transformer's parameters. We replace each linear layer with one that stores $K$ out of $mn$ two-dimensional DCT coefficients per weight matrix and reconstructs the full matrix through an inverse DCT at every forward pass; the $K$ coefficients are the trainable parameters. A 4-layer, 128-dim transformer trained from scratch on character-level Shakespeare reaches validation loss $1.604$ at $K = mn/2$, against $1.580$ for a standard dense baseline -- a gap of $+0.024$ at half the trainable parameter count, within the terminal-epoch variation of the dense run. A rank-48 LoRA factorization at the same trainable parameter count reaches only $1.801$ ($+0.221$). The structural advantage of sparse-coefficient over low-rank parameterizations at matched $K$ is qualitative. We identify rank flexibility as the mechanism. A random orthonormal basis matches the DCT within noise at $K = mn/2$, and a compression sweep through $K = mn/10$ and $K = mn/20$ shows that subspaces that can host high-rank matrices keep the loss low, while subspaces that flatten into a low-rank block (zigzag-selection variants) converge onto the observed stable rank \emph{and} the loss line of the rank-48 LoRA reference in lock-step. Among these orthonormal bases, the DCT is preferred because its separable fast transform admits a fused reconstruction kernel: the materialized weight matrix never leaves on-chip memory, so the parameter saving translates into a bandwidth saving as well.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。