KSamplerAdvanced - Alternating Sampling
The A1111-Style Alternating Prompt Sampler, Ported to ComfyUI
- model
- clip
- latent_image
- LATENT
- POSITIVE
- NEGATIVE
If you came from A1111 you remember [cat|dog] in a prompt: the sampler swaps the word partway through generation, so a few steps run on "cat" and the rest run on "dog", and you get a hybrid that's a little of both. ComfyUI's core sampler can't do that - the prompt is encoded once at the start. This node is a whole sampler that re-encodes the prompt mid-run and alternates, which is the only real way to recreate that behavior.
Why you'd reach for it
It's a novelty node, let's be honest, but it's a fun and occasionally useful one. The technique is prompt editing / alternation - good for morphing between two subjects, blending styles ("watercolor|oil painting"), or exploring a concept that sits between two words. It's the single node in this pack where the mechanism is the feature, not a convenience wrapper. If you don't have an A1111 nostalgia itch, you can skip it; if you do, nothing else in core ComfyUI does this.
How it works
Under the hood it's a loop. It finds every [a|b] group in your prompt and, at each step of sampling, picks one side based on the step number, re-encodes the whole prompt through your CLIP model, then runs the sampler for a chunk of steps. Two dials control the rhythm: image_advance (how many steps each chunk runs, default 4) and weight (the fraction of the total run spent on the alternation - default 0.5). There's also new_seed_after_steps, which injects a fresh random seed partway through - the author's trick for cleaning up artifacts or blur. If your prompt has no [a|b] groups, it just samples normally, so it doubles as a plain KSampler in a pinch.
Inputs and outputs
- prompt / negPrompt - the text, with
[word1|word2]alternations. - clip - a CLIP model (the node encodes the prompt itself).
- model, latent_image, seed, steps, cfg, sampler_name, scheduler - standard sampling controls.
- image_advance (1–10, default 4), weight (0.1–1.0, default 0.5), new_seed_after_steps (default 1).
- upscale_latent plus optional upscale_method / ratio - the same latent-upscale option as the pack's other samplers.
Outputs: LATENT (the result), plus POSITIVE and NEGATIVE as strings, echoing back the prompt you used - handy if you want the exact prompt recorded.
Installing it
Part of "quadmoon's ComfyUI nodes". ComfyUI Manager: search the pack title or Install via GIT URL with https://github.com/traugdor/ComfyUI-quadMoons-nodes.git. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/traugdor/ComfyUI-quadMoons-nodes.git
Restart ComfyUI. No models to download.
Common issues
It's slower than a normal sampler because it re-encodes the prompt every few steps - that's expected, not a bug. The alternation uses [a|b] pipes only; other prompt-editing syntaxes from A1111 ([a:b:0.5] fading, for instance) are not handled, so don't expect those to work. And new_seed_after_steps means the seed you set is only the starting seed - the run may swap to random ones partway, which surprises people who expect deterministic seed behavior. The README's advice holds: the defaults are tuned, so experiment from there rather than cranking everything.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| negPrompt | STRING | — | |
| model | MODEL | — | |
| clip | CLIP | — | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| image_advance | INT | 41–10 | — |
| weight | FLOAT | 0.500.1–1 | — |
| new_seed_after_steps | INT | 11–100 | — |
| sampler_name | COMBO | 44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| latent_image | LATENT | — | |
| upscale_latent | COMBO | 2 options: Yes, No | |
| upscale_methodopt | COMBO | 5 options: nearest-exact, bilinear, area, bicubic, bislerp | |
| ratioopt | FLOAT | 1.500.01–8 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| POSITIVE | STRING | — |
| NEGATIVE | STRING | — |