fix: enable weights_only=True in torch.load for secure state loading#593
fix: enable weights_only=True in torch.load for secure state loading#593RinZ27 wants to merge 2 commits intoPrunaAI:mainfrom
Conversation
|
Thank you for the PR @RinZ27! I've run the tests :) |
|
This PR has been inactive for 10 days and is now marked as stale. |
2415798 to
e2609f4
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
|
Thanks for the patience @sdiazlor. Just finished rebasing onto the latest main and cleared out the conflicts. Everything should be clean now and ready for another check whenever you have a moment. |
|
This PR has been inactive for 10 days and is now marked as stale. |
|
@sdiazlor Just a quick ping as the stale bot kicked in. Everything is rebased and conflicts are cleared, so it's ready for a final look whenever you have a moment. |
|
This PR has been inactive for 10 days and is now marked as stale. |
|
Hey @begumcig, just giving this a quick nudge since the stale bot reached out. Been following the discussion in #632 about the broader architectural shift towards safetensors and fallback logic. Merging this now seems like a solid interim step because it targets isolated metrics and data modules where the loading logic is already predictable. Since @sdiazlor already gave it a green light, I think we can safely harden these specific paths without impacting the larger refactoring efforts for the engine. Let me know if you’d prefer me to hold off until the unified save/load logic is ready, or if we can push this through as a quick win for those specific modules. |
Description
Enable
weights_only=Truefor specifictorch.loadcalls in data modules and metrics where only tensors or state dicts are being loaded. This reduces the security surface by preventing arbitrary code execution when loading these files.Related Issue
Related to #592
Type of Change
How Has This Been Tested?
I've reviewed the loading logic in
diffuser_distillation_data_module.pyandaesthetic_laion.pyto ensure they only load supported data types (tensors, dicts, strings). Everything looks green and compatible withweights_only=True.Checklist
Additional Notes
While
src/pruna/engine/load.pystill requiresweights_only=Falsefor loading full model objects, I've opted to fix these specific instances where it's safe and beneficial. I've also opened a separate issue #592 to discuss a longer-term architectural improvement for model persistence.