Nodes/LoRA Block Surgeon/LoRA Block Profiler
ComfyUI Node

LoRA Block Profiler

Find Out Which Blocks a LoRA Actually Lives In

By Hearmeman24·Created 28 days ago·Updated 15 days ago· 1
LoRA Block Profiler
    • report
    lora_name
    sort_by
    top_n0

    Every once in a while you get a LoRA that works - the character is right - but it drags along something you never asked for. A color cast. A lighting mood. A style you can't prompt away. The LoRA author is often just as stuck as you are, because nothing in the training output tells you where the adapter stored its learned change. That's the exact question this node answers: pick a LoRA and it prints the Frobenius norm of the effective weight delta per transformer block, its share of total energy, a bar profile, and - the headline number - how many blocks hold 90% of the energy.

    That last line is the whole game. A LoRA is one small adapter per targeted layer, and the concept you trained usually concentrates in a handful of blocks while the rest carry small diffuse nudges that add up to a global style shift. Know which blocks hold the character and you can feed that range straight into the pack's filter node.

    Why "effective delta" and not "the stored factors"

    This is the part the author got right, and it's load-bearing. LoRA has a free scale: multiply the up matrix by 10 and divide down by 10 and the resulting delta - the tensor actually added to the base weight - is identical. So the norms of the stored factors carry literally zero information; only their product is well defined. The profiler measures that product, exactly, and without ever materialising the full delta: a rank-32 adapter on a 6144-wide layer reduces to a pair of 32×32 matrices via the cyclic property of trace, instead of a 6144×6144 product. LoKr adapters are measured through ‖kron(w1, w2)‖_F = ‖w1‖_F · ‖w2‖_F, exact, with no Kronecker product built.

    And it's honest about what it can't measure: LoHa and anything else unrecognised come back as NOT MEASURED and are excluded from every number, never folded into a zero. A silent zero would make a block look prunable when it was merely not understood - the one failure mode that would make the tool actively dangerous. Blocks are also aggregated in quadrature (sqrt(Σ nᵢ²), the norm of the stacked deltas), not summed linearly - a plain sum would over-rank blocks that simply contain more adapted layers.

    The inputs and output

    Three fields, all simple:

    • lora_name - pick the adapter from your loras folder. Read-only, never modified.
    • sort_by - block reads as a profile across depth (block 0 at the top); norm ranks the heaviest blocks first. norm is the one you want when you're hunting for the 90% cutoff.
    • top_n - how many rows to show. 0 means everything.

    The single output is report (STRING). It's an output node, so the report also goes to the ComfyUI console - keep the terminal open, because that's where you'll actually read it. Each row shows the block label, how many adapted layers it contains, the norm ‖ΔW‖_F, the energy percentage, and a # bar scaled against the biggest block. Embedders, heads and other index-less tensors are grouped as unblocked; token-refiner blocks are labelled token_refiner.N so they never collide with main block N. The report closes with something like 90% of the energy sits in 5 of 28 block groups: 31-35.

    The intended loop

    Profile a LoRA once, read the 90% line, type that exact range into LoRA Block Filter's blocks field in keep mode. If the character survives and the style cast drops, you just learned something about your file that the trainer couldn't tell you.

    Gotchas

    • Block numbering is base-specific. The matcher is verified against real reference files - Krea (28 blocks), WAN 2.2 (40), LTX 2.3 (48) - and the report's main blocks present: 0..27 line tells you the range you're actually working with. Don't copy a range from someone's screenshot of a different base model.
    • A LoHa LoRA returns "No measurable adapter tensors found." Not a bug - that format isn't supported, and the output says so rather than lying.
    • It's a console report, not a pretty widget. If you're on a remote setup with a hidden terminal, the report string is still available as a value you can route anywhere.

    Install

    ComfyUI Manager, search LoRA Block Surgeon, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Hearmeman24/ComfyUI-LoRABlockSurgeon
    

    Restart ComfyUI and you're done - no extra dependencies, no model downloads, nothing but the torch already inside ComfyUI. Two nodes, one tiny pack, and it's read-only against your files the whole time.

    CategoryLoRA Block Surgeon

    Inputs (3)

    NameTypeDefaultDescription
    lora_nameCOMBOOpened read-only. Never modified.
    sort_byCOMBO'block' reads as a profile across depth; 'norm' ranks the heaviest blocks first.
    top_noptINT00–5120 shows every block.

    Outputs (1)

    NameTypeDescription
    reportSTRING