Nodes/JLC Flux2 ControlNet/ JLC Flux2 Inpaint Context Cache - Experimental
ComfyUI Node

 JLC Flux2 Inpaint Context Cache - Experimental

The experimental inpaint cache that moves work out of your first sampling step

By Damkohler·Created 2 months ago·Updated 26 days ago· 20
 JLC Flux2 Inpaint Context Cache - Experimental
  • vae
  • image
  • mask
  • latent
  • image
  • mask
  • cache_set
  • cache_report
clear_before_preparefalse
diagnosticstrue

The FLUX.2 Fun ControlNet Union has a mask-aware inpaint path, and it's not cheap: before the first sampling step, ComfyUI has to pack a hard keep-mask context and VAE-encode the masked source image into a Flux2 latent. JLC Flux2 Inpaint Context Cache - Experimental exists to do all of that once, stash the result in a CPU cache, and let the experimental Inpaint Adapter reuse it across every run with the same source image and mask. Every "experimental" label on this node is earned, so read the caveats before you build a production pipeline on it.

Why you'd reach for it

If you're doing repeated in/out-painting against the same source - fixing a hand, extending a canvas, regenerating a region across many seeds - that masked-source VAE encode plus context packing runs every single time without it. This node moves it out of the sampling path entirely. The author's validated configuration is 1024×1536 output with warmed caches, and that's the setup where the savings actually show up.

How it works

Feed it the vae, the source image, the mask, and - this is the part people get wrong - the same Empty Flux2 Latent your sampler uses. Never the sampler output. The node validates that image, mask, and latent canvas all match exactly, then computes and caches two things: the packed four-channel hard keep-mask context and the VAE-encoded masked-source Flux2 latent. clear_before_prepare resets the cache domain, and diagnostics controls reporting. Outputs are pass-through image and mask, plus cache_set and cache_report.

Mismatched dimensions are rejected with a clear error rather than silently resized - this is deliberate. The experimental adapter requires the source and mask to already match the active sampling canvas exactly, because the Union model's hard binary mask contract doesn't tolerate a sloppy resize.

Installing it

Part of the JLC-Flux2-ControlNet pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Damkohler/JLC-Flux2-ControlNet.git

Restart ComfyUI (or use ComfyUI Manager, search "JLC Flux2 ControlNet"). Needs current ComfyUI with native FLUX.2 support and Python 3.10+. No pip dependencies; the ControlNet checkpoint in ComfyUI/models/controlnet/ is required for actual sampling.

Gotchas

This is the least stable corner of the pack. The cache only hits when source image, mask, VAE identity, and sampling geometry all match exactly; anything off and it falls back to inline preparation (correct, just slower). If you change the mask, clear the cache or the old context gets served. And remember the whole inpaint path is explicitly experimental: hard mask boundaries can produce seed-variable edge artifacts, especially when dense auxiliary ControlNets compete with the inpaint guidance. OpenPose/DWPose as the host control with conservative auxiliary strengths is the author's tested recipe. New workflows should prefer JLC Flux2 Conditioning Cache Prep for this cache too - it wraps the inpaint context behind the same single surface.

CategoryFlux2 Latents Cache/utils

Inputs (6)

NameTypeDefaultDescription
vaeVAE
imageIMAGE
maskMASK
latentLATENT
clear_before_prepareBOOLEANfalse
diagnosticsBOOLEANtrue

Outputs (4)

NameTypeDescription
imageIMAGE
maskMASK
cache_setBOOLEAN
cache_reportSTRING