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

Dependency Resolver Ignores Platform-Specific Version Constraints #9988

Open
merajhashemi opened this issue Dec 18, 2024 · 5 comments
Open
Assignees
Labels
resolver Related to the package resolver

Comments

@merajhashemi
Copy link

merajhashemi commented Dec 18, 2024

Hello,

I want to bring up an issue again about PyTorch dependency resolution on Intel-based macOS. This follows the discussion in #9515, which I wasn’t able to reopen.

I really appreciate the updates with the fork-strategy option and the closure of issues #8686 and #7190, but the main problem I brought up is still there: the dependency resolver enforces a single version of PyTorch across all platforms, even when conditional version constraints are specified in pyproject.toml.

Here’s a minimal example of my configuration:

[project]  
name = "test"  
version = "0.1.0"  
description = "Add your description here"  
readme = "README.md"  
requires-python = ">=3.11"  
dependencies = [  
    "torch>1.13,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",  
    "torch>1.13; sys_platform != 'darwin' or platform_machine != 'x86_64'",  
]  

[tool.uv]  
fork-strategy = "requires-python"  

The expectation here is that the resolver should pick PyTorch version 2.2.2 for Intel MacOS, and a different version (e.g., 2.5.1) for other platforms. However, the current behavior enforces a single version (2.2.2) across all platforms.

I was hoping the introduction of the fork-strategy option would address this limitation, but it doesn’t seem to allow opting out of this unified resolution behavior.

Would it be possible to consider adding a new fork-strategy option (or another mechanism) to handle cases like this? This would allow for platform-specific resolution of dependencies as defined in the pyproject.toml.

@charliermarsh
Copy link
Member

That PR is unrelated -- you're looking for #9711 and the linked PRs. I don't know if we'll support this specific case by default though. If you want to be getting an old version of a package for a platform like Intel macOS (which is no longer supported in new PyTorch versions), you'll likely be required to opt-in in some way.

@charliermarsh charliermarsh added the resolver Related to the package resolver label Dec 18, 2024
@merajhashemi
Copy link
Author

@konstin @charliermarsh I noticed your discussion regarding this issue in #9711. I have a suggestion that might help address the problem, although I'm not fully aware of its potential implications. Perhaps you could consider adding an option for the resolver to function similarly to the resolver in the pip interface.

@charliermarsh
Copy link
Member

It's actually plausible that your case could be supported since you're willing to define multiple version constraints.

@charliermarsh charliermarsh self-assigned this Dec 18, 2024
@charliermarsh
Copy link
Member

Can I ask why you don't do:

dependencies = [  
    "torch>1.13,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",  
    "torch>=2.3; sys_platform != 'darwin' or platform_machine != 'x86_64'",  
]  

@merajhashemi
Copy link
Author

It's actually plausible that your case could be supported since you're willing to define multiple version constraints.

That’s true, but ideally, I’d prefer if it worked the same way as pip, where a simple dependencies = ["torch>1.13"] would resolve correctly across all platforms without needing platform-specific constraints.

Can I ask why you don't do:

dependencies = [  
    "torch>1.13,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",  
    "torch>=2.3; sys_platform != 'darwin' or platform_machine != 'x86_64'",  
]  

This is for a library I’m working on, and we want to support all PyTorch versions above 1.13. Forcing users to install version 2.3 or higher on some platforms wouldn’t work well since it limits compatibility for no good reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolver Related to the package resolver
Projects
None yet
Development

No branches or pull requests

2 participants