FLUX.2 SDNQ Clear Caches
When your SDNQ pipeline eats your VRAM, Clear Caches is the eject button
- image
- pipeline
- IMAGE
Every pack with a session-based runtime ends up with one of these nodes, and here it is. The FLUX.2 SDNQ pack keeps the loaded Klein pipeline cached between generations so the next run doesn't pay the load cost again. That's great for throughput and lousy for VRAM: the pipeline session - transformer, VAE, and the Qwen3 text encoder - sits in memory until something evicts it. This node is that something.
What makes it easy to live with is the pass-through design. The required image input just flows straight to the IMAGE output untouched. So you drop the Clear Caches node anywhere in an existing chain - even on a wire you don't care about - and when execution reaches it, the teardown happens while your images keep flowing. You never have to restructure a workflow around it.
What the two switches actually do
- clear_pipeline_cache (default on) - releases every live FLUX.2 SDNQ pipeline session. The code moves the transformer, VAE, and parked text encoder to CPU, clears the prompt cache, and then empties the torch cache. This is the "give the VRAM back" button. Note it also clears torch memory even if the other switch is off - pipeline clear implies memory clear.
- clear_torch_cache (default on) - garbage-collects and runs ComfyUI's soft empty cache (falling back to
torch.cuda.empty_cache()/torch.mps.empty_cache()). If you flip pipeline clearing off and leave this on, it's a lighter touch: session survives, allocator gets swept. - pipeline (optional, advanced) - a
FLUX2_SDNQ_PIPELINEinput. It's deliberately discarded (del pipelinein the source), so its role is mostly to make the node's relationship to a session explicit in your graph. You can ignore it.
When to actually use it
The auto residency policies already do a lot of the VRAM management for you - the Loader's text_encoder_residency parks the Qwen3 encoder off-GPU on MPS and on ≤24 GB CUDA/ROCm cards. This node is for the moments auto can't anticipate:
- You finished a heavy multi-reference edit batch and are about to switch to a different workflow or model. Clear it, then let the next run reload fresh.
- You're on a 12 GB card and the decode OOMs mid-batch. Insert Clear Caches between stages to hand memory back.
- You want a deterministic "fresh pipeline" state for a test - clear the session, rerun, and the Loader redoes everything.
The trap
Clearing the pipeline means the next generation reloads the model from disk - on a slow SSD that's a real pause, and on a small card it re-triggers all the load-time memory pressure. Don't drop this node into the hot loop of a workflow you're iterating on; put it at the end of a chain, or between distinct model runs, where you actually want the teardown. The image pass-through makes it tempting to sprinkle everywhere. Resist.
Install
Same pack, same three steps: ComfyUI Manager → search FLUX.2 SDNQ, or git clone https://github.com/GeneralShan/comfyui-flux2-sdnq into custom_nodes; restart; and have sdnq/diffusers/peft pip-installed (ComfyUI 0.17+, Python 3.12+). No models, no extra weights - this node has nothing to download beyond the pack itself. It's the rare zero-dependency utility in an otherwise heavy stack, and it's the one you'll be glad exists on the second hour of a Klein editing session.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Pass-through image so the clear node can be inserted into a workflow chain. | |
| clear_torch_cache | BOOLEAN | true | Clear CUDA or MPS torch cache after the node runs. |
| clear_pipeline_cache | BOOLEAN | true | Release the cached FLUX.2 SDNQ pipeline session. |
| pipelineopt | FLUX2_SDNQ_PIPELINE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |