Ethanfel 97954cd06e Fix shared tensor warning by cloning before save
Aliased tensors (patch_embedding / expanded_patch_embedding /
original_patch_embedding) share memory, causing safetensors
save_file to warn about duplicates. Clone each tensor to break
sharing while keeping all keys for loader compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 18:18:34 +01:00
2026-02-10 17:46:27 +01:00

ComfyUI WanVideo Save Merged Model

A ComfyUI custom node that saves a WanVideo Wrapper diffusion model — including merged LoRAs — as a standalone .safetensors checkpoint.

This lets you bake LoRA weights into a base model once and reload the result directly, without re-merging every time.

Installation

Clone or copy this repository into your ComfyUI custom_nodes directory:

cd ComfyUI/custom_nodes
git clone <repo-url> Comfyui_WW_msave

Restart ComfyUI. The node will appear under the WanVideoWrapper category.

Node: WanVideo Save Merged Model

Inputs

Input Type Required Description
model WANVIDEOMODEL Yes Model output from the WanVideo Model Loader node (with LoRA merged)
filename_prefix STRING Yes Filename for the saved file (default: merged_wanvideo)
save_dtype Dropdown No Cast weights before saving: same, bf16, fp16, fp32. Defaults to same (keeps current dtype). Set explicitly if the model was loaded in fp8.
custom_path STRING No Absolute path to a save directory. Leave empty to save in ComfyUI/models/diffusion_models/

Usage

  1. Set up the WanVideo Model Loader with a base model and one or more LoRAs (with merge_loras enabled)
  2. Connect the model output to WanVideo Save Merged Model
  3. Set a filename prefix and optionally choose a dtype and save path
  4. Queue the prompt — the merged checkpoint will be saved as <filename_prefix>.safetensors
[WanVideo Lora Select] --> lora
                             |
[WanVideo Model Loader] --> model --> [WanVideo Save Merged Model]

The saved file can then be loaded directly by the WanVideo Model Loader as a regular diffusion model, without needing the original LoRA files.

Metadata

The saved .safetensors file includes metadata for traceability:

  • source_model — name of the base model
  • merged_loras — JSON list of merged LoRA names and strengths
  • save_dtype — dtype used when saving

You can inspect this metadata with any safetensors viewer or with Python:

from safetensors import safe_open
with safe_open("merged_wanvideo.safetensors", framework="pt") as f:
    print(f.metadata())

Notes

  • Existing files are never overwritten — a counter suffix (_1, _2, ...) is appended automatically
  • The custom_path input only accepts absolute paths; relative paths are ignored and the default location is used
  • Saving a 14B model in bf16 produces a ~28 GB file — make sure you have enough disk space
  • If the model was quantized to fp8, use save_dtype to cast back to bf16 or fp16 for a more portable checkpoint

Requirements

License

MIT

Description
No description provided
Readme 30 KiB
Languages
Python 100%