Incorrect Pytorch version check while loading model #2660
-
|
In whisper/__init__.py line 150, for adding the 'weights_only' argument the if condition checks the python version using a simple string comparison as shown below: Since string comparison uses lexicographical ordering the comparison returns incorrect results. This can be fixed by modifying the code as follows: I would like to create a PR for the same. Would this be a good solution or is there any better ones? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You’re right — comparing version strings directly is unsafe because of lexicographic ordering (e.g. "1.8.1" > "1.13.0"). The standard way to handle this is to parse versions properly. Your solution using That’s a clean fix and definitely PR-worthy. Just make sure to import |
Beta Was this translation helpful? Give feedback.
You’re right — comparing version strings directly is unsafe because of lexicographic ordering (e.g. "1.8.1" > "1.13.0"). The standard way to handle this is to parse versions properly. Your solution using
packaging.version.parseis correct and aligns with PEP 440.That’s a clean fix and definitely PR-worthy. Just make sure to import
packaging.version(notpkg_resources.packaging) sincepackagingis the modern maintained package.