Skip to content

feat: Added cuda version selection to uv build.#433

Open
BlueCrescent wants to merge 8 commits intomainfrom
uv_support_for_different_cuda_versions
Open

feat: Added cuda version selection to uv build.#433
BlueCrescent wants to merge 8 commits intomainfrom
uv_support_for_different_cuda_versions

Conversation

@BlueCrescent
Copy link
Member

@BlueCrescent BlueCrescent commented Feb 18, 2026

What does this PR do?

Support different CUDA versions in uv installation.

General Changes

  • Added different optional dependency version for pytorch which use different index urls when used via uv.
  • Updated Readme.
  • Also added B200 to MFU calculator.

Checklist before submitting final PR

  • My PR is minimal and addresses one issue in isolation
  • I have merged the latest version of the target branch into this feature branch
  • I have reviewed my own code w.r.t. correct implementation, missing type hints, proper documentation, etc.
  • I have run a sample config for model training
  • I have checked that all tests run through (python tests/tests.py)
  • I have updated the internal changelog (CHANGELOG_DEV.md)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Comment on lines 46 to 49
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"]
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
curl -LsSf https://astral.sh/uv/install.sh | sh

uv sync
uv sync --extra [cpu|cu126|cu128|cu130] # Get CUDA version via nvidia-smi
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

# 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
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@rrutmann rrutmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

#
# 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?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify this value? Why are you considering different values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"torchvision",
"flash-attn==2.8.3; platform_system != 'Darwin' and platform_machine != 'aarch64'"
]
cu130 = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the dependencies for all 3 cu the same? Why do we differentiate here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the comment. The pytorch requirements are the same for all CUDA versions, or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is about selecting the correct PyTorch index for the installed cuda version. I changed the comment to point that out clearly.

BlueCrescent and others added 3 commits February 27, 2026 22:27
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants