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.

Support LynnReal light Minimax-H3 vae (#16657)

Jukka Seppänen986c4d154ef8
diff --git a/comfy/ldm/minimax/vae.py b/comfy/ldm/minimax/vae.py
index ffb358463..53b5ccb75 100644
--- a/comfy/ldm/minimax/vae.py
+++ b/comfy/ldm/minimax/vae.py
@@ -426,6 +426,7 @@ class MiniMaxH3VideoVAE(nn.Module):
tile_overlap_min=64,
tiling=True,
operations=ops,
+ num_layers=36,
):
super().__init__()
self.vae_ratio = int(math.prod(space_down))
@@ -461,6 +462,7 @@ class MiniMaxH3VideoVAE(nn.Module):
patch_size_t=self.vae_ratio_t,
in_channels=z_channels,
out_channels=out_ch,
+ num_layers=num_layers,
operations=operations,
)
diff --git a/comfy/sd.py b/comfy/sd.py
index 73a35aaa4..50176f79c 100644
--- a/comfy/sd.py
+++ b/comfy/sd.py
@@ -1031,7 +1031,8 @@ class VAE:
minimax_quant = comfy.utils.detect_layer_quantization(sd, "")
if minimax_quant is not None: # int8+convrot quantized decoder
minimax_ops = comfy.ops.mixed_precision_ops(minimax_quant, dtype if dtype is not None else torch.float16)
- self.first_stage_model = comfy.ldm.minimax.vae.MiniMaxH3VideoVAE(operations=minimax_ops)
+ minimax_layers = sum(k.startswith("decoder.transformer_blocks.") and k.endswith(".scale1") for k in sd)
+ self.first_stage_model = comfy.ldm.minimax.vae.MiniMaxH3VideoVAE(operations=minimax_ops, num_layers=minimax_layers)
self.latent_channels = 24
self.latent_dim = 3
# frames 17k+5 <-> latents 5k+2, 16x spatial