Nodes/comfyui-ltx2-efficient/LTX2 Model Patcher
ComfyUI Node

LTX2 Model Patcher

Make SamplerCustomAdvanced and GGUF loaders behave

By kakachiex2·Created 7 months ago·Updated 7 months ago· 10
LTX2 Model Patcher
  • model
  • latent
  • MODEL
context_slice_methodKeep Last 4096 (Slot 2 - LTX Connector)

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:

  1. Always passes attention_mask - even when it's None. That satisfies LTX-2's required argument and makes SamplerCustomAdvanced and GGUF-loaded models stop exploding.
  2. Slices context 7680 → 4096 - the same dual-encoder fix as LTX2ConditioningHelper, applied at the model level instead of the conditioning level. The context_slice_method dropdown (Keep Last 4096 (Slot 2) / Keep First 4096 (Slot 1) / Auto-detect) picks which half to keep.
  3. Reshapes 3D latents back to 5D - SamplerCustomAdvanced can hand the model a packed 3D latent, and LTX wants 5D. The node captures the original latent's shape from the optional latent input 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 via UnetLoaderGGUF, or a normal UNETLoader).
  • 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 MODEL output 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; LTX2EfficientSamplerPro and LTX2EfficientSampler bake in the same attention-mask handling. This standalone node exists for people who want to keep SamplerCustomAdvanced in 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.

CategoryLTX2-Video

Inputs (3)

NameTypeDefaultDescription
modelMODEL
latentoptLATENTConnect your latent here to capture shape for 3D->5D reconstruction
context_slice_methodoptCOMBOKeep 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)

NameTypeDescription
MODELMODEL