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

HfModelHandler: Call save_metadata after model is saved #1485

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jambayk
Copy link
Contributor

@jambayk jambayk commented Nov 13, 2024

Describe your changes

  • Previously, we save the metadata before calling save_pretrained on the modified PreTrained model object. This was done so that save_metadata doesn't override any files saved by save_pretrained.
  • However, this leads to SameFileError if the model was loaded from a local path with trust_remote_code=True since it also tries to save the module files.
  • To support this case as well as correctly update the auto_map in the config file to point to the saved files, we now call save_metadata after save_pretrained in `save_model_files. This is made possible with the following changes:
    • config is loaded from the save directory if already present
    • generation config and tokenizer are not saved if they already exist.
  • test_hf_model is more comprehensive now with both local and hf-hub models.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.
  • Is this PR including examples changes? If yes, please remember to update example documentation in a follow-up PR.

(Optional) Issue link

Fixes #1442

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.

Using a local model in input_model causes SameFileError in MergeAdapters Pass
2 participants