Skip to content
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

Universal resolution issue with torch cpu / non-cpu #9963

Closed
aachkar-samsara opened this issue Dec 17, 2024 · 5 comments
Closed

Universal resolution issue with torch cpu / non-cpu #9963

aachkar-samsara opened this issue Dec 17, 2024 · 5 comments
Assignees
Labels
bug Something isn't working question Asking for clarification or support

Comments

@aachkar-samsara
Copy link

I am attempting to select a cpu build of torch for linux and the regular build of torch for darwin with the following minimal reproducer:

requirements.in

torch==1.13.1+cpu ; platform_system == 'Linux' and sys_platform == 'linux'
torch==1.13.1 ; platform_system == 'Darwin' and sys_platform == 'darwin'

(note: it fails also with just sys_platform or just platform_system; I was trying to force it)

command

uv pip compile requirements.in -o requirements.txt --universal --no-strip-markers --extra-index-url https://download.pytorch.org/whl/cpu --native-tls --verbose

The output file is:

# This file was autogenerated by uv via the following command:
#    uv pip compile requirements.in -o requirements.txt --universal --no-strip-markers --native-tls
torch==1.13.1+cpu ; (platform_system == 'Darwin' and sys_platform == 'darwin') or (platform_system == 'Linux' and sys_platform == 'linux')
    # via -r test.in
typing-extensions==4.9.0 ; (platform_system == 'Darwin' and sys_platform == 'darwin') or (platform_system == 'Linux' and sys_platform == 'linux')
    # via torch

This fails to install on darwin because the torch==1.13.1+cpu is only available for linux. The verbose log output is:

DEBUG uv 0.5.9
DEBUG Starting Python discovery for a default Python
DEBUG Looking for exact match for request a default Python
DEBUG Searching for default Python interpreter in virtual environments, managed installations, or search path
DEBUG Searching for managed installations at `/Users/me/.local/share/uv/python`
DEBUG Found managed installation `cpython-3.10.15-macos-aarch64-none`
DEBUG Found `cpython-3.10.15-macos-aarch64-none` at `/Users/me/.local/share/uv/python/cpython-3.10.15-macos-aarch64-none/bin/python3.10` (managed installations)
DEBUG Using Python 3.10.15 interpreter at /Users/me/.local/share/uv/python/cpython-3.10.15-macos-aarch64-none/bin/python3.10 for builds
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.10.15
DEBUG Solving with target Python version: >=3.10.15
DEBUG Pre-fork all marker environments took 0.000s
DEBUG Splitting resolution on root==0a0.dev0 over torch into 3 resolutions with separate markers
DEBUG Adding direct dependency: torch{platform_system == 'Darwin' and sys_platform == 'darwin'}>=1.13.1, <1.13.1+
DEBUG Adding direct dependency: torch{platform_system == 'Linux' and sys_platform == 'linux'}==1.13.1+cpu
DEBUG Solving split (platform_system == 'Linux' and sys_platform == 'linux') (requires-python: RequiresPython { specifiers: VersionSpecifiers([VersionSpecifier { operator: GreaterThanEqual, version: "3.10.15" }]), range: RequiresPythonRange(LowerBound(Included("3.10.15")), UpperBound(Unbounded)) })
DEBUG No cache entry for: https://download.pytorch.org/whl/cpu/torch/
DEBUG Searching for a compatible version of torch{platform_system == 'Linux' and sys_platform == 'linux'} (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [compatible] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch==1.13.1+cpu
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch{platform_system == 'Linux' and sys_platform == 'linux'}==1.13.1+cpu
DEBUG Searching for a compatible version of torch{platform_system == 'Linux' and sys_platform == 'linux'} (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [compatible] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Found stale response for: https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014
DEBUG Sending revalidation request for: https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014
DEBUG Found not-modified response for: https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG Searching for a compatible version of torch (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [compatible] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG No cache entry for: https://download.pytorch.org/whl/cpu/typing-extensions/
DEBUG Searching for a compatible version of typing-extensions (*)
DEBUG Selecting: typing-extensions==4.9.0 [compatible] (typing_extensions-4.9.0-py3-none-any.whl)
DEBUG Found stale response for: https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl#sha256=af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
DEBUG Sending revalidation request for: https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl#sha256=af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
DEBUG Found not-modified response for: https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl#sha256=af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
DEBUG Tried 2 versions: torch 1, typing-extensions 1
DEBUG split `platform_system == 'Linux' and sys_platform == 'linux'` resolution took 0.687s
DEBUG Solving split (platform_system == 'Darwin' and sys_platform == 'darwin') (requires-python: RequiresPython { specifiers: VersionSpecifiers([VersionSpecifier { operator: GreaterThanEqual, version: "3.10.15" }]), range: RequiresPythonRange(LowerBound(Included("3.10.15")), UpperBound(Unbounded)) })
DEBUG Searching for a compatible version of torch{platform_system == 'Darwin' and sys_platform == 'darwin'} (>=1.13.1, <1.13.1+)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch==1.13.1+cpu
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch{platform_system == 'Darwin' and sys_platform == 'darwin'}==1.13.1+cpu
DEBUG Searching for a compatible version of torch{platform_system == 'Darwin' and sys_platform == 'darwin'} (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG Searching for a compatible version of torch (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG Searching for a compatible version of typing-extensions (*)
DEBUG Selecting: typing-extensions==4.9.0 [preference] (typing_extensions-4.9.0-py3-none-any.whl)
DEBUG Tried 4 versions: torch 2, typing-extensions 2
DEBUG split `platform_system == 'Darwin' and sys_platform == 'darwin'` resolution took 0.000s
DEBUG Solving split ((platform_system != 'Darwin' and sys_platform == 'darwin') or (platform_system != 'Linux' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')) (requires-python: RequiresPython { specifiers: VersionSpecifiers([VersionSpecifier { operator: GreaterThanEqual, version: "3.10.15" }]), range: RequiresPythonRange(LowerBound(Included("3.10.15")), UpperBound(Unbounded)) })
DEBUG Tried 4 versions: torch 2, typing-extensions 2
DEBUG split `(platform_system != 'Darwin' and sys_platform == 'darwin') or (platform_system != 'Linux' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')` resolution took 0.000s
INFO Solved your requirements for 3 environments
DEBUG Distinct solution for split (platform_system == 'Linux' and sys_platform == 'linux') with 2 packages
DEBUG Distinct solution for split (platform_system == 'Darwin' and sys_platform == 'darwin') with 2 packages
DEBUG Distinct solution for split ((platform_system != 'Darwin' and sys_platform == 'darwin') or (platform_system != 'Linux' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')) with 0 packages

In particular, I am really confused why this line is occuring:

DEBUG Searching for a compatible version of torch{platform_system == 'Darwin' and sys_platform == 'darwin'} (>=1.13.1, <1.13.1+)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)

How can it be selecting a linux wheel here?

@charliermarsh
Copy link
Member

You need torch===1.13.1. 1.13.1+cpu is a valid version for torch==1.13.1.

@charliermarsh charliermarsh added the question Asking for clarification or support label Dec 17, 2024
@aachkar-samsara
Copy link
Author

That version is only available for a different platform though. So why is it being considered as valid for darwin?

@charliermarsh
Copy link
Member

That’s not really what’s happening. It’s looking for a torch version, and it picks that version, and that version happens to be lacking macOS wheels. You can read this issue if you want more detail: #9711. There’s also a linked PR that would fix this automatically.

@charliermarsh
Copy link
Member

The logging you mentioned is also a red herring. We just pick an arbitrary wheel to determine the package metadata. It has nothing to do with whether the wheel is considered valid on macOS.

@charliermarsh
Copy link
Member

Fixed by #10046.

@charliermarsh charliermarsh self-assigned this Dec 20, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

2 participants