[Model] Migrate GPT-NeoX, Phi, Seed-OSS and Jais2 to the Transformers modeling backend (#59701)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5d20979fc9
commit
6e4efafc6e
@@ -32,6 +32,7 @@ from torch import nn
|
||||
from transformers import AutoModel, PreTrainedConfig
|
||||
from transformers.conversion_mapping import (
|
||||
WeightRenaming,
|
||||
get_checkpoint_conversion_mapping,
|
||||
get_model_conversion_mapping,
|
||||
)
|
||||
|
||||
@@ -311,7 +312,14 @@ class Base(
|
||||
orig_to_new_renaming: list[WeightRenaming] = []
|
||||
orig_to_new_regex: dict[re.Pattern, str | None] = {}
|
||||
|
||||
for mapping in get_model_conversion_mapping(self.model):
|
||||
mappings = get_model_conversion_mapping(self.model)
|
||||
# Ensure layers that are part of the model, but not AutoModel, get their mapping
|
||||
instantiated = {type(m).__name__ for m in self.model.modules()}
|
||||
for arch in self.config.architectures or []:
|
||||
if arch not in instantiated:
|
||||
mappings.extend(get_checkpoint_conversion_mapping(arch) or [])
|
||||
|
||||
for mapping in mappings:
|
||||
# Handle weights which have been renamed in Transformers
|
||||
if isinstance(mapping, WeightRenaming):
|
||||
orig_to_new_renaming.append(mapping)
|
||||
|
||||
Reference in New Issue
Block a user