Rename Checkpoint Keys
Rename Checkpoint Keys — fix a checkpoint whose layer names don't match
- output_path
Every checkpoint is a dictionary of tensor names mapped to weights, and every training framework has its own opinion about what those names should be. Diffusers uses one convention, the original Stable Diffusion repo uses another, kohya's scripts sometimes produce a third, and a loader written against one of them will throw "these weights are unused" warnings - or just silently ignore half the file - when handed a checkpoint saved under a different one. CheckpointRenameKeys is the tool for when that happens to you: point it at a checkpoint, tell it which key names to swap for which, and it saves a new file with the fix baked in.
This is exactly the kind of glue work that otherwise means writing a one-off Python script with safetensors.torch.load_file, some string replacement, and save_file - the sort of thing everyone in this space has done at least once and nobody enjoys doing twice. Having it as a ComfyUI node means you don't leave the app, and you don't need a script lying around for a problem you hit maybe once a month.
How it works. It loads the checkpoint, walks its tensor keys, and applies whatever renaming you specify, then writes the result out as a new .safetensors file - your original is left untouched.
Inputs that matter. ckpt_name is a dropdown of your local checkpoints - the file to work on. old_keys and new_keys are both multiline text fields: you list the key names (or key-name fragments) you want replaced, one set old and one set new. This is where ModelMetaKeys earns its keep as a companion node - run that first to get the actual key names in your file, since renaming blind is a good way to match nothing and silently produce an identical output. output_filename (default renamed_checkpoint) is what the new file gets called.
Output. output_path (STRING) - where the renamed checkpoint landed. It's an output node, so ComfyUI runs it as a terminal step in the graph whether or not you wire that path anywhere else.
Installing it. ComfyUI Manager, search "Model Utility Toolkit," or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-ModelUtils
Restart ComfyUI. Nothing extra to fetch - this operates purely on checkpoints you already have on disk.
Troubleshooting. The single most useful habit here: always inspect the keys first with ModelMetaKeys before you rename anything. A checkpoint's tensor names can run into the hundreds, and getting the old-key string even slightly wrong means the rename quietly matches nothing rather than erroring loudly - you'll get an output file that looks identical to the input, and you'll spend time debugging a node that isn't actually broken. Keep your old_keys and new_keys lists in the same order and the same count; a mismatch between the two is on you to catch, since nothing in the schema enforces it. And because this writes a brand-new file rather than modifying in place, it's safe to experiment with - if a rename goes wrong, your original checkpoint is exactly as it was, and you just delete the bad output and try again. Safetensors itself carries no code-execution risk either way, so the worst case here is a checkpoint that won't load, not a compromised one.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| ckpt_name | COMBO | 0 options: | |
| old_keys | STRING | — | |
| new_keys | STRING | — | |
| output_filename | STRING | renamed_checkpoint | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_path | STRING | — |