Nodes/SimpleSyrup/KSampler (Attention Coupling + Contextual Diffusion)
ComfyUI Node

KSampler (Attention Coupling + Contextual Diffusion)

The sampler that keeps a big edit from becoming a dozen little lies

By Artificial-Sweetener·Created 4 months ago·Updated 2 days ago· 2
KSampler (Attention Coupling + Contextual Diffusion)
  • model
  • positive
  • negative
  • region_masks
  • latent_image
  • segs
  • latent
  • contexts_segs
seed0
steps20
cfg8.0
sampler_name
scheduler
regional_prompt_weight1.00
region_mask_feather0
denoise1.00
diffusion_modemultidiffusion
latent_context_size96
latent_context_overlap32
latent_context_batch_size4
global_weight1.00
global_steps1
global_decay0.50

This is the flagship, and the pack's own README tells the story that made it. The author was editing a 2160×3072 source with FLUX.2 Klein 4B. Downscaling made the edit coherent but defeated the point of starting high-res. Ordinary tiled diffusion kept the detail - and then he looked at the whole image. One tile had found a figure, another had invented a second figure, and the cathedral had become two different buildings. The overlaps were smooth. The scene was nonsense.

That's the failure Contextual Diffusion exists to fix, and this node fuses it with the pack's regional attention coupling: regional prompts that apply in every local tile and in the reduced whole-image view. It's for large-canvas edits where the tiles have to see the whole composition or they'll each improvise their own.

How Contextual Diffusion works

The mechanism is worth understanding because it's the whole pitch. Every early step runs the tiled local prediction and one smaller, aspect-preserving view of the entire image. The clever part is how the two combine - the author subtracts the low-frequency interpretation already present in the tiled prediction and adds only the difference from the whole-image view:

prediction = local + scheduled_weight × (global_upsampled − local_low_frequency)

Blending the whole-image prediction straight into the tiles makes things blurry; leaving it on too long smears detail. Subtracting the tiles' own low-frequency component first means the global view only supplies what the tiles lost - composition - without wrecking their texture. (The author notes the result is mathematically related to Upsample Guidance from early 2024, which he says he developed independently; either way the practical behavior is: early steps lock the scene, then it hands off to the tiles for detail.)

Inputs that matter

It's the Contextual variant of KSampler (Attention Coupling), so you get the full coupling contract - global-first conditioning batch in positive/negative, optional region_masks, regional_prompt_weight, region_mask_feather - plus the diffusion stack:

  • diffusion_mode - MultiDiffusion (average) or Mixture of Diffusers (center-weighted), for tile fusion.
  • latent_context_size / latent_context_overlap / latent_context_batch_size - tile geometry, default 96 size with 32 overlap.
  • global_weight - how authoritative the whole-image view is (1 = authoritative, default).
  • global_steps - how many initial steps use the global context. Default 1. This is the knob that matters most.
  • global_decay - multiplier on whole-image strength after each global step (default 0.5); lower hands control to the tiles faster.
  • segs (optional) - SEGS that replace the regular grid with region-guided contexts, so the local windows fall where you want instead of on a plain grid.

There are two outputs: the latent, and contexts_segs - the rectangular windows actually evaluated during sampling. Its SEGS masks are only created when that output is connected, so leave it unplugged unless you want to inspect what the sampler looked at.

When to reach for it - and when not to

The README is refreshingly honest about scope. Contextual Diffusion is for edits the model already knows how to make at normal resolution: clothing, materials, color, jewelry, expression, local lighting - changes that keep the source pose and composition. If you need a brand-new pose, camera, or environment, establish that at a normal working resolution first and refine afterward; don't fight the big canvas from step one. And it's slower than plain tiled diffusion, by construction: a tiled prediction per step plus a whole-image evaluation for each corrected step. Distilled models that finish in a handful of steps change the math - with a 4-step model, one corrected step is already a quarter of the entire denoising.

The base Contextual sampler historically rejects sampling paths and extra conditioning whose spatial behavior isn't validated across both context sizes (UniPC, ControlNet, GLIGEN, and so on). This node exists because attention coupling was validated in both views - it runs in every local and reduced-global context on supported Anima and standard SD/SDXL models, and unsupported combinations fail before sampling with a clear error rather than silently producing nonsense.

Install and expectations

It's in SimpleSyrup: ComfyUI Manager search, or clone into custom_nodes plus requirements.txt, and keep ComfyUI current for the V3 node API. No model downloads for the sampler itself. Don't expect a hundred tutorials for this yet - the pack is young and this method is its own research, so a few small test crops will teach you more than any guide. Start with one edit, one mask, global_steps at 1, and look at the whole image before you trust the seams.

CategorySimpleSyrup/Sampling

Inputs (21)

NameTypeDefaultDescription
modelMODELSupported Anima or standard SD/SDXL model used for one shared denoiser trajectory; apply global model LoRAs before connecting it.
seedINT00–18446744073709550000Seed used to create sampling noise. Reusing it with matching settings makes results repeatable.
stepsINT201–10000Number of denoising steps. More steps can add refinement but take longer.
cfgFLOAT8.00–100Prompt guidance strength. Higher values follow the positive prompt more strongly but can look overcooked.
sampler_nameCOMBOSampling algorithm. It affects the image's look, speed, and stability.
schedulerCOMBONoise schedule used during sampling. It changes how quickly structure and detail form.
positiveCONDITIONING,CONDITIONING_BATCHGlobal-first positive conditioning: entry 0 is global and later entries pair with masks. Regional Prompt Control WeightHooks may contain ordered full-rank Anima LoRA stacks with independent schedules; standard SD/SDXL rejects regional model-side hooks.
negativeCONDITIONING,CONDITIONING_BATCHGlobal-first negative conditioning aligned to the same masks; Anima regional LoRA hooks retain their negative-branch ownership and independent schedules.
region_masksMASKOptional ordered masks paired with conditioning entries 1 onward. Leave disconnected with ordinary conditioning to bypass Attention Coupling. In overlaps, prompt contributions are normalized while Anima regional LoRA deltas add in declared adapter and region order.
regional_prompt_weightFLOAT1.000–1Balances regional cross-attention against the global prompt from 0 (global only) to 1 (regional only inside solid masks); regional Anima LoRA strength remains controlled by each hook.
region_mask_featherINT00–512Softens Attention Coupling and Anima regional LoRA boundaries by this many image pixels; 0 preserves authored mask values.
latent_imageLATENTLatent input whose samples will be denoised.
denoiseFLOAT1.000–1Sampling strength. Lower values preserve the input more; higher values allow larger changes.
diffusion_modeCOMBOmultidiffusionTile overlap blend. MultiDiffusion averages predictions; Mixture of Diffusers gives tile centers more influence.
latent_context_sizeINT9616–512Maximum side of each model context in latent pixels. Larger contexts preserve more relationships but use more memory.
latent_context_overlapINT320–256Overlap between local latent contexts in latent pixels. Larger overlaps reduce seams but increase sampling work.
latent_context_batch_sizeINT41–8Number of equal-sized latent contexts sampled together. Higher values can be faster but use more memory.
global_weightFLOAT1.000–2Strength of whole-image low-frequency guidance. 1 makes the global context authoritative; lower values allow more tile interpretation.
global_stepsINT10–10000Number of initial denoising steps that use the global context. Fewer steps leave more late sampling for local detail.
global_decayFLOAT0.500–1Multiplier applied to whole-image strength after each global step. Lower values hand control to local contexts faster.
segsoptSEGSOptional regions that replace the regular grid with SEGS-guided contexts.

Outputs (2)

NameTypeDescription
latentLATENTDenoised latent for VAE decode or more latent processing.
contexts_segsSEGSRectangular non-global contexts actually evaluated during sampling. Their SEGS masks are created only when this output is connected.