DreamLite: disabling attention slicing replaces the GQA processor and breaks inference

未關閉
#15,161 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@Kaiden118 已經在處理了。

開始於 2026年10月31日。

  • #15191 來自 @davrens101 —— 已關閉,未合併

評估

難度
3/5
預估耗時
1-2 天
新手友好度
70/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python, pytorch

研究方向

Locate DreamLiteUNetModel and the DreamLite pipeline classes in the diffusers source; inspect set_attention_slice and set_default_attn_processor to see where AttnProcessor2_0 replaces DreamLiteAttnProcessor2_0. Run the provided CPU reproduction to observe the RMSNorm tensor mismatch. The fix should preserve the correct GQA processor when slicing is disabled and add regression tests for both pipelines.

由索引模型根據 Issue 內容生成。

描述

bug
Describe the bug

Calling disable_attention_slicing() on either DreamLite pipeline replaces DreamLiteAttnProcessor2_0 with AttnProcessor2_0. The next inference then fails in RMSNorm, even if attention slicing was never enabled. The inherited UNet method calls set_attention_slice(None) on each attention layer, installing a processor that does not support DreamLite's grouped-query attention layout. DreamLite's existing set_default_attn_processor() restores the correct processor and produces exactly the original output.

I found this by inspecting the source code and reproduced it on CPU. Standard attention slicing is already known to be incompatible with DreamLite's GQA layout. This issue is about what happens when slicing is disabled.

Reproduction

This example uses the published DreamLite-mobile UNet weights with smaller spatial dimensions and synthetic text-conditioning vectors.

import torch
from diffusers import DreamLiteUNetModel

torch.set_num_threads(1)

unet = DreamLiteUNetModel.from_pretrained(
    "carlofkl/DreamLite-mobile",
    subfolder="unet",
    revision="6695c3f4be230f0493fa5dbf78be3bc4d3bb2ab4",
    torch_dtype=torch.float32,
).eval()

torch.manual_seed(23)
sample = torch.randn(1, 4, 8, 8)
inputs = dict(
    encoder_hidden_states=torch.randn(1, 5, 2048),
    added_cond_kwargs={"time_ids": torch.tensor([[64., 64.]])},
)

with torch.no_grad():
    print(unet(sample, 500, **inputs).sample.shape)
    unet.set_attention_slice(None)  # Called by pipeline.disable_attention_slicing()
    print(unet(sample, 500, **inputs).sample.shape)
Logs
torch.Size([1, 4, 8, 8])
RuntimeError: The size of tensor a (16) must match the size of tensor b (64) at non-singleton dimension 3
System Info

Diffusers main at 86ef420b17363c28e36ebad6b58555e9aa8feda2, Linux x86_64, Python 3.11.17, PyTorch 2.14.1+cpu, Transformers 5.19.0, Accelerate 1.15.0. I used Codex to help investigate the issue and reproduce it.

Would you be open to a focused fix that keeps DreamLite's correct default processor when attention slicing is disabled? I'd be happy to implement it and add regression tests for both pipeline classes. I'd also appreciate guidance on what should happen if users try to enable unsupported attention slicing.

Who can help?

No response

主要語言
Python
星號
35k
分支
7.5k
平均合併
2 天 22 小時
30 天內合併 PR
58

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

huggingface/diffusers 的其他 Issue

查看 huggingface/diffusers 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。