Nodes/ComfyUI-SD3-Powerlab/SD3 Layer to Image
ComfyUI Node

SD3 Layer to Image

Dump any tensor in the model, not just the attention

By G-370·Created 2 years ago·Updated 2 years ago· 20
SD3 Layer to Image
  • sd3_model
  • IMAGE
layer

The attention-specific nodes in this pack are cute, but SD3 Layer to Image is the one that makes you feel like you're rummaging through the model's actual insides. Instead of caring about attention, it takes any tensor name you type and renders it as an image - if the tensor happens to be 2D (or 1D, or the special position-embedding case). It's the generic "let me see what's in there" tool, and it works on far more than just SD3 attention.

You feed it a loaded SD3 model and a layer string, and it searches the model's state dict for a key containing that text. Substring match, deliberately fuzzy - type pos_embed, patchify, or final_layer and it finds the first (well, the last) key that contains it. If that tensor is two-dimensional, out comes an image; one-dimensional, it gets stretched into a viewable strip; three-dimensional only works for diffusion_model.pos_embed, where it grabs the first slice.

The inputs

Just two, both required:

  • sd3_model - the loaded checkpoint.
  • layer - a layer/tensor name, multiline. Because it's a substring search, partial names work. There's a dynamicPrompts flag on the field, but you'll normally just type a name.

Output is a single IMAGE. 2D tensors render as grayscale (the one channel is repeated three times so ComfyUI's image pipeline accepts it); 1D tensors are repeated sideways into a 256-wide strip so you can at least squint at the values. It's a data dump in image clothing, not a picture of anything - a 1536×1536 bias tensor isn't going to look like a cat, and it isn't supposed to.

Why you'd reach for it

Two reasons. First, curiosity and verification: dump a layer you're about to patch (the pack's Image into Layer does the reverse) and see what you're working with. Second, the "perturbed" experiments this pack grew out of - people were comparing tensors across blocks to figure out which ones safety training had touched, and a quick visual diff is a real way to spot a layer that looks degenerate next to its neighbors. If you're poking around SD3 Medium trying to understand its internals, this is the least intimidating on-ramp.

Installing it

Same pack, same drill: 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. The pack imports matplotlib at module load and ComfyUI doesn't bundle it - nodes missing from your menu means pip install matplotlib into ComfyUI's Python.

Gotchas

Because the match is a substring search, a vague name grabs the last matching key, which may not be the one you meant - be specific (diffusion_model.joint_blocks.0.x_block.attn.qkv.weight if you want that exact one). And anything that's not 2D, not 1D, and not the named pos_embed case just fails. The error is raised as a bare string, which Python 3 reports as a cryptic TypeError: exceptions must derive from BaseException - a pack quirk, not your mistake. Keep in mind the 1536-centric assumptions are tuned to SD3 Medium; other SD 3.5 variants have different shapes, though the generic search still finds their tensors.

CategorySD3 Power Lab/Hack

Inputs (2)

NameTypeDefaultDescription
sd3_modelMODEL
layerSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE