Nodes/Comfyui-DiffusersUtils/Diffusers Generate Prior Tokens Debug
ComfyUI Node

Diffusers Generate Prior Tokens Debug

The GLM prior-token node that runs in your face instead of a subprocess

By lrzjason·Created 9 months ago·Updated 8 months ago· 14
Diffusers Generate Prior Tokens Debug
  • diffusers_cond
  • image
  • diffusers_cond
model_pathF:/HF_Models/GLM/GLM-Image
promptMasterpiece, best quality, 8k uhd, photo realistic,
width1024
height1024

This is the debug twin of DiffusersGenPriorTokens. Same job, same inputs, same output - but instead of shelling out to an isolated Python subprocess to generate GLM-Image's prior tokens, it runs the whole thing inside ComfyUI's own process. That one difference is the entire point of its existence.

When do you reach for it? When the normal node fails. The non-debug version deliberately spawns a separate interpreter to keep the autoregressive stage isolated from whatever ComfyUI has loaded - but that isolation is exactly what goes wrong when your environments disagree. If the subprocess can't import the GLM classes (diffusers, transformers, or peft versions mismatched between your venv and what sys.executable resolves to), you get a cryptic traceback with no real way to poke at it. Swapping in this node runs the identical generate_prior_tokens() call directly in your main process. If it works there, your pack and model are fine and the problem is subprocess environment plumbing. If it also fails, you've narrowed it to the pack or the model install itself.

Inputs and output

Identical to its sibling: model_path (full path to the GLM-Image directory), the required diffusers_cond from DiffusersTextEncode, a prompt, optional image for image-to-image, and width/height (256–4096, step 64). It returns the same augmented diffusers_cond with prior_tokens, width, and height folded in, ready for DiffusersSampling.

There is one real behavioral difference beyond the subprocess: the debug version loads the minimal pipeline (text/vision components only) through the standard from_pretrained path with bfloat16 right there in the node, and it doesn't force the fixed seed-42 that the isolated script sets. In practice you won't notice - you're here to diagnose, not to match output.

Install

Same pack, same rules: ComfyUI Manager → "Comfyui-DiffusersUtils", or

cd ComfyUI/custom_nodes
git clone https://github.com/lrzjason/Comfyui-DiffusersUtils

then restart, plus the GLM-specific git installs of transformers, diffusers, and peft:

pip install git+https://github.com/huggingface/transformers.git
pip install git+https://github.com/huggingface/diffusers.git
pip install git+https://github.com/huggingface/peft.git

Remember the README's requirements.txt step is a mirage - there's no such file in the repo.

The honest take

This is a diagnostic node, not a daily-driver. Once you've confirmed the subprocess variant is healthy, go back to DiffusersGenPriorTokens and leave this one in the drawer - running the AR stage in-process means a memory-hungry model loads into ComfyUI's context and lingers. But when GLM-Image "just won't import," this is the fastest way to tell whether the pack is broken or your Python is.

CategoryDiffusers/GLM

Inputs (6)

NameTypeDefaultDescription
model_pathSTRINGF:/HF_Models/GLM/GLM-Image
diffusers_condDIFFUSERS_COND
promptSTRINGMasterpiece, best quality, 8k uhd, photo realistic,
imageoptIMAGE
widthoptINT1024256–4096
heightoptINT1024256–4096

Outputs (1)

NameTypeDescription
diffusers_condDIFFUSERS_COND