Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Clamp Qwen Image 2.1 fp16 activations in place. (#16608)

Davide bert47e63a20a4cb
diff --git a/comfy/ldm/qwen_image21/model.py b/comfy/ldm/qwen_image21/model.py
index b4f0755e7..f38874ea2 100644
--- a/comfy/ldm/qwen_image21/model.py
+++ b/comfy/ldm/qwen_image21/model.py
@@ -145,7 +145,7 @@ class QwenImage21TransformerBlock(nn.Module):
x = _gated_residual(x, self.attn(_modulated_norm(self.img_norm1, x, scale1, prefix_len, zero), pe, attn_fn, prefix_len, transformer_options), gate1, prefix_len)
x = _gated_residual(x, self.img_mlp(_modulated_norm(self.img_norm2, x, scale2, prefix_len, zero)), gate2, prefix_len)
if x.dtype == torch.float16:
- x = x.clip(-65504, 65504)
+ x.clamp_(-65504, 65504)
return x