Nodes/Comfyui-Qwen-Image-Prompt-Rewrite-T8/Qwen Image 2.1 PE Unload T8
ComfyUI Node

Qwen Image 2.1 PE Unload T8

Evict the prompt rewriter before it costs you a render

By T8mars·Created 22 days ago·Updated 7 days ago· 48
Qwen Image 2.1 PE Unload T8
  • pe_result
  • pe_result

The tax on a nice feature

The Rewrite node has a model_lifetime setting with two values, and the fast one has a cost. after_run is the default: the node shuts its own llama-server down when the rewrite finishes, which is safe and slightly wasteful. keep_loaded leaves the server running so your next rewrite doesn't pay for a fresh load of a 5.6 GB GGUF - great while you're iterating on wording, less great when you queue the final render and find your diffusion model has to share the card with a resident prompt rewriter.

PE Unload T8 is the manual release valve. It's a single-purpose node: hand it the structured result from Rewrite, and it terminates the model service the pack itself started. The README's own lifecycle testing - twenty rounds of model switching - found no leftover processes, which is the kind of thing you verify once and then stop thinking about.

What it does, precisely

One input, pe_result, and one output, pe_result - the same value passed straight through. That pass-through is the only clever part of the design: it means you can drop the node into an existing chain without breaking the wire between Canvas and the sampler, instead of being forced to hang it awkwardly off the end.

Under the hood it calls the pack's runtime stop(), which kills the llama-server subprocess this node launched. Two honest limits follow from that. It only stops the PE server - it does not free your ComfyUI diffusion model, so it isn't a general "clear my VRAM" node; the Rewrite node already asks ComfyUI to release memory before it starts the server, and if you need more than that, use the core unload/free path. And it does nothing at all when you're running after_run, because there's no server left to stop. If you've left the default alone, this node is decorative.

The other half of the trick is that it always runs. It's marked as an output node and its change-detection deliberately returns "always changed," so ComfyUI won't lazily skip it because nothing upstream was re-executed. That's why you don't have to jiggle a widget to get it to fire - queue the prompt and it runs.

Wiring it

Take pe_result from PE Rewrite T8 and connect it to the Unload node's input. Leave the output unconnected, or feed it onward if you like; it's the same packet.

The author's Qwen-PE-2.1-Keep-Then-Unload-Demo.json shows the minimal shape: a Rewrite node set to keep_loaded, a Canvas, three PreviewAny nodes for the prompt, the ratio source and the diagnostics, and this node hanging off pe_result. Load it, run it once to watch the load happen, then run it again to see how much faster the second rewrite is with the model still warm.

Here's the part worth being deliberate about: the unload executes as soon as its input is ready, which is right after the rewrite - not after your sampler. In a graph that both rewrites and generates, wiring Unload into the same run gets you the worst of both worlds: you paid the load cost and then threw the model away mid-graph. The workflow that makes sense is two queued prompts. First one rewrites with keep_loaded on, so you can rerun the rewrite a dozen times cheaply while you tune the wording. When the prompt is right, either flip model_lifetime back to after_run, or queue a graph where this node runs and evicts the server once and for all.

Installing it

Same pack, no extra anything:

cd ComfyUI/custom_nodes
git clone https://github.com/T8mars/Comfyui-Qwen-Image-Prompt-Rewrite-T8.git

Model GGUFs and llama-server are needed for the Rewrite node, not for this one - Unload just calls stop() on a server that isn't running if you haven't downloaded anything yet. In practice you install the pack once:

cd Comfyui-Qwen-Image-Prompt-Rewrite-T8 && python tools/download_models.py

When it looks broken

VRAM didn't drop. Check the Rewrite node's model_lifetime. On after_run there's nothing to unload and this node silently does nothing useful. Also remember it only touches the PE server - the diffusion model, text encoder and VAE are ComfyUI's business.

It ran but the next rewrite was still slow. The node keeps one profile warm per model and vision-file combination; switch from the T2I GGUF to the Heretic one and you're paying a cold load again regardless.

Errors about a missing pe_result. You wired the rewritten string instead of the structured output. The types don't convert - use the pe_result socket.

CategoryQwen Image 2.1/Prompt Rewrite

Inputs (1)

NameTypeDefaultDescription
pe_resultPE_RESULT—

Outputs (1)

NameTypeDescription
pe_resultPE_RESULT—