ComfyUI Node

T5Gemma Loader

Load the encoder half of Google's T5Gemma as your SDXL text encoder

By NeuroSenko·Created about a year ago·Updated 10 months ago· 68
T5Gemma Loader
    • model
    • tokenizer
    • info
    model_name
    deviceauto
    force_reloadfalse

    T5GEMMALoader is the pack's second model-loader branch, and it loads something different from the Gemma one. Where LLMModelLoader grabs a full causal LLM, this node pulls in T5GemmaEncoderModel - the encoder half of Google's T5Gemma-4B, the encoder-decoder sibling in the Gemma 3 family. Same job (produce the LLM_MODEL + LLM_TOKENIZER that the encoder node wants), different architecture, and a notably bigger hidden size that the adapter chain has to account for.

    Why would you bother with the T5Gemma branch at all? T5-style encoders are a different breed from decoder-only LLMs: no chat template, no causal masking, just an encoder reading the whole prompt at once and producing a representation for every token. That's structurally closer to what SDXL's CLIP encoders did, so it's a natural fit for the "replace the CLIP encoders" idea. The type: t5gemma preset in LLMAdapterLoader (llm_dim 2304, versus 1152 for Gemma) exists specifically to match this model's hidden states - that 2x dimension jump is the whole difference you need to respect.

    What it does

    T5GEMMALoader scans ComfyUI/models/llm/ for model directories (same folder convention as the other loaders), then loads the chosen one with T5GemmaEncoderModel.from_pretrained at bfloat16, is_encoder_decoder=False, plus the matching tokenizer. Same controls as its siblings:

    • model_name - dropdown of LLM folders in models/llm/.
    • device - auto (default), cuda:0, cuda:1, or cpu.
    • force_reload - off by default; the loader caches the model and only re-reads when the path changes.

    Outputs: model (LLM_MODEL), tokenizer (LLM_TOKENIZER), and info (STRING with path/device/loaded status).

    How it fits in

    The T5Gemma chain swaps in cleanly:

    T5GEMMALoader → T5GEMMATextEncoder → t5gemmaApplyLLMToSDXLAdapter → KSampler
                        ↑                      ↑
       LLMAdapterLoader (type: t5gemma) ──────┘
    

    That type: t5gemma in the adapter loader is non-negotiable - it's what sets the 2304-dim projection. Wire a Gemma-type adapter into this branch and the shapes won't match. Note this branch also needs its adapter weights; the README's documented adapter is the Gemma one, so the T5Gemma path is more "here's the plumbing, weights on you" territory.

    Install

    Ships with the ComfyUI LLM SDXL Adapter pack. ComfyUI Manager → search "ComfyUI LLM SDXL Adapter", or git clone https://github.com/NeuroSenko/ComfyUI_LLM_SDXL_Adapter.git into ComfyUI/custom_nodes/, restart. Dependencies: transformers>=4.53.1 (the version that has T5GemmaEncoderModel), einops, safetensors, torch. The T5Gemma model itself goes in ComfyUI/models/llm/.

    Troubleshooting

    • "T5GemmaEncoderModel not found" - your transformers is too old. The pack pins >=4.53.1; upgrade.
    • Empty model_name dropdown - same folder rules as the other loaders: the directory needs a config.json.
    • Adapter mismatch downstream - you loaded a Gemma-type adapter. Switch LLMAdapterLoader to t5gemma.
    Categoryllm_sdxl

    Inputs (3)

    NameTypeDefaultDescription
    model_nameCOMBO0 options:
    deviceoptCOMBOauto4 options: auto, cuda:0, cuda:1, cpu
    force_reloadoptBOOLEANfalse

    Outputs (3)

    NameTypeDescription
    modelLLM_MODEL
    tokenizerLLM_TOKENIZER
    infoSTRING