Nodes/SimpleSyrup/KSampler (Attention Coupling)
ComfyUI Node

KSampler (Attention Coupling)

One sampler that runs your regional prompts in a single trajectory

By Artificial-Sweetener·Created 4 months ago·Updated 2 days ago· 2
KSampler (Attention Coupling)
  • model
  • positive
  • negative
  • latent_image
  • region_masks
  • latent
seed0
steps20
cfg8.0
sampler_name
scheduler
regional_prompt_weight1.00
region_mask_feather0
denoise1.00

Regional prompting has a ComfyUI problem. The built-in approach - ConditioningSetArea and friends - is awkward, SD-era, and falls apart on Anima, which has no native regional conditioning at all. Meanwhile the "couple" technique that Forge users take for granted never made the jump properly. This node is a full KSampler that brings attention coupling to ComfyUI: one denoising trajectory, a global prompt for the whole image, and per-region prompts that only influence their masks, all coupled through cross-attention instead of stitched-together separate passes.

How it works

The key idea is in the name and it's genuinely different from the alternatives. Older regional approaches either run separate sampling passes per region and composite (slow, and regions never see each other), or set conditioning areas and hope. Attention Coupling denoises the whole latent through one shared trajectory, with global and masked regional cross-attention coupled at every step. Each region's tokens contribute where its mask says, the global prompt stays in play everywhere, and in mask overlaps prompt contributions are normalized rather than doubled.

The graceful part is the fallback: connect ordinary (non-batch) conditioning and leave region_masks disconnected, and this node just runs the normal KSampler path - no coupling preparation at all. It only activates when you hand it the right inputs.

The inputs that matter

Everything a normal KSampler has - model, seed, steps, cfg, sampler_name, scheduler, latent_image, denoise - behaves exactly as you'd expect. On top of those:

  • positive / negative - these accept a conditioning batch, and the ordering is the whole contract: entry 0 is global, entries 1 onward pair with the masks. Build them with SimpleSyrup's regional builders (Encode Prompt Batch with [SEP], Conditioning Batch Start/Append, Compose Regional Conditioning).
  • region_masks (optional) - ordered masks paired with conditioning entries 1 onward. No masks, no coupling.
  • regional_prompt_weight - balances regional cross-attention against the global prompt: 0 is global-only, 1 is regional-only inside solid masks. Start at 1 and back off if regions feel disconnected.
  • region_mask_feather - softens region boundaries by N image pixels. Default 0 preserves your authored mask values; raise it when you see hard banding at region edges.

What it actually supports

The model input accepts Anima and standard SD/SDXL. A global LoRA rides on the model as usual. Where it gets interesting is Anima: with ComfyUI Prompt Control installed (an optional integration), each region can carry its own ordered, independently scheduled LoRA stack whose overlapping deltas compose in declared order - regional LoRAs, not just regional prompts. On standard SD/SDXL, regional model-side hooks are rejected, and unsupported Anima adapter targets fail before sampling rather than half-way through. That early failure is a real courtesy; you'll get a clear error instead of garbage.

Who this is for

If you've ever fought the two-character attribute-bleed problem - red-hair girl on the left, blue-hair girl on the right, and both coming out purple - this is the direct fix, and on Anima it may be the only bundled regional option that works. It's also how you'd apply per-region style without leaving one sampler. The trade is that you're committed to the conditioning-batch mental model and, ideally, Prompt Control for the fancier LoRA scheduling. For a one-off two-subject scene, that's still less plumbing than the old area-conditioning dance.

Where people trip

The ordering mistake is the classic: masks and conditioning entries must line up, entry 0 global, or your "region two" prompt lands on the wrong region or nowhere. Start with regional_prompt_weight at 1 and a couple of masks before adding feathering, LoRAs, and multiple regions. And remember the fallback works both ways - if you only ever feed it ordinary conditioning, you've just added a dependency for no reason, and the plain KSampler is the simpler choice.

Part of SimpleSyrup: ComfyUI Manager (search SimpleSyrup), or clone into custom_nodes and install requirements.txt. No model downloads. The pack uses ComfyUI's V3 extension API, so keep ComfyUI current - on an old build the nodes simply won't appear.

CategorySimpleSyrup/Sampling

Inputs (13)

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.
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.
region_masksoptMASKOptional 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.

Outputs (1)

NameTypeDescription
latentLATENTDenoised latent for VAE decode or more latent processing.