Comfy-Org / Comfy-Org/ComfyUI

v0.33.1版本更新导致flux2无法正常使用gguf格式的clip模型

Open
#15,616 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

v0.33.1 的 `comfy/text_encoders/llama.py` 中,8月13日 "Cuda Graphs" 相关提交将 TransformerBlock 的 MLP 后残差相加从:

```python
x = residual + x
```

改为:

```python
x = torch.add(residual, x, out=output) # 配合函数开头 output = x,原地写回 block 输入张量
```

该写法对普通 PyTorch 模型数学等价,但**实际改变了 Qwen3-8B GGUF CLIP 的编码输出数值**,导致FLUX2 条件编码异常 → 采样偏离提示词、图片过曝泛白。

临时修复方案

修改 `ComfyUI\comfy\text_encoders\llama.py`,将两处(TransformerBlock 与 TransformerBlockGemma2)的 `torch.add(residual, x, out=output)` 恢复为 `x = residual + x`,并删除无用的 `output = x`:

```python
# Self Attention
residual = x
x = self.input_layernorm(x)
x, present_key_value = self.self_attn(...)
x = residual + x

# MLP
residual = x
x = self.post_attention_layernorm(x)
x = self.mlp(x)
x = residual + x # 恢复:原为 torch.add(residual, x, out=output)
```

Contributor guide

Open the contributing guide

Research direction

Start in comfy/text_encoders/llama.py and inspect TransformerBlock and TransformerBlockGemma2, especially the residual additions changed by the Cuda Graphs commit. Reproduce FLUX2 conditioning with a Qwen3-8B GGUF CLIP model, then verify that restoring the reported residual behavior prevents prompt deviation and overexposed output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.