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

Raise error on wrong type for to modules_to_save #1496

Conversation

BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented Feb 21, 2024

Resolves #1492

This PR is for user convenience. When they try to pass the wrong type to modules_to_save, they will now get an early error message, instead of getting an obscure error when calling forward later.

Note:

The reason why ModulesToSaveWrapper cannot support ModuleDict et al. is because it tries to call forward on the original or copied module, but these modules don't implement a forward method.

Resolves huggingface#1492

This PR is for user convenience. When they try to pass the wrong type to
modules_to_save, they will now get an early error message, instead of
getting an obscure error when calling forward later.

Note:

The reason why ModulesToSaveWrapper cannot support ModuleDict et al. is
because it tries to call forward on the original or copied module, but
these modules don't implement a forward method.
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks @BenjaminBossan for working on this !

@BenjaminBossan BenjaminBossan merged commit 2efc36c into huggingface:main Feb 21, 2024
14 checks passed
@BenjaminBossan BenjaminBossan deleted the raise-error-when-modules_to_save-wrong-type branch February 21, 2024 12:18
BenjaminBossan added a commit to BenjaminBossan/peft that referenced this pull request Mar 14, 2024
Resolves huggingface#1492

This PR is for user convenience. When they try to pass the wrong type to
modules_to_save, they will now get an early error message, instead of
getting an obscure error when calling forward later.

Note:

The reason why ModulesToSaveWrapper cannot support ModuleDict et al. is
because it tries to call forward on the original or copied module, but
these modules don't implement a forward method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ModulesToSaveWrapper not working with ModulesDict dictionary methods
3 participants