ComfyUI Node

TBG Split-Aware Inpaint Sampler

Split-pass sampling that finally respects your inpaint mask

By Ltamann·Created about a year ago·Updated a day ago· 148
TBG Split-Aware Inpaint Sampler
  • model
  • positive
  • negative
  • latent_image
  • sampler_state
  • Sampler
  • LATENT
  • sampler_state
add_noisetrue
noise_seed0
steps20
cfg1.00
sampler_name
scheduler
denoise1.00
start_at_step0
end_at_step10000
inpaint_start0
inpaint_end10000
smoother_sharper0.00
detail_enhancer0.00
return_with_leftover_noisefalse

The bug it exists to fix

Split-pass sampling is the trick of breaking one generation into a high-sigma stage and a low-sigma stage, often with a different model or a different denoise. It's how people get the creative freedom of a high denoise with the structure of a low one. But there's a long-standing ComfyUI flaw: when you split the sigma schedule, the latent mask stops being honored, so masked regions come back full of residual noise and that tell-tale latent grid pattern. It's ComfyUI issue #5452, and for a long time the practical answer was "don't split while inpainting."

This sampler is the fix. TBG's split-aware sampler forks KSamplerAdvanced so the differential-diffusion blend keeps the original image as a reference across the split, and it interpolates the denoise mask with a small fade to kill the grid artifacts. The author built it while making the ETUR tiled refiner and spun it out as a standalone CE node - free, no Patreon key.

What's different from a stock KSamplerAdvanced

Look at the inputs and you'll spot the extras, plus one very important window:

  • inpaint_start / inpaint_end - the step range where the masked latent actually blends. Defaults (0 and 10000) mean the mask is active through the whole schedule. Raise inpaint_start to let the image cook freely before the mask locks in; lower inpaint_end to let late steps polish without mask constraints. This is your "how much creative freedom before it must match" dial.
  • smoother_sharper - dual-stage adaptive sharpening. Positive values inject structured noise for detail invention at high sigma and high-pass edge sharpening at low sigma; negative values soften and blur. Zero is off.
  • detail_enhancer - substep evaluation. Positive is lookahead (coherent refinement, but 2× slower on affected steps), negative is lookback (more creative variation). Zero is disabled and fastest - which is where you should start.
  • return_with_leftover_noise - on for intermediate passes, off on the last one.
  • add_noise - on for the first sampler, off for every chained one.
  • sampler_state (optional) and Sampler (optional) - chain state between passes; connect a SAMPLER object to override the dropdown.

And because it ships beside the Krea2 conditioning node, it also reads the vl_start_percent / vl_end_percent metadata from that node's conditioning and only applies the visual-token conditioning during that window. That's the "split-aware" bit - it knows there's a schedule to respect, not just a mask.

Wiring it up

The natural chain, all in one pack:

  1. TBG Krea2 Inpainting Conditioning → gives you positive, negative, and the masked latent.
  2. TBG Split-Aware Inpaint Sampler - add_noise on, return_with_leftover_noise on if you're chaining.
  3. A second pass if you want one - add_noise off, sampler_state connected.
  4. Final pass with return_with_leftover_noise off → VAE Decode.

It also works with any standard inpainting setup; InpaintModelConditioning or Set Latent Noise Mask feed it fine. Outputs are LATENT plus a sampler_state to hand down the chain.

Installing it

Same pack as the whole TBG ETUR set:

cd ComfyUI/custom_nodes
git clone https://github.com/Ltamann/ComfyUI-TBG-ETUR
cd ComfyUI-TBG-ETUR
pip install -r requirements.txt

or ComfyUI Manager → search "TBG" → install TBG Enhanced Upscaler and Refiner, then restart. Give the requirements install time - opencv, timm, kornia, bitsandbytes, optimum and friends is a big tree for what looks like one node. The pack is migrated to ComfyUI's v3 node API, so if the node won't load, update ComfyUI first.

Troubleshooting

  • CFG 1 is correct for Krea 2, and for most current flow-matching models - they're guidance-distilled, so cranking CFG just burns the image at double the time. This sampler's default of 1.0 is right; don't "fix" it out of SDXL habit.
  • detail_enhancer is expensive. The tooltip says it plainly: 2× slower on affected steps. Start at 0 and only turn it on when you're chasing a specific look.
  • Noisy masked area on a chained pass → you almost certainly left add_noise on, or disconnected sampler_state.
  • It's new and under-documented (basically zero search impressions yet). The pack is updated near-daily and the author is responsive in the GitHub issues - if something's off, that's the fastest source of truth.
CategoryTBG/Krea2 Inpainting

Inputs (20)

NameTypeDefaultDescription
modelMODEL
add_noiseBOOLEANtrueEnable: add random noise (first sampler). Disable: no noise added (sampler chaining/img2img). Use 'enable' for first sampler, 'disable' for subsequent ones.
noise_seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT1.000–100
sampler_nameCOMBO47 options: euler, TBG Flux2 Sampler, pid_sde, pid_creative_sde, euler_cfg_pp, euler_ancestral, +41
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
denoiseFLOAT1.000–1
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
start_at_stepINT00–10000
end_at_stepINT100000–10000
inpaint_startINT00–10000Step number where inpainting injection begins. Inpainting blends the original latent with the denoised latent within the masked area. Set to 0 to start inpainting from the first step. Higher values delay inpainting, allowing more creative freedom before preserving masked regions.
inpaint_endINT100000–10000Step number where inpainting injection ends. Set to a high value (e.g., 1000) to inpaint through all steps. Lower values allow later steps to refine without mask constraints. Works with inpaint_start to define the inpainting window.
smoother_sharperFLOAT0.00-1–1Dual-stage adaptive sharpening. At high sigma (early steps), adds structured noise for detail invention. At low sigma (late steps), applies high-pass edge sharpening. Positive values sharpen and add details. Negative values soften and blur. Zero disables sharpening. Higher absolute values create stronger effects.
detail_enhancerFLOAT0.00-1–1Substep evaluation for detail control. Positive values (0.1-1.0): lookahead to next sigma, adds coherent details and refinement, reduces variation. Negative values (-0.1 to -1.0): lookback to previous sigma, adds creative variation and texture complexity. Zero = disabled (single pass, fastest). Performance cost: 2x slower on affected steps.
return_with_leftover_noiseBOOLEANfalseEnable: keeps noise for sampler chaining. Disable: fully denoise output. Use 'enable' for split workflows, 'disable' for final step.
sampler_stateoptsampler_stateChain state from previous sampler. Leave empty for first sampler, connect for subsequent samplers in multi-pass workflows.
SampleroptSAMPLEROptional sampler object. When connected, it overrides the Sampler Name selection.

Outputs (2)

NameTypeDescription
LATENTLATENT
sampler_statesampler_state