Multiple Reference Latent 🍌
The batch-builder the Reference Apply nodes need to actually do anything
- latent
- LATENT
ReferenceApply and MultipleReferenceApply - the two other nodes in this pack's reference folder - patch a model so certain batch positions share their self-attention with the rest of the batch during sampling. Neither of them takes a reference image or reference latent as a direct input, though. They expect the reference to already be sitting inside the batch at a specific index. Multiple Reference Latent is the node that builds that batch.
This is the plumbing half of cgem156's take on reference-only conditioning - the technique where a generation borrows a reference's own self-attention instead of routing through a separate ControlNet or adapter model. It's an old trick (predates IP-Adapter, let alone today's instruction-editing models) but it's a real one, and it still works without any training or extra checkpoint. This node exists purely to set up the batch structure the technique needs.
What it does
Feed it one latent - typically whatever came out of an EmptyLatentImage or an encoded reference image - and it expands that into a batch of batch_size positions, stamping copies of your reference latent into the batch slots you name in indices (a comma-separated string, default "0"). The rest of the batch is left for your sampler to fill with its own independently-seeded latents.
In other words: you're not handing this node a finished batch and asking it to insert a reference - you're handing it one latent and telling it where in a larger batch that latent should live. ReferenceApply's index or MultipleReferenceApply's indices then point at those same positions to know where to pull the shared attention from.
With the defaults - indices="0", batch_size=1 - this node does essentially nothing interesting: a one-item batch that's just your reference latent, unmodified. The node only earns its place once you raise batch_size so there's room for actual generation targets alongside the reference, and set indices to match wherever you want the reference (or references, for multi-reference setups) to sit.
Installing it
Via ComfyUI Manager: search cgem156-ComfyUI, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/laksjdjf/cgem156-ComfyUI
Restart afterward. Pure latent-batch manipulation - no model downloads, no extra dependencies.
Common issues & troubleshooting
Downstream Reference Apply node isn't picking up the reference. Double-check the index you set on ReferenceApply (or the indices string on MultipleReferenceApply) actually matches one of the indices you set here - this node and the patch node need to agree on the same batch positions.
Batch size mismatch further down the graph. batch_size here needs to match what the rest of your sampling pipeline expects (your latent_image going into the sampler). If they disagree, you'll get a shape error rather than a subtle bug - check batch sizes line up end to end.
Left at defaults, nothing seems to happen. That's expected - indices="0", batch_size=1 is a no-op configuration. This node only does something once you deliberately expand the batch and place the reference(s) inside it.
Sparse documentation. This is one of the pack's quieter corners - it isn't called out in the README's feature table, and there's no real community writeup of this specific node. Treat it as plumbing you wire up alongside ReferenceApply/MultipleReferenceApply rather than something with its own settings guide to follow.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| latent | LATENT | — | |
| indices | STRING | 0 | — |
| batch_size | INT | 11–256 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |