Checking how many agents are working

How this works
Contatti
← Blog
A cinematic photograph of an old brass telegraph key beside a coil of punched paper tape on a dark steel bench, in teal and steel with a warm amber light, the AMARBARO mark and wordmark centered over it.
✎post del blog

The text encoder: the part that reads your prompt

The short version

The text encoder is a separate model that turns a prompt into numbers once, its output can be cached per prompt, and a cache hit means the encoder does not need to be loaded again.

What this is about

When you type a prompt, the drawing model never sees your letters. A different model reads them first and turns them into numbers. That model is the text encoder. It is a quiet part of the system, but it can be one of the biggest files you load.

This article explains what it does, why it is big, and when you can unload it.

Why it matters

Two reasons. First, the encoder decides how well the model understands your words. If you wonder why a model ignores part of a prompt, the encoder is part of the answer. Second, the encoder uses memory. On a card with limited memory, you can free gigabytes by knowing when it is no longer needed.

How it works

Picture a picture model as a team of three. (For the whole story, see How AI makes a picture from words.)

  1. The text encoder reads your prompt and writes its meaning as a long list of numbers.
  2. The drawing model cleans noise into a picture, guided by those numbers.
  3. The VAE turns the finished working picture into pixels.

The encoder works once at the start. Its job is a bit like a translator who reads a letter, writes a summary for the artist, and goes home. The artist does the drawing.

The summary is called the conditioning. It has the same job every step of the way: it tells the drawing model what you asked for. The encoder does not run again at each step. That is why the encoder can be loaded, used and put away.

Why it is so big

An encoder has to understand language. It is a language model, the same family as a chat model, only used for reading. For our picture model, Z-Image Turbo, the encoder is Qwen3-4B, and it takes 4.8 GB. Our drawing model takes 11.3 GB, so the encoder is more than a third of that. For our video model, the encoder is Gemma and its numbers take 14.74 GB.

When we shrank the encoder to int8, which stores each number in one byte, a picture took 6.02 seconds instead of 6.52. A little speed, with the same composition. The full table is in A Z-Image picture in 1.7 seconds.

When can it be unloaded?

ComfyUI keeps the conditioning for prompts it has seen. If you run the same prompt again, it can reuse the saved numbers and skip the encoder. We measured that on our video server:

  • Cache miss: the encoder loads for each new prompt, and a warm shot took 85 seconds.
  • Cache hit: the encoder was never loaded. RAM after a shot was 3.1 GB, not 31.7 GB, and a warm shot took 49 seconds.
  • Cache off: memory stayed flat at 2.9 GB, the picture was identical, and a shot took 61 seconds, in a range of 54 to 67.

So the encoder is needed only when you give a new prompt. Once the numbers are saved, it can go. The catch is that a cache entry can keep a reference to the encoder and hold it in memory anyway. That was our problem: the Gemma encoder stayed in RAM between prompts. Our post A cache that holds 14 gigabytes of encoder shows how we found it, and Why making pictures needs so much memory shows the sizes of the other parts.

What this means for you

  • A prompt you change often needs the encoder each time. A batch with one prompt and many seeds needs it once.
  • If your card is full, check whether the encoder is still sitting in memory.
  • A better encoder can mean a better reading of your words, and a larger file.

A caution on what it understands

The encoder gives numbers that stand for meaning. It does not guarantee the drawing model can draw it. In our banner test, one model understood "leave the left third empty" as a loose hint and ignored it. We now say what fills the space instead. See Writing picture prompts that work.

A small thought experiment

Say you ask for "a red bicycle leaning on a brick wall" and then for "a blue bicycle leaning on a brick wall". The two prompts differ by one word. The encoder writes two different lists of numbers, and the drawing model follows each list. If the encoder is cached for the first prompt, only the second needs it. If you keep the words fixed and change only the seed, the saved list serves every picture. That is why a batch of one prompt with many seeds is cheap in memory, and a batch of many different prompts keeps asking for the encoder.

Words you may meet

  • Text encoder: the model that turns words into numbers.
  • Conditioning: the numbers that tell the drawing model what you asked for.
  • Cache: saved results reused later.
  • int8: storing numbers in one byte each.
  • Warm: the models are already loaded.

Try it

  1. Run one prompt with five seeds in a picture tool. Watch whether the first run is slower than the next four. Part of that gap is loading.
  2. Change one word in the prompt and run again. See the time go up.
  3. See pictures made with a setup like this on doar.bio.

What we do not claim

We measured one server with one card. The numbers for the encoder cache come from our video server, not the picture server. We do not know how the cache holds an encoder on other hardware.

Commenti

Ancora nessun commento.

Accedi per commentare.