Nodes/ComfyUI-Zlycoris/Z-Image Comfy Injector
ComfyUI Node

Z-Image Comfy Injector

The bridge that turns raw weights back into a sampler-ready model

By TripleHeadedMonkey·Created 7 months ago·Updated 7 months ago· 4
Z-Image Comfy Injector
  • raw_model
  • raw_clip
  • MODEL
  • CLIP

Every Zlycoris loader outputs RAW_MODEL and RAW_CLIP - and none of those raw wrappers can go into a KSampler. ZImageComfyInjector is the exit ramp: it takes the raw state dicts, rebuilds them into a real ComfyUI MODEL and CLIP, and hands you something you can actually sample with. If you've been following the pack's philosophy so far - everything stays raw until the last second so it can be merged and patched freely - this is the node that makes that philosophy usable.

How it works

The clever bit: instead of reimplementing ComfyUI's model loading, the node reaches in and monkey-patches comfy.utils.load_torch_file to return the raw state dict it already has, then calls ComfyUI's own load_diffusion_model and load_clip. So you get ComfyUI's genuine model construction - weight layouts, patches, the works - with your in-memory state dict as the source. No temp files, no re-reading from disk.

Both inputs are optional, which is deliberate:

  • raw_model (RAW_MODEL) → the MODEL output.
  • raw_clip (RAW_CLIP) → the CLIP output.

Leave one unplugged and it just doesn't inject that half. So a workflow that only patched the transformer still gets a working MODEL, and you supply the CLIP however you like.

The full round trip

For a normal Z-Image render the flow is: ZImageLoaderAndPatcher → (merge/stack/whatever you want in raw land) → ZImageComfyInjectorMODEL/CLIP → sampler. The injector is also the natural home for raw output from ZImageRawModelMerge, ZImageRawClipMerge, or ZImageComfyUninjector - the "raw" universe is where all of Zlycoris's interesting surgery happens, and this node is the only way back to renderable reality. If you're running GGUF files, use ZImageGGUFInjector instead - it does the same job with the GGML ops the quantized weights need. Don't use the Comfy injector for GGUF raw output.

Install

ComfyUI Manager (search ComfyUI-Zlycoris) or:

cd ComfyUI/custom_nodes
git clone https://github.com/TripleHeadedMonkey/ComfyUI-Zlycoris.git

Restart ComfyUI. No models, no extra downloads.

Where people get burned

  • The raw wrapper carries a path, and it matters. The injector calls ComfyUI's loader with raw_model.path as the filename. A raw wrapper built by a merge node has a synthetic path like merged_model.safetensors - fine, because the patched load_torch_file intercepts the read. But if something upstream produced a raw wrapper with a missing path, the loader can fail oddly. Keep the chain inside the pack's own nodes and you're safe.
  • Injection is real model construction - it costs load time and VRAM. The first injection after a patch isn't free; it's the same work ComfyUI does when you load a checkpoint. Don't chain a dozen injectors in one graph.
  • This is not for quantized raw data. GGUF raw state dicts carry GGML tensor types that the standard injector's load_diffusion_model won't understand. Use ZImageGGUFInjector for anything that came out of the GGUF standalone loader.
  • Both inputs optional means it's easy to wire only half and end up with a missing CLIP. Double-check both sockets if your sampler complains about a missing model or encoder.
CategoryZ-Image/Loaders

Inputs (2)

NameTypeDefaultDescription
raw_modeloptRAW_MODEL
raw_clipoptRAW_CLIP

Outputs (2)

NameTypeDescription
MODELMODEL
CLIPCLIP