Nodes/comfyui_bmad_nodes/MaskGrid N KSamplers Advanced
ComfyUI Node Runs on cloud

MaskGrid N KSamplers Advanced

One sampler, many grid cells — DIY regional control without the regional packs

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
MaskGrid N KSamplers Advanced
  • model
  • positive
  • negative
  • latent_image
  • mask
  • LATENT
add_noise
noise_seed0
steps20
cfg8.0
sampler_name
scheduler
start_at_step0
end_at_step10000
return_with_leftover_noise
rows1
columns3
modeSample then Fork

This one is filed under Bmad/experimental in the menu, and the author's warning label is worth respecting: it works, but it's the fiddliest node in this pack and the kind of thing you use when you specifically want per-region control and don't want to install a regional-conditioning pack to get it.

It's a KSamplerAdvanced with extra machinery. You give it a mask, a rows and columns grid, and it produces a batch of latents - one per grid cell - each with its own sampling behavior, so you can vary prompt, cfg, or denoise range per cell and then stitch the result back together. That's your poor man's regional prompting: prompt A in the left column, prompt B in the right, all in one pass.

How the two modes differ

The mode dropdown is the whole personality of the node, and the names are a fair description:

  • Sample then Fork (default). Your mask gets tiled into a rows × columns grid, applied as the latent's noise mask, and the sampler runs once. Then each cell's region is copied out of the sampled latent into its own batch entry. One sampling pass, then split.
  • Fork then Sample. The mask is stamped into one cell at a time, and the full sampler runs once per cell, each pass seeing only that region as the denoising target. The results get concatenated into a batch. Slower, but each cell's generation is independent and can be wildly different.

Either way you get a single LATENT output whose batch size is rows × columns. That's the input for the pack's Merge Latent Batch Gridwise node, which composites the batch back into one grid-shaped latent - they're clearly designed as a pair. Decode after merging and you have one image.

The inputs that matter

All the standard KSamplerAdvanced stuff is there (model, positive, negative, latent_image, steps, cfg, sampler_name, scheduler, noise_seed, add_noise, start_at_step, end_at_step, return_with_leftover_noise). What you're really setting:

  • mask (IMAGE) - defines the cell boundaries; its size is divided by 8 to work in latent space.
  • rows / columns (1–16) - the grid shape.
  • mode - Sample then Fork or Fork then Sample.

Where the pain is

The mask has to divide cleanly against your latent's resolution, and mismatches are the #1 way this node silently does the wrong thing. Feed it a mask that isn't a multiple of the latent's 8×8 tile size and the cell copying will land slightly off. Also, "Fork then Sample" is genuinely slow - it's one full sampling run per cell. Keep the grid small until you've confirmed the regions line up, and don't expect pixel-perfect seams; adjacent cells will still have visible boundaries unless you blur them afterward (the pack's MaskOuterBlur is handy for exactly that).

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes

restart, or grab it through ComfyUI Manager by searching comfyui_bmad_nodes. It needs the pack's pip dependencies (OpenCV, scikit-image) which Manager installs for you. No model downloads.

If it's ever missing from your node list after an update, remember this pack's startup banner reports which modules loaded - check your console, not your sanity.

CategoryBmad/experimental

Inputs (17)

NameTypeDefaultDescription
modelMODEL
add_noiseCOMBO2 options: enable, disable
noise_seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
sampler_nameCOMBO44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
start_at_stepINT00–10000
end_at_stepINT100000–10000
return_with_leftover_noiseCOMBO2 options: disable, enable
maskIMAGE
rowsINT11–16
columnsINT31–16
modeCOMBOSample then Fork2 options: Sample then Fork, Fork then Sample

Outputs (1)

NameTypeDescription
LATENTLATENT