LTX2 Model Patcher
Make SamplerCustomAdvanced and GGUF loaders behave
- model
- latent
- MODEL
Here's a genuinely weird LTX-2 bug: the model's forward() requires an attention_mask argument - with no default - but ComfyUI's advanced sampling path (SamplerCustomAdvanced) doesn't always pass one through. Result: "missing required argument" crashes on workflows that load the model with GGUF loaders and then sample custom. LTX2ModelPatcher patches the loaded model so this stops happening, plus handles the context-dimension slicing and a 3D-latent reshaping quirk. It's the "glue that makes non-standard sampling paths work" node of the kakachiex2/comfyui-ltx2-efficient pack.
How it works
You give it a MODEL, it clones it and wraps the diffusion model's forward() with a patched version that:
- Always passes
attention_mask- even when it'sNone. That satisfies LTX-2's required argument and makesSamplerCustomAdvancedand GGUF-loaded models stop exploding. - Slices context 7680 → 4096 - the same dual-encoder fix as
LTX2ConditioningHelper, applied at the model level instead of the conditioning level. Thecontext_slice_methoddropdown (Keep Last 4096 (Slot 2)/Keep First 4096 (Slot 1)/Auto-detect) picks which half to keep. - Reshapes 3D latents back to 5D -
SamplerCustomAdvancedcan hand the model a packed 3D latent, and LTX wants 5D. The node captures the original latent's shape from the optionallatentinput and rebuilds it.
The patcher keeps a _ltx2_patched flag on the model, so running the same model through it twice is a no-op rather than a double-wrap.
The inputs
model- the loaded LTX-2 model (GGUF viaUnetLoaderGGUF, or a normalUNETLoader).latent(optional) - wire your latent here so the patcher can capture its shape for the 3D→5D reconstruction. If you skip it and your path never produces 3D latents, it's not critical, but connecting it costs nothing.context_slice_method- same slot logic as the conditioning helper.
Output is a patched MODEL, which you route into your sampler - the author's guidance is to place it before SamplerCustomAdvanced.
[UnetLoaderGGUF] --MODEL--> [LTX2ModelPatcher] --MODEL--> [SamplerCustomAdvanced] --LATENT--> decode
Installation
It's part of the kakachiex2/comfyui-ltx2-efficient pack. ComfyUI Manager (search "LTX2 Efficient") or:
cd ComfyUI/custom_nodes/
git clone https://github.com/kakachiex2/comfyui-ltx2-efficient
cd comfyui-ltx2-efficient
pip install -r requirements.txt
Restart ComfyUI. No models or heavy deps - just the pack's optional pynvml.
Troubleshooting
- "Model already patched, skipping" - that's the no-op safety working; the output model is still valid.
- Still missing attention_mask errors - make sure the patched
MODELoutput is the one feeding your sampler, and that you didn't wire a second, unpatched model clone into the same spot. - Workflow uses the pack's own samplers instead - then you probably don't need this node;
LTX2EfficientSamplerProandLTX2EfficientSamplerbake in the same attention-mask handling. This standalone node exists for people who want to keepSamplerCustomAdvancedin the graph.
If you're on a GGUF + custom-sampler workflow and LTX-2 keeps throwing argument errors, this is a targeted fix. It's boring, it patches, and it gets out of the way.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| latentopt | LATENT | Connect your latent here to capture shape for 3D->5D reconstruction | |
| context_slice_methodopt | COMBO | Keep Last 4096 (Slot 2 - LTX Connector) | 3 options: Keep Last 4096 (Slot 2 - LTX Connector), Keep First 4096 (Slot 1 - T5), Auto-detect |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |