-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: adding secure loading of models by default for haystack #3901
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to see this improvement! I have two small change requests specified in the comments below but I approve the idea of setting TORCH_FORCE_WEIGHTS_ONLY_LOAD in general. 👍
@@ -18,6 +18,12 @@ | |||
env_meta_data: Dict[str, Any] = {} | |||
|
|||
|
|||
def set_pytorch_secure_model_loading(flag_val="1"): | |||
# To load secure only model pytorch requires value of | |||
# TORCH_FORCE_WEIGHTS_ONLY_LOAD to be ["1", "y", "yes", "true"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check whether this flag is set to any value different from ["1", "y", "yes", "true"]
before setting it to 1. Maybe a user explicitly set it to False. In that case we shouldn't silently overwrite it. Instead, let's at least log a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it. I think your suggestion is taken care of, but please do let me know if you disagree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a minor suggestion but the PR looks good to me!
Co-authored-by: Massimiliano Pippi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. 👍 I will merge this now so that we have it on main before branching off.
* adding secure loading of models by default * simplified set function * testing import effect correctly * added appropriate log line, adapted the test * change log string formatting Co-authored-by: Massimiliano Pippi <[email protected]> * remove extra closing bracket ) Co-authored-by: Julian Risch <[email protected]> Co-authored-by: Massimiliano Pippi <[email protected]>
Related Issues
Proposed Changes:
setting TORCH_FORCE_WEIGHTS_ONLY_LOAD to 1 by default
How did you test it?
added unit test
Notes for the reviewer
To load secure-only model pytorch requires the value of TORCH_FORCE_WEIGHTS_ONLY_LOAD to be ["1", "y", "yes", "true"]
For more details please refer to pytorch PR pytorch/pytorch#87443.
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.