Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mamba] from pretrained issue with self.embeddings #29851

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/transformers/models/mamba/modeling_mamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,15 @@ def __init__(self, config):
self.gradient_checkpointing = False
self.norm_f = MambaRMSNorm(config.hidden_size, eps=config.layer_norm_epsilon)
# Initialize weights and apply final processing
self._register_load_state_dict_pre_hook(self.load_hook)
self.post_init()

def load_hook(self, state_dict, prefix, *args):
for k in state_dict:
if "embedding" in k:
ArthurZucker marked this conversation as resolved.
Show resolved Hide resolved
state_dict[k.replace("embedding.", "embeddings.")] = state_dict.pop(k)
break

def get_input_embeddings(self):
return self.embeddings

Expand Down
Loading