Nodes/Flux blocks patcher sampler/Flux Block Patcher Sampler
ComfyUI Node

Flux Block Patcher Sampler

Sweep Every Flux Block Weight in One Run, Then See It All Side by Side

By cubiq·Created 2 years ago·Updated 2 years ago· 86
Flux Block Patcher Sampler
  • model
  • conditioning
  • latent_image
  • latent
  • sampler_params
  • patched_blocks
noise_seed0
steps24
sampler
scheduler
guidance3.5
denoise1.00
blocksdouble_blocks\.([0-9]+)\.(img|txt)_(mod|attn|mlp\.[02])\.(lin|qkv|proj)\.(weight|bias)=1.1 single_blocks\.([0-9]+)\.(linear[12]|modulation\.lin)\.(weight|bias)=1.1

The Flux block-patting rabbit hole usually goes like this: someone tells you a certain double_blocks layer is what makes your LoRA do the thing, you scale its weights up, generate, eyeball it, and repeat - one number at a time, one image at a time, and your memory of image #3 is already gone. This node is the "stop doing it one at a time" answer. You give it a list of regex=value lines and it samples a full image per line in a single run, stacking the results into one batch so you can lay the whole sweep out next to each other.

It's from cubiq (Matteo, the Latent Vision YouTuber and author of ComfyUI_IPAdapter_plus and ComfyUI-Extra-Samplers), and its README is upfront about what you're getting into: "very advanced and very experimental." It's a research tool, not a daily driver - but for figuring out which Flux block matters, nothing else does it this directly.

What it actually does

FluxBlockPatcherSampler is a full sampler node, not a helper. Wire it exactly like a KSampler: model, conditioning, latent_image in, and it runs the sampling itself. For each line in the blocks box it:

  1. clones the model,
  2. finds every weight whose parameter name matches the regex,
  3. multiplies those weights by your value (1.1 = +10%) using ComfyUI's own model patching - no training, no files written, the clone is discarded after,
  4. samples one image, then moves on to the next line.

The latents get batched in the same order as your lines. So one run with three lines = three images, and you're looking at an actual controlled experiment instead of vibes.

The inputs that matter

The usual sampler suspects are all here - steps, sampler (34 choices), scheduler (9), guidance, denoise, noise_seed. Flux's own defaults hold: Euler + Simple, 20-30 steps. One thing worth doing: the guidance default of 3.5 is the value everyone blames for Flux's same-face look; the community norm is ~1.8-2.0 for people.

The whole node is really about the blocks box:

  • One regex=weight per line. The pattern matches against full parameter names, so dots must be escaped.
  • double_blocks\.0\.=1.1 - scale everything inside double block 0.
  • single_blocks=1.1 - scale all 38 single blocks.
  • The shipped default targets the img/txt modulation, attention and MLP linear weights in the 19 double blocks plus the linear/modulation weights in the single blocks.

Bonus: the field has dynamic prompts enabled, so {1.0|1.05|1.1} will roll a different value per run - handy when you're tired of typing.

What comes out

Three outputs, and you'll use two of them. latent feeds a VAE Decode (or straight into this pack's PlotBlockParams). sampler_params is a list of {regex, value, matched_blocks} that PlotBlockParams consumes to caption each image. patched_blocks is a plain string listing every weight name and value that actually got patched - keep an eye on it, because a regex typo that matches nothing silently produces a duplicate of your baseline image rather than an error.

Installing

ComfyUI Manager (search "Flux blocks patcher sampler"), or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/cubiq/Block_Patcher_ComfyUI

Restart ComfyUI. There's no requirements.txt - it only uses ComfyUI's own modules plus torch, PIL and einops, which are already there. It downloads no models; you bring your own Flux (the example workflow uses flux1-dev in fp8 with the usual clip_l, t5xxl and ae files).

Gotchas

The runtime is lines × a full sampling - the README's "iterate through all 57 blocks" example means 57 images. Also, the default regex multiplies a lot of weights by 1.1; that's an aggressive baseline. Start near 1.0-1.05, see what moves, and only then go loud. And don't forget it's experimental - one block patched one way might be great for one prompt and garbage for another, so treat the results as a map, not a target.

Categorysd

Inputs (10)

NameTypeDefaultDescription
modelMODEL
conditioningCONDITIONING
latent_imageLATENT
noise_seedINT00–18446744073709550000
stepsINT241–10000
samplerCOMBO34 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +28
schedulerCOMBO9 options: normal, karras, exponential, sgm_uniform, simple, ddim_uniform, +3
guidanceFLOAT3.5-10–10
denoiseFLOAT1.000–1
blocksSTRINGdouble_blocks\.([0-9]+)\.(img|txt)_(mod|attn|mlp\.[02])\.(lin|qkv|proj)\.(weight|bias)=1.1 single_blocks\.([0-9]+)\.(linear[12]|modulation\.lin)\.(weight|bias)=1.1

Outputs (3)

NameTypeDescription
latentLATENT
sampler_paramsSAMPLER_PARAMS
patched_blocksSTRING