From 479536e34de5ba6c75e263c3c08da5d83fc37933 Mon Sep 17 00:00:00 2001 From: azazeal04 <132445160+azazeal04@users.noreply.github.com> Date: Sat, 4 Apr 2026 19:45:05 +0200 Subject: [PATCH] Prevent overwriting existing keys in state_dict Ensure new key is added only if it doesn't exist. --- comfy/lora_convert.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comfy/lora_convert.py b/comfy/lora_convert.py index 4b00d6ebc..5b4a869be 100644 --- a/comfy/lora_convert.py +++ b/comfy/lora_convert.py @@ -37,7 +37,8 @@ def twinflow_z_image_lora_to_diffusers(state_dict): for key in list(state_dict.keys()): if "t_embedder_2" not in key and key.startswith("t_embedder."): new_key = key.replace("t_embedder.", "t_embedder_2.", 1) - state_dict[new_key] = state_dict.pop(key) + if new_key not in state_dict: + state_dict[new_key] = state_dict.pop(key) return state_dict def convert_lora(sd):