Nodes/ComfyUI fabric/KSampler FABRIC (Advanced)
ComfyUI Node

KSampler FABRIC (Advanced)

FABRIC for multi-stage and img2img workflows

By ssitu·Created 3 years ago·Updated 2 years ago· 94
KSampler FABRIC (Advanced)
  • model
  • positive
  • negative
  • latent_image
  • null_pos
  • null_neg
  • pos_latents
  • neg_latents
  • LATENT
add_noise
noise_seed0
steps20
cfg8.0
sampler_name
scheduler
start_at_step0
end_at_step10000
return_with_leftover_noise
pos_weight1.00
neg_weight1.00
feedback_start0
feedback_end10000

This is the FABRIC node for people whose workflow doesn't fit inside a single plain KSampler. FABRIC, in one line, is the training-free "personal RLHF" technique (paper arXiv 2307.10159): reference images you like and dislike get their attention states injected during denoising, pulling the output toward the liked ones and away from the disliked ones. The other sampler nodes in ComfyUI_fabric wrap a regular KSampler; this one wraps KSamplerAdvanced, which means it comes with add_noise, start_at_step, end_at_step, and return_with_leftover_noise on top of the full FABRIC input set.

When you'd reach for it. Two situations. First, img2img and partial-denoise passes: the advanced sampler's start_at_step/end_at_step let you denoise only part of the schedule, which matters when your input latent already carries content you want to keep. Second, multi-stage pipelines - refiner passes, upscale-then-denoise, or any workflow where a plain denoise value doesn't cut it. If you just want FABRIC steering from a text-to-image, the plain "KSampler FABRIC" or the Simple variant will serve you better and annoy you less.

The FABRIC inputs are the full set, shared with the plain KSamplerFABRICAdv:

  • null_pos / null_neg - required conditionings (feed both an empty CLIPTextEncode string; that's the intended setup).
  • pos_weight / neg_weight - both default 1.0; the README warns that's usually too strong.
  • feedback_start / feedback_end - the explicit step window for feedback. Defaults 0 and 10000 (the whole run). The researchers recommend feedback only in the first half of denoising.
  • pos_latents / neg_latents - your liked/disliked references as VAE-encoded latent batches.

One quirk to know up front: denoise is not an input here - the source hard-codes it to 1.0. The advanced KSampler it's built on normally offers denoise alongside start_at_step/end_at_step, but this node silently forces full denoise and uses those two fields for scheduling instead. If you're coming from stock KSamplerAdvanced muscle memory, that's the difference that will trip you up.

How it works. Everything funnels into fabric_sample: it computes the sampler's timestep schedule, translates feedback_start/feedback_end into that schedule, and wraps the model so that during the feedback window each reference latent gets noised to the current timestep, run through the U-Net against the null conditioning, and has its per-block attention states appended to the live keys and values - scaled by your weights. Pure inference-time attention injection, no training, no extra weights. Outside the window it samples completely normally.

Install. Identical to the rest of the pack - no dependencies, no model downloads:

cd ComfyUI/custom_nodes
git clone https://github.com/ssitu/ComfyUI_fabric

Restart ComfyUI (or find "ComfyUI fabric" in Manager). It's under the FABRIC/ menu.

Gotchas. The usual FABRIC trio: keep input, pos, and neg latents the same pixel size (mismatches get bilinear-resized, which the author says is a poor way to do it - resize in pixel space), expect memory pressure because each reference adds forward passes (switch cross-attention backends or shrink the reference batch on OOM), and remember this pack hasn't been updated since May 2024 and monkeypatches attention internals, so a big ComfyUI update may break it or silently degrade it to a plain sampler. If generations stop reacting to your references, check the console - the [FABRIC] prints will tell you what it's doing.

CategoryFABRIC

Inputs (21)

NameTypeDefaultDescription
modelMODEL
add_noiseCOMBO2 options: enable, disable
noise_seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
sampler_nameCOMBO44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
start_at_stepINT00–10000
end_at_stepINT100000–10000
return_with_leftover_noiseCOMBO2 options: disable, enable
null_posCONDITIONING
null_negCONDITIONING
pos_weightFLOAT1.000–1
neg_weightFLOAT1.000–1
feedback_startINT00–10000
feedback_endINT100000–10000
pos_latentsoptLATENT
neg_latentsoptLATENT

Outputs (1)

NameTypeDescription
LATENTLATENT