From 490122dbae622e5182f658488d4d4e498d37e005 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 21 Apr 2026 10:39:22 -0400 Subject: [PATCH] Update PyTorch documentation for PyTorch 2.11 --- crates/uv-distribution-types/src/index.rs | 4 +- crates/uv-resolver/src/resolver/indexes.rs | 4 +- crates/uv-settings/src/settings.rs | 4 +- crates/uv-torch/src/backend.rs | 4 + crates/uv-workspace/src/pyproject.rs | 4 +- docs/concepts/indexes.md | 12 +-- docs/concepts/projects/dependencies.md | 4 +- docs/guides/integration/pytorch.md | 96 +++++++++++----------- uv.schema.json | 6 +- 9 files changed, 71 insertions(+), 67 deletions(-) diff --git a/crates/uv-distribution-types/src/index.rs b/crates/uv-distribution-types/src/index.rs index 37f29cde1e1..41d84b1264c 100644 --- a/crates/uv-distribution-types/src/index.rs +++ b/crates/uv-distribution-types/src/index.rs @@ -136,7 +136,7 @@ pub struct Index { /// ```toml /// [[tool.uv.index]] /// name = "pytorch" - /// url = "https://download.pytorch.org/whl/cu121" + /// url = "https://download.pytorch.org/whl/cu130" /// /// [tool.uv.sources] /// torch = { index = "pytorch" } @@ -154,7 +154,7 @@ pub struct Index { /// ```toml /// [[tool.uv.index]] /// name = "pytorch" - /// url = "https://download.pytorch.org/whl/cu121" + /// url = "https://download.pytorch.org/whl/cu130" /// explicit = true /// /// [tool.uv.sources] diff --git a/crates/uv-resolver/src/resolver/indexes.rs b/crates/uv-resolver/src/resolver/indexes.rs index a4b7c7b6a7a..0d9f8eda154 100644 --- a/crates/uv-resolver/src/resolver/indexes.rs +++ b/crates/uv-resolver/src/resolver/indexes.rs @@ -9,13 +9,13 @@ use uv_normalize::PackageName; /// ```toml /// [[tool.uv.index]] /// name = "pytorch" -/// url = "https://download.pytorch.org/whl/cu121" +/// url = "https://download.pytorch.org/whl/cu130" /// /// [tool.uv.sources] /// torch = { index = "pytorch" } /// ``` /// -/// [`Indexes`] would contain a single entry mapping `torch` to `https://download.pytorch.org/whl/cu121`. +/// [`Indexes`] would contain a single entry mapping `torch` to `https://download.pytorch.org/whl/cu130`. #[derive(Debug, Default, Clone)] pub(crate) struct Indexes(ForkMap); diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index 76c9a53082a..16e4b32f9f2 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -668,7 +668,7 @@ pub struct ResolverInstallerSchema { /// ```toml /// [[tool.uv.index]] /// name = "pytorch" - /// url = "https://download.pytorch.org/whl/cu121" + /// url = "https://download.pytorch.org/whl/cu130" /// explicit = true /// /// [tool.uv.sources] @@ -684,7 +684,7 @@ pub struct ResolverInstallerSchema { example = r#" [[tool.uv.index]] name = "pytorch" - url = "https://download.pytorch.org/whl/cu121" + url = "https://download.pytorch.org/whl/cu130" "# )] pub index: Option>, diff --git a/crates/uv-torch/src/backend.rs b/crates/uv-torch/src/backend.rs index 75f11403140..775faf3749e 100644 --- a/crates/uv-torch/src/backend.rs +++ b/crates/uv-torch/src/backend.rs @@ -344,6 +344,8 @@ impl TorchStrategy { | "torchtune" | "torchvision" | "triton" + | "triton-rocm" + | "triton-xpu" | "xformers" ) } @@ -379,6 +381,8 @@ impl TorchStrategy { | "torchtune" | "torchvision" | "triton" + | "triton-rocm" + | "triton-xpu" | "vllm" | "xformers" ) diff --git a/crates/uv-workspace/src/pyproject.rs b/crates/uv-workspace/src/pyproject.rs index fe9aa086124..7bf61338362 100644 --- a/crates/uv-workspace/src/pyproject.rs +++ b/crates/uv-workspace/src/pyproject.rs @@ -349,7 +349,7 @@ pub struct ToolUv { /// ```toml /// [[tool.uv.index]] /// name = "pytorch" - /// url = "https://download.pytorch.org/whl/cu121" + /// url = "https://download.pytorch.org/whl/cu130" /// explicit = true /// /// [tool.uv.sources] @@ -365,7 +365,7 @@ pub struct ToolUv { example = r#" [[tool.uv.index]] name = "pytorch" - url = "https://download.pytorch.org/whl/cu121" + url = "https://download.pytorch.org/whl/cu130" "# )] #[serde(deserialize_with = "deserialize_index_vec", default)] diff --git a/docs/concepts/indexes.md b/docs/concepts/indexes.md index 68f4ec8baa4..afe5d4376e7 100644 --- a/docs/concepts/indexes.md +++ b/docs/concepts/indexes.md @@ -74,17 +74,17 @@ dependencies = ["torch"] [tool.uv.sources] torch = [ - { index = "pytorch-cu118", marker = "sys_platform == 'darwin'"}, - { index = "pytorch-cu124", marker = "sys_platform != 'darwin'"}, + { index = "pytorch-cpu", marker = "sys_platform == 'darwin'"}, + { index = "pytorch-cu130", marker = "sys_platform != 'darwin'"}, ] [[tool.uv.index]] -name = "pytorch-cu118" -url = "https://download.pytorch.org/whl/cu118" +name = "pytorch-cpu" +url = "https://download.pytorch.org/whl/cpu" [[tool.uv.index]] -name = "pytorch-cu124" -url = "https://download.pytorch.org/whl/cu124" +name = "pytorch-cu130" +url = "https://download.pytorch.org/whl/cu130" ``` An index can be marked as `explicit = true` to prevent packages from being installed from that index diff --git a/docs/concepts/projects/dependencies.md b/docs/concepts/projects/dependencies.md index 8ddd396bab9..37c72a3eaaf 100644 --- a/docs/concepts/projects/dependencies.md +++ b/docs/concepts/projects/dependencies.md @@ -542,7 +542,7 @@ explicit = true [[tool.uv.index]] name = "torch-gpu" -url = "https://download.pytorch.org/whl/cu124" +url = "https://download.pytorch.org/whl/cu130" explicit = true ``` @@ -630,7 +630,7 @@ url = "https://download.pytorch.org/whl/cpu" [[tool.uv.index]] name = "torch-gpu" -url = "https://download.pytorch.org/whl/cu124" +url = "https://download.pytorch.org/whl/cu130" ``` ## Development dependencies diff --git a/docs/guides/integration/pytorch.md b/docs/guides/integration/pytorch.md index 47e41e6d83f..9ba4d638342 100644 --- a/docs/guides/integration/pytorch.md +++ b/docs/guides/integration/pytorch.md @@ -25,10 +25,10 @@ From a packaging perspective, PyTorch has a few uncommon characteristics: - PyTorch produces distinct builds for each accelerator (e.g., CPU-only, CUDA). Since there's no standardized mechanism for specifying these accelerators when publishing or installing, PyTorch encodes them in the local version specifier. As such, PyTorch versions will often look like - `2.5.1+cpu`, `2.5.1+cu121`, etc. + `2.11.0+cpu`, `2.11.0+cu130`, etc. - Builds for different accelerators are published to different indexes. For example, the `+cpu` - builds are published on https://download.pytorch.org/whl/cpu, while the `+cu121` builds are - published on https://download.pytorch.org/whl/cu121. + builds are published on https://download.pytorch.org/whl/cpu, while the `+cu130` builds are + published on https://download.pytorch.org/whl/cu130. As such, the necessary packaging configuration will vary depending on both the platforms you need to support and the accelerators you want to enable. @@ -37,7 +37,7 @@ To start, consider the following (default) configuration, which would be generat `uv init --python 3.14` followed by `uv add torch torchvision`. In this case, PyTorch would be installed from PyPI, which hosts CPU-only wheels for Windows and -macOS, and GPU-accelerated wheels on Linux (targeting CUDA 12.8, as of PyTorch 2.9.1): +macOS, and GPU-accelerated wheels on Linux (targeting CUDA 13.0, as of PyTorch 2.11.0): ```toml [project] @@ -45,8 +45,8 @@ name = "project" version = "0.1.0" requires-python = ">=3.14" dependencies = [ - "torch>=2.9.1", - "torchvision>=0.24.1", + "torch>=2.11.0", + "torchvision>=0.26.0", ] ``` @@ -106,12 +106,12 @@ In such cases, the first step is to add the relevant PyTorch index to your `pypr explicit = true ``` -=== "ROCm6" +=== "ROCm 7.2" ```toml [[tool.uv.index]] name = "pytorch-rocm" - url = "https://download.pytorch.org/whl/rocm6.4" + url = "https://download.pytorch.org/whl/rocm7.2" explicit = true ``` @@ -202,9 +202,9 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi ] ``` -=== "ROCm6" +=== "ROCm 7.2" - PyTorch doesn't publish ROCm6 builds for macOS or Windows. As such, we gate on `sys_platform` to instruct uv + PyTorch doesn't publish ROCm builds for macOS or Windows. As such, we gate on `sys_platform` to instruct uv to limit the PyTorch index to Linux, falling back to PyPI on macOS and Windows: ```toml @@ -215,9 +215,9 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi torchvision = [ { index = "pytorch-rocm", marker = "sys_platform == 'linux'" }, ] - # ROCm6 support relies on `pytorch-triton-rocm`, which should also be installed from the PyTorch index + # ROCm support relies on `triton-rocm`, which should also be installed from the PyTorch index # (and included in `project.dependencies`). - pytorch-triton-rocm = [ + triton-rocm = [ { index = "pytorch-rocm", marker = "sys_platform == 'linux'" }, ] ``` @@ -235,9 +235,9 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi torchvision = [ { index = "pytorch-xpu", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, ] - # Intel GPU support relies on `pytorch-triton-xpu`, which should also be installed from the PyTorch index + # Intel GPU support relies on `triton-xpu`, which should also be installed from the PyTorch index # (and included in `project.dependencies`). - pytorch-triton-xpu = [ + triton-xpu = [ { index = "pytorch-xpu", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, ] ``` @@ -250,8 +250,8 @@ name = "project" version = "0.1.0" requires-python = ">=3.14.0" dependencies = [ - "torch>=2.9.1", - "torchvision>=0.24.1", + "torch>=2.11.0", + "torchvision>=0.26.0", ] [tool.uv.sources] @@ -283,18 +283,18 @@ name = "project" version = "0.1.0" requires-python = ">=3.14.0" dependencies = [ - "torch>=2.9.1", - "torchvision>=0.24.1", + "torch>=2.11.0", + "torchvision>=0.26.0", ] [tool.uv.sources] torch = [ { index = "pytorch-cpu", marker = "sys_platform != 'linux'" }, - { index = "pytorch-cu128", marker = "sys_platform == 'linux'" }, + { index = "pytorch-cu130", marker = "sys_platform == 'linux'" }, ] torchvision = [ { index = "pytorch-cpu", marker = "sys_platform != 'linux'" }, - { index = "pytorch-cu128", marker = "sys_platform == 'linux'" }, + { index = "pytorch-cu130", marker = "sys_platform == 'linux'" }, ] [[tool.uv.index]] @@ -303,8 +303,8 @@ url = "https://download.pytorch.org/whl/cpu" explicit = true [[tool.uv.index]] -name = "pytorch-cu128" -url = "https://download.pytorch.org/whl/cu128" +name = "pytorch-cu130" +url = "https://download.pytorch.org/whl/cu130" explicit = true ``` @@ -317,9 +317,9 @@ name = "project" version = "0.1.0" requires-python = ">=3.14.0" dependencies = [ - "torch>=2.9.1", - "torchvision>=0.24.1", - "pytorch-triton-rocm>=3.5.1 ; sys_platform == 'linux'", + "torch>=2.11.0", + "torchvision>=0.26.0", + "triton-rocm>=3.6.0 ; sys_platform == 'linux'", ] [tool.uv.sources] @@ -329,13 +329,13 @@ torch = [ torchvision = [ { index = "pytorch-rocm", marker = "sys_platform == 'linux'" }, ] -pytorch-triton-rocm = [ +triton-rocm = [ { index = "pytorch-rocm", marker = "sys_platform == 'linux'" }, ] [[tool.uv.index]] name = "pytorch-rocm" -url = "https://download.pytorch.org/whl/rocm6.4" +url = "https://download.pytorch.org/whl/rocm7.2" explicit = true ``` @@ -347,9 +347,9 @@ name = "project" version = "0.1.0" requires-python = ">=3.14.0" dependencies = [ - "torch>=2.9.1", - "torchvision>=0.24.1", - "pytorch-triton-xpu>=3.5.0 ; sys_platform == 'win32' or sys_platform == 'linux'", + "torch>=2.11.0", + "torchvision>=0.26.0", + "triton-xpu>=3.7.0 ; sys_platform == 'win32' or sys_platform == 'linux'", ] [tool.uv.sources] @@ -359,7 +359,7 @@ torch = [ torchvision = [ { index = "pytorch-xpu", marker = "sys_platform == 'win32' or sys_platform == 'linux'" }, ] -pytorch-triton-xpu = [ +triton-xpu = [ { index = "pytorch-xpu", marker = "sys_platform == 'win32' or sys_platform == 'linux'" }, ] @@ -373,11 +373,11 @@ explicit = true In some cases, you may want to use CPU-only builds in some cases, but CUDA-enabled builds in others, with the choice toggled by a user-provided extra (e.g., `uv sync --extra cpu` vs. -`uv sync --extra cu128`). +`uv sync --extra cu130`). With `tool.uv.sources`, you can use extra markers to specify the desired index for each enabled extra. For example, the following configuration would use PyTorch's CPU-only for -`uv sync --extra cpu` and CUDA-enabled builds for `uv sync --extra cu128`: +`uv sync --extra cpu` and CUDA-enabled builds for `uv sync --extra cu130`: ```toml [project] @@ -388,30 +388,30 @@ dependencies = [] [project.optional-dependencies] cpu = [ - "torch>=2.9.1", - "torchvision>=0.24.1", + "torch>=2.11.0", + "torchvision>=0.26.0", ] -cu128 = [ - "torch>=2.9.1", - "torchvision>=0.24.1", +cu130 = [ + "torch>=2.11.0", + "torchvision>=0.26.0", ] [tool.uv] conflicts = [ [ { extra = "cpu" }, - { extra = "cu128" }, + { extra = "cu130" }, ], ] [tool.uv.sources] torch = [ { index = "pytorch-cpu", extra = "cpu" }, - { index = "pytorch-cu128", extra = "cu128" }, + { index = "pytorch-cu130", extra = "cu130" }, ] torchvision = [ { index = "pytorch-cpu", extra = "cpu" }, - { index = "pytorch-cu128", extra = "cu128" }, + { index = "pytorch-cu130", extra = "cu130" }, ] [[tool.uv.index]] @@ -420,15 +420,15 @@ url = "https://download.pytorch.org/whl/cpu" explicit = true [[tool.uv.index]] -name = "pytorch-cu128" -url = "https://download.pytorch.org/whl/cu128" +name = "pytorch-cu130" +url = "https://download.pytorch.org/whl/cu130" explicit = true ``` !!! note Since GPU-accelerated builds aren't available on macOS, the above configuration will fail to install - on macOS when the `cu128` extra is enabled. + on macOS when the `cu130` extra is enabled. ## The `uv pip` interface @@ -467,15 +467,15 @@ then use the most-compatible PyTorch index for all relevant packages (e.g., `tor etc.). If no such GPU is found, uv will fall back to the CPU-only index. uv will continue to respect existing index configuration for any packages outside the PyTorch ecosystem. -You can also select a specific backend (e.g., CUDA 12.8) with `--torch-backend=cu126` (or -`UV_TORCH_BACKEND=cu126`): +You can also select a specific backend (e.g., CUDA 13.0) with `--torch-backend=cu130` (or +`UV_TORCH_BACKEND=cu130`): ```shell $ # With a command-line argument. -$ uv pip install torch torchvision --torch-backend=cu126 +$ uv pip install torch torchvision --torch-backend=cu130 $ # With an environment variable. -$ UV_TORCH_BACKEND=cu128 uv pip install torch torchvision +$ UV_TORCH_BACKEND=cu130 uv pip install torch torchvision ``` At present, `--torch-backend` is only available in the `uv pip` interface. diff --git a/uv.schema.json b/uv.schema.json index 2b73a40cbdd..3d96bae4f38 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -276,7 +276,7 @@ ] }, "index": { - "description": "The indexes to use when resolving dependencies.\n\nAccepts either a repository compliant with [PEP 503](https://peps.python.org/pep-0503/)\n(the simple repository API), or a local directory laid out in the same format.\n\nIndexes are considered in the order in which they're defined, such that the first-defined\nindex has the highest priority. Further, the indexes provided by this setting are given\nhigher priority than any indexes specified via [`index_url`](#index-url) or\n[`extra_index_url`](#extra-index-url). uv will only consider the first index that contains\na given package, unless an alternative [index strategy](#index-strategy) is specified.\n\nIf an index is marked as `explicit = true`, it will be used exclusively for the\ndependencies that select it explicitly via `[tool.uv.sources]`, as in:\n\n```toml\n[[tool.uv.index]]\nname = \"pytorch\"\nurl = \"https://download.pytorch.org/whl/cu121\"\nexplicit = true\n\n[tool.uv.sources]\ntorch = { index = \"pytorch\" }\n```\n\nIf an index is marked as `default = true`, it will be moved to the end of the prioritized list, such that it is\ngiven the lowest priority when resolving packages. Additionally, marking an index as default will disable the\nPyPI default index.", + "description": "The indexes to use when resolving dependencies.\n\nAccepts either a repository compliant with [PEP 503](https://peps.python.org/pep-0503/)\n(the simple repository API), or a local directory laid out in the same format.\n\nIndexes are considered in the order in which they're defined, such that the first-defined\nindex has the highest priority. Further, the indexes provided by this setting are given\nhigher priority than any indexes specified via [`index_url`](#index-url) or\n[`extra_index_url`](#extra-index-url). uv will only consider the first index that contains\na given package, unless an alternative [index strategy](#index-strategy) is specified.\n\nIf an index is marked as `explicit = true`, it will be used exclusively for the\ndependencies that select it explicitly via `[tool.uv.sources]`, as in:\n\n```toml\n[[tool.uv.index]]\nname = \"pytorch\"\nurl = \"https://download.pytorch.org/whl/cu130\"\nexplicit = true\n\n[tool.uv.sources]\ntorch = { index = \"pytorch\" }\n```\n\nIf an index is marked as `default = true`, it will be moved to the end of the prioritized list, such that it is\ngiven the lowest priority when resolving packages. Additionally, marking an index as default will disable the\nPyPI default index.", "type": ["array", "null"], "default": null, "items": { @@ -980,7 +980,7 @@ ] }, "explicit": { - "description": "Mark the index as explicit.\n\nExplicit indexes will _only_ be used when explicitly requested via a `[tool.uv.sources]`\ndefinition, as in:\n\n```toml\n[[tool.uv.index]]\nname = \"pytorch\"\nurl = \"https://download.pytorch.org/whl/cu121\"\nexplicit = true\n\n[tool.uv.sources]\ntorch = { index = \"pytorch\" }\n```", + "description": "Mark the index as explicit.\n\nExplicit indexes will _only_ be used when explicitly requested via a `[tool.uv.sources]`\ndefinition, as in:\n\n```toml\n[[tool.uv.index]]\nname = \"pytorch\"\nurl = \"https://download.pytorch.org/whl/cu130\"\nexplicit = true\n\n[tool.uv.sources]\ntorch = { index = \"pytorch\" }\n```", "type": "boolean", "default": false }, @@ -1002,7 +1002,7 @@ } }, "name": { - "description": "The name of the index.\n\nIndex names can be used to reference indexes elsewhere in the configuration. For example,\nyou can pin a package to a specific index by name:\n\n```toml\n[[tool.uv.index]]\nname = \"pytorch\"\nurl = \"https://download.pytorch.org/whl/cu121\"\n\n[tool.uv.sources]\ntorch = { index = \"pytorch\" }\n```", + "description": "The name of the index.\n\nIndex names can be used to reference indexes elsewhere in the configuration. For example,\nyou can pin a package to a specific index by name:\n\n```toml\n[[tool.uv.index]]\nname = \"pytorch\"\nurl = \"https://download.pytorch.org/whl/cu130\"\n\n[tool.uv.sources]\ntorch = { index = \"pytorch\" }\n```", "anyOf": [ { "$ref": "#/definitions/IndexName"