# ComfyUI WanVideo Save Merged Model A ComfyUI custom node that saves a [WanVideo Wrapper](https://github.com/kijai/ComfyUI-WanVideoWrapper) 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: ```bash cd ComfyUI/custom_nodes git clone 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 `.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: ```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 - [ComfyUI](https://github.com/comfyanonymous/ComfyUI) - [ComfyUI-WanVideoWrapper](https://github.com/kijai/ComfyUI-WanVideoWrapper) ## License MIT