Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/uv-torch/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ pub enum TorchMode {
Auto,
/// Use the CPU-only PyTorch index.
Cpu,
/// Use the PyTorch index for CUDA 12.9.
Cu129,
/// Use the PyTorch index for CUDA 12.8.
Cu128,
/// Use the PyTorch index for CUDA 12.6.
Expand Down Expand Up @@ -208,6 +210,7 @@ impl TorchStrategy {
None => Ok(Self::Backend(TorchBackend::Cpu)),
},
TorchMode::Cpu => Ok(Self::Backend(TorchBackend::Cpu)),
TorchMode::Cu129 => Ok(Self::Backend(TorchBackend::Cu129)),
TorchMode::Cu128 => Ok(Self::Backend(TorchBackend::Cu128)),
TorchMode::Cu126 => Ok(Self::Backend(TorchBackend::Cu126)),
TorchMode::Cu125 => Ok(Self::Backend(TorchBackend::Cu125)),
Expand Down Expand Up @@ -380,6 +383,7 @@ impl TorchStrategy {
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum TorchBackend {
Cpu,
Cu129,
Cu128,
Cu126,
Cu125,
Expand Down Expand Up @@ -428,6 +432,7 @@ impl TorchBackend {
fn index_url(self) -> &'static IndexUrl {
match self {
Self::Cpu => &CPU_INDEX_URL,
Self::Cu129 => &CU129_INDEX_URL,
Self::Cu128 => &CU128_INDEX_URL,
Self::Cu126 => &CU126_INDEX_URL,
Self::Cu125 => &CU125_INDEX_URL,
Expand Down Expand Up @@ -491,6 +496,7 @@ impl TorchBackend {
pub fn cuda_version(&self) -> Option<Version> {
match self {
Self::Cpu => None,
Self::Cu129 => Some(Version::new([12, 9])),
Self::Cu128 => Some(Version::new([12, 8])),
Self::Cu126 => Some(Version::new([12, 6])),
Self::Cu125 => Some(Version::new([12, 5])),
Expand Down Expand Up @@ -539,6 +545,7 @@ impl TorchBackend {
pub fn rocm_version(&self) -> Option<Version> {
match self {
Self::Cpu => None,
Self::Cu129 => None,
Self::Cu128 => None,
Self::Cu126 => None,
Self::Cu125 => None,
Expand Down Expand Up @@ -590,6 +597,7 @@ impl FromStr for TorchBackend {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"cpu" => Ok(Self::Cpu),
"cu129" => Ok(Self::Cu129),
"cu128" => Ok(Self::Cu128),
"cu126" => Ok(Self::Cu126),
"cu125" => Ok(Self::Cu125),
Expand Down Expand Up @@ -639,10 +647,11 @@ impl FromStr for TorchBackend {
/// Linux CUDA driver versions and the corresponding CUDA versions.
///
/// See: <https://github.com/pmeier/light-the-torch/blob/33397cbe45d07b51ad8ee76b004571a4c236e37f/light_the_torch/_cb.py#L150-L213>
static LINUX_CUDA_DRIVERS: LazyLock<[(TorchBackend, Version); 24]> = LazyLock::new(|| {
static LINUX_CUDA_DRIVERS: LazyLock<[(TorchBackend, Version); 25]> = LazyLock::new(|| {
[
// Table 2 from
// https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
(TorchBackend::Cu129, Version::new([525, 60, 13])),
(TorchBackend::Cu128, Version::new([525, 60, 13])),
(TorchBackend::Cu126, Version::new([525, 60, 13])),
(TorchBackend::Cu125, Version::new([525, 60, 13])),
Expand Down Expand Up @@ -677,10 +686,11 @@ static LINUX_CUDA_DRIVERS: LazyLock<[(TorchBackend, Version); 24]> = LazyLock::n
/// Windows CUDA driver versions and the corresponding CUDA versions.
///
/// See: <https://github.com/pmeier/light-the-torch/blob/33397cbe45d07b51ad8ee76b004571a4c236e37f/light_the_torch/_cb.py#L150-L213>
static WINDOWS_CUDA_VERSIONS: LazyLock<[(TorchBackend, Version); 24]> = LazyLock::new(|| {
static WINDOWS_CUDA_VERSIONS: LazyLock<[(TorchBackend, Version); 25]> = LazyLock::new(|| {
[
// Table 2 from
// https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
(TorchBackend::Cu129, Version::new([528, 33])),
(TorchBackend::Cu128, Version::new([528, 33])),
(TorchBackend::Cu126, Version::new([528, 33])),
(TorchBackend::Cu125, Version::new([528, 33])),
Expand Down Expand Up @@ -781,6 +791,8 @@ static LINUX_AMD_GPU_DRIVERS: LazyLock<[(TorchBackend, AmdGpuArchitecture); 44]>

static CPU_INDEX_URL: LazyLock<IndexUrl> =
LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/cpu").unwrap());
static CU129_INDEX_URL: LazyLock<IndexUrl> =
LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/cu129").unwrap());
static CU128_INDEX_URL: LazyLock<IndexUrl> =
LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/cu128").unwrap());
static CU126_INDEX_URL: LazyLock<IndexUrl> =
Expand Down
3 changes: 3 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3701,6 +3701,7 @@ by <code>--python-version</code>.</p>
<ul>
<li><code>auto</code>: Select the appropriate PyTorch index based on the operating system and CUDA driver version</li>
<li><code>cpu</code>: Use the CPU-only PyTorch index</li>
<li><code>cu129</code>: Use the PyTorch index for CUDA 12.9</li>
<li><code>cu128</code>: Use the PyTorch index for CUDA 12.8</li>
<li><code>cu126</code>: Use the PyTorch index for CUDA 12.6</li>
<li><code>cu125</code>: Use the PyTorch index for CUDA 12.5</li>
Expand Down Expand Up @@ -3973,6 +3974,7 @@ be used with caution, as it can modify the system Python installation.</p>
<ul>
<li><code>auto</code>: Select the appropriate PyTorch index based on the operating system and CUDA driver version</li>
<li><code>cpu</code>: Use the CPU-only PyTorch index</li>
<li><code>cu129</code>: Use the PyTorch index for CUDA 12.9</li>
<li><code>cu128</code>: Use the PyTorch index for CUDA 12.8</li>
<li><code>cu126</code>: Use the PyTorch index for CUDA 12.6</li>
<li><code>cu125</code>: Use the PyTorch index for CUDA 12.5</li>
Expand Down Expand Up @@ -4271,6 +4273,7 @@ should be used with caution, as it can modify the system Python installation.</p
<ul>
<li><code>auto</code>: Select the appropriate PyTorch index based on the operating system and CUDA driver version</li>
<li><code>cpu</code>: Use the CPU-only PyTorch index</li>
<li><code>cu129</code>: Use the PyTorch index for CUDA 12.9</li>
<li><code>cu128</code>: Use the PyTorch index for CUDA 12.8</li>
<li><code>cu126</code>: Use the PyTorch index for CUDA 12.6</li>
<li><code>cu125</code>: Use the PyTorch index for CUDA 12.5</li>
Expand Down
5 changes: 5 additions & 0 deletions uv.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading