Klein Cross-Batch Identity Anchor
Same character in every carousel frame — one batch, one anchor
- model
- MODEL
You know the carousel workflow: one character, five poses, batch size 5, and the model hands you five different people who happen to be wearing the same outfit. Klein's Cross-Batch Identity Anchor is a single node that attacks exactly that problem - it makes images 2 through N of a batch borrow the identity of image 1 while they denoise, all in one pass, no LoRA, no reference image, no second model.
The README calls the result "molecular consistency," which is marketing, but the trick underneath is real and worth understanding, because it's the same family as the old reference-only ControlNet: inject the first image's self-attention context into everyone else.
How it works
The node is a model patch, not a pipeline. You feed it a model and it hands back the same model with a hook welded into every self-attention block. When the batch size is greater than 1, the patch does three things:
- Grabs the keys and values from the first image of the batch (
k[:num_heads],v[:num_heads]). - Tiles that reference across the batch so every image gets a copy.
- Concatenates it onto the end of each image's own keys and values, scaled by
anchor_weight.
The concat is the whole trick. Self-attention computes how each pixel relates to every other pixel in the image - by appending image 1's key/value pairs to every other image's sequence, image 3 suddenly "sees" image 1's pixels while it's drawing itself. The faces, the clothing, the texture all get pulled toward the anchor. Identity leaks from frame 1 to the rest of the batch, which is why it's called an anchor.
The two inputs that matter
That's the entire interface, so there's not much to fiddle with:
- model - any loaded checkpoint. Wire it between your model loader and the KSampler. You can chain it after other patchers too.
- anchor_weight - a 0 to 1 float, default 0.85, step 0.05. How hard the anchor's keys and values push into every other frame. 0 disables the patch entirely. If you get the same face but it starts looking smeared or "averaged," drop it toward 0.5; if the character drifts anyway, nudge it up.
Output is a single MODEL - the patched model, straight into your sampler.
Setting up the batch
This node is dead on arrival unless your batch is bigger than 1, because there's no image 1 to anchor to. The README pattern: set Empty Latent Image's batch to N (5 is a good carousel), give the text encoder N prompts (same character, different pose or scene wording), and the sampler runs them together. The anchor is whatever image 1 denoises into, not a finished reference - so the whole batch lives and dies with frame 1. If frame 1 comes out wrong, everyone inherits it. Curate the anchor prompt carefully.
Installation
No dependencies, no model downloads, no requirements.txt - it's one Python file.
cd ComfyUI/custom_nodes
git clone https://github.com/Bigornh2o/ComfyUI-KleinCarousel.git
Restart ComfyUI. Or just search "KleinCarousel" in ComfyUI Manager and hit install.
Where people get burned
- Nothing happens with batch size 1. The node quietly passes through. If you see no effect, check the batch size first.
- Silent failures. The patch wraps itself in a try/except and only prints "Klein Anchor Patch Error" to the console. If you're on a model whose self-attention doesn't expose
n_headsthe way SDXL/Flux do, it bails without telling you. Watch the console. - Memory. Appending anchor keys and values to every frame's sequence makes the attention longer, so VRAM climbs with batch size. Don't run this at batch 16 on a 8GB card and expect a miracle.
- It's one lever, not a full identity solution. Self-attention anchoring gets you closer, but face identity lives partly in the text conditioning and cross-attention too. This is a batch-internal shortcut in the spirit of reference-only ControlNet - treat it as a consistency booster to stack on top of a character LoRA or tight prompt discipline, not a replacement for them.
One honest footnote: this pack has essentially zero community footprint, and it shows in the rough edges. But the core mechanism is sound, it's free of heavy dependencies, and for the narrow "same character, N poses, one pass" case it's a genuinely interesting trick that costs nothing to try. Set the anchor prompt right, batch it, and you might skip the LoRA for once.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| anchor_weight | FLOAT | 0.850–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |