fix(model): fix Model.from_pretrained to support lightning 2.6+
#1962
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.
weights_only=Falseparameter topl_load()call inModel.from_pretrainedmethodSecurity Summary
No security vulnerabilities were discovered during the security scan. The change to add
weights_only=Falseis considered safe because:Summary
Successfully fixed the issue where
Model.from_pretrainedwas failing with PyTorch 2.6+ by explicitly settingweights_only=Falsewhen loading model checkpoints through Lightning'spl_loadfunction. Added a CHANGELOG entry documenting the fix.Original prompt
This section details on the original issue you should resolve
<issue_title>
Model.from_pretrainedraises Error (related toweights_only=Trueoftorch.load())</issue_title><issue_description>### Tested versions
pyannote-audio==4.0.2System information
Windows 11
Issue description
Model.from_pretrainedseems to be broken by the default behavior oftorch.load()MRE:
and
raises the following Error
The former part is about
torchcodecand is not related and can be ignored (Windows with just ffmpeg andtorchcodecdoes not correctly, but it's fine), but we have an UnpicklingError fortorch.load.I think this is because of the following loading part does not include
weights_only=False:pyannote-audio/src/pyannote/audio/core/model.py
Line 602 in ad15cf4
Minimal repr...
Model.from_pretrainedraises Error (related toweights_only=Trueoftorch.load()) #1960✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.