MUReplaceModelWeights
The '100% a hack' that saves your Stable-Fast recompile
- model
- MODEL
- CLIP
If you've ever run Stable-Fast (chengzeyi's C++ acceleration for ComfyUI inference) you know the deal: compiling a model once is a long wait, and every time you swap to a different checkpoint you're looking at that wait again, because ComfyUI builds a fresh model object and the compiled graph dies with the old one. MUReplaceModelWeights exists to dodge that. It swaps the weights of an already-loaded model in-place - same model object, same compiled graph, new numbers inside.
The author's own framing is the honest one: "It is 100% a hack, but it works and will save time if you change models often." The workflow is: load a checkpoint as usual, apply Stable-Fast to compile it, then use this node to "reapply" the weights of whatever checkpoint you actually want. Because the model object is never recreated, the compilation survives the swap and you skip the rebuild.
Mechanically, here's what it does under the hood. It takes your loaded model and a ckpt_name picked from a dropdown that's populated from your ComfyUI models/checkpoints folder (the node uses the standard folder_paths list, so anything in the usual place shows up). It loads that checkpoint's state dict, builds a fresh CLIP from it, then shoves the model.diffusion_model.* weights into the existing model via load_state_dict(..., strict=False). Two outputs come out: the MODEL with replaced weights and the freshly-loaded CLIP, so you get both halves of the checkpoint back.
The gotchas are all in the "hack" part. strict=False means mismatched shapes are silently ignored - so don't change the model type. The README is blunt about it: don't try to load SD1.5 weights into an SDXL model. Same family, same architecture, or you're getting garbage back with no error telling you why. It also won't help you with ComfyUI's newer compilation paths that key the compiled graph off the weights themselves - this trick is specifically aimed at the Stable-Fast / torch.compile world where the compiled object outlives the weights. And one more practical note: this is a "do it and trust it" node. If the checkpoint you point it at isn't compatible, the silent strict=False means you'll find out from the output, not from an exception.
The interface: model in, ckpt_name dropdown, MODEL and CLIP out. That's it. It's part of asagi4's six-node comfyui-utility-nodes pack - install through ComfyUI Manager (search "comfyui-utility-nodes") or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/asagi4/comfyui-utility-nodes
cd comfyui-utility-nodes
pip install -r requirements.txt
Restart and it's under "utils". Is it for everyone? No - if you don't use Stable-Fast, this node is a solution to a problem you don't have, and you can skip it. But if you're a serial checkpoint-swapper on a compiled model, a few seconds of weight-swapping beats a multi-minute recompile every single time.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| ckpt_name | COMBO | 0 options: |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| CLIP | CLIP | — |