Nodes/ComfyUI-nunchaku/Nunchaku Text Encoder Loader V2
ComfyUI Node Runs on cloud

Nunchaku Text Encoder Loader V2

Load the 4-bit T5 encoder for Flux

By nunchaku-ai·Created about a year ago·Updated 6 months ago· 2,909
Nunchaku Text Encoder Loader V2
    • CLIP
    model_type
    text_encoder1
    text_encoder2
    t5_min_length512

    Everyone obsesses over quantizing the diffusion model and forgets the text encoder is sitting right there eating VRAM too. On Flux that encoder is T5-XXL, and it's not small. NunchakuTextEncoderLoaderV2 loads Flux's text encoders - including Nunchaku's 4-bit T5 - and hands you a CLIP output, freeing memory the checkpoint can actually use.

    This is the current, cleaned-up encoder loader (the older NunchakuTextEncoderLoader is deprecated). The reason it's worth caring about: the text encoder is its own separate file you load and quantize independently of the model, and on low-VRAM setups the encoder quant is sometimes the decision that matters more than the model quant. Nunchaku's upgraded 4-bit T5 was called out in the pack's own release notes as matching fp8 T5 in quality - so you get the memory saving without the usual "the encoder made my prompts worse" tax.

    How it works

    Flux conditions on two encoders: CLIP-L for tag-style tokens and T5-XXL for natural language. This node loads both and packages them into the single CLIP object ComfyUI's text-encode nodes expect. The interesting slot is the T5 - point it at Nunchaku's 4-bit T5 build and you're running the big encoder at a quarter of its fp16 size. Point it at a normal fp8 or fp16 T5 and it still works; the node handles the loading either way.

    Because T5 reads whole sentences, this is the encoder that made Flux prompting natural-language rather than a soup of Danbooru tags. Keeping it at good quality is why the 4-bit-T5-that-matches-fp8 claim matters.

    The inputs and outputs that matter

    • model_type - fixed at flux.1. This loader is Flux-family.
    • text_encoder1 and text_encoder2 - your two encoder files (CLIP-L and T5). This is where you select the Nunchaku 4-bit T5 if you're using it. If a dropdown is empty, you haven't downloaded that encoder yet.
    • t5_min_length (default 512, range 256–1024, step 128) - the minimum token length T5 pads to. The 512 default is the standard Flux setting and you can leave it there; it exists mostly for edge cases where a specific length helps adherence.

    Output is a CLIP, which goes straight into your CLIP Text Encode (Prompt) nodes.

    How to install it

    Comes with the ComfyUI-nunchaku pack. ComfyUI Manager → search "ComfyUI-nunchaku" → install, or

    cd ComfyUI/custom_nodes
    git clone https://github.com/mit-han-lab/ComfyUI-nunchaku
    

    then restart. You'll also want the backend wheel (via NunchakuWheelInstaller) if you're running Nunchaku's 4-bit T5, and the encoder files themselves in models/text_encoders (or models/clip) - the 4-bit T5 comes from Nunchaku's HuggingFace, a standard fp16/fp8 T5 from the usual Flux sources.

    Common issues & troubleshooting

    Empty encoder dropdowns. No encoder files in your text_encoders folder. Download at least CLIP-L plus a T5 (4-bit, fp8, or fp16).

    Prompts feel weaker after switching to 4-bit T5. Nunchaku's 4-bit T5 is designed to hold fp8-level quality, but if you dropped from fp16 you may notice a hair of difference on very fine wording. It's usually the right trade for the VRAM; if you have the memory, an fp16 T5 loads here fine too.

    Use the V2, not the old one. The deprecated NunchakuTextEncoderLoader had extra toggles (use_4bit_t5, int4_model) that this V2 tidied away. New graphs should use this node.

    It loaded but sampling still OOMs. The encoder is only half the footprint - pair it with a quantized NunchakuFluxDiTLoader and, if needed, turn on that loader's cpu_offload.

    CategoryNunchaku

    Inputs (4)

    NameTypeDefaultDescription
    model_typeCOMBO1 options: flux.1
    text_encoder1COMBO0 options:
    text_encoder2COMBO0 options:
    t5_min_lengthINT512256–1024Minimum sequence length for the T5 encoder.

    Outputs (1)

    NameTypeDescription
    CLIPCLIP