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.

Fix minimax vae offload issue. (#16698)

comfyanonymous83071e1aec31
diff --git a/comfy/ldm/minimax/vae.py b/comfy/ldm/minimax/vae.py
index 53b5ccb75..f4dd9ae89 100644
--- a/comfy/ldm/minimax/vae.py
+++ b/comfy/ldm/minimax/vae.py
@@ -269,7 +269,8 @@ class FeedForward(nn.Module):
def forward(self, x, pre_norm, residual, residual_scale):
# norm, gated silu and residual addcmul fold into the INT8 kernels
- h = comfy.ops.linear_input_act(self.w1, x, "rms_norm", pre_norm.weight, pre_norm.eps)
+ with comfy.ops.CastBiasWeightContext(pre_norm if pre_norm.weight is not None else None, x, offloadable=True) as (weight, bias):
+ h = comfy.ops.linear_input_act(self.w1, x, "rms_norm", weight, pre_norm.eps)
return comfy.ops.linear_input_act(
self.w2, h, "swiglu", residual=residual, residual_scale=residual_scale)
@@ -290,7 +291,8 @@ class Attention(nn.Module):
def forward(self, x, rotary_pos_emb, pre_norm, residual, residual_scale):
batch_size, seq_len, _ = x.shape
- qkv = comfy.ops.linear_input_act(self.to_qkv, x, "rms_norm", pre_norm.weight, pre_norm.eps)
+ with comfy.ops.CastBiasWeightContext(pre_norm if pre_norm.weight is not None else None, x, offloadable=True) as (weight, bias):
+ qkv = comfy.ops.linear_input_act(self.to_qkv, x, "rms_norm", weight, pre_norm.eps)
qkv = qkv.view(batch_size, seq_len, -1, 3 * self.dim_head)
query, key, value = torch.chunk(qkv, 3, dim=-1)