Nodes/RES4LYF/ClownStyle_Attn_MMDiT
ComfyUI Node Runs on cloud

ClownStyle_Attn_MMDiT

Style transfer at the attention level for Flux, SD3.5 and HiDream

By ClownsharkBatwing·Created 2 years ago·Updated 18 days ago· 1,222
ClownStyle_Attn_MMDiT
  • mask
  • blocks
  • blocks
modescattersort
apply_toimg+txt
block_typesingle
block_listall
block_weights1.0
q_proj0.00
k_proj0.00
v_proj0.00
q_norm0.00
k_norm0.00
out0.00
tile_h128
tile_w128
invert_maskfalse

This is the attention-layer dial for RES4LYF's style-transfer system, built for MMDiT-architecture models - Flux, SD3.5, HiDream, AuraFlow, Chroma, the dual-stream/single-stream transformer designs that replaced the classic U-Net. You don't use this on its own: you chain it into ClownStyle_UNet's blocks input to push style matching deeper into the network than that node's own proj_in/proj_out taps reach, right down into the query/key/value math itself.

How it works

MMDiT models run image and text tokens through "double" blocks (separate streams that cross-attend) and "single" blocks (streams merged into one). block_type picks which you're targeting. Inside whichever type, this node taps the attention computation directly: q_proj/k_proj/v_proj are the query/key/value projection weights, q_norm/k_norm are the normalization applied to query and key (a detail specific to how MMDiT attention is built - plain U-Net attention doesn't have this step, which is why the sibling ClownStyle_Attn_UNet doesn't expose it), and out is the attention's output projection. Each is a float weight for how hard the chosen mode (the same style-matching algorithm list as ClownStyle_UNet - scattersort, AdaIN, WCT, and friends) gets applied at that specific tap.

The inputs and outputs that matter

  • mode - which style-matching algorithm runs at the taps you enable. See ClownStyle_UNet for what each one does.
  • apply_to (img / img+txt / img,txt / txt) - whether the matching touches image tokens, text tokens, or both. For most style work you want the image tokens involved; txt alone is a narrower, more experimental target.
  • block_type (double / double,single / single) - which block family to hit.
  • block_list (default "all") and block_weights (default "1.0") - target specific block indices instead of the whole stack, and taper the effect across whichever blocks you picked instead of applying it uniformly.
  • The six float taps - q_proj, k_proj, v_proj, q_norm, k_norm, out - all default to 0 (off). These are the actual dials; start with one or two nonzero rather than all six at once, since they compound fast.
  • mask + invert_mask restrict the effect spatially; tile_h/tile_w only matter for the tiled_ modes.
  • blocks (optional in) chains from an earlier ClownStyle_* node; the node's own blocks output chains onward, ultimately into ClownStyle_UNet.

How to install it

Via ComfyUI Manager, search "RES4LYF". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

then restart.

Common issues & troubleshooting

All six weight floats default to zero. Wiring this node in and seeing no change at all almost always just means you haven't turned any tap on yet - that's the expected starting state, not a bug.

Start at ClownStyle_UNet before reaching for this. This node is deep, per-block tuning on top of the entry-point node's own proj_in/proj_out control. If you haven't already gotten a result you like from the simpler top-level knobs, this is a much bigger search space than you need yet.

A syntax slip in block_list (a stray comma, a bad index range) is the likeliest reason "all" silently stops applying to the blocks you meant to target. If you're not sure, leave it at "all" while you're still dialing in the weight floats, then narrow it down once you know the effect works at all.

CategoryRES4LYF/sampler_extensions

Inputs (16)

NameTypeDefaultDescription
modeCOMBOscattersort10 options: none, scattersort_dir, scattersort_dir2, scattersort, tiled_scattersort, AdaIN, +4
apply_toCOMBOimg+txt4 options: img, img+txt, img,txt, txt
block_typeCOMBOsingle3 options: double, double,single, single
block_listSTRINGall
block_weightsSTRING1.0
q_projFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
k_projFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
v_projFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
q_normFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
k_normFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
outFLOAT0.00-100–100Strength of effect on layer; skips extra calculation if set to 0.0. Skips interpolation if set to 1.0.
tile_hINT12816–10000Tile size for tiled modes. Lower values will transfer composition more effectively. Dimensions of image must be divisible by this value.
tile_wINT12816–10000Tile size for tiled modes. Lower values will transfer composition more effectively. Dimensions of image must be divisible by this value.
invert_maskBOOLEANfalse
maskoptMASK
blocksoptBLOCKS

Outputs (1)

NameTypeDescription
blocksBLOCKS