Nodes/ComfyUI-BFSNodes/BFS H3 Regional Reference Attention
ComfyUI Node

BFS H3 Regional Reference Attention

Routes each reference picture to its own person inside the attention, without masks: the guide's colored face contours seed each person, the model's own features follow them through the video, and a soft bias makes person j read Picture j (color order) and the background read no picture. Works with H3 video and H3 Image face swap. Recommended: routing soft, strength 4, background 4, bias_layers 'from route layer'. Not compatible with Model Sparse Attention (sol-attn) or other block-sparse / block-replacing attention nodes: they skip this node (a warning is logged). SageAttention and plain SDPA work.

By alisson-anjos·Created 9 months ago·Updated 6 days ago· 141
BFS H3 Regional Reference Attention
  • model
  • positive
  • guide
  • subject_map
  • MODEL
◄isolationpeople►
◄outside_subjectsno picture►
◄dilate1►
◄route_layer12►
◄margin0.05►
◄routingsoft►
◄strength4.0►
◄sharpness0.050►
◄background4.0►
◄trackingpropagate►
◄bias_layersfrom route layer►
◄radius3►
◄bias_start0►
◄bias_end0►
CategoryBFS/MiniMax H3

Inputs (18)

NameTypeDefaultDescription
modelMODEL—
positiveCONDITIONINGThe conditioning with the pictures (to find each picture's vision tokens in the text).
isolationCOMBOpeoplepictures only: each person reads only its picture; people still see each other. people: each person is an island: reads its picture, the guide, the background and the text, never another person; the background and unpicked people read only the guide, the background and the text; a person's guide tokens read only that person's picture. people + text: the text rows inside the DiT also stop reading pictures and people.
outside_subjectsCOMBOno pictureWhat the background and unpicked people may read. 'no picture' = no identity can land outside the picked subjects.
dilateINT10–8Grow every subject by N tokens (32 px each).
guideoptIMAGEAttention tracking (no masks): the marked guide (Video Segment Picker `hybrid` output in 'Multi Face Swap — Sparse Face Contour' mode). The contours seed each person; the model's own attention finds that person in every frame.
subject_mapoptIMAGEMask mode instead: BFS Video Segment Picker `subject_map` (each subject's mask in its color).
route_layeroptINT121–49Attention tracking: DiT layer whose queries/keys find the people (mid layers are the most semantic).
marginoptFLOAT0.050–0.5Attention tracking, hard routing: how clearly a token must match a person over the background and the other people.
routingoptCOMBOsoftAttention tracking. soft: nothing is blocked, the attention is only biased: a token pays more attention to the picture of the person it looks like (the model's own affinity) and less to the others. hard: blocked.
strengthoptFLOAT4.00–20Soft routing: logit bias (4 = about 55x more attention to the right picture than to a wrong one).
sharpnessoptFLOAT0.0500.005–1Soft routing: temperature of the person affinity (lower = closer to all-or-nothing).
backgroundoptFLOAT4.00–20Soft routing: logit push away from every picture for tokens that are no tracked person (0 = neutral).
trackingoptCOMBOpropagatepropagate: each person is followed frame to frame from the marked frames. propagate + match: what the frame-to-frame step cannot reach (fast motion, camera cuts) is matched to the most similar marked tokens of the whole clip.
bias_layersoptCOMBOfrom route layerWhich DiT layers get the bias: all, or only the tracking layer and the ones after it (what an attention-trained LoRA saw).
radiusoptINT31–12Attention tracking: how far (in 32 px tokens) a person may move between two latent frames (4 video frames).
bias_startoptINT00–49First block that gets the bias (0 = as bias_layers says). The tracking still runs at route_layer. 24 keeps the quality of the full range in tests (the face identity is decided from about block 24) and runs about 30% faster.
bias_endoptINT00–49Last block that gets the bias (0 = the last block). Fewer biased blocks keep more of the fast attention backend.

Outputs (1)

NameTypeDescription
MODELMODEL—