diff --git a/clippy.toml b/clippy.toml index bb1f365b5..6b3031c84 100644 --- a/clippy.toml +++ b/clippy.toml @@ -7,6 +7,7 @@ doc-valid-idents = [ "ReFS", "PyTorch", "ROCm", + "XPU", ".." # Include the defaults ] diff --git a/crates/uv-resolver/src/resolver/system.rs b/crates/uv-resolver/src/resolver/system.rs index a47000846..a815697da 100644 --- a/crates/uv-resolver/src/resolver/system.rs +++ b/crates/uv-resolver/src/resolver/system.rs @@ -86,4 +86,10 @@ mod tests { let url = DisplaySafeUrl::parse("https://download.pytorch.org/whl/cpu").unwrap(); assert_eq!(SystemDependency::from_index(&url), None); } + + #[test] + fn pytorch_xpu() { + let url = DisplaySafeUrl::parse("https://download.pytorch.org/whl/xpu").unwrap(); + assert_eq!(SystemDependency::from_index(&url), None); + } } diff --git a/crates/uv-torch/src/backend.rs b/crates/uv-torch/src/backend.rs index 958ea3d9e..60d43f3d7 100644 --- a/crates/uv-torch/src/backend.rs +++ b/crates/uv-torch/src/backend.rs @@ -171,6 +171,8 @@ pub enum TorchMode { #[serde(rename = "rocm4.0.1")] #[cfg_attr(feature = "clap", clap(name = "rocm4.0.1"))] Rocm401, + /// Use the PyTorch index for Intel XPU. + Xpu, } /// The strategy to use when determining the appropriate PyTorch index. @@ -237,6 +239,7 @@ impl TorchStrategy { TorchMode::Rocm42 => Ok(Self::Backend(TorchBackend::Rocm42)), TorchMode::Rocm41 => Ok(Self::Backend(TorchBackend::Rocm41)), TorchMode::Rocm401 => Ok(Self::Backend(TorchBackend::Rocm401)), + TorchMode::Xpu => Ok(Self::Backend(TorchBackend::Xpu)), } } @@ -356,6 +359,7 @@ pub enum TorchBackend { Rocm42, Rocm41, Rocm401, + Xpu, } impl TorchBackend { @@ -403,6 +407,7 @@ impl TorchBackend { Self::Rocm42 => &ROCM42_INDEX_URL, Self::Rocm41 => &ROCM41_INDEX_URL, Self::Rocm401 => &ROCM401_INDEX_URL, + Self::Xpu => &XPU_INDEX_URL, } } @@ -465,6 +470,7 @@ impl TorchBackend { TorchBackend::Rocm42 => None, TorchBackend::Rocm41 => None, TorchBackend::Rocm401 => None, + TorchBackend::Xpu => None, } } @@ -512,6 +518,7 @@ impl TorchBackend { TorchBackend::Rocm42 => Some(Version::new([4, 2])), TorchBackend::Rocm41 => Some(Version::new([4, 1])), TorchBackend::Rocm401 => Some(Version::new([4, 0, 1])), + TorchBackend::Xpu => None, } } } @@ -562,6 +569,7 @@ impl FromStr for TorchBackend { "rocm4.2" => Ok(TorchBackend::Rocm42), "rocm4.1" => Ok(TorchBackend::Rocm41), "rocm4.0.1" => Ok(TorchBackend::Rocm401), + "xpu" => Ok(TorchBackend::Xpu), _ => Err(format!("Unknown PyTorch backend: {s}")), } } @@ -725,3 +733,5 @@ static ROCM41_INDEX_URL: LazyLock = LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/rocm4.1").unwrap()); static ROCM401_INDEX_URL: LazyLock = LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/rocm4.0.1").unwrap()); +static XPU_INDEX_URL: LazyLock = + LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/xpu").unwrap()); diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 48b0351fe..b9490e2ce 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -3451,6 +3451,7 @@ by --python-version.

  • rocm4.2: Use the PyTorch index for ROCm 4.2
  • rocm4.1: Use the PyTorch index for ROCm 4.1
  • rocm4.0.1: Use the PyTorch index for ROCm 4.0.1
  • +
  • xpu: Use the PyTorch index for Intel XPU
  • --universal

    Perform a universal resolution, attempting to generate a single requirements.txt output file that is compatible with all operating systems, architectures, and Python implementations.

    In universal mode, the current Python version (or user-provided --python-version) will be treated as a lower bound. For example, --universal --python-version 3.7 would produce a universal resolution for Python 3.7 and later.

    Implies --no-strip-markers.

    @@ -3708,6 +3709,7 @@ be used with caution, as it can modify the system Python installation.

  • rocm4.2: Use the PyTorch index for ROCm 4.2
  • rocm4.1: Use the PyTorch index for ROCm 4.1
  • rocm4.0.1: Use the PyTorch index for ROCm 4.0.1
  • +
  • xpu: Use the PyTorch index for Intel XPU
  • --verbose, -v

    Use verbose output.

    You can configure fine-grained logging using the RUST_LOG environment variable. (https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives)

    @@ -3998,6 +4000,7 @@ should be used with caution, as it can modify the system Python installation.

    rocm4.2: Use the PyTorch index for ROCm 4.2
  • rocm4.1: Use the PyTorch index for ROCm 4.1
  • rocm4.0.1: Use the PyTorch index for ROCm 4.0.1
  • +
  • xpu: Use the PyTorch index for Intel XPU
  • --upgrade, -U

    Allow package upgrades, ignoring pinned versions in any existing output file. Implies --refresh

    --upgrade-package, -P upgrade-package

    Allow upgrades for a specific package, ignoring pinned versions in any existing output file. Implies --refresh-package

    --user
    --verbose, -v

    Use verbose output.

    diff --git a/uv.schema.json b/uv.schema.json index 0d2b47490..0b9bd6f15 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -2701,6 +2701,13 @@ "enum": [ "rocm4.0.1" ] + }, + { + "description": "Use the PyTorch index for Intel XPU.", + "type": "string", + "enum": [ + "xpu" + ] } ] },