[Bugfix] Fix _CONFIG_REGISTRY types getting wrong config class when on-disk model_type differs (#39554)
Signed-off-by: Misa <misaAle@users.noreply.github.com> Signed-off-by: Misael Casarez <misacasa@amazon.com> Co-authored-by: Misael Casarez <misacasa@amazon.com>
This commit is contained in:
@@ -210,6 +210,16 @@ class HFConfigParser(ConfigParserBase):
|
||||
config_class = _CONFIG_REGISTRY[model_type]
|
||||
config_class.model_type = model_type
|
||||
AutoConfig.register(model_type, config_class, exist_ok=True)
|
||||
# If the on-disk model_type differs from the overridden
|
||||
# one, register under both so AutoConfig.from_pretrained
|
||||
# returns the correct class regardless of what the
|
||||
# checkpoint says
|
||||
if (
|
||||
config_model_type := config_dict.get("model_type")
|
||||
) and config_model_type != model_type:
|
||||
config_class.model_type = config_model_type
|
||||
AutoConfig.register(config_model_type, config_class, exist_ok=True)
|
||||
config_class.model_type = model_type
|
||||
# Now that it is registered, it is not considered remote code anymore
|
||||
trust_remote_code = False
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user