用线性注意力实现1张卡1分钟生成16K图像
LinFusion: 1 GPU, 1 Minute, 16K Image
- 设计线性注意力机制,突破传统扩散模型的内存瓶颈
- 仅需少量训练即可超越原版Stable Diffusion,支持16K图像生成
- 兼容现有SD工具链,无需改造直接使用
当前基于Transformer的去噪扩散模型依赖自注意力操作处理复杂空间关系,但其时间与内存复杂度随空间标记数呈二次增长,难以高效生成高分辨率图像。为此,本文从Mamba2、RWKV6、门控线性注意力等线性复杂度模型中提炼出注意力归一化与非因果推理两项关键特性,提出一种广义线性注意力范式,作为多种主流线性令牌混合器的低秩近似。为降低训练成本并复用预训练模型,采用知识蒸馏从StableDiffusion(SD)初始化并训练,得到的LinFusion模型在仅经小幅训练后性能媲美或超越原版SD,同时显著降低时间与内存开销。在SD-v1.5、SD-v2.1和SD-XL上的大量实验表明,LinFusion可实现高质量零样本跨分辨率生成,在单张GPU上支持16K超分辨率图像生成,且与ControlNet、IP-Adapter、DemoFusion、DistriFusion等现有组件完全兼容,无需额外适配。
原文摘要 · Abstract (English)
Modern diffusion models, particularly those utilizing a Transformer-based UNet for denoising, rely heavily on self-attention operations to manage complex spatial relationships, thus achieving impressive generation performance. However, this existing paradigm faces significant challenges in generating high-resolution visual content due to its quadratic time and memory complexity with respect to the number of spatial tokens. To address this limitation, we aim at a novel linear attention mechanism as an alternative in this paper. Specifically, we begin our exploration from recently introduced models with linear complexity, e.g., Mamba2, RWKV6, Gated Linear Attention, etc, and identify two key features--attention normalization and non-causal inference--that enhance high-resolution visual generation performance. Building on these insights, we introduce a generalized linear attention paradigm, which serves as a low-rank approximation of a wide spectrum of popular linear token mixers. To save the training cost and better leverage pre-trained models, we initialize our models and distill the knowledge from pre-trained StableDiffusion (SD). We find that the distilled model, termed LinFusion, achieves performance on par with or superior to the original SD after only modest training, while significantly reducing time and memory complexity. Extensive experiments on SD-v1.5, SD-v2.1, and SD-XL demonstrate that LinFusion enables satisfactory and efficient zero-shot cross-resolution generation, accommodating ultra-resolution images like 16K on a single GPU. Moreover, it is highly compatible with pre-trained SD components and pipelines, such as ControlNet, IP-Adapter, DemoFusion, DistriFusion, etc, requiring no adaptation efforts. Codes are available at https://github.com/Huage001/LinFusion.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。