mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Remove preview label from --torch-backend
(#14119)
This is now used in enough places that I'm comfortable committing to maintaining it under our versioning policy. Closes #14091.
This commit is contained in:
parent
8808e67cff
commit
6c096246d8
4 changed files with 52 additions and 51 deletions
|
@ -388,20 +388,18 @@ pub(crate) async fn pip_compile(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the PyTorch backend.
|
// Determine the PyTorch backend.
|
||||||
let torch_backend = torch_backend.map(|mode| {
|
let torch_backend = torch_backend
|
||||||
if preview.is_disabled() {
|
.map(|mode| {
|
||||||
warn_user!("The `--torch-backend` setting is experimental and may change without warning. Pass `--preview` to disable this warning.");
|
TorchStrategy::from_mode(
|
||||||
}
|
mode,
|
||||||
|
python_platform
|
||||||
TorchStrategy::from_mode(
|
.map(TargetTriple::platform)
|
||||||
mode,
|
.as_ref()
|
||||||
python_platform
|
.unwrap_or(interpreter.platform())
|
||||||
.map(TargetTriple::platform)
|
.os(),
|
||||||
.as_ref()
|
)
|
||||||
.unwrap_or(interpreter.platform())
|
})
|
||||||
.os(),
|
.transpose()?;
|
||||||
)
|
|
||||||
}).transpose()?;
|
|
||||||
|
|
||||||
// Initialize the registry client.
|
// Initialize the registry client.
|
||||||
let client = RegistryClientBuilder::try_from(client_builder)?
|
let client = RegistryClientBuilder::try_from(client_builder)?
|
||||||
|
|
|
@ -344,20 +344,18 @@ pub(crate) async fn pip_install(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the PyTorch backend.
|
// Determine the PyTorch backend.
|
||||||
let torch_backend = torch_backend.map(|mode| {
|
let torch_backend = torch_backend
|
||||||
if preview.is_disabled() {
|
.map(|mode| {
|
||||||
warn_user!("The `--torch-backend` setting is experimental and may change without warning. Pass `--preview` to disable this warning.");
|
TorchStrategy::from_mode(
|
||||||
}
|
mode,
|
||||||
|
python_platform
|
||||||
TorchStrategy::from_mode(
|
.map(TargetTriple::platform)
|
||||||
mode,
|
.as_ref()
|
||||||
python_platform
|
.unwrap_or(interpreter.platform())
|
||||||
.map(TargetTriple::platform)
|
.os(),
|
||||||
.as_ref()
|
)
|
||||||
.unwrap_or(interpreter.platform())
|
})
|
||||||
.os(),
|
.transpose()?;
|
||||||
)
|
|
||||||
}).transpose()?;
|
|
||||||
|
|
||||||
// Initialize the registry client.
|
// Initialize the registry client.
|
||||||
let client = RegistryClientBuilder::try_from(client_builder)?
|
let client = RegistryClientBuilder::try_from(client_builder)?
|
||||||
|
|
|
@ -277,20 +277,18 @@ pub(crate) async fn pip_sync(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the PyTorch backend.
|
// Determine the PyTorch backend.
|
||||||
let torch_backend = torch_backend.map(|mode| {
|
let torch_backend = torch_backend
|
||||||
if preview.is_disabled() {
|
.map(|mode| {
|
||||||
warn_user!("The `--torch-backend` setting is experimental and may change without warning. Pass `--preview` to disable this warning.");
|
TorchStrategy::from_mode(
|
||||||
}
|
mode,
|
||||||
|
python_platform
|
||||||
TorchStrategy::from_mode(
|
.map(TargetTriple::platform)
|
||||||
mode,
|
.as_ref()
|
||||||
python_platform
|
.unwrap_or(interpreter.platform())
|
||||||
.map(TargetTriple::platform)
|
.os(),
|
||||||
.as_ref()
|
)
|
||||||
.unwrap_or(interpreter.platform())
|
})
|
||||||
.os(),
|
.transpose()?;
|
||||||
)
|
|
||||||
}).transpose()?;
|
|
||||||
|
|
||||||
// Initialize the registry client.
|
// Initialize the registry client.
|
||||||
let client = RegistryClientBuilder::try_from(client_builder)?
|
let client = RegistryClientBuilder::try_from(client_builder)?
|
||||||
|
|
|
@ -433,11 +433,14 @@ $ uv pip install torch torchvision torchaudio --index-url https://download.pytor
|
||||||
|
|
||||||
## Automatic backend selection
|
## Automatic backend selection
|
||||||
|
|
||||||
In [preview](../../reference/settings.md#preview), uv can automatically select the appropriate
|
uv supports automatic selection of the appropriate PyTorch index via the `--torch-backend=auto`
|
||||||
PyTorch index at runtime by inspecting the system configuration via `--torch-backend=auto` (or
|
command-line argument (or the `UV_TORCH_BACKEND=auto` environment variable), as in:
|
||||||
`UV_TORCH_BACKEND=auto`):
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
$ # With a command-line argument.
|
||||||
|
$ uv pip install torch --torch-backend=auto
|
||||||
|
|
||||||
|
$ # With an environment variable.
|
||||||
$ UV_TORCH_BACKEND=auto uv pip install torch
|
$ UV_TORCH_BACKEND=auto uv pip install torch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -446,12 +449,16 @@ PyTorch index for all relevant packages (e.g., `torch`, `torchvision`, etc.). If
|
||||||
is found, uv will fall back to the CPU-only index. uv will continue to respect existing index
|
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.
|
configuration for any packages outside the PyTorch ecosystem.
|
||||||
|
|
||||||
To select a specific backend (e.g., `cu126`), set `--torch-backend=cu126` (or
|
You can also select a specific backend (e.g., CUDA 12.6) with `--torch-backend=cu126` (or
|
||||||
`UV_TORCH_BACKEND=cu126`).
|
`UV_TORCH_BACKEND=cu126`):
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ # With a command-line argument.
|
||||||
|
$ uv pip install torch torchvision --torch-backend=cu126
|
||||||
|
|
||||||
|
$ # With an environment variable.
|
||||||
|
$ UV_TORCH_BACKEND=cu126 uv pip install torch torchvision
|
||||||
|
```
|
||||||
|
|
||||||
At present, `--torch-backend` is only available in the `uv pip` interface, and only supports
|
At present, `--torch-backend` is only available in the `uv pip` interface, and only supports
|
||||||
detection of CUDA drivers (as opposed to other accelerators like ROCm or Intel GPUs).
|
detection of CUDA drivers (as opposed to other accelerators like ROCm or Intel GPUs).
|
||||||
|
|
||||||
As `--torch-backend` is a preview feature, it should be considered experimental and is not governed
|
|
||||||
by uv's standard [versioning policy](../../reference/policies/versioning.md). `--torch-backend` may
|
|
||||||
change or be removed entirely in future versions of uv.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue