Ignore unknown parameters in quantize_config.json

This commit is contained in:
ZXED 2023-09-10 18:39:40 +03:00
parent 1793227283
commit 121dbd15a5
No known key found for this signature in database
GPG key ID: 637FB44813DCFD66

View file

@ -91,9 +91,17 @@ class BaseQuantizeConfig(PushToHubMixin):
_commit_hash=commit_hash, _commit_hash=commit_hash,
) )
field_names = [field.name for field in fields(cls)]
with open(resolved_config_file, "r", encoding="utf-8") as f: with open(resolved_config_file, "r", encoding="utf-8") as f:
return cls(**json.load(f)) args_from_json = json.load(f)
filtered_args = {}
for key, val in args_from_json.items():
if key in field_names:
filtered_args[key] = val
else:
logger.warning(f"ignoring unknown parameter in {quantize_config_filename}: {key}.")
return cls(**filtered_args)
def to_dict(self): def to_dict(self):
return { return {
"bits": self.bits, "bits": self.bits,