Nodes/ComfyUI-SD3-Powerlab/SD3 Attention To Image
ComfyUI Node

SD3 Attention To Image

The boring, exact dump you can edit and put back

By G-370·Created 2 years ago·Updated 2 years ago· 20
SD3 Attention To Image
  • sd3_model
  • IMAGE
joint_block0
backbone

If you try SD3 Attention To Image expecting a pretty heatmap, you'll be disappointed. It renders the raw QKV weight matrix of a joint block as a 1536×1536 RGB image with zero normalization, no colormap, no styling. It looks like TV static with a color cast. That's not a bug - it's the entire point. This is the pack's exact dump node, the one you use when your plan is to edit the numbers and hand them back to the model.

It's the sibling of Render SD3 Attention in the same pack. Where that node pretty-prints a block's weights for eyeballing, this one gives you the lossless version: the query, key, and value matrices interleaved as the three color channels of one image, so a 4608×1536 weight tensor fits exactly into 1536×1536×3 pixels. Nothing is scaled, nothing is smoothed, every pixel maps to a real weight value.

What it's for

Step one of a "edit the weights with an image editor" workflow. The pattern is:

  1. SD3 Attention To Image - pull a block's attention weights out as an image.
  2. Edit it - in an external editor, or through ComfyUI image nodes.
  3. SD3 Image Into Attention (same pack) - patch the edited image back into the model.

Feed the untouched image back at full strength and you get the original weights - a clean round trip. Hand-edit the image and you're literally rewriting how that block attends, which is the "power lab" fantasy this whole repo is built around. It's also handy for diffing: dump block 4 and block 5, save both, and visually compare how different the attention looks across the network.

The inputs

Only three, and all required:

  • sd3_model - the loaded SD3 checkpoint you're reading from.
  • joint_block - which of the 24 blocks (0–23).
  • backbone - text (context_block, text tokens) or latent (x_block, image tokens).

Output is a single IMAGE. The code clones the tensor before reshaping, so dumping a block doesn't mutate the model you loaded.

Installing it

Same pack as always: ComfyUI Manager → search ComfyUI-SD3-Powerlab → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/G-370/ComfyUI-SD3-Powerlab

No requirements.txt, no model downloads. One real dependency gotcha: the pack imports matplotlib at module load and ComfyUI doesn't install it, so if your Python env lacks it, every node in the pack stays missing from your menu. pip install matplotlib fixes it.

Gotchas

The 1536-wide reshape is hardcoded for SD3 Medium's architecture. Other SD 3.5 family members have different hidden sizes, so the view(1536, 1536, 3) will fail with a shape error. And remember this dump is interleaved, not a faithful "image of the model" - the three channels are three different matrices packed into one picture. It's a data container wearing a disguise, which is exactly why the write-back node can swallow it whole.

CategorySD3 Power Lab/Hack

Inputs (3)

NameTypeDefaultDescription
sd3_modelMODEL
joint_blockINT0
backboneCOMBO2 options: text, latent

Outputs (1)

NameTypeDescription
IMAGEIMAGE