@@ -45,6 +45,7 @@ def detect_lora_format(keys: List[str]) -> Dict:
4545 - Diffusers: *.lora_A.weight, *.lora_B.weight
4646 - PEFT: base_model.model.*.lora_A/B
4747 - ComfyUI native: *.lora_down.weight, *.lora_up.weight
48+ - HuggingFace: *.lora.down.weight, *.lora.up.weight (dots instead of underscores)
4849 - Full diff: *.diff, *.diff_b (full weight differences, not low-rank)
4950 - Flux/SDXL: Various transformer key patterns
5051
@@ -96,6 +97,13 @@ def detect_lora_format(keys: List[str]) -> Dict:
9697 format_info ["down_suffix" ] = ".lora_A.default.weight"
9798 format_info ["up_suffix" ] = ".lora_B.default.weight"
9899
100+ # HuggingFace format: transformer.*.lora.down.weight (dots instead of underscores)
101+ elif any ('.lora.down.weight' in k for k in sample_keys ):
102+ format_info ["format" ] = "huggingface"
103+ format_info ["down_suffix" ] = ".lora.down.weight"
104+ format_info ["up_suffix" ] = ".lora.up.weight"
105+ format_info ["alpha_suffix" ] = ".alpha"
106+
99107 # ComfyUI native / standard
100108 elif any ('.lora_down.weight' in k for k in sample_keys ):
101109 format_info ["format" ] = "comfy"
@@ -109,6 +117,7 @@ def detect_lora_format(keys: List[str]) -> Dict:
109117 return format_info
110118
111119
120+
112121def extract_lora_pairs (keys : List [str ], format_info : Dict ) -> Dict [str , Dict [str , str ]]:
113122 """
114123 Group LoRA keys into down/up/alpha pairs.
@@ -739,9 +748,13 @@ def extract_core_layer_lora(block_name: str) -> str:
739748 if block_name .startswith (prefix ):
740749 block_name = block_name [len (prefix ):]
741750 break
751+ # Strip trailing .lora suffix (HuggingFace format leaves this after suffix removal)
752+ if block_name .endswith (".lora" ):
753+ block_name = block_name [:- 5 ]
742754 # Convert dots to underscores (diffusers format uses dots)
743755 return block_name .replace ("." , "_" )
744756
757+
745758 # Build lookup table: core layer name (underscored) -> original base key
746759 base_key_lookup = {}
747760 for bk in base_handler .keys ():
@@ -1262,8 +1275,12 @@ def extract_core_layer_lora(block_name: str) -> str:
12621275 if block_name .startswith (prefix ):
12631276 block_name = block_name [len (prefix ):]
12641277 break
1278+ # Strip trailing .lora suffix (HuggingFace format leaves this after suffix removal)
1279+ if block_name .endswith (".lora" ):
1280+ block_name = block_name [:- 5 ]
12651281 return block_name .replace ("." , "_" )
12661282
1283+
12671284 # Build base key lookup
12681285 base_key_lookup = {}
12691286 for bk in base_handler .keys ():
@@ -1657,8 +1674,12 @@ def extract_core_layer_lora(block_name: str) -> str:
16571674 if result .startswith (prefix ):
16581675 result = result [len (prefix ):]
16591676 break
1677+ # Strip trailing .lora suffix (HuggingFace format leaves this after suffix removal)
1678+ if result .endswith (".lora" ):
1679+ result = result [:- 5 ]
16601680 return result .replace ("." , "_" )
16611681
1682+
16621683 # Build LoRA lookup: core layer name (underscored) -> list of (info, block_keys)
16631684 lora_lookup = {}
16641685 for info in lora_infos :
0 commit comments