Nodes/comfyui-toml-prompt/UNETLoaderFromString
ComfyUI Node

UNETLoaderFromString

A Diffusion-Model Loader You Can Drive With Text

By morino-kumasan·Created 2 years ago·Updated a day ago· 1
UNETLoaderFromString
    • MODEL
    unet_name

    If you've ever wanted your workflow to pick the base model for you - from a text file, a batch queue, or a link coming out of another node - this is the node that does it.

    In core ComfyUI, loading a diffusion model (Flux, SD3, Qwen-Image, Wan 2.2, and everything else that ships as a bare UNET rather than a full checkpoint) means the UNETLoader in advanced/loaders. It gives you a dropdown listing every file in ComfyUI/models/diffusion_models, and you pick one with the mouse. That's fine when you're swapping models by hand. It's useless when the filename lives somewhere else.

    UNETLoaderFromString from morino-kumasan/comfyui-toml-prompt is the version that takes the filename as a string instead. Same job, different plumbing: the value can arrive over a wire, which is the whole point of this pack - its headline feature is a system that reads prompts, seeds, sampler settings and model names out of a TOML text file, so of course it can't have a dropdown in the middle of it. You don't need any of the rest of the pack to use this node, though.

    How it works

    Under the hood it's a thin wrapper. It resolves your string against the diffusion_models folder and calls ComfyUI's own loader:

    unet_path = folder_paths.get_full_path_or_raise("diffusion_models", unet_name)
    model = comfy.sd.load_diffusion_model(unet_path, model_options={})
    

    Three things follow from that.

    The string has to be exactly right. No file list, no validation, no "did you mean". Subfolders are part of the name, so wan\wan2.2_high_noise.safetensors on Windows or wan/wan2.2_high_noise.safetensors on Linux - and case matters on Linux. Get it wrong and the node fails at run time with a missing-file error, not with a red outline before you queue.

    There's no weight_dtype control. The core loader lets you force a dtype at load time; this one passes empty model_options, so the model loads at whatever precision the file declares. For the fp8_scaled files that basically everything ships as now (see the concepts essay on quantization), that's fine - that's what you want. If your workflow depends on forcing a cast, keep the core node.

    There's a two-model cache, and it's the real reason this node exists. The source keeps a module-level cache of the last two loaded UNETs and the author's comment says it flat out: this was written so WAN 2.2 workflows wouldn't keep re-reading from disk. WAN 2.2's two-pass architecture wants a high-noise model and a low-noise model loaded at once - high-noise handles motion and composition, low-noise refines detail - and when you alternate between two filenames run after run, every pass asks for a fresh read of a multi-gigabyte file. Here the second pass over the same name hands back the model object it already has. Ask for a third name and the oldest one gets evicted.

    Inputs and outputs

    One input: unet_name, a plain STRING. It renders as a text field you can type into, and it accepts a link - that's the feature. One output: MODEL ("the diffusion model"), which goes wherever a model goes: a LoRA loader, ModelSamplingSD3 (WAN's shift node), or straight into a sampler.

    The wiring worth copying is what the pack's own i2v.sample.json does. Two of these nodes, one per WAN expert, each fed by a JsonExtractString reading model_h / model_l out of the TOML prompt's export table, with the real filename sitting in the node's default field as a fallback. Then ModelSamplingSD3 (shift 5), then two KSamplerAdvanced passes at euler/simple, cfg 1, splitting at step 2 of 4. If you'd rather not wire anything, type the filename into the widget - it works identically, and the cache still does its job.

    Install

    ComfyUI Manager: search comfyui-toml-prompt. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/morino-kumasan/comfyui-toml-prompt
    

    Restart ComfyUI. That's the entire install. The README's pip install -r requirements.txt line is boilerplate - the shipped requirements.txt is literally zero bytes, so there's nothing to install. The node lives under the loaders category, not advanced/loaders. No models ship with it; grab the weights yourself (the Comfy-Org repackaged Wan 2.2 fp8_scaled files are the usual pick) into ComfyUI/models/diffusion_models.

    Where people get burned

    The stale-model trap. The cache is keyed on the filename only. Re-download a model, overwrite it, keep the same name, and you'll still be rendering with the old weights until you restart ComfyUI. That one has eaten an afternoon for everyone who has used a cache like this.

    The memory tax. Two cached models are two model objects ComfyUI's memory manager can keep around. On a 12-16GB card running two 14B fp8 UNETs, the second slot is not free - the cache keeps both referenced by design. If you're tight on VRAM and you only ever load one model, the cache isn't buying you anything.

    It's not a GGUF loader. Low-VRAM WAN users are usually on GGUF quants, which load through the ComfyUI-GGUF pack. This is the safetensors path.

    Don't trust its description. Its own text says "Load checkpoint from string" - copy-paste from the checkpoint loaders it shares a file with. It loads a diffusion model. Search the node list by class name.

    Categoryloaders

    Inputs (1)

    NameTypeDefaultDescription
    unet_nameSTRING

    Outputs (1)

    NameTypeDescription
    MODELMODELThe diffusion model.