Nodes/SDXL Adherence/Align Hints To Latent
ComfyUI Node

Align Hints To Latent

Make your ControlNet hints actually line up with the latent

By regiellis·Created about a year ago·Updated 12 months ago· 10
Align Hints To Latent
  • latent
  • image
  • image_aligned
  • bbox_json
  • width
  • height
snap_modepad_up
pad_kindreflect
pad_value128
keep_alphafalse

A ControlNet hint that doesn't match the latent's pixel size isn't just ugly - it's wasted steps. Most ControlNet-apply nodes feed your canny, depth, or lineart map into the UNet at whatever size you hand over, and if the hint is 1088 wide while your latent is 896, the model spends the whole run trying to reconcile two grids that disagree. The result is a half-shifted edge map, detail landing where you didn't ask for it, and occasionally a shape-mismatch crash. Align Hints To Latent is the small node that fixes exactly that: it takes any hint image and pads or resizes it to the exact working dimensions of your latent, so hint and denoising grid are 1:1.

It's a helper from the SDXL Adherence pack (regiellis/ComfyUI-SDXL-Adherence), a set of nodes for making SDXL obey prompts and run cleanly on single-GPU rigs. Where Smart Latent handles the latent itself, this node handles whatever external hints you're feeding in alongside it.

How it works

The node reads your latent's shape, multiplies the latent-space H/8 and W/8 back up to full pixels, and fits the image into that box. The snap_mode decides how:

  • pad_up (default) - letterbox the hint up to the latent size, preserving the content. What you usually want.
  • downscale_only - shrink to fit inside the nearest 64-multiple, then pad the small residual.
  • resize_round - stretch the hint to the target size; can distort the aspect ratio.
  • crop_center - center-crop down to the lower 64-multiple, no resize.

pad_kind (reflect/edge/constant) controls the padding style, and pad_value is the fill value if you use constant padding. If your hint has an alpha channel you want kept, flip keep_alpha on.

Inputs and outputs that matter

Two required inputs: latent (whose W×H defines the target) and image (the hint, H×W×C or batched). You mostly just wire those and leave the rest at defaults.

Outputs: image_aligned is the reshaped hint - that's the one that goes into your ControlNet-apply node. bbox_json, width, and height are metadata, useful if you later want to crop something back to the original hint's region.

Installing it

It ships inside the SDXL Adherence pack, so install that once:

cd ComfyUI/custom_nodes
git clone https://github.com/regiellis/ComfyUI-SDXL-Adherence

Restart ComfyUI, or just search "SDXL Adherence" in ComfyUI Manager. There are no model downloads and no extra Python dependencies - the pack's requirements file is empty and it runs on the torch that already ships with ComfyUI.

Where people get burned

  • Tiny hints + reflect padding. The node pads with reflect directly, and PyTorch's reflect mode can throw when the padding is larger than the hint's own dimension. If you're aligning a small crop to a big latent and it errors, switch pad_kind to edge.
  • Sampler shape mismatch. The pack's own troubleshooting says it plainly: make sure hints go through this node and that the latent W×H actually match what the sampler gets. Skip this node and the shape mismatch is on you.
  • Example workflows from the repo. The author noted in the release thread that the bundled workflows load with node-id issues - if nodes come in red, right-click and recreate them.

The name is honest, which is rare. It doesn't make your ControlNet better, it just makes sure the ControlNet you already have is looking at the same canvas you're painting on.

Categoryitsjustregi / SDXL Adherence

Inputs (6)

NameTypeDefaultDescription
latentLATENTLatent whose W×H defines the target size.
imageIMAGEHint image to align (B×H×W×C or H×W×C).
snap_modeCOMBOpad_upHow to match the latent size: pad, downscale, resize, or crop.
pad_kindCOMBOreflectPadding mode for pad-up/downscale residual.
pad_valueoptINT1280–255Constant pad value (0..255).
keep_alphaoptBOOLEANfalsePreserve alpha channel if present.

Outputs (4)

NameTypeDescription
image_alignedIMAGE
bbox_jsonSTRING
widthINT
heightINT