Nodes/ComfyUI-RefUNet/REF] Ref Attn Map Adv
ComfyUI Node

REF] Ref Attn Map Adv

Pick exactly which attention blocks the reference talks to

By logtd·Created 2 years ago·Updated 2 years ago· 46
REF] Ref Attn Map Adv
    • ATTN_MAP
    input_attns0,1,2,3,4,5
    middle_attns0
    output_attns0,1,2,3,4,5,6,7,8

    ComfyUI-RefUNet's reference feature doesn't get captured from the whole UNet - it gets captured from a chosen subset of self-attention blocks. ConfigRefMapAdv ("REF] Ref Attn Map Adv") is the node that makes that choice, by typing block indices as text. It's the "advanced" sibling of CustomRefMapSD1, which gives you the same control as a grid of booleans; here you type comma-separated lists.

    The three inputs are input_attns, middle_attns, and output_attns, each a multiline string of indices, with sensible defaults pre-filled: 0,1,2,3,4,5 for input, 0 for middle, 0,1,2,3,4,5,6,7,8 for output. Those correspond to the self-attention blocks in an SD1.5 UNet's three sections, and the output is a single ATTN_MAP - a set of (block, index) pairs that you feed into the opt_attn_map input on WriteSampler and ReadSampler.

    What's actually being selected? Each block's attention writes/reads the reference features during the two sampling passes. Roughly: input blocks carry early, low-level structure; output blocks carry later detail; the single middle block is the bottleneck. More blocks on = closer adherence to the reference, more VRAM and slower. Fewer blocks = faster and lighter, but the character drifts. The defaults are a reasonable starting point, and if you unplug opt_attn_map entirely the samplers fall back to a built-in full SD1.5 map that covers more blocks than the node's defaults do - so the defaults here are a "trimmed but safe" preset, not the maximum.

    A couple of practical notes. Empty string means "no blocks from that section," which is legitimate. And this map is only meaningful if the model actually has those blocks - this whole pack targets SD1.5 UNets (the BasicTransformerBlock-based architecture), not SDXL, Flux, or DiT models. You're not going to point this at a Flux checkpoint and get anywhere.

    Install is the pack-wide step: ComfyUI Manager → search "ComfyUI-RefUNet", or git clone https://github.com/logtd/ComfyUI-RefUNet into custom_nodes/, restart. No Python dependencies - the README says so outright. The realistic workflow: leave the defaults, get your animation working end to end first, then start pruning blocks if VRAM is tight or the reference is too strong. This node is fine-tuning, not the first thing you configure.

    Categoryreference/custom

    Inputs (3)

    NameTypeDefaultDescription
    input_attnsSTRING0,1,2,3,4,5
    middle_attnsSTRING0
    output_attnsSTRING0,1,2,3,4,5,6,7,8

    Outputs (1)

    NameTypeDescription
    ATTN_MAPATTN_MAP