Fix for use_safetensors parameters, allow use of parameter on loading submodels (#9576) #9587
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes the issue described in (#9576) where use_safetensors parameter from pipeline is not passed to submodules when them is loaded from "from_pretrained" method.
Reproduction tests:
1. If I do not pass use_safetensors in the pipeline, it will set use_safetensors to True and allow_pickle to True and then an alert will be issued if it does not find ".safetensors" in the directory, however it will continue loading the .bin files normally.
Log:
2. If I pass use_safetensors True in the pipeline, it will not issue the warning, it will simply give the error message that it did not find ".safetensors" files in the directory.
Log:
3. If I pass use_safetensors False in the pipeline (the scenario where this PR is fixing), then it means that it will directly search for the .bin files in the directory without throwing errors, except if the model is .safetensors, then it will throw an error saying that it didn't find any .bin files in the directory.
IF model is .bin:
IF model is .safetensors:
Log:
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@yiyixuxu and @asomoza