Set Reference Latents
Multi-reference Flux 2 editing without the node spaghetti
- positive
- vae
- negative
- image_1
- image_2
- image_3
- image_4
- image_5
- image_6
- image_7
- image_8
- image_9
- image_10
- positive
- negative
Set Reference Latents (class DA_ReferenceLatents) is the thing you reach for when Flux 2 / Klein is doing its party trick - editing or generating from a reference image, or three, or eight - and you're tired of hand-wiring the pipeline. The native ComfyUI way to feed references into Flux 2 is to VAE-encode each image and append the latents to your conditioning. That's normally three nodes per image, repeated, plus manual scaling. This node collapses the whole chain - scale, VAE-encode, append - into one box with ten image inputs, and it skips the ones you leave empty. So one workflow serves one reference and ten.
How it works
For every image_1 through image_10 slot you actually connect, it does the same three steps:
- Scales the image with ComfyUI's
ImageScaleToTotalPixels- target resolution set bymegapixels(default 1.0, i.e. roughly a megapixel of total pixels), method set byupscale_method(lanczos by default), andresolution_steps(advanced, default 1) rounds the result to a clean multiple. - VAE-encodes it with your connected
vae. - Appends the resulting latent to your conditioning under the
reference_latentskey - appended, not replaced, so multiple references accumulate.
If you connect a negative conditioning too, the same reference latents get appended to it, so both halves of CFG see the references. The output is just your conditioning back: positive and negative, ready to hand to the sampler.
The inputs that matter
positiveandvae- the only required inputs.positiveis your text-encoded prompt conditioning.negative- optional; connect it if your workflow uses CFG and you want the references honored on the negative side too.megapixels- how big each reference gets before encoding. 1.0 is a fine default; raise it for detail-hungry edits, drop it toward 0.5 when VRAM is tight.upscale_method/resolution_steps- leave on defaults until you have a reason not to.image_1throughimage_10- the references. Empty = skipped.
Where it fits
This is how Flux 2 and Klein do single- and multi-reference editing natively - the same mechanism that powers its famous identity-consistent edits, character sheets, and virtual-try-on results. Wire the positive output into the sampler or CFGGuider that reads reference latents, and prompt like you're giving the model an editing instruction ("keep this character, replace the background") rather than a scene description.
Installing it
It's part of DA_Nodes - ComfyUI Manager, search "DA_Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/dauncle2026/DA_Nodes
Restart after. No requirements.txt, no model files to fetch. The pack uses ComfyUI's newer extension entrypoint, so if nothing shows up after install, update ComfyUI first.
The trap
The node will happily run with any model - and for most of them, silently do nothing. It only appends reference_latents to the conditioning; whether that does anything depends entirely on the downstream model reading that key. Flux 2 and Klein do, natively. SD, SDXL, Flux.1, Wan, LTX do not. If your reference image is having zero effect, that's not the node failing - the model is ignoring the data it never asked for. Also budget VRAM: ten references at a megapixel each is ten extra VAE-encoded latents riding through every step. If you're doing serious multi-reference work and latency matters, the kv-fp8 trick (caching reference attention keys and values) is the standard complement to this exact workflow.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| positive | CONDITIONING | — | |
| vae | VAE | — | |
| negativeopt | CONDITIONING | — | |
| upscale_methodopt | COMBO | lanczos | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| megapixelsopt | FLOAT | 1.000.01–16 | — |
| resolution_stepsopt | INT | 11–256 | — |
| image_1opt | IMAGE | — | |
| image_2opt | IMAGE | — | |
| image_3opt | IMAGE | — | |
| image_4opt | IMAGE | — | |
| image_5opt | IMAGE | — | |
| image_6opt | IMAGE | — | |
| image_7opt | IMAGE | — | |
| image_8opt | IMAGE | — | |
| image_9opt | IMAGE | — | |
| image_10opt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |