KSampler (Contextual Diffusion)
The Node That Fixes Tiled Diffusion's Big Failure Mode
- model
- positive
- negative
- latent_image
- segs
- latent
- contexts_segs
Tiled diffusion has a dirty secret. It keeps each evaluation small enough to fit in VRAM, but every tile sees only a piece of the image - so on a big canvas, tiles quietly invent their own version of the scene. The pack author hit this hard editing a 2160×3072 photo with FLUX.2 Klein: one tile found a figure, another invented a second figure, and different parts of a cathedral became different buildings. The overlaps were seamless and the scene was nonsense. KSampler (Contextual Diffusion) is the original method they built to fix that, and it's the flagship node of SimpleSyrup.
How it works
The idea is deceptively simple: while tiled local predictions handle full-resolution detail, a second, smaller, aspect-preserving view of the whole image keeps the composition honest. The whole-image prediction is upsampled and blended into the tiles - but not by direct averaging, which produced blur, and not for the whole run, which smeared detail. What worked is subtracting the low-frequency interpretation already present in the tiled prediction and adding only the difference:
prediction = local + scheduled_weight × (global_upsampled − local_low_frequency)
In plain terms: the global branch corrects composition early, then hands control back to the tiles for fine texture before it can smear anything. The author acknowledges this is closely related to Upsample Guidance (arXiv:2404.01709), developed independently - a multiscale low-frequency-guidance idea.
The controls map onto that story:
- global_weight (1): how authoritative the whole-image guidance is. Lower it to let tiles interpret more freely.
- global_steps (1): how many initial steps use the global context. For distilled models that finish in four steps, even one corrected step is a quarter of the process - hence the defaults of steps 4, cfg 1.
- global_decay (0.5): how fast the whole-image strength fades after each global step. Lower = tiles take over sooner.
Plus the tiled plumbing: diffusion_mode (multidiffusion or Mixture of Diffusers), latent_context_size (96), latent_context_overlap (32), latent_context_batch_size (4). There's an optional segs input that replaces the regular grid with SEGS-guided context windows - a way to steer where the local evaluations land - and a contexts_segs output that shows you the windows that actually ran (masks are only built when you connect it, so don't leave it dangling if you're tight on VRAM).
What it's for - and what it isn't
Contextual Diffusion is for edits the model already knows how to make at normal resolution: clothing, color, material, jewelry, expression, local lighting - changes where you want to keep the source pose and composition. It is not for inventing a new pose, camera, or environment; establish those at a normal resolution first, then refine. Honest limitations: UniPC, regional conditioning, ControlNet, and GLIGEN are rejected because the author hasn't validated their spatial behavior across both context sizes. If you need per-region prompts on a big canvas, that's KSampler (Prompt by Tiled Region); if you need plain tiling with no whole-image correction, that's KSampler (Tiled Diffusion).
Install
Ships in the SimpleSyrup pack. ComfyUI Manager → search SimpleSyrup → Install → restart, or:
Set-Location ComfyUI\custom_nodes
git clone https://github.com/Artificial-Sweetener/SimpleSyrup.git
Set-Location SimpleSyrup
..\..\venv\Scripts\python.exe -m pip install -r requirements.txt
Restart ComfyUI; current build required (v3 extension API).
Common issues
- Blurry result - the whole-image branch overstayed. Lower
global_stepsorglobal_decay. - Smears / repeated edges - global correction active too long at high weight. Reduce
global_stepsorglobal_weight. - Composition still drifts - raise
global_weightandglobal_steps; you went too far the other way. - Nodes missing - update ComfyUI first.
It's the most interesting node in the pack: a genuinely new sampler method, documented honestly, built for the exact case where ordinary tiled diffusion fails.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | Diffusion model used to denoise the input latent. | |
| seed | INT | 00–18446744073709550000 | Seed used to create sampling noise. Reusing it with matching settings makes results repeatable. |
| steps | INT | 41–10000 | Number of denoising steps. More steps can add refinement but take longer. |
| cfg | FLOAT | 1.00–100 | Prompt guidance strength. Higher values follow the positive prompt more strongly but can look overcooked. |
| sampler_name | COMBO | Sampling algorithm. It affects the image's look, speed, and stability. | |
| scheduler | COMBO | Noise schedule used during sampling. It changes how quickly structure and detail form. | |
| positive | CONDITIONING,CONDITIONING_BATCH | Positive conditioning that guides what the sampler should add. | |
| negative | CONDITIONING,CONDITIONING_BATCH | Negative conditioning that guides what the sampler should avoid. | |
| latent_image | LATENT | Latent input whose samples will be denoised. | |
| denoise | FLOAT | 1.000–1 | Sampling strength. Lower values preserve the input more; higher values allow larger changes. |
| diffusion_mode | COMBO | multidiffusion | Tile overlap blend. MultiDiffusion averages predictions; Mixture of Diffusers gives tile centers more influence. |
| latent_context_size | INT | 9616–512 | Maximum side of each model context in latent pixels. Larger contexts preserve more relationships but use more memory. |
| latent_context_overlap | INT | 320–256 | Overlap between local latent contexts in latent pixels. Larger overlaps reduce seams but increase sampling work. |
| latent_context_batch_size | INT | 41–8 | Number of equal-sized latent contexts sampled together. Higher values can be faster but use more memory. |
| global_weight | FLOAT | 1.000–2 | Strength of whole-image low-frequency guidance. 1 makes the global context authoritative; lower values allow more tile interpretation. |
| global_steps | INT | 10–10000 | Number of initial denoising steps that use the global context. Fewer steps leave more late sampling for local detail. |
| global_decay | FLOAT | 0.500–1 | Multiplier applied to whole-image strength after each global step. Lower values hand control to local contexts faster. |
| segsopt | SEGS | Optional regions that replace the regular grid with SEGS-guided contexts. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | Denoised latent for VAE decode or more latent processing. |
| contexts_segs | SEGS | Rectangular non-global contexts actually evaluated during sampling. Their SEGS masks are created only when this output is connected. |