SeedVR2-1.4B / comfyui /seedvr2_1.4b_detection.patch
lvladikov's picture
Upload 324 files
7694e0f verified
Raw
History Blame Contribute Delete
4.17 kB
SeedVR2-1.4B β€” ComfyUI native support patch (MANUAL ALTERNATIVE β€” most people want the folder)
================================================================================================
>>> PREFER `ComfyUI-SeedVR2-1.4B/` INSTEAD OF THIS FILE. <<<
>>>
>>> Copy that folder into ComfyUI/custom_nodes/ and restart. It does everything this patch does
>>> WITHOUT editing any ComfyUI source file (so it survives updates), and it ALSO adds a
>>> single-frame VAE fast path worth 3-4.6x on decode. This file is kept only for people who
>>> would rather edit one line of ComfyUI than install a folder into custom_nodes/.
>>>
>>> Apply ONE of the two, never both.
WHAT THIS IS
------------
ComfyUI has native SeedVR2 support. It works out which architecture to build by inspecting the
checkpoint in `comfy/model_detection.py`, and every existing branch keys on `blocks.31` or
`blocks.35`. This model has six blocks (0-5), so no branch matches and the model will not load.
This patch adds one branch that recognises it. Nothing else changes.
The values are not guesses β€” they are the existing 7B "separate key" branch with the depth changed,
and each was cross-checked against the published weights:
vid_dim 3072 <- blocks.0.ada.vid.attn_gate has shape [3072]
heads 24 <- 24 x head_dim 128 = 3072 = vid_dim
num_layers 6 <- the checkpoint has blocks.0 .. blocks.5 and no others
mm_layers 6 <- every block carries BOTH .vid. and .txt. streams (31 tensors each)
mlp_type "normal" <- keys are mlp.vid.proj_in, NOT mlp.vid.proj_in_gate (which would be swiglu)
rope_type "rope3d", rope_dim 64, norm_eps 1e-5 <- unchanged from the 7B branch
The guard matters: it requires `blocks.5` to be PRESENT and `blocks.6` to be ABSENT, so it cannot
capture the real 7B (which has blocks 0-35) or the 3B (blocks 0-31).
HOW TO APPLY
------------
Edit `comfy/model_detection.py` in your ComfyUI install. Find this line (search for "seedvr2_7b_separate_key"):
seedvr2_7b_separate_key = "{}blocks.35.mlp.vid.proj_out.weight".format(key_prefix)
Insert the block below IMMEDIATELY BEFORE that line, at the same indentation (4 spaces).
THE PATCH
---------
# SeedVR2-1.4B β€” 6-layer distillation of the 7B.
# Same architecture as the 7B separate-key variant below (vid_dim 3072, heads 24, separate
# vid/txt MMModule keys in every block, non-gated MLP) but 6 blocks instead of 36.
seedvr2_1_4b_key = "{}blocks.5.mlp.vid.proj_out.weight".format(key_prefix)
if (seedvr2_1_4b_key in state_dict_keys
and "{}blocks.6.mlp.vid.proj_out.weight".format(key_prefix) not in state_dict_keys
and state_dict[seedvr2_1_4b_key].shape[0] == 3072):
dit_config = {}
dit_config["image_model"] = "seedvr2"
dit_config["vid_dim"] = 3072
dit_config["heads"] = 24
dit_config["num_layers"] = 6
dit_config["mm_layers"] = 6
dit_config["norm_eps"] = 1e-5
dit_config["rope_type"] = "rope3d"
dit_config["rope_dim"] = 64
dit_config["mlp_type"] = "normal"
return dit_config
WHERE TO PUT THE MODEL FILES
----------------------------
seedvr2_distill_6L_1.4B_sharp_fp16.safetensors -> ComfyUI/models/diffusion_models/
ema_vae_fp16.safetensors -> ComfyUI/models/vae/
Load the transformer with **Load Diffusion Model** (not Load Checkpoint β€” this is a bare diffusion
model, not a packaged checkpoint with bundled VAE/text-encoder/conditioning), and the VAE with
**Load VAE**. The `SeedVR2 Preprocess` / `SeedVR2 Conditioning` / `SeedVR2 PostProcessing` nodes then
work exactly as they do for the stock SeedVR2 models.
STATUS
------
VERIFIED. With this patch applied, ComfyUI's own detect_unet_config() reads the checkpoint and
returns:
image_model seedvr2
num_layers 6
mm_layers 6
vid_dim 3072
heads 24
mlp_type normal
rope_type rope3d
rope_dim 64
i.e. it builds the correct architecture. Tested against ComfyUI's real detection code, not a mock.
If ComfyUI upstream adds official support for this model, prefer that over this patch.