StyleAligned Reference Sampler ♾️Mixlab
Generate a batch that matches one reference style
- ref_latents
- model
- clip
- positive
- negative
- output
- denoised_output
This is the payoff node of Mixlab's StyleAligned pipeline. First StyleAligned Sample Reference Latents runs your reference image through the diffusion process and records its per-step latent trajectory - the style anchor. This node takes that anchor and actually generates a new batch of images that share attention with it during sampling, so everything it produces inherits the reference's palette, texture, and rendering while your own conditioning drives what's actually depicted. It's Mixlab's port of Google's StyleAligned technique (via brianfitzgerald's style_aligned_comfy) - the same underlying method as the pack's Batch Align node, but anchored to one specific image instead of just aligning a batch to itself.
Structurally, this node bundles what would normally be two separate steps - a StyleAligned model patch, then a full KSampler - into one. That's why the input list is long: ref_latents (the STEP_LATENTS captured upstream) and reference_image_text (a caption of that reference - describe it honestly, since it anchors what the technique understands the style to be about) sit alongside the full generation pipeline, model, clip, positive, and negative, plus every standard sampler control: steps (default 20), cfg (default 8), scheduler (a full modern list - simple, sgm_uniform, karras, exponential, ddim_uniform, beta, normal, linear_quadratic, kl_optimal), denoise (default 1), and seed. batch_size (1–8, default 2) is how many new images you're generating in this style-matched batch. Then the StyleAligned-specific pair - share_norm (both/group/layer/disabled) and share_attn (q+k/q+k+v/disabled) - controls which parts of attention and normalization actually get shared with the reference, and scale (0 to 2, default 1, a wider range than Batch Align's 0–1) dials how strongly that sharing applies.
Two LATENT outputs come back: output and denoised_output. Decode either through a standard VAEDecode to get images - in practice, denoised_output is the one to reach for first if you just want the finished, fully-sampled batch, while output is there for cases where you want the less-processed latent state, useful if you're chaining into further sampling rather than decoding immediately.
Because model and clip and positive/negative all have to line up with the same checkpoint used to capture ref_latents upstream, that's the first thing to check if a run behaves strangely - StyleAligned's shared attention only makes sense if the reference pass and the generation pass are speaking the same model's language.
Install is the pack-wide standard:
cd ComfyUI/custom_nodes
git clone https://github.com/shadowcz007/comfyui-mixlab-nodes.git
cd comfyui-mixlab-nodes
install.bat
or via ComfyUI Manager (search "comfyui-mixlab-nodes"), or pip3 install -r requirements.txt in a venv. No separate model download - it samples with whatever checkpoint and VAE you already have loaded, the same ones you used for the reference-latent capture step.
Set expectations honestly: StyleAligned is a soft consistency trick, not hard identity preservation. It nudges a batch toward a shared look; it doesn't clone the reference image or guarantee an exact style match on every output. If what you actually need is a specific character or subject reproduced precisely across images, this is the wrong tool - reach for IP-Adapter, a trained LoRA, or a reference-conditioned edit model instead. If the style barely transfers here, the two most common culprits are a scale set too low and a thin or generic reference_image_text - the caption is doing more work than it looks like, and a vague one weakens the whole effect. If the batch style-matches but content bleeds in from the reference that you didn't want, that's shared attention leaking composition along with style - push your positive prompt harder toward what you actually want depicted, and pick references whose look you want more than their content.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| ref_latents | STEP_LATENTS | — | |
| reference_image_text | STRING | — | |
| model | MODEL | — | |
| clip | CLIP | — | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| share_norm | COMBO | 4 options: both, group, layer, disabled | |
| share_attn | COMBO | 3 options: q+k, q+k+v, disabled | |
| scale | FLOAT | 1.000–2 | — |
| batch_size | INT | 21–8 | — |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| denoise | FLOAT | 1.000–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output | LATENT | — |
| denoised_output | LATENT | — |