Nodes/ComfyUI-UtilsCollection/Gemma System Edit Text Encode (Advanced)
ComfyUI Node

Gemma System Edit Text Encode (Advanced)

Advanced Image-Edit Encoding With Gemma and Your Own System Prompt

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
Gemma System Edit Text Encode (Advanced)
  • clip
  • image_inputs
  • vae
  • CONDITIONING
prompt
system_prompt
vlm_resolutionFast (384)
vae_resolutionFast (1024)
ref_latent_modeoff
vae_dimension_multiple8

Editing models on the Gemma text-encoder lineage take the image and the edit instruction together, and how you feed that image matters as much as the words. UC_TextEncodeGemmaSystemEditAdvanced is the heavy-duty version of the Gemma system-edit encode: it takes a prompt, a custom system message, and one or more reference images, and it encodes them through two separate paths - a VLM semantic path and a VAE structural path - with a choice of how those combine. It's the "I actually want to control the reference handling" node.

What the two paths are

Gemma-3-based edit encoders are chat models: your edit request is a user turn, the image is the thing being edited. This node splits the image's influence into:

  • VLM path - the image resized to a chosen vlm_resolution (Fast 384 → XX-Large 1536, or Original) and fed to the vision-language encoder as visual tokens. This is the semantic understanding: what's in the picture.
  • VAE path - the reference latent, encoded by the connected vae at a vae_resolution (Ultra 512 → Detailed 1536 / Original). This is structural: the pixel-level scaffold the edit preserves.

ref_latent_mode decides how they combine: single/multi append the latents to the conditioning; parallel-single/parallel-multi run them in a separate conditioning stream so the reference can't semantically override your edit instruction. If you've ever had an edit where the model just re-drew the source image instead of applying your change, parallel mode is the fix. vae_dimension_multiple (8) aligns reference pixels to that multiple before encoding.

The inputs that matter

  • clip - the Gemma text encoder for your model.
  • prompt + system_prompt - the edit request, plus the role instruction (this is where the UC_SystemMessagePresets style presets plug in).
  • image_inputs - an autogrow set of image sockets, flattened in ascending order, with every frame of a connected batch becoming the next sequential input. This is the multiple-images feature the plain version lacks.
  • vae - optional, only needed if you use a reference-latent mode.

Output: one CONDITIONING tensor for your sampler.

Installing it

It's in ComfyUI-UtilsCollection (author: silveroxides):

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection

Restart ComfyUI, or install "ComfyUI-UtilsCollection" via Manager. Only opencv-python and typing-extensions come from the pack.

The honest warnings

This is the advanced node for a reason - if you're on a workflow that already works with the plain Gemma System Edit encode, you don't need it. The two most common missteps: using a VAE path resolution way above your actual reference (wasted VRAM, no quality gain), and forgetting that the Gemma encoder is enormous - on LTX-2 it's the 12B, ~22GB at fp16, and it's the first thing to OOM. If you hit OOM, quantize the encoder or bypass it, don't blame the node. And note the parallel-* modes change semantics, not just performance - pick them deliberately.

Categorymodel/conditioning

Inputs (9)

NameTypeDefaultDescription
clipCLIP
promptSTRING
system_promptSTRING
vlm_resolutionCOMBOFast (384)Resolution of the image passed to the VLM (semantic path). 'Fast' = 384x384, 'Balanced' = 512x512, 'Detailed' = 768x768, 'Large' = 1024x1024, 'X-Large' = 1280x1280, 'XX-Large' = 1536x1536, 'Original' uses native resolution.
vae_resolutionCOMBOFast (1024)Resolution of the reference latent encoded by the VAE (structural path).
ref_latent_modeCOMBOoffReference latent encoding mode. 'single'/'multi' append latents; 'parallel-single'/'parallel-multi' run them in a separate conditioning stream to prevent semantic override.
vae_dimension_multipleINT84–256Pixel multiple used to align reference images before VAE encoding.
image_inputsCOMFY_AUTOGROW_V3Images are flattened in ascending socket order; every image in a connected batch becomes the next sequential image input.
vaeoptVAE

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING