Merge pull request #335 from z80maniac/ignore-extra-args

Ignore unknown parameters in quantize_config.json
This commit is contained in:
潘其威(William) 2023-09-26 14:00:38 +08:00 committed by GitHub
commit b461b6fa13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,