Skip to content

remove FSDP prefix when using save_pretrained with FSDP2 #40207

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
3 changes: 2 additions & 1 deletion src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3923,7 +3923,8 @@ def save_pretrained(
model_to_save.config.torch_dtype = str(dtype).split(".")[1]

# Attach architecture to the config
model_to_save.config.architectures = [model_to_save.__class__.__name__]
# When using FSDP2, unwrapping is a noop, so the model name doesn't change back to the original model name
model_to_save.config.architectures = [model_to_save.__class__.__name__.lstrip("FSDP")]

# If we have a custom model, we copy the file defining it in the folder and set the attributes so it can be
# loaded from the Hub.
Expand Down