Nodes/ComfyUI GLM-4 Wrapper/GLM-4 Model Loader
ComfyUI Node

GLM-4 Model Loader

The tollbooth at the front of every GLM-4 workflow

By Nojahhh·Created 2 years ago·Updated about a year ago· 30
GLM-4 Model Loader
    • GLMPipeline
    model
    precisionbf16
    quantization4

    Every workflow built from this pack starts here. GLM-4 Model Loader is the node that picks which model you're running, downloads it if it isn't on disk, and hands the loaded model to the pack's other two nodes under a single GLMPipeline output. On its own it does nothing visible - no text, no image, no prompt. It's the engine room, and it's where you make the decisions that decide whether the rest of the pack fits in your VRAM or chokes.

    How it works

    Under the hood it's a thin wrapper around Hugging Face Transformers. You choose a model, a precision, and a quantization, and it builds the pipeline on first use via AutoModelForCausalLM (or Qwen2_5_VLForConditionalGeneration for the Qwen choices). Quantization uses BitsAndBytesConfig for 4/8-bit; the GPTQ models load through trust_remote_code from their Hugging Face repo. Everything is device_map="auto", so it spreads across your GPUs if you have more than one.

    Two things worth internalizing. First, the model caches once loaded - run the workflow twice and the second run skips the load entirely, which is why the pack's unload_model toggle on the downstream nodes exists. Second, the model downloads to Hugging Face's cache folder, not ComfyUI's models directory. You don't download GLM weights by hand; the loader fetches them on first load. There's no progress bar in the node, so the first run looks frozen. It isn't.

    Inputs that matter

    • model - 11 choices across the GLM-4 and Qwen 2.5 families. The ones you'll actually pick between:
      • THUDM/glm-4-9b (and the -chat, -chat-1m, LongCite, LongWriter variants) - text only, ~18 GB disk. The plain glm-4-9b isn't chat-tuned, so for the Inferencing node you want glm-4-9b-chat.
      • THUDM/glm-4v-9b - the vision model, ~26 GB disk, needs bf16 and defaults to 4-bit (it needs over 28 GB VRAM in 16-bit, ~11 GB at 4-bit). This is the one that accepts images.
      • alexwww94/glm-4v-9b-gptq-4bit / -gptq-3bit - the same vision model pre-quantized, ~8.5 / 7.6 GB disk. Significantly friendlier on both disk and VRAM, at the price of the auto-gptq install.
      • Qwen/Qwen2.5-VL-* - the 2025 addition; vision-capable and noticeably smaller (3B / 7B).
    • precision - fp16, fp32, bf16. The vision GLM models require bf16; the text GLM models take anything.
    • quantization - 4, 8, or 16 bits. The catch: it only applies to the vision GLM model and the Qwen VL models. The text-only GLM models ignore it and load fp16, and the GPTQ models are already quantized, so this setting is bypassed there too. The default of 4 is the right call for the vision model on any consumer GPU.

    The single output, GLMPipeline, wires into the GLMPipeline input of GLM-4 Prompt Enhancer and GLM-4 Inferencing - one loader can feed both.

    Installing it

    This node ships in the ComfyUI GLM-4 Wrapper pack, so ComfyUI Manager (search "GLM-4") handles it, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Nojahhh/ComfyUI_GLM4_Wrapper
    cd ComfyUI_GLM4_Wrapper
    python -m pip install -r requirements.txt
    

    Restart ComfyUI after. That requirements.txt is the pack's real footprint, and it's heavy: transformers pinned to the GitHub source, bitsandbytes, accelerate, optimum, sentence-transformers, plus a numpy==1.26.4 pin that can force a downgrade in an environment with newer packages. If you plan to use the GPTQ vision models, also run pip install auto-gptq - on Windows that typically means building from source to get the CUDA extensions, which is where a lot of people give up.

    Where people get burned

    Model choice is the whole game. Pick a text model and the image input on the downstream nodes silently does nothing. Pick glm-4v-9b without bf16 and it errors. And remember the first load is a multi-gigabyte download with no progress bar - watch the console, not the node. If you're on a 12 GB card, the 4-bit GPTQ vision model is the sweet spot; on Windows, the 4-bit quantized glm-4v-9b is the lower-friction alternative.

    CategoryGLM4Wrapper

    Inputs (3)

    NameTypeDefaultDescription
    modelCOMBOChoose the GLM-4 model to load. Only glm-4v-9b, glm-4v-9b-gptq-4bit, glm-4v-9b-gptq-3bit, Qwen2.5-VL-3B-Instruct and Qwen2.5-VL-7B-Instruct models supports image input.
    precisionCOMBObf16Recommended precision for GLM-4 model. bf16 required for glm-4v-9b (4-/8-bit quant), glm-4v-9b-gptq-4bit and glm-4v-9b-gptq-3bit.
    quantizationCOMBO4Choose the number of bits for quantization. Only supported for glm-4v-9b model.

    Outputs (1)

    NameTypeDescription
    GLMPipelineGLMPipeline