The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
//! Which PyTorch wheels belong on THIS machine.
//!
//! Two environments in the app build a Python venv and put torch in it: the
//! ComfyUI environment (`install/`) and the character trainer (`trainer.rs`).
//! Both used to ask `nvidia-smi` and nothing else, so an AMD card was
//! indistinguishable from a machine with no card at all and got the wheels a
//! card-less box gets. On the ComfyUI side that is exactly what a user,
//! A user reported: ComfyUI installs, starts,
//! and renders on the processor, and forcing the GPU produces
//! "Torch not compiled with CUDA enabled" because the wheels really are
//! CUDA-only.
//!
//! The decisions live here as pure functions with the probes injected, so a
//! test can drive every branch on a machine that has none of the hardware.
//!
//! The LINUX ROCm side is MEASURED as of 2026-09-03, on a rented AMD Instinct
//! MI325X (gfx942): the first channel below installs,
//! `torch.cuda.is_available()` answers True, and ComfyUI rendered an image, a
//! video, a song, a 4x upscale and a cutout on the card. Details in
//! ~/Desktop/LU/amd-beweise/00-BEFUND.md. The WINDOWS side is still researched
//! against AMD's own index and Comfy-Desktop, because no Windows box with an
//! AMD card exists here.
use std::time::Duration;
/// PyTorch's ROCm channels, the one we want most first.
///
/// Listing read from download.pytorch.org on 2026-08-28: rocm7.2 and rocm7.1
/// both carry torch up to 2.13.0, rocm6.4 stops at 2.9.1, and every single
/// wheel in every ROCm channel is `manylinux_2_28_x86_64`. There is no
/// win_amd64 ROCm wheel anywhere, which is the whole reason the Windows
/// branch below installs processor wheels instead of pretending. ComfyUI's
/// own README names rocm7.2 as the AMD install line, so that one leads and
/// the two older channels are there to catch a channel that gets retired.
///
/// MEASURED 2026-09-03, the first entry, end to end on an MI325X: the index
/// served torch 2.14.0+rocm7.2 (6224.9 MB), `torch.version.hip` came back
/// 7.2.53211, `torch.cuda.is_available()` True, and a bf16 matmul ran at 153
/// TFLOP/s. This is the line the whole Linux branch stands on, and it is no
/// longer taken on trust.
pub(crate) const ROCM_CHANNELS: &[&str] = &[
"https://download.pytorch.org/whl/rocm7.2",
"https://download.pytorch.org/whl/rocm7.1",
"https://download.pytorch.org/whl/rocm6.4",
];
/// AMD's own ROCm wheels for Windows. RESEARCHED, NOT PROVEN ON A CARD.
///
/// pytorch.org really does publish Linux ROCm wheels only, and the comment
/// above still holds for it. AMD publishes win_amd64 ROCm wheels from its own
/// index, and ComfyUI's README names exactly this one in its section
/// "AMD GPUs (Windows, ROCm 10.0)".
///
/// 3.0.8 (kinghebes, RX 9070 XT, ComfyUI on the processor): until 3.0.7 this
/// was `repo.amd.com/rocm/whl-multi-arch/`, which repo.amd.com now files under
/// "Old releases" and which stops at torch 2.12.0+rocm7.14.1. The current
/// index is `stable.repo.amd.com/rocm/whl-next/` (read 2026-10-20: torch
/// 2.11 to 2.14 for win_amd64 cp310 to cp314, ROCm 10.0.0 and 10.1.0).
///
/// MEASURED 2026-10-20, against the index itself and without a card: `uv pip
/// compile` with `--python-platform windows` resolves `AMD_WINDOWS_TORCH`,
/// `AMD_WINDOWS_TORCHVISION` and `AMD_WINDOWS_TORCHAUDIO` below for gfx1100,
/// 1101, 1102, 1103, 1150, 1151, 1200 and 1201 and for Python 3.10 to 3.14, to
/// torch 2.13.0+rocm10.1.0, torchvision 0.28.0+rocm10.1.0 and torchaudio
/// 2.11.0.3+rocm10.1.0. For one gfx1201 card that is about 1.5 GB of wheels
/// (rocm-sdk-core 777 MB, rocm-sdk-device-gfx1201 314 MB, the two torch device
/// packages 209 MB, rocm-sdk-libraries 119 MB, torch itself 116 MB).
///
/// We own no AMD card. Nobody here has watched this install render. That is
/// why the plan falls back to the processor wheels when the index does not
/// answer instead of handing out a dead channel.
pub(crate) const ROCM_WINDOWS_CHANNELS: &[&str] = &["https://stable.repo.amd.com/rocm/whl-next/"];
/// The torch series on AMD's Windows index, as a range and not a pin.
///
/// Why a range: an exact `==2.13.0+rocm10.0.0` (ComfyUI README's line) dies
/// the day AMD retires that one build. Why THIS range: left alone, pip takes
/// torch 2.14.0 and torchvision 0.28.0, because 0.29 only exists as an alpha
/// there, and torchvision 0.28 is built against torch 2.13 (TheRock's own
/// compatibility table: 2.13 goes with 0.28 and 2.11). Neither torchvision on
/// that index pins torch, so nothing in pip stops the mismatch. ComfyUI's
/// README pins the same pair.
pub(crate) const AMD_WINDOWS_TORCH: &str = ">=2.13,<2.14";
pub(crate) const AMD_WINDOWS_TORCHVISION: &str = ">=0.28,<0.29";
pub(crate) const AMD_WINDOWS_TORCHAUDIO: &str = ">=2.11,<2.12";
/// What pip installs when the index is a plain PyTorch channel.
pub(crate) const TORCH_TRIO: &[&str] = &["torch", "torchvision", "torchaudio"];
/// The gfx targets LU sends to AMD's Windows index: RDNA 3, 3.5 and 4, the
/// families AMD builds the full stack for on Windows (TheRock RELEASES.md,
/// "GFX target lookup table"). RDNA 2 has device packages there too, but
/// 3.0.7 kept it on the processor build on purpose and nothing measured since
/// changes that.
pub(crate) const AMD_WINDOWS_TARGETS: &[&str] = &[
"gfx1100", "gfx1101", "gfx1102", "gfx1103", "gfx1150", "gfx1151", "gfx1152", "gfx1153",
"gfx1200", "gfx1201",
];
/// The pip requirements for AMD's Windows index, for these gfx targets.
///
/// The device extra is not optional: the index serves a slim `torch` plus one
/// device package per gfx target, so bare `torch` installs an environment with
/// no kernels for any card. torchvision has the same split since ROCm 10, and
/// 3.0.7 installed it bare, so torchvision's own GPU kernels were missing.
/// One extra per card instead of `device-all`, which downloads every target.
pub(crate) fn amd_windows_packages(targets: &[&str]) -> Vec<String> {
let extras = targets
.iter()
.map(|t| format!("device-{t}"))
.collect::<Vec<_>>()
.join(",");
vec![
format!("torch[{extras}]{AMD_WINDOWS_TORCH}"),
format!("torchvision[{extras}]{AMD_WINDOWS_TORCHVISION}"),
format!("torchaudio{AMD_WINDOWS_TORCHAUDIO}"),
]
}
/// The bare package name of a pip requirement: no extras, no version range.
/// "torch[device-gfx1201]>=2.13,<2.14" is "torch".
pub(crate) fn requirement_name(req: &str) -> &str {
let end = req.find(['[', '<', '>', '=', '!', '~', ';', ' ']).unwrap_or(req.len());
&req[..end]
}
/// The version range of a pip requirement, "" when it has none.
pub(crate) fn requirement_range(req: &str) -> &str {
let after_extras = match req.find(']') {
Some(i) => &req[i + 1..],
None => &req[requirement_name(req).len()..],
};
after_extras.trim()
}
/// Intel's channel on pytorch.org. ComfyUI's README names it for Arc cards on
/// Windows and Linux.
///
/// MEASURED 2026-10-20, against the index: `uv pip compile` for torch,
/// torchvision and torchaudio resolves to 2.14.1+xpu, 0.29.1+xpu and
/// 2.11.0+xpu on win_amd64 and on Linux, Python 3.12. Never run on an Arc card
/// here, which is why it rides `IndexOrCpu` like the AMD channel.
pub(crate) const XPU_CHANNELS: &[&str] = &["https://download.pytorch.org/whl/xpu"];
/// Blackwell and newer: CUDA 12.6 has no sm_120 kernels at all, so cu126 is
/// not a fallback for these cards, it is a broken install. Only channels that
/// carry the kernel may appear here.
pub(crate) const CUDA_BLACKWELL_CHANNELS: &[&str] = &[
"https://download.pytorch.org/whl/cu130",
"https://download.pytorch.org/whl/cu128",
];
/// Turing (compute capability 7.5) up to Ada and Hopper.
///
/// ComfyUI moved its own recommendation on 2026-08-16 and its README now says
/// a cu130 or newer PyTorch is REQUIRED on 20 series cards and above, while
/// the cu126 portable is labelled for 10 series and older with a written
/// warning not to use it on anything newer. NVIDIA's CUDA 13.0 release notes
/// give the same line from the other side: support was removed for Maxwell,
/// Pascal and Volta, meaning everything below Turing, so cu130 starts exactly
/// at 7.5 and cu126 is what stays behind for the cards below it.
///
/// Index listings read on 2026-08-28: cu130 carries torch 2.9.1 through
/// 2.13.0 for manylinux_2_28_x86_64, manylinux_2_28_aarch64 and win_amd64,
/// with matching torchvision and torchaudio. cu128 has stopped at 2.11.0,
/// which is why it now sits behind cu130 rather than in front of it, and
/// cu126 still moves (2.13.0) so it remains a real fallback for this range.
pub(crate) const CUDA_MODERN_CHANNELS: &[&str] = &[
"https://download.pytorch.org/whl/cu130",
"https://download.pytorch.org/whl/cu128",
"https://download.pytorch.org/whl/cu126",
];
/// Below Turing, and the machine whose capability probe stayed silent. cu126
/// is the living channel ComfyUI documents for this silicon (torch 2.6+,
/// sm_50 through sm_90). A silent probe means an nvidia-smi too old to answer
/// `--query-gpu=compute_cap`, which points at an old driver on an old card,
/// so the wide channel is the honest guess rather than the narrow new one.
pub(crate) const CUDA_LEGACY_CHANNELS: &[&str] = &[
"https://download.pytorch.org/whl/cu126",
];
/// Where CUDA 13 begins. NVIDIA removed every architecture below Turing in
/// CUDA 13.0, and Turing is 7.5 while Volta is 7.0, so the minor number is
/// what decides here.
pub(crate) const CU130_MIN_CAP: (u32, u32) = (7, 5);
/// What the pip step should do about torch.
#[derive(Debug, PartialEq, Eq)]
pub(crate) enum WheelPlan {
/// Install from the first of these indexes that answers. The list is
/// never empty, and its last entry is the fallback that gets used even
/// when nothing answers, so a blocked network cannot leave the installer
/// without a channel.
Index {
candidates: &'static [&'static str],
note: String,
},
/// Try these indexes, and install the PROCESSOR wheels if none answers.
///
/// The difference from `Index` is the dead-network case, and it is
/// deliberate: this variant exists for a channel nobody here has ever run,
/// so an unreachable channel falls back to what the app did before rather
/// than to a guess.
IndexOrCpu {
candidates: &'static [&'static str],
/// What pip installs from that index. Not every channel serves the
/// same package names, so the plan carries them. Owned, because AMD's
/// device extra is built from the card the machine has.
packages: Vec<String>,
note: String,
/// The sentence the fallback shows when no candidate answered.
cpu_note: String,
},
/// Install the plain PyPI wheels, which run on the processor. No index.
Cpu { note: String },
}
// `WheelPlan::note()` used to be the accessor the installer read its sentence
// from. It is gone because a plan can now change its mind: `IndexOrCpu` falls
// back to the processor wheels when its channel does not answer, and then the
// sentence to show is the fallback's. `resolve_plan` hands out the index and
// the note together so the two can never drift apart.
/// What is known about an AMD card LU can only see by the name the OS gives it.
///
/// Nothing here is a guess about silicon: the gfx targets behind these ranges
/// were read out of the published wheels on 2026-08-30 (the code object list in
/// libtorch, which is what `torch.cuda.get_arch_list()` reports) and matched
/// against AMD's own compatibility matrix.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub(crate) enum AmdCoverage {
/// The wheels carry this family's gfx target and AMD supports it here.
Supported,
/// Wheels for this family exist on this OS, but AMD makes no support
/// promise for it, so LU will not send the user down that road.
NotPromised,
/// No official wheel carries this family's gfx target at all. The install
/// SUCCEEDS and the first kernel then dies.
NoKernels,
/// The name says AMD and nothing more. An APU that reports itself as
/// "AMD Radeon(TM) Graphics" lands here.
Unknown,
}
/// The gfx target behind an AMD adapter name, from the name alone.
///
/// The mapping is TheRock's "GFX target lookup table" (RELEASES.md, read
/// 2026-10-20) plus the RX ranges the 3.0.7 code already read. Workstation
/// cards ("Radeon PRO W7900", "Radeon AI PRO R9700") and the named APUs
/// ("Radeon 890M", "Radeon 8060S") are read here too, which closes the gap the
/// note on `radeon_rx_model` describes. A name that says "AMD Radeon(TM)
/// Graphics" and nothing else stays `None`: that is the Raphael iGPU in every
/// Ryzen 7000/9000 desktop CPU, kinghebes' 9900X3D included, and also a
/// handful of other APUs nobody can tell apart by that name.
pub(crate) fn amd_gfx_target(name: &str) -> Option<&'static str> {
let lower = name.to_lowercase();
if let Some(model) = radeon_rx_model(name) {
// "RX 7900M" is Navi 32 like the 7800 XT, not Navi 31.
let mobile = lower.contains(&format!("{model}m")) || lower.contains(&format!("{model} m "));
return match model {
9070..=9099 => Some("gfx1201"),
9000..=9069 => Some("gfx1200"),
7900..=7999 if mobile => Some("gfx1101"),
7900..=7999 => Some("gfx1100"),
7700..=7899 => Some("gfx1101"),
7000..=7699 => Some("gfx1102"),
6800..=6999 => Some("gfx1030"),
6700..=6799 => Some("gfx1031"),
6600..=6699 => Some("gfx1032"),
6400..=6599 => Some("gfx1034"),
5000..=5999 => Some("gfx1010"),
_ => None,
};
}
// Workstation and AI PRO cards: a letter and four digits as their own word.
for (prefix, table) in [
('r', &[(9700u32, "gfx1201"), (9600, "gfx1201")][..]),
('w', &[(7900, "gfx1100"), (7800, "gfx1100"), (7700, "gfx1101"), (7600, "gfx1102"),
(7500, "gfx1102"), (6800, "gfx1030"), (6600, "gfx1032")][..]),
('v', &[(710, "gfx1101"), (620, "gfx1030")][..]),
] {
if !lower.contains("pro") {
break;
}
for word in lower.split(|c: char| !c.is_ascii_alphanumeric()) {
let Some(rest) = word.strip_prefix(prefix) else { continue };
let Ok(n) = rest.parse::<u32>() else { continue };
if let Some((_, gfx)) = table.iter().find(|(m, _)| *m == n) {
return Some(gfx);
}
}
}
// APUs that carry their graphics name.
for (needle, gfx) in [
("8060s", "gfx1151"), ("8050s", "gfx1151"), ("8040s", "gfx1151"),
("890m", "gfx1150"), ("880m", "gfx1150"),
("860m", "gfx1152"), ("840m", "gfx1152"), ("820m", "gfx1153"),
("780m", "gfx1103"), ("760m", "gfx1103"), ("740m", "gfx1103"),
("680m", "gfx1035"), ("660m", "gfx1035"),
] {
if lower.split(|c: char| !c.is_ascii_alphanumeric()).any(|w| w == needle) {
return Some(gfx);
}
}
None
}
/// The gfx targets on this machine that AMD's Windows index serves, in the
/// order the cards were listed, without repeats. Empty means no card here gets
/// the ROCm build on Windows.
pub(crate) fn amd_windows_targets(names: &[&str]) -> Vec<&'static str> {
let mut out: Vec<&'static str> = Vec::new();
for name in names {
if let Some(gfx) = amd_gfx_target(name) {
if AMD_WINDOWS_TARGETS.contains(&gfx) && !out.contains(&gfx) {
out.push(gfx);
}
}
}
out
}
/// An Intel card PyTorch's XPU build drives: the Arc family, discrete (A770,
/// B580) and integrated (Meteor Lake and Lunar Lake report "Arc" too). UHD and
/// Iris Xe are left alone.
pub(crate) fn is_intel_arc(name: &str) -> bool {
name.to_lowercase()
.split(|c: char| !c.is_ascii_alphanumeric())
.any(|w| w == "arc")
}
/// The Radeon RX model number out of an adapter name, if it carries one.
///
/// Every probe spells it differently. wmic and the registry give
/// "AMD Radeon RX 6700 XT", lspci gives
/// "Advanced Micro Devices, Inc. [AMD/ATI] Navi 22 [Radeon RX 6700 XT]", and
/// rocm-smi gives the product name. All three contain "RX <four digits>", so
/// that is what is read, and nothing else is inferred.
///
/// Known gap, written down rather than guessed away: AMD's workstation cards
/// carry no "RX ####" at all. A Radeon AI PRO R9700 is gfx1201 and a PRO W7900
/// is gfx1100, both fully carried by the wheels, and both come back as `None`
/// here, so `amd_coverage` calls them `Unknown`. On Linux that costs nothing
/// because `Unknown` keeps the ROCm wheels. On Windows it costs them the ROCm
/// path, because only `Supported` reaches AMD's index. Closing it means
/// reading PRO model names too, which changes which cards the plan sends to
/// that index, so it is a decision and not a cleanup.
fn radeon_rx_model(name: &str) -> Option<u32> {
let lower = name.to_lowercase();
let bytes = lower.as_bytes();
let mut from = 0usize;
while let Some(rel) = lower[from..].find("rx") {
let at = from + rel;
// "rx" has to be a word of its own, or "Firepro Sx" style names and
// any word ending in rx would start matching digits after them.
let before_ok = at == 0 || !bytes[at - 1].is_ascii_alphanumeric();
if before_ok {
let digits: String = lower[at + 2..]
.trim_start()
.chars()
.take_while(|c| c.is_ascii_digit())
.collect();
if digits.len() == 4 {
if let Ok(n) = digits.parse::<u32>() {
return Some(n);
}
}
}
from = at + 2;
}
None
}
/// What one AMD card can expect from the wheels this OS has.
///
/// Measured wheel contents, counted file by file inside
/// `torch-2.13.0+rocm7.2-cp312-cp312-manylinux_2_28_x86_64.whl` on 2026-08-31.
/// A gfx target is only usable when the compute layers carry it, and they do
/// not all carry the same list, so the layers are named here instead of one
/// flat "is in" that hides the difference:
///
/// - rocBLAS and hipBLASLt and aotriton all three: gfx1100, 1101, 1102, 1150,
/// 1151, 1200, 1201, 90a, 942, 950. These are the targets the wheel really
/// serves.
/// - hipBLASLt only, no rocBLAS: gfx1103. That is the Ryzen Phoenix APU, and
/// the half-coverage is exactly why it is worth naming.
/// - rocBLAS only, no hipBLASLt: gfx1030.
/// - MIOpen only, in neither BLAS layer: gfx900, gfx906.
/// - In no layer at all: gfx1010, 1012, 1031, 1032, 1033 to 1036, 90c. That is
/// the byte-level ground for the Linux brake below.
///
/// RE-MEASURED 2026-09-03 in the INSTALLED 2.14.0+rocm7.2 on the MI325X, and
/// it agrees point for point: gfx1103 in hipBLASLt and not in rocBLAS, gfx1030
/// in rocBLAS and not in hipBLASLt, and none of gfx1010, 1012, 1031, 1032,
/// 1033 to 1036 or 90c in any layer. One change from 2.13.0: gfx908 is in both
/// BLAS layers now. The same list comes back a second way from the card itself,
/// through `torch.cuda.get_arch_list()`, which reports gfx900, 906, 908, 90a,
/// 942, 950, 1030, 1100, 1101, 1102, 1103, 1150, 1151, 1200, 1201. Note that
/// gfx900 and gfx906 appear there and in NEITHER BLAS layer, which is exactly
/// the "MIOpen only" nuance above rather than a contradiction of it.
///
/// Windows: AMD names RX 9070 and 9070 XT, AI PRO R9700, RX 9060 XT,
/// RX 7900 XTX and PRO W7900 in its own support promise, and publishes device
/// wheels more widely than that promise reaches. An RX 7600 (gfx1102) has a
/// 48.4 MiB device package in the index (MEASURED 2026-08-31) without being on
/// AMD's named list, so the range below is wider than the promise on purpose:
/// it follows the published wheels. RDNA 2 wheels are built for Windows but
/// with hipBLASLt, composable_kernel and rocWMMA excluded from every gfx103X
/// target, and AMD promises nothing for them.
pub(crate) fn amd_coverage(name: &str, os: &str) -> AmdCoverage {
// 3.0.8: on Windows the verdict is the gfx target, because that is what
// the device extra is built from. A card whose target is served is
// supported there, whether its name carries "RX ####" or not.
if os == "windows" {
if let Some(gfx) = amd_gfx_target(name) {
if AMD_WINDOWS_TARGETS.contains(&gfx) {
return AmdCoverage::Supported;
}
}
}
let Some(model) = radeon_rx_model(name) else {
return AmdCoverage::Unknown;
};
match (os, model) {
// RDNA1. In no wheel on either OS.
(_, 5000..=5999) => AmdCoverage::NoKernels,
// RX 6400 to 6750 are gfx1031/1032/1034, in no official wheel anywhere.
(_, 6000..=6799) => AmdCoverage::NoKernels,
// RX 6800 and up are gfx1030: in the Linux wheels and sound over the
// rocBLAS path, but outside AMD's Windows promise.
("linux", 6800..=6999) => AmdCoverage::Supported,
(_, 6800..=6999) => AmdCoverage::NotPromised,
// RDNA3 (gfx1100/1101/1102) and RDNA4 (gfx1200/1201).
(_, 7000..=7999) | (_, 9000..=9999) => AmdCoverage::Supported,
_ => AmdCoverage::Unknown,
}
}
/// The verdict for a whole machine. The best card wins, for the same reason
/// NVIDIA wins over AMD: the plan has to serve the card the user renders on.
/// A card we cannot place never overrides one we can.
pub(crate) fn amd_fleet_coverage(names: &[&str], os: &str) -> AmdCoverage {
let mut verdict = AmdCoverage::Unknown;
for name in names {
match amd_coverage(name, os) {
AmdCoverage::Supported => return AmdCoverage::Supported,
AmdCoverage::NoKernels => verdict = AmdCoverage::NoKernels,
AmdCoverage::NotPromised if verdict != AmdCoverage::NoKernels => {
verdict = AmdCoverage::NotPromised
}
_ => {}
}
}
verdict
}
/// Which vendors this machine has, from the same probe the hardware picker
/// uses, so a card that shows up in Settings is a card the installers know
/// about. That probe survives a missing rocm-smi, which is the only reason an
/// AMD card is visible here at all.
pub(crate) fn gpu_vendors_present() -> (bool, bool) {
let (nvidia, amd, _) = gpu_vendor_facts();
(nvidia, amd)
}
/// The same probe, plus the names of the AMD cards it found. The names are what
/// `amd_coverage` reads, and they are the only thing we have: no probe here
/// reports a gfx target, and rocm-smi, which could, is exactly the tool the
/// affected machines do not have installed.
pub(crate) fn gpu_vendor_facts() -> (bool, bool, Vec<String>) {
let gpus = crate::commands::gpu::detect_gpus().unwrap_or_default();
let amd_names: Vec<String> = gpus
.iter()
.filter(|g| g.vendor == "amd")
.map(|g| g.name.clone())
.collect();
(
gpus.iter().any(|g| g.vendor == "nvidia"),
!amd_names.is_empty(),
amd_names,
)
}
/// The Intel adapter names the same probe found. Kept apart from
/// `gpu_vendor_facts` so its callers, the trainer among them, stay as they are.
pub(crate) fn intel_gpu_names() -> Vec<String> {
crate::commands::gpu::detect_gpus()
.unwrap_or_default()
.into_iter()
.filter(|g| g.vendor == "intel")
.map(|g| g.name)
.collect()
}
/// The torch plan for the ComfyUI environment, for a machine without Intel.
#[cfg(test)]
pub(crate) fn comfy_wheel_plan(
has_nvidia: bool,
nvidia_cap: Option<(u32, u32)>,
has_amd: bool,
amd_names: &[&str],
os: &str,
) -> WheelPlan {
comfy_wheel_plan_for(has_nvidia, nvidia_cap, has_amd, amd_names, &[], os)
}
/// The torch plan for the ComfyUI environment.
///
/// NVIDIA wins on a box that has both cards: it is the one every ComfyUI
/// feature is proven on. An AMD card the ROCm build serves comes next, then an
/// Intel Arc card, then whatever the AMD branch says about the rest. That
/// order matters on a Ryzen desktop with an Arc card: its "AMD Radeon(TM)
/// Graphics" iGPU is a card we cannot place, and it may not take the XPU build
/// away from the Arc. macOS never reaches this code, local media there is MLX
/// and `install_comfyui` refuses before it starts.
pub(crate) fn comfy_wheel_plan_for(
has_nvidia: bool,
nvidia_cap: Option<(u32, u32)>,
has_amd: bool,
amd_names: &[&str],
intel_names: &[&str],
os: &str,
) -> WheelPlan {
if has_nvidia || nvidia_cap.is_some() {
return nvidia_plan(nvidia_cap);
}
let amd_served = has_amd && amd_fleet_coverage(amd_names, os) == AmdCoverage::Supported;
let arc: Vec<&str> = intel_names.iter().copied().filter(|n| is_intel_arc(n)).collect();
if !amd_served && !arc.is_empty() && matches!(os, "windows" | "linux") {
return WheelPlan::IndexOrCpu {
candidates: XPU_CHANNELS,
packages: TORCH_TRIO.iter().map(|s| s.to_string()).collect(),
note: format!(
"Intel Arc GPU detected ({}). Installing the XPU build of PyTorch from \
download.pytorch.org/whl/xpu, the channel ComfyUI's README names for Arc \
cards. Not proven on our hardware: LU owns no Arc card. Arc needs a current \
Intel graphics driver.",
arc.join(", "),
),
cpu_note: "Intel's XPU channel on pytorch.org did not answer, so ComfyUI is being \
installed with the processor build of PyTorch, which works but is slow. \
Repair the environment later to try the XPU build again."
.to_string(),
};
}
if has_amd {
let coverage = amd_fleet_coverage(amd_names, os);
if os == "linux" {
// The card families no wheel carries would INSTALL fine here and
// then die at the first kernel, which is worse than what 2.6.6 did
// for them (slow, but running). Only cards we can actually name are
// held back; a card we cannot place keeps the ROCm wheels, because
// guessing the other way would take the fix away from the cards it
// was built for.
if coverage == AmdCoverage::NoKernels {
return WheelPlan::Cpu {
note: amd_uncovered_linux_note(amd_names),
};
}
return WheelPlan::Index {
candidates: ROCM_CHANNELS,
note: "AMD GPU detected, installing the ROCm build of PyTorch. \
ComfyUI will run on the card instead of the processor once this finishes."
.to_string(),
};
}
if os == "windows" && coverage == AmdCoverage::Supported {
let targets = amd_windows_targets(amd_names);
return WheelPlan::IndexOrCpu {
candidates: ROCM_WINDOWS_CHANNELS,
packages: amd_windows_packages(&targets),
note: format!(
"AMD GPU detected ({}). Installing AMD's own ROCm build of PyTorch for \
Windows (torch 2.13, ROCm 10, about 1.5 GB), from the index ComfyUI's \
README names. It needs Windows 11 and a current AMD Software: Adrenalin \
Edition driver. Researched, not proven: LU owns no AMD card, so this \
path has never run on our hardware. If the index does not answer, the \
processor build is installed instead and this stays exactly as slow as \
it was before.",
targets.join(", "),
),
cpu_note: format!(
"AMD's Windows ROCm index did not answer. {}",
amd_without_rocm_note(os),
),
};
}
return WheelPlan::Cpu {
note: amd_without_rocm_note(os),
};
}
WheelPlan::Cpu {
note: "No GPU detected, installing the processor build of PyTorch.".to_string(),
}
}
fn nvidia_plan(cap: Option<(u32, u32)>) -> WheelPlan {
match cap {
Some((major, minor)) if major >= 12 => WheelPlan::Index {
candidates: CUDA_BLACKWELL_CHANNELS,
note: format!(
"NVIDIA Blackwell GPU detected (compute capability {major}.{minor}), \
installing CUDA PyTorch."
),
},
Some(cap) if cap >= CU130_MIN_CAP => WheelPlan::Index {
candidates: CUDA_MODERN_CHANNELS,
note: format!(
"NVIDIA GPU detected (compute capability {}.{}), installing CUDA PyTorch.",
cap.0, cap.1,
),
},
Some((major, minor)) => WheelPlan::Index {
candidates: CUDA_LEGACY_CHANNELS,
note: format!(
"NVIDIA GPU detected (compute capability {major}.{minor}, below Turing), \
installing the CUDA PyTorch that still carries kernels for it."
),
},
None => WheelPlan::Index {
candidates: CUDA_LEGACY_CHANNELS,
note: "NVIDIA GPU detected (the compute capability probe stayed silent), \
installing the CUDA PyTorch that covers the widest range of cards."
.to_string(),
},
}
}
/// What an AMD card can and cannot do on an operating system PyTorch ships no
/// ROCm wheels for. Windows is the case that matters (all four reporters of
/// the AMD bundle who are not on Linux are there); anything else that is not
/// Linux gets the same honest answer minus the Windows-only names.
/// The measured fact behind the Linux brake, and the one sentence every caller
/// starts from.
///
/// It lives here alone because two environments have to say it, and a fact that
/// is written twice is a fact that gets updated once. `install/torch.rs` puts the
/// ComfyUI consequence behind it, `trainer.rs` puts the trainer's behind it,
/// and neither restates the measurement.
///
/// The install itself would succeed, which is the trap: pip is happy, the venv
/// looks right, and the first kernel dies with "HIP error: invalid device
/// function" or a rocBLAS complaint about a missing TensileLibrary. For these
/// cards the ROCm wheels are 6.2 GB of download that ends worse than the
/// processor build they would replace.
///
/// The size was "about 3 GB" here until 2026-08-31, when the wheel was
/// measured instead of estimated: `torch-2.13.0+rocm7.2-cp312` alone is
/// 6,227,849,000 bytes, and torchvision and torchaudio still come on top. The
/// old number was less than half of what the customer would have waited for.
pub(crate) const AMD_UNCOVERED_GFX_FACT: &str =
"AMD GPU detected, but no official ROCm wheel carries kernels for this card \
(checked 2026-08-31 against the code object lists inside the published wheels: \
gfx1010, gfx1012, gfx1031, gfx1032 and gfx1034 appear in none of them). \
Installing the ROCm build would download over 6 GB (the ROCm PyTorch wheel \
alone is 6.2 GB, measured 2026-08-31, with torchvision and torchaudio on top) \
and then fail at the first kernel with \"HIP error: invalid device function\".";
/// The one workaround that exists, offered only where it can work.
///
/// RDNA 2 below the 6800 has a real one, because gfx1030 kernels ARE in the
/// wheels and the runtime can be pointed at them. RDNA 1 has no such neighbour,
/// so it is not sent chasing one. `before_what` is what the user would start
/// with the variable set, which is a different program per caller.
pub(crate) fn amd_rdna2_override_hint(names: &[&str], before_what: &str) -> Option<String> {
let has_rdna2 = names
.iter()
.any(|n| matches!(radeon_rx_model(n), Some(6000..=6799)));
if !has_rdna2 {
return None;
}
Some(format!(
"If you want to try the card anyway, the community route is to set \
HSA_OVERRIDE_GFX_VERSION=10.3.0 before starting {before_what}, which makes an \
RDNA 2 card use the gfx1030 kernels. LU does not do that for you, because \
AMD does not support it and we cannot test it."
))
}
/// What an AMD card gets told on Linux when the ROCm wheels have no kernels
/// for it: the shared fact, then what the ComfyUI installer does about it.
pub(crate) fn amd_uncovered_linux_note(names: &[&str]) -> String {
let mut note = format!(
"{AMD_UNCOVERED_GFX_FACT} So LU is installing the processor build instead, \
which is slow but works."
);
if let Some(hint) = amd_rdna2_override_hint(names, "ComfyUI") {
note.push(' ');
note.push_str(&hint);
}
note
}
pub(crate) fn amd_without_rocm_note(os: &str) -> String {
let head = "AMD GPU detected, but pytorch.org publishes ROCm wheels for Linux only \
(checked 2026-08-28: every wheel in the rocm7.2, rocm7.1 and rocm6.4 \
channels is a Linux wheel). ComfyUI is being installed with the \
processor build, which works but is slow.";
if os == "windows" {
// The old version of this sentence said PyTorch has no Windows ROCm
// wheels at all, full stop, and sent the reader to DirectML first. Both
// halves were wrong by 2026-08-30: AMD publishes its own Windows ROCm
// wheels, LU installs them for the cards AMD supports, and torch-directml
// has not seen a release since 2024-09-15, pins torch 2.4.1 and is in
// Microsoft's declared maintenance mode. A customer who reads ComfyUI's
// README finds the AMD channel in a minute, so claiming it does not
// exist costs us the whole answer.
format!(
"{head} AMD publishes its own Windows ROCm wheels, and LU installs those for \
the RDNA 3, 3.5 and 4 cards AMD publishes them for, but not for this card. \
To drive it anyway you need a ComfyUI of your own on ZLUDA or DirectML, \
then point LU at it and set Settings > Hardware > ComfyUI GPU to force GPU. \
ZLUDA stands in for the CUDA runtime, it is not a CUDA PyTorch build, so it \
only helps a ComfyUI that was set up for it, and DirectML has been frozen on \
an old PyTorch since 2024."
)
} else {
format!("{head} Linux with ROCm is the supported way to use this card for image and video.")
}
}
/// The first candidate that answers, otherwise the last one.
///
/// Pure over the probe, so a test can drive both ends without a network. The
/// fallback is deliberate: an install behind a proxy that blocks our probe
/// still gets a channel to try, which is the behaviour the app had before any
/// of this existed.
pub(crate) fn first_live_index<'a>(
candidates: &[&'a str],
mut alive: impl FnMut(&str) -> bool,
) -> Option<&'a str> {
if candidates.is_empty() {
return None;
}
for c in candidates {
if alive(c) {
return Some(c);
}
}
candidates.last().copied()
}
/// Does this wheel index actually serve torch right now?
///
/// Runs on its own thread: a blocking HTTP client panics inside a tokio
/// runtime, and this is called from both a plain worker thread and a Tauri
/// command, so the thread makes the call site irrelevant.
pub(crate) fn index_serves_torch(index: &str) -> bool {
let url = format!("{}/torch/", index.trim_end_matches('/'));
std::thread::spawn(move || {
reqwest::blocking::Client::builder()
.timeout(Duration::from_secs(8))
.build()
.ok()
.and_then(|c| c.get(&url).send().ok())
.map(|r| r.status().is_success())
.unwrap_or(false)
})
.join()
.unwrap_or(false)
}
/// The first candidate that answers, and nothing if none does.
///
/// The strict twin of `first_live_index`, for a channel that has never been
/// proven here: handing out an unreachable index would leave the user with a
/// failed install where the old behaviour gave a working, slow one.
pub(crate) fn first_live_index_strict<'a>(
candidates: &[&'a str],
mut alive: impl FnMut(&str) -> bool,
) -> Option<&'a str> {
candidates.iter().copied().find(|c| alive(c))
}
/// Resolve a plan into (index, packages, note). A `None` index means the plain
/// PyPI wheels, which is what `pytorch_pip_args(None, ..)` installs. The note
/// comes back with it because a plan that falls back to the processor has a
/// different sentence to show than the one it started with.
pub(crate) fn resolve_plan(plan: &WheelPlan) -> (Option<&'static str>, Vec<String>, String) {
resolve_plan_with(plan, index_serves_torch)
}
/// `resolve_plan` over an injected probe, so a test can drive both ends.
pub(crate) fn resolve_plan_with(
plan: &WheelPlan,
mut alive: impl FnMut(&str) -> bool,
) -> (Option<&'static str>, Vec<String>, String) {
let trio = || TORCH_TRIO.iter().map(|s| s.to_string()).collect::<Vec<_>>();
match plan {
WheelPlan::Cpu { note } => (None, trio(), note.clone()),
WheelPlan::Index { candidates, note } => {
(first_live_index(candidates, &mut alive), trio(), note.clone())
}
WheelPlan::IndexOrCpu { candidates, packages, note, cpu_note } => {
match first_live_index_strict(candidates, &mut alive) {
Some(url) => (Some(url), packages.clone(), note.clone()),
None => (None, trio(), cpu_note.clone()),
}
}
}
}
/// What a plan is, in one word, for the settings line and the status call.
pub(crate) fn plan_kind(plan: &WheelPlan) -> &'static str {
match plan {
WheelPlan::Cpu { .. } => "cpu",
WheelPlan::Index { candidates, .. } | WheelPlan::IndexOrCpu { candidates, .. } => {
let first = candidates.first().copied().unwrap_or("");
if first.contains("/xpu") {
"xpu"
} else if first.contains("rocm") {
"rocm"
} else {
"cuda"
}
}
}
}
/// The plan for THIS machine, from the real probes, with no network call.
/// What the settings show as "what LU installs here", and the same plan
/// `plan_pytorch_install` resolves.
pub(crate) fn comfy_wheel_plan_here() -> WheelPlan {
let (has_nvidia, has_amd, amd_names) = gpu_vendor_facts();
let intel = intel_gpu_names();
let cap = if has_nvidia { crate::commands::install::detect_nvidia_compute_cap() } else { None };
let amd_refs: Vec<&str> = amd_names.iter().map(String::as_str).collect();
let intel_refs: Vec<&str> = intel.iter().map(String::as_str).collect();
let plan = comfy_wheel_plan_for(has_nvidia, cap, has_amd, &amd_refs, &intel_refs, std::env::consts::OS);
let found = usize::from(has_nvidia) + amd_names.len() + intel.len();
with_probe_gap_hint(plan, crate::commands::gpu::pciutils_hint_here(found))
}
/// C74: der Prozessor-Plan sagt dazu, warum, wenn die Karte nur deshalb
/// fehlt, weil unter Linux lspci fehlt. Ohne diesen Satz las c1rrus (Bazzite,
/// RX 6900 XT, Distrobox) nur "No GPU detected" und bekam still die
/// Prozessor-Wheels.
pub(crate) fn with_probe_gap_hint(plan: WheelPlan, hint: Option<String>) -> WheelPlan {
match (plan, hint) {
(WheelPlan::Cpu { note }, Some(hint)) => WheelPlan::Cpu { note: format!("{note} {hint}") },
(plan, _) => plan,
}
}
/// The line the installer adds after the PyTorch download, when the build was
/// meant for a card and torch then does not see one. `index` is the channel
/// pip installed from (None: the processor build, nothing to check), `sees_gpu`
/// what the probe said (None: it did not answer, so nothing is claimed).
///
/// The point is the AMD Windows case: the ROCm build installs cleanly on any
/// driver, and only answers "no GPU" when AMD Software is too old. That is a
/// fix the user can make in five minutes, and without this line it looks
/// exactly like LU ignoring the card.
pub(crate) fn post_install_gpu_line(index: Option<&str>, sees_gpu: Option<bool>, os: &str) -> Option<String> {
let index = index?;
if sees_gpu != Some(false) {
return None;
}
let why = if index.contains("rocm") && os == "windows" {
"AMD's ROCm build needs Windows 11 and a current AMD Software: Adrenalin Edition \
driver. Update the driver, restart the PC, then start ComfyUI again; the \
installed build stays and nothing needs to be reinstalled."
} else if index.contains("rocm") {
"Check that the amdgpu driver is loaded and that your user is in the render and \
video groups, then start ComfyUI again."
} else if index.contains("/xpu") {
"The XPU build needs a current Intel graphics driver. Update it, restart the PC, \
then start ComfyUI again."
} else {
"Update the NVIDIA driver, restart the PC, then start ComfyUI again."
};
Some(format!(
"PyTorch is installed, but it does not see your graphics card yet, so ComfyUI \
would run on the processor. {why}"
))
}
/// Does LU install the ROCm build for an AMD card on this machine? The fact
/// the Force GPU warning and the CPU banner need to say "repair" instead of
/// "use a ComfyUI of your own".
pub(crate) fn amd_rocm_served(amd_names: &[&str], os: &str) -> bool {
match os {
"linux" => amd_fleet_coverage(amd_names, os) != AmdCoverage::NoKernels,
"windows" => amd_fleet_coverage(amd_names, os) == AmdCoverage::Supported,
_ => false,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn an_amd_linux_box_gets_rocm_wheels_not_processor_wheels() {
match comfy_wheel_plan(false, None, true, &[], "linux") {
WheelPlan::Index { candidates, note } => {
assert_eq!(candidates, ROCM_CHANNELS);
assert!(candidates[0].contains("rocm"), "first candidate is a ROCm channel");
assert!(note.contains("AMD"), "the log says what was detected: {note}");
}
other => panic!("AMD on Linux must get wheels, got {other:?}"),
}
}
#[test]
fn an_amd_box_without_rocm_wheels_is_told_the_truth_instead_of_getting_cuda() {
// Negative control: no ROCm channel exists for Windows, so the plan
// must NOT hand out an index at all, and it must not claim CUDA.
for os in ["windows", "freebsd"] {
match comfy_wheel_plan(false, None, true, &[], os) {
WheelPlan::Cpu { note } => {
assert!(
!note.contains("installing CUDA PyTorch"),
"{os}: promised CUDA wheels to an AMD card",
);
assert!(note.contains("AMD"), "{os}: never named the card");
}
other => panic!("{os} has no ROCm wheels, got {other:?}"),
}
}
assert!(amd_without_rocm_note("windows").contains("DirectML"));
assert!(!amd_without_rocm_note("linux").contains("DirectML"));
}
#[test]
fn an_nvidia_card_still_wins_over_an_amd_card_in_the_same_box() {
match comfy_wheel_plan(true, Some((8, 6)), true, &[], "linux") {
WheelPlan::Index { candidates, .. } => {
assert!(candidates.iter().all(|c| c.contains("/cu")), "{candidates:?}");
}
other => panic!("expected CUDA wheels, got {other:?}"),
}
}
#[test]
fn a_box_with_no_card_at_all_keeps_the_processor_build() {
match comfy_wheel_plan(false, None, false, &[], "linux") {
WheelPlan::Cpu { note } => assert!(note.contains("No GPU")),
other => panic!("expected processor wheels, got {other:?}"),
}
}
#[test]
fn blackwell_never_gets_a_channel_without_its_kernels() {
// Negative control: cu126 has no sm_120 kernel, so it may not appear
// in the Blackwell ladder even as a last fallback.
match comfy_wheel_plan(true, Some((12, 0)), false, &[], "windows") {
WheelPlan::Index { candidates, .. } => {
assert!(!candidates.iter().any(|c| c.ends_with("cu126")), "{candidates:?}");
}
other => panic!("expected CUDA wheels, got {other:?}"),
}
}
#[test]
fn the_first_answering_index_wins_and_a_dead_network_still_yields_one() {
let list = ["a", "b", "c"];
assert_eq!(first_live_index(&list, |i| i == "a"), Some("a"));
assert_eq!(first_live_index(&list, |i| i == "b"), Some("b"));
// Negative control: nothing answers, so the last entry is handed out
// rather than nothing at all.
assert_eq!(first_live_index(&list, |_| false), Some("c"));
assert_eq!(first_live_index(&[], |_| true), None);
}
/// The channel a plan would try first.
fn first_channel(cap: Option<(u32, u32)>) -> &'static str {
match comfy_wheel_plan(true, cap, false, &[], "windows") {
WheelPlan::Index { candidates, .. } => candidates[0],
other => panic!("an NVIDIA card must get wheels, got {other:?}"),
}
}
#[test]
fn turing_and_newer_ride_cu130_and_older_cards_stay_on_cu126() {
// ComfyUI 2026-08-16: cu130 or newer is required on 20 series and up.
// NVIDIA CUDA 13.0: everything below Turing was removed. Turing is
// 7.5, Volta is 7.0, so the line runs between those two.
assert!(first_channel(Some((7, 5))).ends_with("cu130"), "Turing");
assert!(first_channel(Some((8, 6))).ends_with("cu130"), "Ampere, the 3060 in the box");
assert!(first_channel(Some((8, 9))).ends_with("cu130"), "Ada");
assert!(first_channel(Some((9, 0))).ends_with("cu130"), "Hopper");
assert!(first_channel(Some((12, 0))).ends_with("cu130"), "Blackwell");
assert!(first_channel(Some((7, 0))).ends_with("cu126"), "Volta");
assert!(first_channel(Some((6, 1))).ends_with("cu126"), "Pascal, a 1080");
assert!(first_channel(Some((5, 2))).ends_with("cu126"), "Maxwell");
}
#[test]
fn a_card_cuda_13_dropped_is_never_offered_cu130_at_all() {
// Negative control, and the reason the minor number is read: a card
// below Turing must not reach cu130 even as a fallback further down
// the list, because CUDA 13 ships no kernel for it.
for cap in [(5, 2), (6, 1), (7, 0)] {
match comfy_wheel_plan(true, Some(cap), false, &[], "linux") {
WheelPlan::Index { candidates, .. } => assert!(
!candidates.iter().any(|c| c.ends_with("cu130")),
"cap {cap:?} was offered cu130: {candidates:?}",
),
other => panic!("expected wheels, got {other:?}"),
}
}
}
#[test]
fn a_silent_capability_probe_keeps_the_wide_channel() {
// An nvidia-smi too old to answer --query-gpu=compute_cap points at an
// old driver on an old card, so the guess that covers the most cards
// wins over the newest channel.
assert!(first_channel(None).ends_with("cu126"));
match comfy_wheel_plan(true, None, false, &[], "linux") {
WheelPlan::Index { candidates, .. } => {
assert!(!candidates.iter().any(|c| c.ends_with("cu130")), "{candidates:?}");
}
other => panic!("expected wheels, got {other:?}"),
}
}
#[test]
fn cu126_stays_reachable_as_a_fallback_for_the_cards_it_can_still_drive() {
// The switch may not turn into a hard wire: a Turing to Hopper card
// that cannot reach cu130 has to land somewhere that works.
match comfy_wheel_plan(true, Some((8, 6)), false, &[], "linux") {
WheelPlan::Index { candidates, .. } => {
assert_eq!(candidates.last().copied(), Some("https://download.pytorch.org/whl/cu126"));
assert!(candidates.len() > 1, "a single entry is a hard wire: {candidates:?}");
}
other => panic!("expected wheels, got {other:?}"),
}
}
// ── Windows plus AMD, Runde 12 ────────────────────────────────────────
//
// "PyTorch ships ROCm wheels for Linux only" was true about pytorch.org and
// false about the world. AMD publishes win_amd64 ROCm wheels from its own
// indexes, ComfyUI documents them in its README, and ComfyUI Desktop
// installs them. LU was the only one of the five products compared on
// 2026-08-30 with no GPU path at all for Windows AMD.
//
// RESEARCHED, NOT PROVEN throughout: we own no AMD card.
const RX_7900: &str = "AMD Radeon RX 7900 XTX";
const RX_9070: &str = "Advanced Micro Devices, Inc. [AMD/ATI] Navi 48 [Radeon RX 9070 XT]";
const RX_6700: &str = "AMD Radeon RX 6700 XT";
const RX_6800: &str = "AMD Radeon RX 6800 XT";
const RX_5700: &str = "AMD Radeon RX 5700 XT";
const APU: &str = "AMD Radeon(TM) Graphics";
#[test]
fn a_supported_amd_card_on_windows_gets_amds_own_wheels_not_processor_wheels() {
for name in [RX_7900, RX_9070] {
match comfy_wheel_plan(false, None, true, &[name], "windows") {
WheelPlan::IndexOrCpu { candidates, packages, note, cpu_note } => {
assert_eq!(candidates, ROCM_WINDOWS_CHANNELS);
assert!(candidates[0].contains("repo.amd.com"), "{candidates:?}");
// The device extra is not optional on this index.
assert!(packages.iter().any(|p| p.contains("[device-")), "{packages:?}");
// Honesty is part of the message, not just the comment.
assert!(note.to_lowercase().contains("researched, not proven"), "{note}");
assert!(cpu_note.contains("did not answer"), "{cpu_note}");
}
other => panic!("{name} must get AMD's Windows wheels, got {other:?}"),
}
}
}
#[test]
fn an_unreachable_amd_channel_falls_back_to_exactly_what_the_app_did_before() {
// NEGATIVE CONTROL for the whole feature: this path has never run on
// real hardware, so a dead index may not leave the user worse off than
// 2.6.6 did. No index, the processor wheels, and the fallback sentence.
let plan = comfy_wheel_plan(false, None, true, &[RX_7900], "windows");
let WheelPlan::IndexOrCpu { candidates, cpu_note, .. } = &plan else {
panic!("expected the AMD Windows plan, got {plan:?}");
};
assert_eq!(first_live_index_strict(candidates, |_| false), None);
assert_eq!(first_live_index_strict(candidates, |_| true), Some(candidates[0]));
assert!(cpu_note.contains("processor build"), "{cpu_note}");
// and the ladder variant would have done the opposite, which is why
// this plan is a different variant and not a longer candidate list
assert_eq!(first_live_index(candidates, |_| false), Some(candidates[0]));
}
#[test]
fn a_card_amd_does_not_support_on_windows_keeps_the_processor_wheels() {
// RDNA1 and the RX 6400 to 6750 range are in no official wheel at all,
// and RDNA2 above them is built for Windows but with hipBLASLt,
// composable_kernel and rocWMMA stripped out and no promise attached.
// Sending any of them to the AMD index would be a guess with a 2.5 GiB
// download (MEASURED 2026-08-31: 1.72 GiB of device packages plus torch,
// plus 723.6 MiB rocm_sdk_core and 110.5 MiB rocm_sdk_libraries) and a
// broken environment at the end.
for name in [RX_6700, RX_6800, RX_5700, APU] {
match comfy_wheel_plan(false, None, true, &[name], "windows") {
WheelPlan::Cpu { note } => {
assert!(note.contains("AMD"), "{name}: never named the card");
assert!(!note.contains("installing CUDA"), "{name}: {note}");
}
other => panic!("{name} has no supported Windows wheel, got {other:?}"),
}
}
// A machine with both still gets the channel, for the card that can use it.
assert!(matches!(
comfy_wheel_plan(false, None, true, &[RX_6700, RX_7900], "windows"),
WheelPlan::IndexOrCpu { .. },
));
}
// ── Linux, the families no wheel carries, Runde 12 ────────────────────
//
// The gfx targets in the published wheels were read out of the wheels
// themselves on 2026-08-30. gfx1010, 1012, 1031, 1032 and 1034 are in none
// of them. For those cards the ROCm wheels install cleanly and the first
// kernel dies, which is WORSE than 2.6.6, where the same machine rendered
// on the processor: slow, but finishing.
#[test]
fn a_linux_card_with_no_kernels_anywhere_keeps_the_processor_wheels() {
for name in [RX_6700, RX_5700, "AMD Radeon RX 6600 XT", "AMD Radeon RX 6500 XT"] {
match comfy_wheel_plan(false, None, true, &[name], "linux") {
WheelPlan::Cpu { note } => {
assert!(note.contains("no official ROCm wheel carries kernels"), "{name}: {note}");
// The reason has to be IN the step message, not only in a log
assert!(note.contains("invalid device function"), "{name}: {note}");
assert!(note.contains("processor build"), "{name}: {note}");
}
other => panic!("{name} would die at the first kernel, got {other:?}"),
}
}
}
#[test]
fn the_rdna2_workaround_is_named_only_where_it_can_work() {
// gfx1030 kernels ARE in the wheels, so an RDNA 2 card can be pointed
// at them. RDNA 1 has no such neighbour and must not be sent chasing one.
assert!(amd_uncovered_linux_note(&[RX_6700]).contains("HSA_OVERRIDE_GFX_VERSION=10.3.0"));
assert!(!amd_uncovered_linux_note(&[RX_5700]).contains("HSA_OVERRIDE"));
// and it is offered, never done for the user
assert!(amd_uncovered_linux_note(&[RX_6700]).contains("LU does not do that for you"));
}
#[test]
fn the_cards_the_linux_fix_was_built_for_still_get_the_rocm_wheels() {
// NEGATIVE CONTROL for the brake: it may only catch the families that
// were measured as uncovered. Everything else, INCLUDING a card whose
// name tells us nothing, keeps the wheels 57196b31 gave it.
for name in [RX_7900, RX_9070, RX_6800, APU, "AMD Radeon Pro W7900", "AMD Radeon Graphics"] {
match comfy_wheel_plan(false, None, true, &[name], "linux") {
WheelPlan::Index { candidates, .. } => assert_eq!(candidates, ROCM_CHANNELS, "{name}"),
other => panic!("{name} must keep the ROCm wheels, got {other:?}"),
}
}
// A box with an uncovered card AND a covered one renders on the covered
// one, so the brake must not take the wheels away from it.
assert!(matches!(
comfy_wheel_plan(false, None, true, &[RX_6700, RX_7900], "linux"),
WheelPlan::Index { .. },
));
// and the brake is an AMD brake: it cannot reach an NVIDIA box
assert!(matches!(
comfy_wheel_plan(true, Some((8, 6)), true, &[RX_6700], "linux"),
WheelPlan::Index { candidates, .. } if candidates[0].contains("/cu"),
));
}
#[test]
fn the_card_name_is_read_and_never_guessed() {
// The three probes spell the same card three ways, and all three have
// to land on the same verdict or the plan depends on which tool ran.
assert_eq!(radeon_rx_model("AMD Radeon RX 7900 XTX"), Some(7900));
assert_eq!(radeon_rx_model(RX_9070), Some(9070));
assert_eq!(radeon_rx_model("Radeon RX 6600"), Some(6600));
// NEGATIVE CONTROL: nothing is invented out of a name without a model.
assert_eq!(radeon_rx_model(APU), None);
assert_eq!(radeon_rx_model("AMD Radeon Pro W7900"), None);
assert_eq!(radeon_rx_model("Intel(R) UHD Graphics 770"), None);
assert_eq!(amd_coverage(APU, "windows"), AmdCoverage::Unknown);
// and a name whose "rx" is part of another word must not match
assert_eq!(radeon_rx_model("Matrox G7900"), None);
}
#[test]
fn the_windows_text_no_longer_claims_a_wheel_that_exists_does_not() {
// The old sentence said PyTorch has no Windows ROCm wheels, period, and
// led with DirectML. A customer who reads ComfyUI's README finds the
// AMD channel in a minute, and then the whole answer is worthless.
let note = amd_without_rocm_note("windows");
assert!(note.contains("pytorch.org publishes ROCm wheels for Linux only"), "{note}");
assert!(note.contains("AMD publishes its own Windows ROCm wheels"), "{note}");
// DirectML may still be named as a last resort, but not before ZLUDA
// and not without saying it has been frozen.
assert!(note.contains("DirectML"));
assert!(note.find("ZLUDA") < note.find("DirectML"), "{note}");
assert!(note.contains("frozen"), "{note}");
assert!(!amd_without_rocm_note("linux").contains("DirectML"));
}
// ── Runde 20: the numbers in the texts are the measured ones ──────────
//
// The AMD deep-dive of 2026-08-31 weighed the wheels byte by byte and the
// texts disagreed with the scale in two places. Both are customer-facing,
// so both get a guard: what the number is now, and what it may never say
// again.
#[test]
fn the_uncovered_card_text_carries_the_measured_download_size() {
let note = amd_uncovered_linux_note(&[RX_6700]);
// The measurement: torch-2.13.0+rocm7.2-cp312 is 6,227,849,000 bytes on
// its own, before torchvision and torchaudio.
assert!(note.contains("over 6 GB"), "no measured size in the text: {note}");
assert!(note.contains("6.2 GB"), "no measured size in the text: {note}");
// House rule: a number a customer reads needs the thing it refers to
// right next to it, or it gets quoted somewhere else as our claim.
assert!(
note.contains("the ROCm PyTorch wheel alone is 6.2 GB"),
"the size has no reference point: {note}",
);
assert!(note.contains("measured 2026-08-31"), "no date on the number: {note}");
// NEGATIVE CONTROL, backwards: the estimate this replaced was less than
// half the real download. It may not come back through either caller.
assert!(!note.contains("about 3 GB"), "the old estimate is back: {note}");
assert!(!AMD_UNCOVERED_GFX_FACT.contains("about 3 GB"), "{AMD_UNCOVERED_GFX_FACT}");
assert!(!AMD_UNCOVERED_GFX_FACT.contains("3 GB"), "{AMD_UNCOVERED_GFX_FACT}");
}
#[test]
fn the_windows_text_promises_published_wheels_and_not_amds_support_list() {
// AMD's named Windows promise is RX 9070/XT, AI PRO R9700, RX 9060 XT,
// RX 7900 XTX and PRO W7900. Our range is wider than that on purpose:
// it follows the published device wheels, and an RX 7600 really has one
// (48.4 MiB, MEASURED 2026-08-31). So the text may claim the wheels,
// never AMD's support.
let note = amd_without_rocm_note("windows");
assert!(note.contains("AMD publishes them for"), "{note}");
// NEGATIVE CONTROL, backwards: the sentence used to hand AMD's support
// promise to every card in the range, which is more than AMD says.
assert!(!note.contains("AMD supports there"), "the wider promise is back: {note}");
}
#[test]
fn nvidia_and_linux_are_untouched_by_the_windows_amd_channel() {
// The point of the whole change is that it adds a branch. Nothing that
// worked before may route through AMD's index or through its extras.
for (nv, cap, amd, names, os) in [
(true, Some((8, 6)), false, &[][..], "windows"),
(true, Some((12, 0)), false, &[][..], "windows"),
(true, None, false, &[][..], "linux"),
(true, Some((8, 6)), true, &[RX_7900][..], "windows"),
(false, None, true, &[RX_7900][..], "linux"),
(false, None, true, &[RX_6700][..], "linux"),
] {
let plan = comfy_wheel_plan(nv, cap, amd, names, os);
assert!(
!matches!(plan, WheelPlan::IndexOrCpu { .. }),
"{os} {names:?} nvidia={nv} must not reach the AMD Windows plan: {plan:?}",
);
let (index, packages, _) = match &plan {
WheelPlan::Index { candidates, note } => {
(first_live_index(candidates, |_| true), TORCH_TRIO, note)
}
WheelPlan::Cpu { note } => (None, TORCH_TRIO, note),
other => panic!("{other:?}"),
};
assert!(
index.is_none_or(|u| u.contains("download.pytorch.org")),
"{os} {names:?} left pytorch.org: {index:?}",
);
assert_eq!(packages, TORCH_TRIO, "{os} {names:?} got a foreign package list");
}
// and a no-GPU box is still a no-GPU box
assert!(matches!(
comfy_wheel_plan(false, None, false, &[], "windows"),
WheelPlan::Cpu { .. },
));
}
// ── 3.0.8: AMD's current Windows index, per-card extras, Intel Arc ────
#[test]
fn every_card_name_lands_on_the_gfx_target_therock_lists_for_it() {
for (name, gfx) in [
("AMD Radeon RX 9070 XT", "gfx1201"),
("AMD Radeon RX 9070", "gfx1201"),
("AMD Radeon RX 9070 GRE", "gfx1201"),
("AMD Radeon RX 9060 XT", "gfx1200"),
("AMD Radeon RX 7900 XTX", "gfx1100"),
("AMD Radeon RX 7900 GRE", "gfx1100"),
("AMD Radeon RX 7900M", "gfx1101"),
("AMD Radeon RX 7800 XT", "gfx1101"),
("AMD Radeon RX 7700 XT", "gfx1101"),
("AMD Radeon RX 7600", "gfx1102"),
("AMD Radeon RX 6800 XT", "gfx1030"),
("AMD Radeon RX 6700 XT", "gfx1031"),
("AMD Radeon RX 6600", "gfx1032"),
("AMD Radeon RX 5700 XT", "gfx1010"),
("AMD Radeon PRO W7900", "gfx1100"),
("AMD Radeon Pro W7800", "gfx1100"),
("AMD Radeon PRO W7700", "gfx1101"),
("AMD Radeon AI PRO R9700", "gfx1201"),
("AMD Radeon(TM) 8060S Graphics", "gfx1151"),
("AMD Radeon(TM) 890M Graphics", "gfx1150"),
("AMD Radeon 780M Graphics", "gfx1103"),
(RX_9070, "gfx1201"),
] {
assert_eq!(amd_gfx_target(name), Some(gfx), "{name}");
}
// NEGATIVE CONTROL: a name with no model in it is never guessed.
for name in [APU, "AMD Radeon Graphics", "Intel(R) Arc(TM) A770 Graphics", "Matrox G7900"] {
assert_eq!(amd_gfx_target(name), None, "{name}");
}
}
#[test]
fn windows_amd_installs_one_device_extra_per_card_from_the_current_index() {
match comfy_wheel_plan(false, None, true, &["AMD Radeon RX 9070 XT"], "windows") {
WheelPlan::IndexOrCpu { candidates, packages, .. } => {
assert_eq!(candidates, &["https://stable.repo.amd.com/rocm/whl-next/"]);
assert_eq!(
packages,
vec![
"torch[device-gfx1201]>=2.13,<2.14",
"torchvision[device-gfx1201]>=0.28,<0.29",
"torchaudio>=2.11,<2.12",
],
);
}
other => panic!("expected AMD's Windows index, got {other:?}"),
}
// Two different served cards: both extras, in one requirement each.
match comfy_wheel_plan(false, None, true, &["AMD Radeon RX 9070 XT", RX_7900, "AMD Radeon RX 9070"], "windows") {
WheelPlan::IndexOrCpu { packages, .. } => {
assert_eq!(packages[0], "torch[device-gfx1201,device-gfx1100]>=2.13,<2.14");
assert_eq!(packages[1], "torchvision[device-gfx1201,device-gfx1100]>=0.28,<0.29");
}
other => panic!("expected AMD's Windows index, got {other:?}"),
}
// A workstation card and a Strix Halo APU, which the RX-only reading
// of 3.0.7 left on the processor.
for name in ["AMD Radeon PRO W7900", "AMD Radeon AI PRO R9700", "AMD Radeon(TM) 8060S Graphics"] {
assert!(
matches!(comfy_wheel_plan(false, None, true, &[name], "windows"), WheelPlan::IndexOrCpu { .. }),
"{name}",
);
}
// NEGATIVE CONTROL: neither the retired index nor device-all, anywhere.
let all = format!("{:?}", comfy_wheel_plan(false, None, true, &[RX_7900], "windows"));
assert!(!all.contains("whl-multi-arch"), "{all}");
assert!(!all.contains("device-all"), "{all}");
}
#[test]
fn torch_and_torchvision_are_held_to_the_series_built_for_each_other() {
// Left alone, pip took torch 2.14.0 and torchvision 0.28.0 from that
// index (0.29 only exists as an alpha there), and 0.28 is built for 2.13.
assert_eq!(AMD_WINDOWS_TORCH, ">=2.13,<2.14");
assert_eq!(AMD_WINDOWS_TORCHVISION, ">=0.28,<0.29");
let p = amd_windows_packages(&["gfx1100"]);
assert!(p[0].starts_with("torch[") && p[0].ends_with(AMD_WINDOWS_TORCH), "{p:?}");
assert!(p[1].starts_with("torchvision[") && p[1].ends_with(AMD_WINDOWS_TORCHVISION), "{p:?}");
assert!(!p[2].contains('['), "torchaudio has no device extra: {p:?}");
}
#[test]
fn an_intel_arc_card_gets_the_xpu_build_and_uhd_graphics_does_not() {
for os in ["windows", "linux"] {
match comfy_wheel_plan_for(false, None, false, &[], &["Intel(R) Arc(TM) B580 Graphics"], os) {
WheelPlan::IndexOrCpu { candidates, packages, note, cpu_note } => {
assert_eq!(candidates, XPU_CHANNELS, "{os}");
assert_eq!(packages, TORCH_TRIO, "{os}");
assert!(note.contains("XPU"), "{note}");
assert!(cpu_note.contains("processor build"), "{cpu_note}");
}
other => panic!("{os}: an Arc card must get the XPU channel, got {other:?}"),
}
}
// A Ryzen desktop with an Arc card: the iGPU nobody can place may not
// take the XPU build away from the Arc.
assert!(matches!(
comfy_wheel_plan_for(false, None, true, &[APU], &["Intel(R) Arc(TM) A770 Graphics"], "linux"),
WheelPlan::IndexOrCpu { candidates, .. } if candidates == XPU_CHANNELS,
));
// NEGATIVE CONTROLS: UHD and Iris Xe stay on the processor build, a
// served AMD card wins over the Arc, and NVIDIA wins over both.
assert!(matches!(
comfy_wheel_plan_for(false, None, false, &[], &["Intel(R) UHD Graphics 770", "Intel(R) Iris(R) Xe Graphics"], "windows"),
WheelPlan::Cpu { .. },
));
assert!(matches!(
comfy_wheel_plan_for(false, None, true, &[RX_7900], &["Intel(R) Arc(TM) A770 Graphics"], "windows"),
WheelPlan::IndexOrCpu { candidates, .. } if candidates == ROCM_WINDOWS_CHANNELS,
));
assert!(matches!(
comfy_wheel_plan_for(true, Some((8, 6)), false, &[], &["Intel(R) Arc(TM) A770 Graphics"], "windows"),
WheelPlan::Index { candidates, .. } if candidates[0].contains("/cu"),
));
}
#[test]
fn the_plan_kind_names_the_build_the_settings_line_talks_about() {
assert_eq!(plan_kind(&comfy_wheel_plan(true, Some((8, 6)), false, &[], "windows")), "cuda");
assert_eq!(plan_kind(&comfy_wheel_plan(false, None, true, &[RX_9070], "windows")), "rocm");
assert_eq!(plan_kind(&comfy_wheel_plan(false, None, true, &[RX_9070], "linux")), "rocm");
assert_eq!(plan_kind(&comfy_wheel_plan_for(false, None, false, &[], &["Intel(R) Arc(TM) A770"], "linux")), "xpu");
assert_eq!(plan_kind(&comfy_wheel_plan(false, None, false, &[], "windows")), "cpu");
}
#[test]
fn amd_rocm_served_follows_the_plan_on_both_systems() {
assert!(amd_rocm_served(&[RX_9070], "windows"));
assert!(amd_rocm_served(&[RX_9070], "linux"));
// Linux keeps ROCm for a card it cannot place, as the plan does.
assert!(amd_rocm_served(&[APU], "linux"));
// NEGATIVE CONTROLS: the cards the plans leave on the processor.
assert!(!amd_rocm_served(&[RX_6700], "windows"));
assert!(!amd_rocm_served(&[RX_6700], "linux"));
assert!(!amd_rocm_served(&[APU], "windows"));
assert!(!amd_rocm_served(&[RX_9070], "macos"));
}
#[test]
fn a_gpu_build_that_sees_no_card_says_what_to_fix() {
let amd = post_install_gpu_line(Some(ROCM_WINDOWS_CHANNELS[0]), Some(false), "windows").unwrap();
assert!(amd.contains("Adrenalin"), "{amd}");
assert!(amd.contains("nothing needs to be reinstalled"), "{amd}");
let arc = post_install_gpu_line(Some(XPU_CHANNELS[0]), Some(false), "linux").unwrap();
assert!(arc.contains("Intel graphics driver"), "{arc}");
// NEGATIVE CONTROLS: a card that answers, a probe that did not, and
// the processor build are all left alone.
assert_eq!(post_install_gpu_line(Some(ROCM_WINDOWS_CHANNELS[0]), Some(true), "windows"), None);
assert_eq!(post_install_gpu_line(Some(ROCM_WINDOWS_CHANNELS[0]), None, "windows"), None);
assert_eq!(post_install_gpu_line(None, Some(false), "windows"), None);
}
#[test]
fn a_processor_plan_never_resolves_to_an_index() {
let plan = WheelPlan::Cpu { note: "x".to_string() };
let (index, packages, note) = resolve_plan(&plan);
assert_eq!(index, None);
assert_eq!(packages, TORCH_TRIO);
assert_eq!(note, "x");
}
}