arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.02772cs.CV
收藏

通过测试时训练线性化视觉Transformer

Linearizing Vision Transformer with Test-Time Training

Tsinghua University(清华大学)

Yining Li, Dongchen Han, Zeyu Liu, Hanyi Wang, Yulin Wang, Gao Huang

AI总结:

提出利用测试时训练(TTT)架构与Softmax注意力的结构对齐性,结合键实例归一化和局部性增强模块,实现从预训练Transformer到线性注意力模型的有效权重迁移,在Stable Diffusion 3.5上仅需1小时微调即可达到相近的图像生成质量并加速推理。

摘要:

虽然线性复杂度注意力机制为克服二次瓶颈提供了Softmax注意力的有前途替代方案,但从头训练此类模型仍然成本高昂。继承预训练Transformer的权重提供了一种有吸引力的捷径,但Softmax与线性注意力之间的基本表征差距阻碍了有效的权重迁移。在这项工作中,我们从两个角度解决这一转换挑战:架构对齐和表征对齐。我们确定测试时训练(TTT)是一种线性复杂度架构,其两层动态公式在结构上与Softmax注意力对齐,从而能够直接继承预训练注意力权重。为了进一步对齐表征属性,包括键平移不变性和局部性,我们引入了键实例归一化和一个轻量级局部性增强模块。我们通过线性化Stable Diffusion 3.5验证了我们的方法,并推出了SD3.5-T$^5$(Transformer到测试时训练)。仅在4$ imes$H20 GPU上微调1小时,SD3.5-T$^5$在文本到图像质量上即可与微调后的Softmax模型相媲美,同时在1K和2K分辨率下分别加速推理1.32倍和1.47倍。代码可在https://github.com/LeapLabTHU/Transformer-to-TTT获取。

英文摘要:

While linear-complexity attention mechanisms offer a promising alternative to Softmax attention for overcoming the quadratic bottleneck, training such models from scratch remains prohibitively expensive. Inheriting weights from pretrained Transformers provides an appealing shortcut, yet the fundamental representational gap between Softmax and linear attention prevents effective weight transfer. In this work, we address this conversion challenge from two perspectives: architectural alignment and representational alignment. We identify Test-Time Training (TTT) as a linear-complexity architecture whose two-layer dynamic formulation is structurally aligned with Softmax attention, enabling direct inheritance of pretrained attention weights. To further align representational properties, including key shift-invariance and locality, we introduce key instance normalization and a lightweight locality enhancement module. We validate our approach by linearizing Stable Diffusion 3.5 and introduce SD3.5-T$^5$ (Transformer To Test Time Training). With only 1 hour of fine-tuning on 4$\times$H20 GPUs, SD3.5-T$^5$ achieves comparable text-to-image quality to the fine-tuned Softmax model, while accelerating inference by 1.32$\times$ and 1.47$\times$ at 1K and 2K resolutions. Code is available at https://github.com/LeapLabTHU/Transformer-to-TTT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑