Add XPU to --torch-backend (#14172)

## Summary

Like ROCm, no auto-detection for now.
This commit is contained in:
Charlie Marsh 2025-06-20 20:33:20 -04:00 committed by GitHub
parent 0133bcc8ca
commit e59835d50c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 0 deletions

View file

@ -7,6 +7,7 @@ doc-valid-idents = [
"ReFS",
"PyTorch",
"ROCm",
"XPU",
".." # Include the defaults
]

View file

@ -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);
}
}

View file

@ -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<IndexUrl> =
LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/rocm4.1").unwrap());
static ROCM401_INDEX_URL: LazyLock<IndexUrl> =
LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/rocm4.0.1").unwrap());
static XPU_INDEX_URL: LazyLock<IndexUrl> =
LazyLock::new(|| IndexUrl::from_str("https://download.pytorch.org/whl/xpu").unwrap());

View file

@ -3451,6 +3451,7 @@ by <code>--python-version</code>.</p>
<li><code>rocm4.2</code>: Use the PyTorch index for ROCm 4.2</li>
<li><code>rocm4.1</code>: Use the PyTorch index for ROCm 4.1</li>
<li><code>rocm4.0.1</code>: Use the PyTorch index for ROCm 4.0.1</li>
<li><code>xpu</code>: Use the PyTorch index for Intel XPU</li>
</ul></dd><dt id="uv-pip-compile--universal"><a href="#uv-pip-compile--universal"><code>--universal</code></a></dt><dd><p>Perform a universal resolution, attempting to generate a single <code>requirements.txt</code> output file that is compatible with all operating systems, architectures, and Python implementations.</p>
<p>In universal mode, the current Python version (or user-provided <code>--python-version</code>) will be treated as a lower bound. For example, <code>--universal --python-version 3.7</code> would produce a universal resolution for Python 3.7 and later.</p>
<p>Implies <code>--no-strip-markers</code>.</p>
@ -3708,6 +3709,7 @@ be used with caution, as it can modify the system Python installation.</p>
<li><code>rocm4.2</code>: Use the PyTorch index for ROCm 4.2</li>
<li><code>rocm4.1</code>: Use the PyTorch index for ROCm 4.1</li>
<li><code>rocm4.0.1</code>: Use the PyTorch index for ROCm 4.0.1</li>
<li><code>xpu</code>: Use the PyTorch index for Intel XPU</li>
</ul></dd><dt id="uv-pip-sync--verbose"><a href="#uv-pip-sync--verbose"><code>--verbose</code></a>, <code>-v</code></dt><dd><p>Use verbose output.</p>
<p>You can configure fine-grained logging using the <code>RUST_LOG</code> environment variable. (<a href="https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives">https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives</a>)</p>
</dd></dl>
@ -3998,6 +4000,7 @@ should be used with caution, as it can modify the system Python installation.</p
<li><code>rocm4.2</code>: Use the PyTorch index for ROCm 4.2</li>
<li><code>rocm4.1</code>: Use the PyTorch index for ROCm 4.1</li>
<li><code>rocm4.0.1</code>: Use the PyTorch index for ROCm 4.0.1</li>
<li><code>xpu</code>: Use the PyTorch index for Intel XPU</li>
</ul></dd><dt id="uv-pip-install--upgrade"><a href="#uv-pip-install--upgrade"><code>--upgrade</code></a>, <code>-U</code></dt><dd><p>Allow package upgrades, ignoring pinned versions in any existing output file. Implies <code>--refresh</code></p>
</dd><dt id="uv-pip-install--upgrade-package"><a href="#uv-pip-install--upgrade-package"><code>--upgrade-package</code></a>, <code>-P</code> <i>upgrade-package</i></dt><dd><p>Allow upgrades for a specific package, ignoring pinned versions in any existing output file. Implies <code>--refresh-package</code></p>
</dd><dt id="uv-pip-install--user"><a href="#uv-pip-install--user"><code>--user</code></a></dt><dt id="uv-pip-install--verbose"><a href="#uv-pip-install--verbose"><code>--verbose</code></a>, <code>-v</code></dt><dd><p>Use verbose output.</p>

7
uv.schema.json generated
View file

@ -2701,6 +2701,13 @@
"enum": [
"rocm4.0.1"
]
},
{
"description": "Use the PyTorch index for Intel XPU.",
"type": "string",
"enum": [
"xpu"
]
}
]
},