Fix CUDA index selection for pinned torch versions #29
+183
−1
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.
Problem
When users pin PyTorch 2.7.x (or torchvision 0.22.x / torchaudio 2.7.x), torchruntime may still select the
cu124index URL based on detected hardware/Python version.PyTorch 2.7 wheels are published under
cu128, so pip fails withNo matching distribution foundwhen it is pointed at thecu124index.Conversely, if hardware defaults to
cu128but the caller pins torch <=2.6, those wheels live undercu124and pip fails for the same reason.This is the root cause of #16.
Solution
cu124vscu128) from pinnedtorch/torchvision/torchaudiorequirements passed totorchruntime.install().cu124/cu128portion so the correcthttps://download.pytorch.org/whl/<platform>index URL is used.nightly/prefix when applicable.cu128 -> cu124since older torch versions won’t support it anyway.If the pinned requirements imply conflicting indices, torchruntime leaves the platform unchanged and lets pip resolve/fail normally.
Tests
python -m pytest(141 tests) passes.Fixes #16.