Z-Image Comfy Injector
The bridge that turns raw weights back into a sampler-ready model
- 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) → theMODELoutput.raw_clip(RAW_CLIP) → theCLIPoutput.
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) → ZImageComfyInjector → MODEL/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.pathas the filename. A raw wrapper built by a merge node has a synthetic path likemerged_model.safetensors- fine, because the patchedload_torch_fileintercepts 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_modelwon't understand. UseZImageGGUFInjectorfor 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.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| raw_modelopt | RAW_MODEL | — | |
| raw_clipopt | RAW_CLIP | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| CLIP | CLIP | — |