Nodes/ComfyUI-YogurtNodes/Create LoRA Mapping JSON (Yogurt Nodes)
ComfyUI Node

Create LoRA Mapping JSON (Yogurt Nodes)

The translation table when one LoRA's keys don't fit another

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
Create LoRA Mapping JSON (Yogurt Nodes)
  • loraA
  • loraB
  • mapping_json

LoRAs are dictionaries of tensors keyed by layer names, and not every trainer names its layers the same way. A LoRA trained for one architecture or with one converter can have keys that simply don't line up with another LoRA you want to merge it with. Create LoRA Mapping JSON (Yogurt Nodes) is the tool that builds the bridge: it takes two LoRA objects and produces a JSON mapping from LoRA A's keys to LoRA B's keys, so you can rename one to match the other.

The honest version of the pitch is in the node's own description: it's a "best-effort" mapping. The whole point is to hand the result to this pack's Convert LoRA Keys node, which renames LoRA A's tensors according to the mapping - turning two incompatible key layouts into one that lines up. It exists to unstick the "these two LoRAs should merge but the shapes/names don't agree" situation that otherwise ends in a pile of manual key surgery.

How it works

It works in two passes, from most confident to least. First it checks every key in A against B directly - exact matches map to themselves. Then it falls back to structure: it strips each key down to its "core structure" (it recognizes transformer_blocks.<n>, and the input_blocks/output_blocks/middle_blocks patterns common in SD-style U-Nets), groups keys by that structure, and pairs them up in order within each group. Keys in A that find no counterpart in B just don't get mapped. The output is a JSON object: A-key → B-key, formatted with two-space indentation.

That's the good news and the caveat at once. The structure-based pairing is smart about ordering, but it's heuristic - it assumes keys in the same structural bucket belong together. It's a strong starting point, not a guarantee.

The inputs that matter

  • loraA - the source, the one whose keys need renaming.
  • loraB - the target layout it should conform to.

One output: mapping_json - a STRING, ready to paste into the Convert LoRA Keys node (or eyeball before you trust it).

Installing it

It's part of ComfyUI-YogurtNodes. Install via ComfyUI Manager (search "ComfyUI-YogurtNodes") or:

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

Restart ComfyUI and it's under "Yogurt Nodes". No models to download.

Where people get burned

Do not skip the review step. Because the fallback matching is structural rather than semantic, a transformer-block count mismatch or an unusual converter can produce plausible-looking but wrong pairings, and a wrong mapping silently shuffles weights. Before you commit, run the mapping through a quick sanity check - count how many keys mapped, spot-check a few against both LoRAs, and confirm the mapped shapes actually match. Also remember this node only produces the JSON; the actual renaming happens in Convert LoRA Keys, so you'll usually want the two wired together.

CategoryYogurtNodes/Models

Inputs (2)

NameTypeDefaultDescription
loraALORASource LoRA key layout.
loraBLORATarget LoRA key layout.

Outputs (1)

NameTypeDescription
mapping_jsonSTRING