feat: Added cuda version selection to uv build.#433
feat: Added cuda version selection to uv build.#433BlueCrescent wants to merge 8 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds support for different CUDA versions in uv installation by moving PyTorch from a required dependency to an optional dependency with multiple CUDA-specific variants (cpu, cu126, cu128, cu130). The PR configures uv to use different PyTorch index URLs based on the selected CUDA variant.
Changes:
- Moved torch from required dependencies to optional dependencies with CUDA version variants
- Added uv-specific configuration for CUDA version conflicts and PyTorch index sources
- Updated README installation instructions to reflect the new CUDA version selection
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pyproject.toml | Removed torch from dependencies, added CUDA-specific torch extras (cpu, cu126, cu128, cu130), and configured uv for handling PyTorch installation from different index URLs |
| README.md | Updated installation commands to include CUDA version selection syntax for uv |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pyproject.toml
Outdated
| cpu = ["torch>=2.10,<2.11.0"] | ||
| cu126 = ["torch>=2.10,<2.11.0"] | ||
| cu128 = ["torch>=2.10,<2.11.0"] | ||
| cu130 = ["torch>=2.10,<2.11.0"] |
There was a problem hiding this comment.
The torch dependency has been moved from the main dependencies to optional dependencies, which means torch is no longer installed by default. Users who install the package without specifying one of the CUDA extras (cpu, cu126, cu128, cu130) will not get PyTorch installed. This is a breaking change that should be documented in the CHANGELOG_DEV.md (which the PR description indicates as incomplete).
Consider whether this is the intended behavior. If users must explicitly choose a CUDA version, this should be clearly communicated in the documentation and changelog.
| curl -LsSf https://astral.sh/uv/install.sh | sh | ||
|
|
||
| uv sync | ||
| uv sync --extra [cpu|cu126|cu128|cu130] # Get CUDA version via nvidia-smi |
There was a problem hiding this comment.
The README shows installation commands using bracket notation [cpu|cu126|cu128|cu130], but this is not valid shell syntax. Users cannot literally type this command and expect it to work. The command should be clarified to show that users need to choose ONE option, for example:
- uv sync --extra cpu
- uv sync --extra cu126
- uv sync --extra cu128
- uv sync --extra cu130
Consider using a different notation or providing explicit examples rather than shell pipe syntax inside brackets.
|
|
||
| # For developers: use [tests,linting] and install pre-commit hooks | ||
| uv sync --extra tests --extra linting | ||
| uv sync --extra [cpu|cu126|cu128|cu130] --extra tests --extra linting |
There was a problem hiding this comment.
The README shows installation commands using bracket notation [cpu|cu126|cu128|cu130], but this is not valid shell syntax. Users cannot literally type this command and expect it to work. The command should be clarified to show that users need to choose ONE option, for example:
- uv sync --extra cpu --extra tests --extra linting
- uv sync --extra cu126 --extra tests --extra linting
Consider using a different notation or providing explicit examples rather than shell pipe syntax inside brackets.
…optional dependencies
…ting PreTrainedModel.
rrutmann
left a comment
There was a problem hiding this comment.
In general the PR looks good, but I don't understand why we have the same requirements for all cuda versions and why we should differentiate them in this case. Only the index-urls are different, correct?
src/modalities/utils/mfu.py
Outdated
| # | ||
| # NOTE: These values are valid for fp16 and bf16 only | ||
| PEAK_PERFORMANCE = {"A100": 312e12, "H100": 989e12, "GH200": 989e12} | ||
| # FIXME: For B200, is 2.25 PFLOPS correct or should it be 4.5 PFLOPS? |
There was a problem hiding this comment.
Did you verify this value? Why are you considering different values?
There was a problem hiding this comment.
On further research, it seems like this value should be correct and the 4.5 one is only for sparse operations:
| "torchvision", | ||
| "flash-attn==2.8.3; platform_system != 'Darwin' and platform_machine != 'aarch64'" | ||
| ] | ||
| cu130 = [ |
There was a problem hiding this comment.
Aren't the dependencies for all 3 cu the same? Why do we differentiate here?
There was a problem hiding this comment.
Sadly, it seems like there is no way around this and this is the recommended way to do it with uv: https://docs.astral.sh/uv/guides/integration/pytorch/#configuring-accelerators-with-optional-dependencies
README.md
Outdated
|
|
||
| # Install PyTorch, psutil, Ninja and Flash Attention | ||
| pip install "torch<2.11.0" | ||
| pip install "torch<2.11.0" # Or appropriate version for your CUDA setup. |
There was a problem hiding this comment.
| pip install "torch<2.11.0" # Or appropriate version for your CUDA setup. | |
| pip install "torch>=2.10,<2.11.0" # Or appropriate version for your CUDA setup. |
There was a problem hiding this comment.
I don't understand the comment. The pytorch requirements are the same for all CUDA versions, or not?
There was a problem hiding this comment.
The comment is about selecting the correct PyTorch index for the installed cuda version. I changed the comment to point that out clearly.
Co-authored-by: Richard Rutmann <97447451+rrutmann@users.noreply.github.com>
- also included torchvision in pip install instructions
2.25 seems to be the correct value for dense operations on B200. 4.5 is for sparse operations.
What does this PR do?
Support different CUDA versions in uv installation.
General Changes
Checklist before submitting final PR
python tests/tests.py)CHANGELOG_DEV.md)