diff --git a/apps/rocm/src/examine_cmd.rs b/apps/rocm/src/examine_cmd.rs index 68961469da..6ae1a22fae 100644 --- a/apps/rocm/src/examine_cmd.rs +++ b/apps/rocm/src/examine_cmd.rs @@ -82,13 +82,18 @@ pub(crate) fn examine(json: bool, framework: rocm_core::FrameworkProbe) -> Resul // torch lives only in its site-packages, so probing PATH would report // `unknown` for a host that has one. let interpreter = rocm_core::active_managed_framework_interpreter(&paths, &config); - let examination = + let mut examination = rocm_core::Examination::probe_with_interpreter(framework, interpreter.as_ref()); // `gather` rather than `examine_human_report`: the latter first runs // `recover_setup_runtime_registration`, which writes. Asking a machine a // question should not change it, and `--json` is the form tooling calls // in a loop. let host = ExamineSummary::gather()?; + // The human report's "AMD GPU detected" line reads this same + // `detected_gfx_target`; WSL skips the probes that would set + // `has_amd_gpu`, so take it from here rather than leave the two forms + // to disagree on a healthy host. + examination.adopt_wsl_host_gpu(host.detected_gfx_target.is_some()); let configured_default_engine = config.default_engine.as_deref(); // Same resolution the human report uses, minus the recovery write above: // an unreadable registry leaves the root `null` rather than failing the diff --git a/apps/rocm/src/model_fit.rs b/apps/rocm/src/model_fit.rs index 0217a01137..20d26fe52f 100644 --- a/apps/rocm/src/model_fit.rs +++ b/apps/rocm/src/model_fit.rs @@ -123,7 +123,9 @@ fn assess_model_with_host_paths( /// /// `examination.has_amd_gpu` cannot answer this on WSL: the hardware probes /// that set it are skipped there (see [`rocm_core::Examination::probe_with_interpreter`]), -/// so it reads `false` on every WSL host, healthy or not, and this command +/// so the probe leaves it `false` on every WSL host, healthy or not. This +/// command reads the probe directly, never the `rocm examine --json` document +/// that fills the field in afterwards from the Windows-side GPU target, so it /// would report a working machine as having no GPU at all -- `Blocked` /// instead of the `Undetermined` a genuinely unmeasurable host deserves. /// `rocm_sees_gpu`, not `has_amd_gpu`, is the WSL-native signal, per the same @@ -764,9 +766,11 @@ mod tests { ); } - /// `has_amd_gpu` is always `false` on WSL (the probes that set it are - /// skipped there), so `host_accelerator_memory` must read `rocm_sees_gpu` - /// instead on a WSL host -- and only a confirmed `Some(false)` counts as + /// `has_amd_gpu` is `false` on a WSL examination as the probe returns it + /// (the probes that set it are skipped there), and what the WSL host's + /// display adapter says is not what ROCm can enumerate, so + /// `host_accelerator_memory` must read `rocm_sees_gpu` instead on a WSL + /// host -- and only a confirmed `Some(false)` counts as /// "no GPU"; `None` means rocminfo was absent, which is not evidence of /// anything, per the same reasoning `fix-wsl-6-host-driver-too-old` in /// `diagnose.rs` already uses. diff --git a/crates/rocm-core/src/examine.rs b/crates/rocm-core/src/examine.rs index e8f65d99d4..cac9a7310c 100644 --- a/crates/rocm-core/src/examine.rs +++ b/crates/rocm-core/src/examine.rs @@ -120,9 +120,12 @@ pub struct WslFacts { /// `None` when `rocminfo` is absent, so the question could not be asked. This /// is the only WSL-collected evidence that the plumbing is complete yet no /// device is reachable, which is what distinguishes an out-of-date Windows - /// host driver from a distro-side fault. The bare-metal `has_amd_gpu` cannot - /// stand in: the probes that populate it are skipped here, so it is always - /// false on WSL and reads as "no GPU" on a perfectly healthy machine. + /// host driver from a distro-side fault. The probe's own `has_amd_gpu` cannot + /// stand in: the probes that populate it are skipped here, so it is `false` + /// straight out of the probe. It only becomes meaningful once + /// [`Examination::adopt_wsl_host_gpu`] has set it from the Windows-side + /// detection, which says a display adapter exists, not that ROCm can + /// enumerate it. This field is the only evidence of the latter. pub rocm_sees_gpu: Option, /// `None` when the distro release could not be parsed, which fails closed: /// an unreadable release is not evidence of a supported one. @@ -212,6 +215,18 @@ pub struct Examination { pub cpu_vendor: String, pub cpu_model: String, pub gpus: Vec, + /// Whether an AMD GPU was found. On bare metal the hardware probes own this + /// field. WSL skips those probes, so [`Examination::probe_with_interpreter`] + /// leaves it `false` there; `rocm examine --json` then sets it with + /// [`Examination::adopt_wsl_host_gpu`] from the Windows-side detection the + /// human report also reads. `gpus`, `has_apu` and `has_discrete_amd` stay + /// at their probe values (empty, `false`, `false`) on WSL either way, so + /// `has_amd_gpu: true` beside both `false` is the normal WSL shape: the + /// Windows side reports a gfx target, not a PCI listing to tell an APU + /// from a discrete part. Other readers do not depend on them on WSL: the + /// failure catalog scopes the checks that read them to `linux` and + /// `windows`, and the WSL checks and the model-fit probe-result check use + /// `wsl.rocm_sees_gpu`. pub has_amd_gpu: bool, pub has_nvidia_gpu: bool, pub has_apu: bool, @@ -559,6 +574,26 @@ impl Examination { e } + /// Set `has_amd_gpu` on a WSL host from whether the Windows side detected a + /// GPU target, the value the human report's "AMD GPU detected" line reads. + /// It sets that one field only: `has_apu` and `has_discrete_amd` stay at + /// their probe values, because a target string does not say which kind of + /// part it is. + /// + /// WSL reaches the GPU through the Windows host driver, so the DRM/KFD probes + /// that fill `has_amd_gpu` are skipped and the field would read `false` on a + /// healthy machine. The caller already holds the detection (it is the + /// `summary` of `rocm examine --json`), so this takes it rather than probing + /// again: the Windows query is a PowerShell call with its own timeout. Does + /// nothing off WSL, where the probes own the field, and leaves `gpus` empty + /// (there is no PCI listing to build entries from) and `status` alone + /// (`compute_status` answers `wsl` before it asks about a GPU). + pub const fn adopt_wsl_host_gpu(&mut self, host_has_amd_gpu: bool) { + if self.is_wsl { + self.has_amd_gpu = host_has_amd_gpu; + } + } + /// Coarse machine-readable verdict reported via the `status` field. The /// process exit code does NOT encode this — `rocm examine` always exits 0 /// when it ran; callers branch on `status` instead. @@ -792,6 +827,56 @@ mod tests { assert_eq!(e.compute_status(), "wsl"); } + /// `rocm examine --json` and the human report must answer "is there an AMD + /// GPU" from one value on WSL. The probe leaves `has_amd_gpu` false there + /// (its hardware probes are skipped), and the human report reads the + /// Windows-side gfx target, so the field follows that target. + #[test] + fn wsl_has_amd_gpu_follows_the_windows_side_gfx_target() { + let mut e = Examination { + os_family: "linux".to_owned(), + is_wsl: true, + ..Examination::default() + }; + assert!(!e.has_amd_gpu, "the probe itself reports no GPU on WSL"); + + e.adopt_wsl_host_gpu(true); + assert!(e.has_amd_gpu, "a detected gfx target means a GPU is there"); + assert!( + e.gpus.is_empty(), + "there is no PCI listing on WSL to build gpu entries from" + ); + assert!( + !e.has_apu && !e.has_discrete_amd, + "a target string does not say which kind of part it is" + ); + assert_eq!( + e.compute_status(), + "wsl", + "status answers wsl before it asks about a GPU" + ); + + e.adopt_wsl_host_gpu(false); + assert!(!e.has_amd_gpu, "no detected target, no GPU: it can go back"); + } + + /// Off WSL the hardware probes own `has_amd_gpu`; a gfx target from the + /// summary must neither set nor clear it. + #[test] + fn adopting_a_host_gpu_does_nothing_off_wsl() { + let mut bare_metal = Examination { + os_family: "linux".to_owned(), + has_amd_gpu: false, + ..Examination::default() + }; + bare_metal.adopt_wsl_host_gpu(true); + assert!(!bare_metal.has_amd_gpu); + + bare_metal.has_amd_gpu = true; + bare_metal.adopt_wsl_host_gpu(false); + assert!(bare_metal.has_amd_gpu); + } + /// The probes themselves, not just `host_path`, answer from a simulated /// host root. Plants a bare-metal machine with one GPU, inside a Podman /// container, then runs the converted probes and asserts they describe it diff --git a/docs/wsl.md b/docs/wsl.md index e1194a247c..b6a86453c1 100644 --- a/docs/wsl.md +++ b/docs/wsl.md @@ -303,9 +303,15 @@ below. - whether `HSA_ENABLE_DXG_DETECTION` is set (`--json` only) - managed TheRock runtime count and active default runtime -The driver, device-node, and group probes stay skipped. In the `--json` output, -`has_amd_gpu` is therefore always false and `gpus` is empty on WSL, even on a -healthy host, because both describe the bare-metal view. +The driver, device-node, and group probes stay skipped, and `gpus` is empty on +WSL, even on a healthy host, because it describes the bare-metal view. In the +`--json` output, `has_amd_gpu` follows the GPU target the Windows side reports, +the same value behind the text report's "AMD GPU detected" line, so the two +forms agree. It says an AMD display adapter exists, not that ROCm can enumerate +it from inside the distro: `rocm_sees_gpu` under `wsl` answers that. `has_apu` +and `has_discrete_amd` stay `false`: the Windows side reports a gfx target, not +a listing that says whether the part is an APU or a discrete card, so +`has_amd_gpu: true` beside both `false` is the expected WSL shape. ## Install UX Recommendations diff --git a/tests/e2e-cucumber/expectations.toml b/tests/e2e-cucumber/expectations.toml index 4f26ef6b59..fec5e0154f 100644 --- a/tests/e2e-cucumber/expectations.toml +++ b/tests/e2e-cucumber/expectations.toml @@ -164,19 +164,3 @@ bug = "EAI-7423" reason = "Lemonade managed serve reaches ready then shuts down immediately, so the benchmark never reaches a live model." serve_timeout_secs = 90 flaky = true - -# --- EAI-7998: `examine --json` disagrees with the human report about the GPU. -# On WSL2 the JSON contradicts ITSELF: `has_amd_gpu: false` and `gpus: []` -# alongside a summary carrying `detected_gfx_target: gfx1151`. The driver/GPU -# probes are routed out on WSL because they read KFD and DRM, neither of which -# exists there, while the summary reads the target from the Windows-side driver. -# -# Scoped to WSL hosts whose human report actually names a gfx target: without -# one both forms correctly report no GPU, so xfail would turn agreement into a -# stale XPASS. The ticket also records the same disagreement on MI300X, -# second-hand from the comment in capability.rs; if that is confirmed the row -# should widen rather than gain a sibling. Remove it when the two forms agree. --- -[["examine-both-forms-agree-on-gpu"]] -when = { is_wsl = true, therock_family = "gfx*" } -bug = "EAI-7998" -reason = "`examine --json` reports has_amd_gpu:false on a WSL2 host whose own summary names a gfx target." diff --git a/tests/e2e-cucumber/features/examine.feature b/tests/e2e-cucumber/features/examine.feature index d5f7218782..83d89d2306 100644 --- a/tests/e2e-cucumber/features/examine.feature +++ b/tests/e2e-cucumber/features/examine.feature @@ -77,7 +77,10 @@ Feature: GPU detection and system inspection # load-bearing: every host capability the suite resolves comes from scraped # text, so if the two forms ever diverge again, every capability-keyed # expectation silently resolves against the wrong host. Since fixed; this is - # the guard that keeps it fixed. + # the guard that keeps it fixed. On WSL2 the same disagreement came from the + # skipped hardware probes (the machine-readable form said no GPU beside a + # human report naming a gfx target); `has_amd_gpu` now follows that target + # there, so this runs on WSL2 hosts too and is no longer an expected failure. @id:examine-both-forms-agree-on-gpu Scenario: examine-08 - Both forms of the inspection agree about the GPU When the user inspects the system both for reading and for scripting diff --git a/tests/e2e-cucumber/src/expectation.rs b/tests/e2e-cucumber/src/expectation.rs index 073ac85baa..dec4d8f15c 100644 --- a/tests/e2e-cucumber/src/expectation.rs +++ b/tests/e2e-cucumber/src/expectation.rs @@ -2057,15 +2057,21 @@ flaky = true )); } + /// EAI-7998's row (`examine --json` reporting `has_amd_gpu: false` on a WSL2 + /// host whose own summary names a gfx target) is resolved by taking the + /// field from that same target on WSL, not by this test, which only guards + /// against a silent regression. A WSL host with a reported target and one + /// without both go through the scenario now, so re-adding the row has to be + /// a deliberate decision. #[test] - fn gpu_report_disagreement_xfail_requires_a_reported_gfx_target() { + fn gpu_report_agreement_has_no_xfail_on_wsl() { let m = Expectations::parse(include_str!("../expectations.toml")).unwrap(); - assert!(m.is_xfail( - "examine-both-forms-agree-on-gpu", - &cap("wsl-no-passthrough"), - "lemonade" - )); - assert!(!m.is_xfail("examine-both-forms-agree-on-gpu", &cap("wsl"), "lemonade")); + for host in ["wsl-no-passthrough", "wsl"] { + assert!( + !m.is_xfail("examine-both-forms-agree-on-gpu", &cap(host), "lemonade"), + "examine-08 must run, not xfail, on the {host} host" + ); + } } /// EAI-8031's row (Windows lane cold-downloading its HF checkpoint every