Avoid duplicate quant metadata markers
This commit is contained in:
parent
50af1a3563
commit
48454d17b6
|
|
@ -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={}):
|
||||
|
|
|
|||
|
|
@ -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 ----
|
||||
|
|
|
|||
Loading…
Reference in New Issue