Nodes/ComfyUI_MS_Diffusion/MS-Diffusion Loader (Native)
ComfyUI Node

MS-Diffusion Loader (Native)

A Dropdown That's Only Ever Supposed to Offer One File

By smthemex·Created 2 years ago·Updated about a month ago· 58
MS-Diffusion Loader (Native)
    • ms_adapter
    ◄ms_adapter▾►

    Three nodes in this pack and this is the boring one: a file picker with an output. You add it because nothing else in the graph can start without it, and there is exactly one correct answer in the dropdown.

    It's worth understanding anyway, because the two ways it fails are both "you picked the wrong file" and the error message for one of them is genuinely good.

    What it's loading

    ms_adapter.bin, the adapter weights from the MS-Diffusion paper - the thing that turns a stock SDXL UNet into a multi-subject, layout-guided UNet. Structurally it's a sibling of IP-Adapter: a small pile of extra cross-attention key/value projections, one pair per attn2 layer, plus an image projection stack. On stock SDXL that's 70 to_k_ip / to_v_ip pairs.

    The loader reads the checkpoint with torch.load(..., weights_only=True), pulls the shapes out of those 70 projections, and builds the module structure to match before anything runs. That's the nice part of the design: a mismatched or truncated file dies here, at load, instead of halfway through your first sample. It also prints how many cross-attention groups it found, so you can see at a glance that it got 70 and not something odd.

    No diffusers, no transformers, no huggingface hub calls. The upstream MS-Diffusion repo needs diffusers and transformers and einops and omegaconf just to instantiate its models; this port reimplemented the inference path in plain torch, so the pack ships with an empty dependency list. That's why installing it is a git clone and a restart rather than twenty minutes of pip resolving conflicts against your torch build - a rare mercy in this corner of the ecosystem.

    Inputs and outputs

    One input: ms_adapter, a dropdown. One output: ms_adapter, an MS_ADAPTER object.

    The dropdown lists every .bin, .safetensors, .pt, .pth and .ckpt file it can find in both models/photomaker and models/ipadapter, because the upstream plugin hard-coded photomaker while most people's file ends up in ipadapter. Files whose name starts with ms_adapter are sorted to the top so the default selection is the right one.

    The output fans out to two places, and it's the same object both times: MSDiffusionConditioning uses the image projection to turn your reference images into tokens, and MSDiffusionApply uses the per-layer key/value projections to inject them. One loader, two wires, done.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/smthemex/ComfyUI_MS_Diffusion
    

    Restart ComfyUI (Manager can install it too - search the pack title). Then grab ms_adapter.bin from doge1516/MS-Diffusion and drop it in either:

    ComfyUI/models/photomaker/ms_adapter.bin
    ComfyUI/models/ipadapter/ms_adapter.bin
    

    The README names photomaker; the code registers both, so pick whichever folder you actually keep adapter weights in. Restart (or refresh your node definitions) and the dropdown should populate. The folder list is built when the node registers its paths, so a file dropped in while ComfyUI is running may not appear until you restart.

    You'll also need an SDXL checkpoint and clip_vision_g.safetensors, but those are other nodes' problems.

    When it doesn't work

    The dropdown only says none. The node found no adapter files in either folder. Wrong directory, or an extension it doesn't scan, or you renamed it .gguf. Selecting none and hitting run gives you a clear no ms_adapter.bin found in models/ipadapter or models/photomaker.

    "is not an ms_adapter.bin checkpoint (needs 'image_proj', 'ms_adapter' and 'dummy_image_tokens' groups)." This is the good error. Your models/ipadapter folder is almost certainly full of ordinary IP-Adapter weights, and the dropdown happily lists them all because they share the folder and the extensions. Picking ip-adapter-plus_sdxl_vit-h.safetensors looks plausible and is completely wrong - it's a different architecture with different tensor names. Read the filename: you want ms_adapter.bin, and nothing else in that folder is it.

    It loads fine and then Apply throws a layer-count error. The adapter is fine; the model isn't stock SDXL-shaped. This loader doesn't validate the UNet - it can't, it never sees one - so an architecture mismatch surfaces at the next node instead of here. If you're getting "UNet has N attn2 modules but the checkpoint has 70 adapter groups," go look at your checkpoint, not your adapter.

    Weight loading fails outright. weights_only=True means the file has to be a plain tensor dict. A pickled pickle, or a diffusers-style folder you zipped into a .bin, won't load. Re-download the original file.

    CategoryMSdiffusion/Native

    Inputs (1)

    NameTypeDefaultDescription
    ms_adapterCOMBO1 options: none

    Outputs (1)

    NameTypeDescription
    ms_adapterMS_ADAPTER—