Nodes/StyleAligned for ComfyUI/StyleAligned Sample Reference Latents
ComfyUI Node

StyleAligned Sample Reference Latents

StyleAligned Sample Reference Latents

By brianfitzgerald·Created 3 years ago·Updated about a year ago· 308
StyleAligned Sample Reference Latents
  • model
  • positive
  • negative
  • sampler
  • sigmas
  • latent_image
  • ref_latents
  • noised_output
noise_seed0
cfg8.0

This node does the unglamorous half of the job: turning an actual reference image into something a sampler can later "copy" the style from. If you just want a batch of new images to share a style with each other, you want Batch Align instead - that one's a single drop-in patch. You reach for Sample Reference Latents when you already have a specific image and you want new generations to inherit its exact style, not just each other's.

The mechanism is DDIM inversion, and it's worth understanding once because it explains every input on this node. Normally a sampler starts from noise and denoises down to an image. DDIM inversion runs that process backwards and deterministically: starting from your reference image's latent, it steps back up toward pure noise. This only works because DDIM is a deterministic ODE sampler - no randomness gets injected at each step the way ancestral or SDE samplers do - so the forward and reverse passes are exact inverses of each other. That determinism is what lets you reconstruct not just "the noise that would have produced this image," but the model's internal state - self-attention and normalization - at every single step along the way. That per-step trail is the actual product of this node: not one output image, but a recorded sequence of latents, one per denoising step.

What you plug in. model is your base model. latent_image is your reference image, VAE-encoded first - this is the image whose style you want to reuse later. positive and negative are the conditioning that describes that reference image (get this reasonably close to what actually generated it, or to what accurately describes it, since the inversion is conditioned on it). sampler needs to come from a sampler-selector node set to DDIM specifically - that's the whole reason inversion is possible here, and a stochastic sampler would break it. sigmas comes from a scheduler node, and for inversion this needs to run in the reversed order from a normal generation (ascending rather than descending) - building that reversed schedule by hand from scratch is fiddly, which is presumably why the README ships a ready-made example workflow (resources/style_aligned_inversion.json) instead of writing the wiring out in prose. Load that first rather than guessing. noise_seed and cfg behave like they do on any sampler.

What comes out. ref_latents is the per-step trail, typed as STEP_LATENTS - a type specific to this pack, and it only talks to one other node: plug it straight into StyleAlignedReferenceSampler's ref_latents input, that's its entire purpose. noised_output is the fully-inverted latent - essentially "what pure noise looks like for this specific image" - which you generally don't need to do anything with beyond a sanity check, though nothing stops you routing it elsewhere.

Install the usual way: search "StyleAligned for ComfyUI" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/brianfitzgerald/style_aligned_comfy and restart. No extra models or dependencies to fetch.

Context worth having before you invest time in this: StyleAligned is a 2023 Google Research technique, it had its moment right when it landed, and community discussion of it had basically dried up by 2024 - people moved to IP-Adapter for zero-shot style/reference work, and more recently to instruction-editing models for anything reference-based. The repo itself carries a "no longer actively maintained" banner. It still does what it always did; it's just not where new development happens, so don't expect fixes if you hit an edge case.

Where people get stuck:

  • Using the wrong sampler. If sampler isn't actually DDIM, the "inversion" property doesn't hold and ref_latents won't represent a real inversion of your image - you'll get something, but it won't correspond to the reference the way you'd expect.
  • Getting the sigma direction wrong. A normal scheduler node gives you a descending schedule for generation; inversion needs it reversed. This is the single fiddliest part of the setup - again, start from the example workflow rather than assembling it from a blank canvas.
  • Assuming this predates or targets modern base models. It doesn't. It was built against SD1.5/SDXL-era UNet attention, well before Flux, SD3, Wan or Qwen existed, and there's no sign the unmaintained pack was ever updated for DiT architectures. Stick to SDXL/SD1.5 checkpoints.
  • Trying to wire ref_latents into anything else. STEP_LATENTS isn't a standard ComfyUI latent type - if you don't see this pack's own Reference Sampler node available to receive it, you can't substitute a normal KSampler in its place.
Categorystyle_aligned

Inputs (8)

NameTypeDefaultDescription
modelMODEL
noise_seedINT00–18446744073709550000
cfgFLOAT8.00–100
positiveCONDITIONING
negativeCONDITIONING
samplerSAMPLER
sigmasSIGMAS
latent_imageLATENT

Outputs (2)

NameTypeDescription
ref_latentsSTEP_LATENTS
noised_outputLATENT