diff --git a/comfy/utils.py b/comfy/utils.py index e1a099fbf..799063273 100644 --- a/comfy/utils.py +++ b/comfy/utils.py @@ -1412,6 +1412,11 @@ def _resolve_quant_metadata_layer_key(state_dict, layer_key, model_prefix): candidate = "{}{}".format(model_prefix, layer_key) if "{}.weight".format(candidate) in state_dict: return candidate + parts = layer_key.split(".") + for i in range(1, len(parts)): + candidate = ".".join(parts[i:]) + if "{}.weight".format(candidate) in state_dict and "{}.comfy_quant".format(candidate) in state_dict: + return candidate return layer_key def convert_old_quants(state_dict, model_prefix="", metadata={}): diff --git a/tests-unit/comfy_quant/test_convert_old_quants_prefix.py b/tests-unit/comfy_quant/test_convert_old_quants_prefix.py index a2aa7da17..86366ab18 100644 --- a/tests-unit/comfy_quant/test_convert_old_quants_prefix.py +++ b/tests-unit/comfy_quant/test_convert_old_quants_prefix.py @@ -176,6 +176,7 @@ class TestConvertOldQuantsPrefixAware(unittest.TestCase): self.assertIn("proj_in.comfy_quant", sd, f"{convention} metadata convention did not resolve after the two-call dance") + self.assertNotIn("model.diffusion_model.proj_in.comfy_quant", sd) self.assertEqual(marker_json(sd, "proj_in.comfy_quant")["format"], "float8_e4m3fn") # ---- extra: repeated calls with identical inputs don't duplicate/clobber ----