Flux KV Cache
Stop re-encoding your reference image every step
- model
- MODEL
FluxKVCache is a speed node for a specific, growing corner of Flux workflows: anything that uses a reference image. Flux Kontext and the newer reference-latent setups are notorious for being slow - the knowledge base notes Kontext runs something like 3x slower than plain Flux even with Nunchaku quantization. A big chunk of that cost is the model re-attending to the reference image's tokens at every single step, over and over, recomputing the same thing. This node says: no, compute it once and keep the result.
What it does. It's a model patcher with a single model input and a patched MODEL output. Under the hood it installs an attention patch that caches the key and value tensors for the reference-image tokens on the first pass through each attention block, then reuses them on every subsequent pass instead of recomputing them. There's a repeat_to_batch_size step so the cache still behaves when the batch size changes, and it sets the model's reference method to index the reference features from timestep zero - the bookkeeping that makes the cached reference stable across the whole denoise. It's the same family of trick as the KV-cache attention optimizations that became a whole genre of 2026 speed posts.
Where it applies. The trigger is subtle and worth knowing: the node only engages when the model is actually processing reference-image tokens (reference_image_num_tokens in the source). That means it does nothing at all in a plain text-to-image Flux graph. It pays off in Kontext-style workflows, reference-latent setups, and any Flux graph where you're feeding a reference image alongside your prompt - which is exactly the workflows where Flux is slowest and you want the win most. If your graph has no reference image, this node is a no-op; don't add it expecting magic.
How to use it. Wire model from your Flux model loader into FluxKVCache, then feed the output MODEL into the rest of your graph (sampler, etc.) exactly where the original model wire went. It slots in before anything that consumes the model, so it composes with the Flux-specific conditioning nodes you're already using. It's one of the newest nodes in the experimental category - the tooltip ("Enables KV Cache optimization for reference images on Flux family models") is the author's own description, and the display name tells you the scope: Flux family.
Gotchas. Because it's brand new and experimental, the rough edges are the usual ones plus a couple of its own. The cache lives on the patched model for its lifetime - if you change the reference image mid-workflow, make sure you're getting a fresh patched model or the cached K/V from the old reference leaks in; that's the failure mode to watch for in batch/reference-swap setups. It only helps reference-image Flux workflows, so verify your graph is actually one of those before you judge it. And since it's experimental, its exact behavior can shift between ComfyUI versions - if a downloaded workflow using it errors after an update, that's the first suspect.
One more honest note: with zero search impressions on the page, virtually nobody has written about it yet. If you're running Flux reference workflows regularly and it works for you, you're an early adopter, and your results may beat the community's. Treat it as a test run: A/B the same generation with and without it and keep whichever is faster for your setup.
Ships with ComfyUI core - search "FluxKVCache" to add it. No install.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model to use KV Cache on. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | The patched model with KV Cache enabled. |