diff --git a/AGENTS.md b/AGENTS.md index 6b972da2dc..ede03f3d25 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -345,14 +345,13 @@ on two counts, and both change how you edit it: the modules it declares, such as [catalog.rs](crates/rocm-core/src/diagnose/catalog.rs) (each mode's checker and OS scoping) — adding, renaming, or re-scoping a failure mode means changing the CLI **first**, then the two docs. That feature is what - catches you if you forget. Two sentences in - [SKILL.md](skills/rocm-doctor/SKILL.md) are fixtures too. One is the Phase 0 - sentence "requires `contract_version` N or higher": scenario skill-07 parses - it and holds that number (the contract number) equal to what - `rocm fix --json` publishes. The other is the "The other N ... print-only" - sentence, whose number (the print-only count) is checked by - [skill_reference.rs](tests/e2e-cucumber/tests/skill_reference.rs) against the - catalog table. Keep both wordings when editing the skill. + catches you if you forget. Some sentences in + [SKILL.md](skills/rocm-doctor/SKILL.md) are fixtures too: the module doc of + [skill_reference.rs](tests/e2e-cucumber/tests/skill_reference.rs) lists them all + and says which test reads each. Reword them only together with the test that reads + them. One is the Phase 0 sentence "requires `contract_version` N or higher": scenario + skill-07 parses it and holds that number (the contract number) equal to what + `rocm fix --json` publishes. Raise the contract number only after a release publishes that contract. The skill is federated from `main`, and the installer that Phase 0 offers installs the release channel, so an earlier raise would make the published skill stop diff --git a/crates/rocm-core/src/diagnose/catalog.rs b/crates/rocm-core/src/diagnose/catalog.rs index 4635d4923b..0b5e1f0928 100644 --- a/crates/rocm-core/src/diagnose/catalog.rs +++ b/crates/rocm-core/src/diagnose/catalog.rs @@ -267,12 +267,15 @@ mod tests { /// Every diagnosis must agree with the fix catalog about whether the CLI /// can apply the fix itself. /// - /// An agent following the rocm-doctor skill branches on `auto_applicable` - /// from `diagnose --json` to decide whether to offer to run `rocm fix` or - /// merely print the plan, while `fix::apply` dispatches on `RECIPES`. The - /// two are written in different files and nothing but this test holds them - /// together, so a drift makes the CLI contradict itself: it would advertise - /// a fix as one it can run and then refuse, or the reverse. + /// An agent following the rocm-doctor skill reads `fix.class` from + /// `diagnose --json` (`auto_applicable` is derived from it) to decide whether + /// `rocm fix` carries the fix out or merely prints the plan, while + /// `fix::apply` dispatches on `RECIPES`. `take_applicability_from_the_catalog` + /// derives `fix.class` and `fix.auto_applicable` from the catalog's class, + /// which is what keeps them in step. This test asserts only the + /// `auto_applicable` half, against the catalog's `applies_itself()` (true for + /// `auto` alone), so a diagnosis that bypassed the derivation would advertise + /// a fix as one the CLI can run and then refuse, or the reverse, and fail here. /// /// Both OS families are exercised because the checkers build their `Fix` /// per-OS and only one branch is taken per run, so a Linux-only test would diff --git a/crates/rocm-core/src/fix.rs b/crates/rocm-core/src/fix.rs index daa59a991a..1d55ede665 100644 --- a/crates/rocm-core/src/fix.rs +++ b/crates/rocm-core/src/fix.rs @@ -41,13 +41,14 @@ use std::io::Write; pub(crate) use catalog::{COMGR_CONFLICT_NEITHER_OPTION_RECOMMENDED, is_catalog_id}; pub use catalog::{class_on, needs_on}; +pub use consent::{DRY_RUN_NOTICE, NON_INTERACTIVE_REFUSAL}; pub use manifest::{ CATALOG_CONTRACT_VERSION, CatalogManifest, ManifestEntry, ManifestPlatform, catalog_manifest, catalog_manifest_json, }; pub use options::{FixClass, FixOptions, exit}; pub(crate) use render::format_flags; -pub use render::list_recipes; +pub use render::{fix_plan_text, list_recipes}; // The catalog's test-only oracles, which the `diagnose` module holds its own copies of // a recipe to. #[cfg(test)] diff --git a/crates/rocm-core/src/fix/catalog.rs b/crates/rocm-core/src/fix/catalog.rs index 9d392f907b..af5a7da837 100644 --- a/crates/rocm-core/src/fix/catalog.rs +++ b/crates/rocm-core/src/fix/catalog.rs @@ -143,8 +143,13 @@ impl FixRecipe { /// it does not apply here at all — callers reach the OS gate in [`apply`] /// before the class is ever acted on, and understating is the safe default. pub(super) fn class_here(&self) -> FixClass { - self.platform(current_os()) - .map_or(FixClass::PrintOnly, |p| p.class) + self.class_on_os(current_os()) + } + + /// What this recipe does on the platform `os`, [`FixClass::PrintOnly`] when it + /// does not apply there (the same understatement as [`Self::class_here`]). + pub(super) fn class_on_os(&self, os: &str) -> FixClass { + self.platform(os).map_or(FixClass::PrintOnly, |p| p.class) } /// The operating systems this applies on, in catalog order. @@ -2378,7 +2383,8 @@ mod tests { // apply() returns 1 only when a platform's class is Auto and the recipe // has no runner (`Plan::MissingRunner`). `a_recipe_that_acts_has_a_runner` // keeps that impossible; assert the reachability argument here so - // reference.md's row 1 is accounted for rather than silently untested. + // the manifest's `internal` exit code is accounted for rather than + // silently untested. assert!( RECIPES.iter().all(|r| { !r.applies_on.iter().any(|p| p.class.applies_itself()) || r.runner.is_some() diff --git a/crates/rocm-core/src/fix/consent.rs b/crates/rocm-core/src/fix/consent.rs index 95b9d8931f..0577db05cb 100644 --- a/crates/rocm-core/src/fix/consent.rs +++ b/crates/rocm-core/src/fix/consent.rs @@ -17,6 +17,22 @@ use std::time::Duration; pub(super) const RUN_TIMEOUT: Duration = Duration::from_mins(1); pub(super) const QUERY_TIMEOUT: Duration = Duration::from_secs(8); +/// What `rocm fix` says on stderr when it is not given `--yes` in a shell with no +/// terminal, where nobody can be asked. +/// +/// `pub` only so the eval-fixture generator in `xtask` replays the same text the +/// command prints, from this one constant; hidden from the docs because it is not an +/// API to build on. +#[doc(hidden)] +pub const NON_INTERACTIVE_REFUSAL: &str = + "Non-interactive shell and --yes not passed; refusing to apply."; + +/// The line a runner prints after a plan when `--dry-run` stopped it before acting. +/// +/// `pub` only for the same reason as [`NON_INTERACTIVE_REFUSAL`]. +#[doc(hidden)] +pub const DRY_RUN_NOTICE: &str = "(dry-run; not executed)"; + /// Print a failure explanation to stderr, ignoring write failures (closed /// stderr, full disk) so an I/O error while explaining a failure can't itself /// panic the process. @@ -70,7 +86,7 @@ const fn consent_without_prompt(assume_yes: bool, stdin_is_terminal: bool) -> Op pub(super) fn confirm(prompt: &str, assume_yes: bool) -> bool { if let Some(verdict) = consent_without_prompt(assume_yes, std::io::stdin().is_terminal()) { if !verdict { - fail!("Non-interactive shell and --yes not passed; refusing to apply."); + fail!("{NON_INTERACTIVE_REFUSAL}"); } return verdict; } diff --git a/crates/rocm-core/src/fix/render.rs b/crates/rocm-core/src/fix/render.rs index 5770399b57..e5ccf33f62 100644 --- a/crates/rocm-core/src/fix/render.rs +++ b/crates/rocm-core/src/fix/render.rs @@ -7,7 +7,7 @@ //! shares, and the refusal printed when a diagnosis position (`#2`) is passed //! as a fix-id. -use super::catalog::{FixRecipe, RECIPES}; +use super::catalog::{FixRecipe, RECIPES, find_recipe}; use super::consent::current_os; use super::options::FixClass; @@ -107,29 +107,53 @@ pub(crate) fn format_flags( } pub(super) fn print_recipe(r: &FixRecipe) { - println!("Fix: {} -- {}", r.fix_id, r.title); - println!("OS scope: {}", r.os_scope().join(", ")); - println!("Rationale: {}", r.rationale); + for line in recipe_plan_lines(r, current_os()) { + println!("{line}"); + } +} + +/// Every line of the plan `rocm fix ` prints for `r` on the platform `os`, in +/// print order. What `os` changes is the class and the argument a plan names, which +/// are per platform; [`print_recipe`] passes the running one. +fn recipe_plan_lines(r: &FixRecipe, os: &str) -> Vec { + let mut lines = vec![ + format!("Fix: {} -- {}", r.fix_id, r.title), + format!("OS scope: {}", r.os_scope().join(", ")), + format!("Rationale: {}", r.rationale), + ]; if !r.commands.is_empty() { - println!("Commands:"); - for c in r.commands { - println!(" $ {c}"); - } + lines.push("Commands:".to_owned()); + lines.extend(r.commands.iter().map(|c| format!(" $ {c}"))); } + let platform = r.platform(os); let flags = format_flags( r.needs_sudo, r.needs_reboot, r.needs_relogin, - r.class_here(), - r.platform(current_os()).and_then(|p| p.needs), + r.class_on_os(os), + platform.and_then(|p| p.needs), ); - println!("Flags: {}", flags.join(", ")); - for n in r.notes { - println!("Note: {n}"); - } - for line in verify_lines(r) { - println!("{line}"); - } + lines.push(format!("Flags: {}", flags.join(", "))); + lines.extend(r.notes.iter().map(|n| format!("Note: {n}"))); + lines.extend(verify_lines(r)); + lines +} + +/// The plan `rocm fix ` prints on `os` (`linux`, `windows` or `wsl`), or +/// `None` when there is no such fix. +/// +/// It is the lines the command prints before it acts, and not the ones a runner adds +/// after (such as the command it is about to run), which name the user and the +/// machine. +/// +/// `pub` only so the eval-fixture generator in `xtask` replays the plan without a +/// second copy of its wording; hidden from the docs because it is not an API to +/// build on. +#[doc(hidden)] +#[must_use] +pub fn fix_plan_text(fix_id: &str, os: &str) -> Option { + let recipe = find_recipe(fix_id)?; + Some(recipe_plan_lines(recipe, os).join("\n") + "\n") } /// The `Verify` lines of the plan `print_recipe` prints, in print order: the @@ -424,6 +448,30 @@ mod tests { ); } + /// The plan a replaying tool prints is the one `rocm fix ` prints: the + /// class on the asked platform picks the flag, and an unknown id has no plan. + #[test] + fn fix_plan_text_is_the_plan_the_command_prints_for_the_platform() { + let linux = fix_plan_text("fix-4-render-group", "linux").expect("a plan"); + assert!(linux.contains("\nOS scope: linux\n"), "{linux}"); + assert!( + linux.contains("\nFlags: requires sudo, requires re-login, rocm fix can run it\n"), + "{linux}" + ); + assert!(linux.ends_with('\n')); + // fix-4 does not apply on Windows, where the class falls back to print-only. + let windows = fix_plan_text("fix-4-render-group", "windows").expect("a plan"); + assert!(windows.contains("manual only"), "{windows}"); + assert_eq!(fix_plan_text("fix-0-nope", "linux"), None); + // The argument a plan waits for is per platform, and the flags line says it. + let needs_argument = fix_plan_text("fix-9-igpu-dgpu", "linux").expect("a plan"); + assert!( + needs_argument + .contains("\nFlags: needs --device-index before `rocm fix` will run it\n"), + "{needs_argument}" + ); + } + #[test] fn indent_continuation_keeps_multi_line_verify_under_its_label() { assert_eq!(indent_continuation("a\nb\nc", " "), "a\n b\n c"); diff --git a/crates/rocm-core/src/fix/runners.rs b/crates/rocm-core/src/fix/runners.rs index 896091cc01..c73fc5f7c7 100644 --- a/crates/rocm-core/src/fix/runners.rs +++ b/crates/rocm-core/src/fix/runners.rs @@ -11,7 +11,7 @@ //! the catalog in `fix/catalog.rs` names the entry point of each recipe's //! runner and the running OS decides which variant runs. -use super::consent::{QUERY_TIMEOUT, RUN_TIMEOUT, confirm, fail, relay_output}; +use super::consent::{DRY_RUN_NOTICE, QUERY_TIMEOUT, RUN_TIMEOUT, confirm, fail, relay_output}; use super::options::{FixOptions, exit}; use crate::probe_exec::{run, which}; use crate::quoting::ps_single_quote_escape; @@ -106,7 +106,7 @@ pub(super) fn run_render_group(opts: &FixOptions) -> i32 { }; println!("Will run: {program} {}", args.join(" ")); if opts.dry_run { - println!("(dry-run; not executed)"); + println!("{DRY_RUN_NOTICE}"); return exit::OK; } if !confirm("Add user to render,video groups?", opts.yes) { @@ -162,9 +162,10 @@ fn run_unset_override_linux() -> i32 { /// /// Takes the paths rather than deriving them from `$HOME`, for the same reason /// [`pin_device_in_rc_file`] takes its rc path: it makes the promise testable -/// without mutating a process-global. And the promise needs testing — fix-2 is -/// flagged `auto_applicable`, so `skills/rocm-doctor/` has to say plainly that -/// this arm still only reports, and something has to hold that true. +/// without mutating a process-global. And the promise needs testing — fix-2 has +/// a runner on every platform and is class `auto` on Windows, so +/// `skills/rocm-doctor/` has to say plainly that this arm still only reports, and +/// something has to hold that true. fn report_persistent_override(candidates: &[PathBuf]) -> i32 { let hits: Vec<&PathBuf> = candidates .iter() @@ -219,8 +220,8 @@ fn run_unset_override_windows(opts: &FixOptions) -> i32 { /// the decline path testable without a real Windows host -- same reason /// [`pin_device_in_rc_file`] takes its consent as a closure. /// -/// A decline must still exit `5`: `skills/rocm-doctor/reference.md` documents -/// `5` as "user declined", and a caller (human or agent) relies on that to +/// A decline must still exit `5`: the manifest's `exit_codes` publishes `5` as +/// `declined` (`exit::DECLINED`), and a caller (human or agent) relies on that to /// tell "nothing happened because you said no" apart from "nothing happened /// because there was nothing to do". Declining just the User scope can't /// short-circuit straight to `return exit::DECLINED`, though -- if the Machine scope is @@ -260,7 +261,7 @@ fn report_and_clear_override_windows( shown.join(" ") ); if opts.dry_run { - println!(" (dry-run; not executed)"); + println!(" {DRY_RUN_NOTICE}"); } else if consent("Clear HSA_OVERRIDE_GFX_VERSION from User scope?") { let (rc, out, err) = run("setx", &setx_args, RUN_TIMEOUT); relay_output(&out, &err); @@ -332,7 +333,7 @@ fn run_path_export_linux(opts: &FixOptions) -> i32 { println!("Plan: append the following line to {}:", rc_file.display()); println!(" {export_line}"); if opts.dry_run { - println!("(dry-run; not executed)"); + println!("{DRY_RUN_NOTICE}"); return exit::OK; } if !confirm(&format!("Append to {}?", rc_file.display()), opts.yes) { @@ -431,7 +432,7 @@ fn path_export_windows( println!("Plan: prepend {bin_dir} to your User PATH:"); println!(" [Environment]::SetEnvironmentVariable('PATH', '{escaped_new_path}', 'User')"); if opts.dry_run { - println!("(dry-run; not executed)"); + println!("{DRY_RUN_NOTICE}"); return exit::OK; } if !confirm("Update User PATH?", opts.yes) { @@ -493,12 +494,12 @@ fn run_hip_visible_devices_linux(opts: &FixOptions) -> i32 { /// the rc file already pins a device, honour `--dry-run`, ask for consent, and /// append. /// -/// Taking the rc path and the consent decision as parameters keeps this — the -/// one auto-fix path on Linux that really mutates a file — testable end to end +/// Taking the rc path and the consent decision as parameters keeps this — +/// unlike the fix-6 PATH runner, which derives both itself — testable end to end /// against a temp file, with no `$HOME` mutation and no dependency on whether -/// stdin happens to be a terminal. Exit codes are the contract documented in -/// `skills/rocm-doctor/reference.md`: 0 applied/dry-run/already-set, 4 write -/// failed, 5 declined. +/// stdin happens to be a terminal. Exit codes are the `exit` constants in +/// `options.rs`, published as the manifest's `exit_codes`: 0 applied/dry-run/ +/// already-set, 4 write failed, 5 declined. fn pin_device_in_rc_file( rc_file: &Path, idx: i64, @@ -518,7 +519,7 @@ fn pin_device_in_rc_file( println!("Plan: append the following line to {}:", rc_file.display()); println!(" {export_line}"); if opts.dry_run { - println!("(dry-run; not executed)"); + println!("{DRY_RUN_NOTICE}"); return exit::OK; } if !consent() { @@ -566,7 +567,7 @@ fn run_hip_visible_devices_windows(opts: &FixOptions) -> i32 { println!("Plan: persist HIP_VISIBLE_DEVICES in the User env scope:"); println!(" setx HIP_VISIBLE_DEVICES {idx}"); if opts.dry_run { - println!("(dry-run; not executed)"); + println!("{DRY_RUN_NOTICE}"); return exit::OK; } if !confirm("Set HIP_VISIBLE_DEVICES in the User scope?", opts.yes) { @@ -816,18 +817,20 @@ mod tests { // ── Consent and mutation contract ────────────────────────────── // - // `skills/rocm-doctor/reference.md` documents six exit codes, and the skill - // tells an agent it may run an auto-fix because the CLI "refuses on a - // non-interactive shell without --yes" and "confirms before mutating". + // The manifest's `exit_codes` (the `exit` constants in `options.rs`) names six + // codes, and `skills/rocm-doctor/SKILL.md` tells an agent to go through + // `--dry-run`, the user's OK and `--yes` because the CLI refuses on a + // non-interactive shell without `--yes` and confirms before mutating. // Before these tests, codes 1, 4 and 5 were asserted nowhere in the repo and // no test ever reached a runner that writes to disk: the two that look like // they cover it don't — `dry_run_never_mutates_...` picks fix-2, whose Linux // runner takes no FixOptions and never prompts, and diagnose.feature's // preview scenario picks print-only fix-1, which returns before any runner. // - // fix-9 is the auto-fix used here because its Linux runner is the one that - // genuinely appends to a file, and `pin_device_in_rc_file` lets that run - // against a temp path with an injected consent verdict. + // fix-9 (class `needs-argument`, applied once `--device-index` is given) is + // used here because its rc path and consent decision are injectable + // (`pin_device_in_rc_file`), so its append can run against a temp path with an + // injected consent verdict. /// A unique scratch path under the workspace's test-artifact dir, following /// the convention in `lib.rs`'s tests (no `tempfile` dev-dependency here). @@ -854,10 +857,11 @@ mod tests { } } - /// `auto_applicable` means "the CLI has a runner", not "the runner mutates". + /// Having a runner is not the same as the `auto` class, and neither means + /// "the runner mutates". /// /// fix-2's Linux arm only reports where the override is persisted; it never - /// edits dotfiles. `auto_applicable_recipes_have_a_runner` cannot catch a + /// edits dotfiles. `a_recipe_that_acts_has_a_runner` cannot catch a /// regression here, because fix-2 does have a runner — so without this, a /// doc promising a `--dry-run` preview the Linux user never gets stays /// green. That is the drift `skills/rocm-doctor/` exists to prevent. @@ -892,9 +896,8 @@ mod tests { /// The Windows arm of fix-2 does mutate (it runs `setx` to clear the User /// scope), so unlike the Linux arm above, a decline has to come back as - /// `5`, not `0` -- `skills/rocm-doctor/reference.md` documents `5` as - /// "user declined" and an agent tells that apart from "nothing to do" - /// this way. + /// `5`, not `0` -- the manifest's `exit_codes` publishes `5` as `declined` + /// and an agent tells that apart from "nothing to do" this way. #[test] fn windows_decline_on_user_scope_returns_5() { let code = diff --git a/crates/rocm-core/src/lib.rs b/crates/rocm-core/src/lib.rs index 36950d0c36..cc06258227 100644 --- a/crates/rocm-core/src/lib.rs +++ b/crates/rocm-core/src/lib.rs @@ -128,9 +128,9 @@ pub use examine::{ Examination, FrameworkProbe, WSL_PLATFORM_NOTE, gfx_is_apu_family, probe_wsl_distro_from_host, }; pub use fix::{ - CATALOG_CONTRACT_VERSION, CatalogManifest, FixOptions, ManifestEntry, ManifestPlatform, - apply as apply_fix, catalog_manifest, catalog_manifest_json, exit as fix_exit, - list_recipes as list_fix_recipes, + CATALOG_CONTRACT_VERSION, CatalogManifest, DRY_RUN_NOTICE, FixOptions, ManifestEntry, + ManifestPlatform, NON_INTERACTIVE_REFUSAL, apply as apply_fix, catalog_manifest, + catalog_manifest_json, exit as fix_exit, fix_plan_text, list_recipes as list_fix_recipes, }; pub use gfx_target::{ extract_first_gfx_token, gfx_target_has_no_rocm_build, known_therock_families, diff --git a/docs/architecture.md b/docs/architecture.md index 10d708e93e..f15a2e2116 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -826,7 +826,7 @@ Gherkin `.feature` files under `features/` backed by Rust step functions that dr | [`tests/driver_host_guard.rs`](../tests/e2e-cucumber/tests/driver_host_guard.rs) | Ordinary test that the Windows driver-install steps run the host guard before calling the CLI, checked against the step source. | flat | | [`tests/e2e.rs`](../tests/e2e-cucumber/tests/e2e.rs) | The cucumber test binary: the `E2eWorld` state and its cleanup on drop, the `run_rocm` helpers, the runner `main`, and reconciliation of results with expectations. | flat | | [`tests/feature_naming.rs`](../tests/e2e-cucumber/tests/feature_naming.rs) | Drift guard, in the ordinary `cargo test` set, for the `-` scenario names and ids in the `.feature` files. | flat | -| [`tests/skill_reference.rs`](../tests/e2e-cucumber/tests/skill_reference.rs) | Drift guard, in the ordinary `cargo test` set, that the catalog table in [`reference.md`](../skills/rocm-doctor/reference.md) uses the vocabulary `rocm fix` prints. | flat | +| [`tests/skill_reference.rs`](../tests/e2e-cucumber/tests/skill_reference.rs) | Drift guard, in the ordinary `cargo test` set, for what the rocm-doctor skill quotes from the CLI: that the catalog table in [`reference.md`](../skills/rocm-doctor/reference.md) uses the vocabulary `rocm fix` prints, that the print-only count `SKILL.md` states matches the table, and that the exit-code and `fix` field names it lists exist in what the CLI publishes. Its module doc lists the fixture sentences. | flat | #### `tests/e2e/` diff --git a/docs/skill-quality.md b/docs/skill-quality.md index 1b065d7645..cb3bb2a31c 100644 --- a/docs/skill-quality.md +++ b/docs/skill-quality.md @@ -147,15 +147,17 @@ review and may decline: Compare absolute counts, and do not read a one-case move as a real change. - **These are our prompts, not the field.** Nothing here measures failures users actually hit. -- **The grading host has no AMD GPU and no `rocm` CLI.** Most behavioral cases therefore - grade the skill's procedure (probing first, asking for consent before anything that +- **The grading host has no AMD GPU and no `rocm` CLI.** A behavioral case therefore + grades the skill's procedure (probing first, asking for consent before anything that mutates, routing upstream when nothing is established), not whether a diagnosis was - correct. The exception is a case with a directory under - [`evals/fixtures/`](../skills/rocm-doctor/evals/fixtures/): it gets a replayed `rocm` + correct, unless it has a directory under + [`evals/fixtures/`](../skills/rocm-doctor/evals/fixtures/): such a case gets a replayed `rocm` that answers `--version`, `fix --json` and `diagnose` (and `examine --json` for a case - that names a host) from a recording, so it can grade the version check, how an answer - is read, or the question the skill asks when the examination finds no AMD GPU. The - recording is of a host with no GPU data, so even there a rise does not mean users get - fixed faster. See [Doctor Skill Eval Replays](testing.md#doctor-skill-eval-replays). + that names a host, and `fix ` with `--dry-run` or no flag for a case that names a + fix to apply) from a recording, so it can grade the version check, how an answer is + read, the question the skill asks when the examination finds no AMD GPU, or that + nothing is applied before the user said OK. The recordings describe a typed host, not a + real machine, so even there a rise does not mean users get fixed faster. See + [Doctor Skill Eval Replays](testing.md#doctor-skill-eval-replays). - **Editing the dataset moves the figures.** A changed content hash between two runs means the scenario set may have changed; look at that diff before comparing them. diff --git a/docs/testing.md b/docs/testing.md index 3cfa36210e..60836cd919 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -4804,8 +4804,9 @@ has a directory under [`evals/fixtures/`](../skills/rocm-doctor/evals/fixtures/) hook writes a stub `rocm` into a temporary directory, puts it first on `PATH`, and removes it afterwards. The stub replays recorded output for `rocm --version`, `rocm fix --json` and `rocm diagnose`, plus `rocm examine --json` for a case that -names a `host` (below), and refuses every other command with exit code 2. It only -prints text read from the recording, so whatever an agent asks it, +names a `host` and `rocm fix ` with `--dry-run` or no flag for a case that names +an `apply` fix (both below), and refuses every other command with exit code 2, `--yes` +included. It only prints text read from the recording, so whatever an agent asks it, it cannot change a machine or send anything; that comes from answering a fixed set of commands, not from the refusals. It also refuses `diagnose` options the recording does not cover (`--report`, `--send`, `--distro`, `--model`), for fidelity @@ -4831,31 +4832,51 @@ cargo xtask eval-fixtures --check # fail if any recording is missing, stale, or The manifest comes from the compiled catalog and each diagnosis from `rocm_core::run_diagnose`, run over the recorded examination in [`tests/remote-ssh/examination.json`](../tests/remote-ssh/examination.json), so a -catalog change cannot leave a stale recording behind. After a change to the failure -catalog or to what `rocm diagnose` prints, run `cargo xtask eval-fixtures` and commit -the result; the check names what is out of date. CI runs the check, and +catalog change cannot leave a stale generated recording behind. After a change to the +failure catalog or to what `rocm diagnose` prints, run `cargo xtask eval-fixtures` and +commit the result; the check names what is out of date. CI runs the check, and `cargo test -p xtask` runs it too. Read the diff after regenerating: a recording that changed is output the skill is now graded against. What an older CLI printed cannot be generated. It was recorded once from a real older build and lives in [`evals/fixtures/recorded/`](../skills/rocm-doctor/evals/fixtures/recorded/). -A case may also name a `host`: `no-amd-gpu`, `wsl-host-gpu-hidden`, `amd-found` or -`examine-fails`. The stub then answers `rocm examine --json`, and a case without a -`host` still refuses it. The reply is the recorded examination with the fields the host -implies set, whatever the recording held for them, and its `status` is recomputed by +A case may also name a `host`: `no-amd-gpu`, `wsl-host-gpu-hidden`, `amd-found`, +`examine-fails` or `container-small-shm` (an AMD GPU found, inside a Docker container +with the default 64 MiB `/dev/shm`, which makes the shared-memory entry score from the +host alone). The stub then answers `rocm examine --json`, and a case without a +`host` still refuses it. The diagnosis a host gives is replayed too, so it is what the +case's judged items rest on. The reply is the recorded examination with the fields the +host implies set, whatever the recording held for them, and its `status` is recomputed by `Examination::compute_status`, the rule the probe uses, so a recording cannot say a status the other fields contradict. The real command prints those fields plus a `summary` object that only the `rocm` binary can build, so the replay leaves `summary` out; the skill reads `status` and `has_amd_gpu` and nothing in it. Some fields are -typed, not probed: the one GPU of `amd-found`, and the WSL facts of +typed, not probed: the one GPU of `amd-found` and `container-small-shm`, the container +and `/dev/shm` figures of the latter, and the WSL facts of `wsl-host-gpu-hidden` (a distro that sees the Windows host's GPU through `/dev/dxg`, with no ROCm-side library). `examine-fails` is not recorded from a real failure: it exits 1 with a fixed message on stderr, which is what the case pins. +A case may also name an `apply` fix id, for a case that reaches the apply step. The +stub then answers `rocm fix --dry-run` (the flag before or after the id) and +`rocm fix ` with no flag, and never `--yes`, so an agent that applies before the +user said OK meets the stub's refusal and the transcript shows the command. The fix +must be `auto` on the host's platform (`wsl` for the `wsl-host-gpu-hidden` host, else +`linux`), and the case's symptom and host must make the replayed +diagnosis match it, that is list it at or above `min_score_for_match`; otherwise the +generator fails with "the replayed diagnosis carries no match for ...". The plan is the CLI's own (`rocm_core::fix_plan_text`), so it +carries the command's wording; only the `Will run:` line the runner adds is not there, +because it names the user and the machine. The layout around the plan (the blank line, +then the notice) is written by hand in the generator and checked only against the +committed replay. The bare command's refusal exit code +and message, and the dry-run notice, are the CLI's own constants, so they cannot drift +from the command's. + To add a case, add an entry to [`evals/fixtures/cases.json`](../skills/rocm-doctor/evals/fixtures/cases.json) (the case id, `current` or `older`, the error text the agent would pass as the symptom, -and optionally a `host`), run the command above, and add the case to +and optionally a `host` and an `apply` fix id, which must be `auto` on the host's platform and matched +by the replayed diagnosis), run the command above, and add the case to [`evals/evals.json`](../skills/rocm-doctor/evals/evals.json) with the same id. The check also fails when a case id is not an id in `evals.json`, or when the part of the symptom before its first `:` does not appear in that case's prompt, because the hook @@ -4863,13 +4884,13 @@ finds a replay by id and a recording for a different question grades nothing. A directory that no case owns fails the check, and the command never deletes one: remove it by hand. -Limits worth knowing. A replay says what the catalog says for a recorded host -with no GPU data, so it grades how the agent reads and relays an answer, not whether +Limits worth knowing. A replay says what the catalog says for a typed host (the +recorded examination, which has no GPU, with the fields a `host` implies changed), not +for a real machine, so it grades how the agent reads and relays an answer, not whether the CLI is right about a real machine; and it answers `diagnose` with the same recorded output whatever `--symptom` is. The current-CLI replay's `--version` line -is not the format the real `rocm --version` prints (the older-CLI replay prints that -one), so only `fix --json` tells -the two replays apart. The marker in it is what the current-CLI case's `logs_contain` +is a fixed marker that no real build prints (the older-CLI replay prints what an +older build printed), so only `fix --json` tells the two replays apart. The marker in it is what the current-CLI case's `logs_contain` pin matches, and `cargo test -p xtask` fails if a pin is quoted in `SKILL.md` or `reference.md`, where it would stop proving the replay ran. @@ -4879,11 +4900,13 @@ On Windows the launcher is a `rocm.cmd` (cmd and PowerShell) plus an extensionle include `skills/**`, so `test_hooks.py` runs the shim there. That covers a temp directory and Python path without spaces; a path with spaces or parentheses is not exercised, and neither is the agent's own shell on the amd/skills Windows leg. -The two cases about the older and the current CLI name no operating system in their -prompts. They used to say "on Linux", and on a Windows host the agent answered that its -own machine is Windows and declined to run the CLI at all, so the recorded replies never -printed. The vLLM cases still say Linux on purpose: their catalog entries apply on Linux -and WSL2 only, so they are not expected to pass on a Windows host. +A replayed case whose answer does not depend on the platform names no operating system +in its prompt. The older- and current-CLI prompts used to say "on Linux", and on a +Windows host the agent answered that its own machine is Windows and declined to run the +CLI at all, so the recorded replies never printed. A case that cannot pass on a Windows +host, because its catalog entries apply on Linux and WSL2 only or because the command +it expects depends on the shell, says so in its `note` in +[`evals.json`](../skills/rocm-doctor/evals/evals.json). A real `rocm` on the machine can answer before the stub. The agent's shell does not always keep the stub first on `PATH`, so a machine that has a `rocm` installed (a diff --git a/skills/rocm-doctor/SKILL.md b/skills/rocm-doctor/SKILL.md index c3377ee89b..cdc1bf0520 100644 --- a/skills/rocm-doctor/SKILL.md +++ b/skills/rocm-doctor/SKILL.md @@ -1,19 +1,19 @@ --- name: rocm-doctor description: >- - Diagnoses why ROCm, the HIP SDK, PyTorch, or llama.cpp is broken on an AMD GPU - on Linux, Windows, or WSL2, then applies a low-risk fix with consent or hands - back the exact next step. Also routes Lemonade, LM Studio, and Ollama problems to the - right upstream channel. Use when the user reports that ROCm or HIP "isn't - working", torch.cuda.is_available() is False, rocminfo / hipInfo can't see the - GPU, a vLLM startup out-of-memory error, a libtorch_cuda.so OSError/ImportError - at vLLM start, or hits hipErrorNoBinaryForGpu, HSA_STATUS_ERROR_INVALID_ISA, "invalid - device function", "no kernel image is available", cannot open /dev/kfd, - permission denied on /dev/kfd, "ROCk module is NOT loaded", a missing - libamdhip64.so / amdhip64_6.dll / hipblas.dll / vcruntime140_1.dll, an - HSA_OVERRIDE_GFX_VERSION page fault, an iGPU+dGPU crash, a container that can't - see the GPU, or a repo-native package-manager install (formerly `amdgpu-install`) / DKMS - failure. Backed by the `rocm` CLI (`rocm examine` / `diagnose` / `fix`). + Diagnoses why ROCm, the HIP SDK, PyTorch, or llama.cpp is broken on an AMD GPU on + Linux, Windows, or WSL2, then applies a low-risk fix with consent or hands back + the exact next step. Also routes Lemonade, LM Studio, and Ollama problems + upstream. Use when ROCm or HIP "isn't working", + torch.cuda.is_available() is False, rocminfo / hipInfo can't see the GPU, + hipErrorNoBinaryForGpu, HSA_STATUS_ERROR_INVALID_ISA, "invalid device function", + "no kernel image is available", cannot open or permission denied on /dev/kfd, + "ROCk module is NOT loaded", a missing libamdhip64.so / amdhip64_6.dll / + hipblas.dll / vcruntime140_1.dll, an HSA_OVERRIDE_GFX_VERSION page fault, an + iGPU+dGPU crash, a container that can't see the GPU, a vLLM startup out-of-memory + error or libtorch_cuda.so OSError/ImportError, or a failed package-manager / + amdgpu-install / DKMS install. Do NOT activate for NVIDIA, Intel, or Apple GPUs, + or for a first-time ROCm setup on a clean machine. --- # ROCm Doctor @@ -22,10 +22,10 @@ Given a "ROCm / PyTorch / llama.cpp isn't working on my AMD GPU" complaint, identify which **known misconfiguration** is the cause and either fix it (with consent) or hand back the exact next step. -This skill does **not** probe or reason on its own. The `rocm` CLI owns the -probe, the closed failure-mode catalog, and the fixes; the skill just drives it -and relays the results. The catalog is a **closed list** — if the symptom -doesn't match a known mode, route the user upstream instead of guessing. +The `rocm` CLI owns the probe, the closed failure-mode catalog, the scoring and +the fixes. This skill drives the CLI, reads what it returns, and decides only what +that result supports (step 2). The catalog is a **closed list**: a symptom that +matches no known mode goes upstream, never guessed at. ## Scope gate — check before anything else @@ -35,34 +35,35 @@ If it is **not** — an **NVIDIA / Intel / Apple** GPU — then **stop and decli - Say plainly that it is **out of scope** for this skill and why (not an AMD GPU). - Give **no** troubleshooting for it: no commands to run, no driver or CUDA - advice, no diagnostic checklist, no "try this first" — not even generic GPU - suggestions. Point at the vendor's own docs and stop there. + advice, no diagnostic checklist, no "try this first". Point at the vendor's own + documentation and stop there; do not invent a URL. - Do **not** run `rocm examine` / `rocm diagnose` / `rocm fix`. -Being helpful here means being honest about the boundary — confidently-wrong -advice for a stack this skill does not cover is worse than no advice. +Confidently wrong advice for a stack this skill does not cover is worse than no +advice. -A fresh install on a clean machine is out of scope too: that is a setup task, -not a diagnosis. Exit cleanly and say so. +A failed or half-finished install is in scope; a request to set ROCm up for the +first time on a clean machine is not, because that is a setup task and not a +diagnosis. For that request, say so and point at AMD's ROCm installation +documentation (for WSL2, AMD's guide at +https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/install/installryz/wsl/howto_wsl.html); +do not invent other URLs. If the user names no GPU vendor, treat ROCm / HIP wording as AMD and continue to -step 1, which checks what the machine has. Continue when the GPU is AMD or no -vendor is named. If the user then says it is NVIDIA, Intel or Apple, decline as -above. +the Workflow, whose step 1 checks what the machine has. If the user then says it is +NVIDIA, Intel or Apple, decline as above. **WSL2 is in scope** and does not stop this gate. It is a platform family of its -own, with its own catalog entries covering `/dev/dxg`, the DXCore handoff, -ROCDXG, the distro floor, the Windows host driver and WSL 1. Do not decline a -WSL2 user or route them away untouched — run the workflow as for any other -platform. The CLI scopes entries itself, so a bare-metal Linux fix is never -offered there. +own, with its own catalog entries, and the CLI scopes entries itself, so a +bare-metal Linux fix is never offered there. Do not decline a WSL2 user or route +them away untouched: run the workflow as for any other platform. ## Prerequisites -- **The `rocm` CLI.** This skill is only a driver over it; Phase 0 below installs - it with the user's consent if `rocm --version` fails, and stops if the installed - CLI is older than the catalog contract this skill requires. Nothing else here is - assumed — the CLI does the probing. +- **The `rocm` CLI.** This skill is only a driver over it. Phase 0 below installs + it with the user's consent when it is missing, and stops when the installed CLI + is older than the catalog contract this skill requires. Nothing else is + assumed: the CLI does the probing. - **Platform:** native Linux (in-tree `amdgpu` module + `/dev/kfd`), Windows (HIP SDK), or WSL2 (`/dev/dxg` + the Windows host driver). - **No fixed ROCm version, GPU arch (`gfx…`), or container image is assumed** — @@ -76,65 +77,78 @@ offered there. Only start here once the [Scope gate](#scope-gate--check-before-anything-else) passes — the GPU is AMD or no vendor was named. -0. **Ensure the `rocm` CLI is present.** Everything below shells out to it, so - check first and install it if missing: - - ``` - rocm --version - ``` - - If that succeeds, go to the contract check below. If it's not found, install - it **with the user's consent** (this fetches and runs an installer that drops - the `rocm` and `rocmd` binaries into `~/.local/bin`). Both installers default - to the `release` channel, so no channel argument is needed: - - - **Linux (x86_64 only):** - ``` - curl -fsSL https://raw.githubusercontent.com/ROCm/rocm-cli/main/install.sh | sh - ``` - - **Windows (PowerShell):** - ``` - irm https://raw.githubusercontent.com/ROCm/rocm-cli/main/install.ps1 | iex - ``` - - There is no macOS build. `install.sh` refuses anything but Linux x86_64, so - on any other host hand the user the install page and stop rather than - suggesting the command anyway. To pin an unreleased build instead, pass - `nightly` (`sh -s -- nightly`, or `$env:ROCM_CLI_CHANNEL = "nightly"`). - - After install, confirm `~/.local/bin` is on `PATH` and re-run `rocm --version`. - If it still isn't available, hand the user the install page - (https://github.com/ROCm/rocm-cli) and stop. - - **Then check the catalog contract.** Run: - - ``` - rocm fix --json - ``` - - It prints the catalog manifest as JSON and applies no fix. Read - `contract_version` from that JSON and ignore the rest. Stdout holds only the - JSON. Any `rocm:` notice goes to stderr. This skill requires - `contract_version` 1 or higher. - - An older CLI rejects `--json` as an unexpected argument and exits with code 2. - In [reference.md](reference.md), exit code 2 is a usage error such as an unknown fix id; here - it means the CLI is too old. If the command exits with code 2 and an - unexpected-argument error, or prints a lower `contract_version`, **stop**. Say - that the installed `rocm` CLI is older than this skill requires, so the CLI is - the side to update. Do **not** run `rocm examine`, `rocm diagnose`, or - `rocm fix `. Offer to update the CLI by re-running the installer above, - with the user's consent, then repeat this check. If the user declines, the - installer cannot run, or the check still fails afterwards (an older `rocm` - earlier on `PATH` can cause that), hand the user the install page - (https://github.com/ROCm/rocm-cli) and stop. - - Any other failure, such as a different exit code or output with no - `contract_version`, is an error from the CLI and not proof that it is old. - Relay the error text and stop, because reinstalling the same version would not - clear it. Against a CLI without this contract, the entry ids, which fixes have - a runner, and the exit codes this skill documents are guesses, and a guess - presented as a fact is the failure this check prevents. +### Phase 0 — ensure the `rocm` CLI is present and current + +Everything below shells out to the CLI, so check first: + +``` +rocm --version +``` + +If that succeeds, go to the contract check. If it is not found, install the CLI +**with the user's consent**. Before asking, say what the installer does: it runs a +script from the project's GitHub repository that installs `rocm` and `rocmd` in +`~/.local/bin` by default (Windows: `%USERPROFILE%\.local\bin`), edits the user's +PATH configuration, and writes its own config under the home directory. It prints +what it changed. To skip the PATH edit, set `ROCM_CLI_UPDATE_SHELL_PATH=0` for +the installer: on Linux and WSL2 put it before `sh` in the command below, on +Windows run `$env:ROCM_CLI_UPDATE_SHELL_PATH = "0"` before the PowerShell +command. + +- **Linux and WSL2 (x86_64 only):** + ``` + curl -fsSL https://raw.githubusercontent.com/ROCm/rocm-cli/main/install.sh | sh + ``` +- **Windows (PowerShell, x86_64 only):** + ``` + irm https://raw.githubusercontent.com/ROCm/rocm-cli/main/install.ps1 | iex + ``` + +There is no macOS build and no ARM build: both installers refuse other hosts, so +on such a host hand the user the install page (https://github.com/ROCm/rocm-cli) +and stop rather than suggesting the command anyway. Both installers default to the +`release` channel, so pass no channel argument. Use `nightly` (`sh -s -- nightly`, +or `$env:ROCM_CLI_CHANNEL = "nightly"`) only when the user asks for an unreleased +build; it is a moving tag, so it names whatever was published last, not a fixed +build. + +After any install or update, the shell you are in may not find the new `rocm` first +on the PATH, and an older one earlier on the PATH can still answer. Run the check by +the full path of the directory the installer says it installed to, and use that full +path wherever this skill writes `rocm`, in commands handed to the user too (in +PowerShell as `& ""`, which a path with a space needs), for the rest of +the session. If the full path fails as well, hand the user the install page +and stop. + +**Then check the catalog contract.** Run: + +``` +rocm fix --json +``` + +It prints the catalog manifest as JSON and applies no fix. Read `contract_version` +from that JSON, and `exit_codes`, which names the numbers `rocm fix` exits with; +ignore the rest. Stdout holds only the JSON; any `rocm:` notice goes to stderr. +This skill requires `contract_version` 1 or higher. + +- **An older CLI** rejects `--json` as an unexpected argument and exits with code 2 + (a usage error), or prints a lower `contract_version`. **Stop.** Say that the + installed `rocm` CLI is older than this skill requires, so the CLI is the side to + update. Do **not** run `rocm examine`, `rocm diagnose`, or `rocm fix `. + Offer to update the CLI by re-running the installer above, with the user's + consent, then repeat this check by the full path. If the user declines, the + installer cannot run, or the check still fails afterwards, hand the user the + install page and stop. +- **Any other failure**, such as a different exit code or output with no + `contract_version`, is an error from the CLI and not proof that it is old. Relay + the error text and stop, because reinstalling the same version would not clear + it. + +Against a CLI without this contract, the entry ids, fix classes and field names +this skill documents are guesses, and a guess presented as a fact is the failure +this check prevents. + +### Steps 1–4 — diagnose, decide, apply, verify 1. **Diagnose.** If the user named no GPU vendor, run `rocm examine --json` first. Status `no-amd-gpu` means the CLI found no AMD GPU. On WSL2 the status @@ -144,144 +158,223 @@ passes — the GPU is AMD or no vendor was named. container without GPU passthrough, or the very failure being diagnosed, can hide it. If the user confirms AMD or cannot say, continue with `rocm diagnose` below, which only reads; if the answer is NVIDIA, Intel or Apple, the scope - gate declines. Any other result: go on. If `rocm examine` itself fails (it - exits 0 whenever it ran, so a non-zero exit is an error from the CLI), relay - the error text and stop, as the contract check does. + gate declines. Any other result: go on. `rocm examine` exits 0 whenever it + ran, so a non-zero exit is an error from the CLI: relay the error text and + stop, as the contract check does. Pass the user's error text as the symptom: ``` - rocm diagnose --symptom "" --json + rocm diagnose --symptom='' --json ``` + In bash or zsh, quote the pasted text as one literal argument in single quotes, + never double quotes, so that a paste containing `$(…)` or a backtick cannot run + as a command. A `'` inside the paste ends the quote early and the rest is parsed + by the shell, so write each `'` as `'\''`. In any other shell, or if you are + unsure the quoting holds, do not run the command with a pasted symptom, because + a paste could otherwise run as a command: hand the user the command to run + themselves, and ask them to paste the JSON back (a run without `--symptom` + would answer a different question). Write the command for them, in their + shell's form (never the bash-escaped one above), only when the paste is one + line with no `"`, no `\` and no `%`: + - PowerShell: `rocm diagnose '--symptom=' --json`, with every single quote + in the text doubled by repeating it. The typographic ‘ ’ ‚ ‛ are single quotes + there too (`it’s` becomes `it’’s`). One left undoubled ends the quote early, + and a `$(…)` after it runs. + - cmd.exe: `rocm diagnose "--symptom=" --json`. + + For any other paste, shells split or rewrite the text in ways that differ by + shell and version, so write no form for it. Ask the user for a single line + without those characters, in their own words (never trim it yourself); only if + they cannot give one, have them run `rocm diagnose "--symptom=" --json` + with their text quoted for their shell in place of ``. + + Keep the `=` in every form: with a space instead, a paste that begins with `-` + (an exit code such as `-1073741819`) is read as a flag and the command fails. + If the user pasted no error text, run `rocm diagnose --json` without - `--symptom`: the CLI probes the host on its own, and a symptom you write - yourself is matched as though the user had said it. + `--symptom`: the CLI probes the host on its own, except for a vLLM startup + failure, where you ask for the error line first. Do not write a symptom yourself, + because the CLI matches it as though the user had said it; the one edit to the + user's text this skill allows, and the vLLM rule, are both under + [vLLM startup failures](#vllm-startup-failures). + + `rocm diagnose` exits 0 whether or not it matched. If it fails or prints + something that is not JSON, relay the error text and stop. Read the JSON: - - `has_match` — **the gate.** True means a cause cleared the threshold and - you may propose a fix; false means nothing was established, so route - upstream. Do **not** substitute "is `matched` empty?": several checkers - open with a nonzero base score for a merely *potentially* relevant - situation (a container, an APU beside a discrete GPU), so a healthy host - still returns a non-empty `matched` of sub-threshold entries. Gating on - emptiness proposes a fix for a machine with nothing wrong. True is not - automatically the end of the question, either: a `diagnose-only` top - match can clear the gate from host state alone, independent of whatever - symptom was pasted — see the refinement in step 2. - - An **advice-only** entry in `matched[]` (today `fix-22-display-driver-old`) - scores below the threshold on purpose and never sets `has_match`. It is - not a cause of the symptom. Relay the entry's `title` and `evidence` to - the user as advice, and never apply it for them. Keep routing upstream if - `has_match` is false. Step 2's rule that a lower cause may be mentioned only - if it also clears `min_score_for_match` does not apply to this entry. - - `matched[]` — ranked causes, each with `id`, `title`, `score` (0–100), - `evidence[]`, and a `fix` (with `fix_id`, `summary`, `commands`, `verify`, - `notes`, and the `needs_sudo` / `needs_reboot` / `needs_relogin` / - `auto_applicable` flags). `score >= 75` = high confidence; `50–74` = likely - (confirm one more piece of evidence with the user first). - **Read `fix.class` before you propose anything.** `diagnose-only` means - the cause is real and explained but has no remedy — currently only - `info-20-gpu-no-rocm-support`, which carries an `info-` id rather than a - `fix-N` / `fix-wsl-N` one for that reason. `rocm fix` still takes that id - and answers for it, by naming the problem and changing nothing. + - `has_match` — **the gate.** True means a cause cleared + `min_score_for_match`; false means nothing was established. Do **not** + substitute "is `matched` empty?": several checkers open with a nonzero base + score for a merely *potentially* relevant situation (a container, an APU + beside a discrete GPU), so a healthy host still returns a non-empty + `matched` of sub-threshold entries. Gating on emptiness proposes a fix for a + machine with nothing wrong. + - `matched[]` — ranked causes, each with `id`, `title`, `score`, `evidence[]`, + and a `fix` whose `fix_id`, `summary`, `commands`, `verify`, `notes`, `class`, + `needs`, `needs_sudo`, `needs_relogin` and `needs_reboot` are the fields this + skill acts on (its "plan" is `summary` and `commands`). **Read `fix.class` + before you propose anything**: step 3 says what each class lets the CLI do. + - An entry that scores below `min_score_for_match` on purpose and never sets + `has_match` is **advice**, not a cause: `fix-22-display-driver-old` is one, and + the Failure mode cell of [reference.md](reference.md)'s catalog table says + which entries are advice only. - `out_of_scope` — set only when the host's platform family has no catalog - entries at all. Linux, Windows and WSL2 are all covered, so this does - **not** fire for WSL2. When it is set, nothing was checked — say so rather - than implying the machine looks fine. First, if the user's symptom clearly - names an app that ships its own runtime (Lemonade, Ollama, LM Studio), - route them to that app's tracker (see - [Framework routing](#framework-routing)) — those trackers apply regardless - of platform. Otherwise relay the `out_of_scope` message and stop. - - `route_when_no_match` — when `has_match` is false, hand the user this - upstream tracker; **do not speculate**. Note the CLI picks this target from - the *host-detected* framework, not from the symptom text — so for an app - named only in the symptom, route it yourself per - [Framework routing](#framework-routing). - -2. **Decide what the diagnosis supports.** Take the first case that fits: - - - **`has_match` is false.** Nothing was established. Say so and route - upstream per `route_when_no_match` (or per - [Framework routing](#framework-routing) for an app named in the symptom). - Propose no fix. - - **The top match is `diagnose-only` and the user pasted a symptom its - `evidence` does not plausibly explain.** A `diagnose-only` cause like - `info-20-gpu-no-rocm-support` scores from host state alone (the GPU - architecture), not from the symptom, so it can be the top match even when - the pasted text describes something the evidence never mentions — a crash - in the engine actually running on this host, say. Relaying the evidence - and stopping would silently drop the user's actual complaint. Say what the - cause does establish about the host, then route upstream for the pasted - symptom itself, exactly as if `has_match` were false. - - **The top match is `diagnose-only` and no symptom was pasted, or its - `evidence` plausibly accounts for the one that was.** There is no fix to - propose: relay its `title` and `evidence` as an explanation of the host and - stop there. - - **Otherwise.** Show the top match's `title`, `evidence`, plan, and `verify` - command. Only propose applying it when the user is on board. + entries at all, and then `matched` is empty. + - `route_when_no_match` — the upstream tracker for when `has_match` is false. + The CLI picks it from the *host-detected* framework, not from the symptom + text or from whose bug it is; step 2 says when that makes it the wrong + tracker. + +2. **Decide what the diagnosis supports.** This judges `matched`. A `--model` + question is answered from its `model` object and is never routed upstream on + `has_match`. Take the first case that fits: + + - **`out_of_scope` is set.** Nothing was checked: say so rather than implying + the machine looks fine. If the symptom names an app in + [Framework routing](#framework-routing), send the user to that app's + tracker, which applies on any platform. Otherwise relay the `out_of_scope` + message and stop. `route_when_no_match` does not apply here. + - **`has_match` is false.** Nothing was established. Say so and propose no fix. + Then route the symptom: + - A vLLM startup failure on native Windows has no tracker to go to. Say that + vLLM is not supported on native Windows and to use WSL or Linux, or the + Lemonade engine (`--engine lemonade`). State this yourself; running + `rocm serve` or `rocm engines install vllm` to read the CLI's refusal adds + nothing. + - A failure of `rocm serve` itself, with any engine (Lemonade included), goes + to this project's tracker, https://github.com/ROCm/rocm-cli/issues. It is + rocm's own run of the engine, so this bullet wins over the next one. + - Any other symptom that names an app in + [Framework routing](#framework-routing) goes to that app's tracker, even if + it also names PyTorch or llama.cpp ("Lemonade's llama.cpp server crashes" + goes to Lemonade). Only when no app is named does a symptom that names + PyTorch or llama.cpp go to that project's tracker (listed in + [reference.md](reference.md)). + - Anything else goes to `route_when_no_match` as returned. Give the user the + URL without the CLI's trailing note, and pass the note on as advice (for + pytorch: tag the issue with the rocm label). + - **The user described a problem, and no match that cleared + `min_score_for_match` has `evidence` plausibly explaining it.** Many entries + score from host state alone (a small `/dev/shm`, an old distro, a missing + runtime), so a match can clear the threshold while its evidence never mentions + what the user described: an `ImportError` in an engine, say, or an app that will + not use the GPU. Presenting one as the cause silently drops the user's actual + complaint. Say what the matches establish about the host and offer their fixes + (step 3), where they have one, as worth doing anyway and never as the remedy + for the problem described. Then route that problem as in the `has_match` is + false case. + - **Otherwise.** Take the highest-ranked match that cleared the threshold and + explains the problem the user described (with none described, the top match). + If its `fix.class` is `diagnose-only`, the cause is real and explained and no + remedy exists: relay its `title`, `evidence`, `summary` and `notes` as an + explanation of the host, and offer no fix for it. With any other class, show + its `title`, `evidence`, plan, `notes` and `verify` command, and propose + applying it only when the user is on board. `notes` carry warnings the user + must see before acting. A score at or above `high_confidence_threshold` is + high confidence; a lower one that cleared `min_score_for_match` is likely, so + confirm one more piece of evidence with the user first. Any other match that cleared the threshold without explaining the + problem is offered as the case above offers its fixes (worth doing anyway, + never the remedy); it adds no routing. Mention a lower cause only if it *also* clears `min_score_for_match`: below - that threshold nothing was established, which is the bar the `has_match` - bullet sets, and a `diagnose-only` top match does not lower it. The advice-only - `fix-22-display-driver-old` entry described under `has_match` is the one - exception: relay it as advice, never as a cause. - -3. **Apply with consent.** For a fix that has a runner: - - ``` - rocm fix # prompts before changing anything - rocm fix --dry-run # show the exact change, touch nothing - rocm fix --yes # required to apply in a non-interactive shell - ``` - - Only four fixes have a runner the CLI executes itself. The other 24 are - **print-only** (bootloader, kernel, reinstall, Windows driver, …): `rocm fix - ` just prints the plan for the user to run themselves — no prompt, and the - CLI never performs those. In a diagnosis, `fix.auto_applicable` is true only - for a fix whose `fix.class` is auto on this host, so it is false for - `fix-9-igpu-dgpu` and for `fix-2-unset-override` on Linux and WSL2. - - One entry is in neither group. `info-20-gpu-no-rocm-support` is - **diagnose-only**: `rocm fix` takes the id, names the problem, says there is - no reliable fix, and exits 0 having changed nothing. - - Of the four, two do not always mutate: - - - **`fix-2-unset-override` mutates on Windows only.** On Linux and WSL2 it - reports where the override is set and which rc files carry it, then stops - — it will not edit the user's dotfiles. So there is no prompt to answer and - nothing for `--dry-run` to preview. Tell the user what to edit; do not - describe it as a change the CLI made or previewed. - - **`fix-9-igpu-dgpu` mutates only when `--device-index N` is passed.** - Without it — on either platform — the runner just prints the - `rocminfo`/`hipInfo` query that identifies the discrete GPU's index and - returns 0; there is no prompt, no `--dry-run` preview, and nothing is - pinned. Once the user knows N, re-run with - `rocm fix fix-9-igpu-dgpu --device-index N`. + that threshold nothing was established. An advice entry (step 1) is the + exception: relay its `title` and `evidence` to the user as advice, never as a + cause, and never apply it. It does not change which case above applies, so + `has_match` false still routes upstream. + +3. **Apply with consent.** Never run a mutating fix without the user's explicit + OK. Pass the full `fix_id` from the diagnosis. What `rocm fix ` does is + the entry's `fix.class` on the machine the diagnosis describes: + + - `auto` — carries the change out itself, after confirming. + - `needs-argument` — carries it out only once the argument `fix.needs` names is + supplied; without it, it prints what to pass and changes nothing. For + `fix-9-igpu-dgpu` that is `--device-index N`, and the bare command prints the + `rocminfo` / `hipInfo` query that identifies the discrete GPU's index. Once + the user knows N, re-run with it. + - `print-only` — prints the plan for the user to run and changes nothing. There + is no prompt, and nothing for `--dry-run` to preview. Such an entry can still + inspect the machine: `fix-2-unset-override` on Linux and WSL2 reports where + the override is set and which rc files carry it, and will not edit the user's + dotfiles. Tell the user what to edit; do not describe it as a change the CLI + made or previewed. + - `diagnose-only` — names the problem, says there is no reliable fix, and + changes nothing. + + [reference.md](reference.md)'s table marks the entries that are not print-only. + The other 24 are **print-only** on every host (bootloader, kernel, reinstall, + Windows driver, …): the CLI never performs those. + + To apply an `auto` fix, or a `needs-argument` fix with its argument, go in this + order. For a `needs-argument` fix, add the argument (`--device-index N` for + `fix-9-igpu-dgpu`) to both commands: without it each exits 0 having changed + nothing. + + - (a) `rocm fix --dry-run` shows the exact change and touches nothing. + It needs no terminal. + - (b) Show that to the user and get their explicit OK in the conversation. If + the change reaches only new sessions (`needs_relogin`, `needs_reboot`, or a + PATH or environment edit), say so here, before the OK: the user must log out + and back in, reboot, or open a new terminal before step 4's check, which fails + in the current session until then. If the fix has `needs_sudo`, say too that + `rocm` runs `sudo` with no input and kills it after one minute. Where sudo + needs a password, it prompts on the user's terminal and the fix applies if + they answer in time; cached credentials, a NOPASSWD rule or running as root + skip the prompt. A shell with no controlling terminal fails at once, and an + unanswered prompt fails after the minute, both with the `failed` exit, and the + user then runs `fix.commands` themselves. + - (c) `rocm fix --yes` applies it. `--yes` is the OK from (b) passed on + to the CLI, so add it only after that OK. Without it the CLI refuses in an + agent's shell, which has no terminal to ask on, and exits with the `declined` + code. Nobody was asked, so do not tell the user they declined. + + Run `rocm fix` on the machine the diagnosis describes. A diagnosis from + `rocm diagnose --distro`, taken from a Windows host, describes the WSL + distribution but `rocm fix` would act on the host, and `--distro` needs nothing + installed in the distribution: do not run `rocm fix` for it, and hand the user + the diagnosis's `fix.commands` to run inside the distribution. + + Judge the outcome from the CLI's output and from step 4, not from the exit status + alone: a run can exit 0 having changed nothing, because the setting was already + in place. Read a non-zero exit by its `exit_codes` name together with the output + (exit 2 is also what a malformed command returns), relay the output, and never + report it as applied; an exit the map does not name gets the same treatment: + - `failed` — the CLI tried and a command it ran failed: give the user the + diagnosis's `fix.commands` to run in their own terminal. + - `not_applicable` — the entry is real but not for this machine, or a + precondition is unmet (for `fix-4-render-group`: no `$USER`/`$LOGNAME`, no + `usermod`, or no `sudo` and not root): nothing was applied. + Do not offer `--dry-run`, which exits the same way; when the cause is a + precondition rather than the machine, hand the user `fix.commands` to run + themselves. + - `unknown_id` — the id is wrong: take it again from the diagnosis. + - `internal` — a fault in the CLI, not in the machine: stop. + - `declined` — nothing changed; without `--yes` in an agent's shell it means + nobody was asked (step (c) above). 4. **Verify.** Have the user run the `verify` command from the diagnosis. -Use `rocm examine` (or `rocm examine --json`) when you only need the host state -(GPU, driver, ROCm install, groups, framework) without a diagnosis. +Use `rocm examine --json` when you only need the host state (GPU, driver, ROCm +install, groups, framework) without a diagnosis; only the JSON carries the groups +and the framework. `rocm diagnose --model --json` answers whether a model +fits before a download: relay `model.verdict` and `model.evidence`, and read the +rest of the `model` object as [reference.md](reference.md) describes. ## Framework routing `rocm diagnose` covers frameworks that build against the **system** ROCm/HIP: +**PyTorch** and **llama.cpp**. Diagnose those normally. -- **PyTorch**, **llama.cpp** — in scope; diagnose normally. - -Apps that ship their **own** ROCm runtime aren't diagnosed here — route the user -to the right tracker. This routing is **yours, not the CLI's**: the host probe -reports only `pytorch`, `llama-cpp` or `unknown`, so `route_when_no_match` can -never name one of these apps. Use the list below. +Apps that ship their **own** ROCm runtime get routed by you, not by the CLI: +`route_when_no_match` (step 1) can never name one. Still run `rocm diagnose` +first, because the catalog covers host faults these apps depend on (a missing +MSVC runtime, an old distro), and a match that explains the symptom applies. Step 2 says when to route. - **Lemonade** → https://github.com/lemonade-sdk/lemonade/issues - **Ollama** → https://github.com/ollama/ollama/issues -- **LM Studio** → in-app support (no public repo) -- Anything else with no catalog match → ROCm core: - https://github.com/ROCm/ROCm/issues (this is what `route_when_no_match` - returns by default). +- **LM Studio** → https://github.com/lmstudio-ai/lmstudio-bug-tracker/issues ## vLLM startup failures @@ -289,36 +382,63 @@ Two vLLM engine failures are in the catalog. Both are **print-only**: `rocm fix` prints the plan and the user runs it. Say so first, in one short sentence at the start of the reply, before relaying a multi-step plan. +If `rocm serve` printed a `rocm diagnose --symptom '...'` command, take the text +inside its quotes as the symptom and run it the way step 1 shows. The printed form +has no `--json`, so it would give step 2 no `has_match` to read. + +If the user describes a vLLM startup failure on Linux or WSL2 in words and pasted no +error line, ask for the exact error line (or that printed command) before +diagnosing. Both vLLM entries score only the symptom text, so a description alone +matches neither, and step 2 would route a failure the catalog covers to a tracker. + - **Out of memory at startup** (`fix-16-vllm-oom`, Linux and WSL2). The match is keyword-based, and `vllm` or `gpu-memory-utilization` has to be on the same line - as the error. Pass one `--symptom` value on a single line: the exact error line - prefixed with `vllm: `, for example `--symptom 'vllm: torch.OutOfMemoryError: HIP - out of memory. ...'`. If `rocm serve` printed a `rocm diagnose --symptom '...'` - command, use that one. Do not put the vLLM mention on a separate line: the - match then fails, and a bare `torch.OutOfMemoryError` does not match either. - Relay both cases the CLI returns: lowering the reservation helps only on a - shared or busy GPU, and a model that does not fit needs a smaller or quantized - model. + as the error. Without a printed command, pass one `--symptom` value on a single + line: the exact error line prefixed with `vllm: `, for example + + ``` + rocm diagnose --symptom='vllm: torch.OutOfMemoryError: HIP out of memory. ...' --json + ``` + + Add the prefix only when vLLM is known to have printed the line (the user said + so, or the log shows the engine), and tell the user you added it: this is the one + edit to the user's text this skill allows. When the engine is unknown, pass the + line unchanged and accept no match, because a prefix on another framework's + out-of-memory error would blame vLLM for it. Do not put the vLLM mention on a + separate line: the match then fails, and a bare `torch.OutOfMemoryError` does not + match either. Relay both cases the CLI returns: lowering the reservation helps + only on a shared or busy GPU, and a model that does not fit needs a smaller or + quantized model. - **OSError or ImportError at engine start** (`fix-17-torch-dlpack`, Linux and WSL2). Pass the exact error line, for example one naming `libtorch_cuda.so`; no - `vllm` mention is needed. The match is *likely*, not high confidence, so say that - and have the user check the engine's torch version first, as the printed plan - does, before the engine reinstall it ends with. It is not a group membership - change, so do not suggest `render` or `video` group edits for it. -- **Native Windows** gets no match from either entry, which is correct because - the vLLM engine does not run there. Do not route that user to an issue tracker. - Relay what the CLI itself says for vLLM on native Windows (`rocm serve` and - `rocm engines install vllm`): vLLM is not supported there, so use WSL or Linux, - or the Lemonade engine. - -`rocm diagnose --model ` answers whether a model fits before a download. + `vllm` mention is needed. Relay the confidence the CLI reports: a paste of only + the `libtorch_cuda.so` line scores at the minimum, so it is likely and not high + confidence, and a fuller traceback scores higher. Have the user check the + engine's torch version first, as the printed plan does, before the engine + reinstall it ends with. It is not a group membership change, so do not suggest + `render` or `video` group edits for it. -## Rules +Native Windows gets no match from either entry, because the vLLM engine does not +run there. Do not route that user to an issue tracker, whatever else matched; step +2 says what to tell them. -- Never invent a fix. If `rocm diagnose` returns no match, route upstream. -- Never run a mutating fix without the user's explicit OK; prefer `--dry-run` - first. New failure modes are added to the CLI catalog, not improvised here. +## Rules -Read [reference.md](reference.md) when `rocm fix` exits non-zero (its exit codes -are listed there), before telling the user which platforms a fix id applies to, -and for the full closed catalog. +- Never suggest running on the CPU instead of the GPU, whatever the diagnosis: not + for a model that does not fit, and not for a GPU ROCm does not support. Keeping + some of a model's layers in system RAM on a GPU that works (llama.cpp's + `--n-gpu-layers`) is not CPU fallback: relay that suggestion when + `rocm diagnose --model` makes it. +- Relay a `suggestions[]` entry of a model estimate in the CLI's words, as the + llama.cpp option it names. `rocm serve` takes no context size, KV cache type or + GPU layer count (`model.warnings` says so), so never write one of them into a + `rocm serve` command. +- Run `rocm diagnose --report` or `--send` only when the user asks: they prepare a + report for the user to send and are no part of diagnosing a problem. +- Never invent a fix: offer only a remedy the CLI returns, a diagnosis `fix` or the + steps in `model.fix`. New failure modes are added to the CLI catalog, not + improvised here. + +Read [reference.md](reference.md) before telling the user which platforms a fix id +applies to, before reading the `model` object from `rocm diagnose --model`, before +handing over a PyTorch or llama.cpp tracker, and for the full closed catalog. diff --git a/skills/rocm-doctor/evals/evals.json b/skills/rocm-doctor/evals/evals.json index cef0ae6b63..ac2b1c33b1 100644 --- a/skills/rocm-doctor/evals/evals.json +++ b/skills/rocm-doctor/evals/evals.json @@ -6,7 +6,8 @@ "prompt": "torch.cuda.is_available() returns False on my AMD GPU and I get 'hipErrorNoBinaryForGpu' when I run my script. What's wrong?", "expected_behavior": [ "Drive the `rocm` CLI to diagnose -- check `rocm --version`, offer to install it with the user's consent, then `rocm diagnose` -- instead of applying a ROCm fix invented from general knowledge", - "Hand the user the CLI install path rather than guessing, if the CLI cannot be installed here" + "Hand the user the CLI install path rather than guessing, if the CLI cannot be installed here", + "Before asking for consent to install the `rocm` CLI, say what the installer changes on the machine (it puts the binaries in the user's home directory, edits the user's PATH configuration and writes its own config) and that the PATH edit can be skipped" ], "unexpected_behavior": [ "Execute a mutating or sudo command without first getting the user's explicit consent" @@ -30,10 +31,62 @@ { "id": "rocm-lemonade-routes-upstream", "skill_should_trigger": true, - "prompt": "The Lemonade app (from lemonade-sdk) fails to load a model on my Radeon GPU -- its bundled ROCm runtime throws an error. Where should I report this?", - "note": "Lemonade ships its own ROCm runtime. The host probe cannot detect it, so `route_when_no_match` never names it -- the skill hands over this tracker from its own routing table. The URL is the proof that it did.", + "prompt": "The Lemonade app (from lemonade-sdk) fails to load a model on my AMD GPU -- its bundled ROCm runtime throws an error. Where should I report this?", + "note": "Lemonade ships its own ROCm runtime. The host probe cannot detect it, so `route_when_no_match` never names it -- the skill hands over this tracker from its own routing table. The tracker URL is not pinned: the skill text carries it, so a pin would hold without the agent doing anything. `evals/hooks.py` replays a current CLI whose diagnosis establishes nothing (`has_match` false) for this symptom, so the case grades the routing itself, and the pin is the replay's own version line, which holds only if the agent ran the replayed `rocm`.", + "expected_behavior": [ + "Run `rocm diagnose`, see that it established no cause, and send the user to Lemonade's own issue tracker, https://github.com/lemonade-sdk/lemonade/issues" + ], + "unexpected_behavior": [ + "Send the user to the upstream tracker that the diagnosis returned instead of Lemonade's own, or propose a fix from the diagnosis, although the failing app is Lemonade" + ], "logs_contain": [ - "lemonade-sdk/lemonade/issues" + "recorded for evals" + ] + }, + { + "id": "rocm-serve-failure-routes-to-this-project", + "skill_should_trigger": true, + "note": "The failure comes from the CLI's own `rocm serve`, not from the Lemonade app, so the skill sends it to this project's tracker. The replayed diagnosis establishes no cause, and its `route_when_no_match` names the ROCm core tracker because the replayed host detected no framework, so the case tells the skill's rule apart from handing over what the diagnosis returned. The pin is the replay's own version line.", + "prompt": "On my AMD GPU, rocm serve --engine lemonade fails to load my model. Where should I report this?", + "expected_behavior": [ + "Run `rocm diagnose`, see that it established no cause, and send the user to this project's issue tracker, https://github.com/ROCm/rocm-cli/issues, because the failure is of `rocm serve` itself" + ], + "unexpected_behavior": [ + "Send the user to Lemonade's own issue tracker (lemonade-sdk/lemonade), or to the ROCm core tracker that the diagnosis's `route_when_no_match` returned, for a failure of `rocm serve --engine lemonade`", + "Propose or apply a fix from the catalog when the diagnosis established no cause" + ], + "logs_contain": [ + "recorded for evals" + ] + }, + { + "id": "rocm-ollama-routes-upstream", + "skill_should_trigger": true, + "note": "Ollama ships its own ROCm runtime, so the skill routes it from its own table whatever the host probe detected. The replayed diagnosis establishes no cause. The pin is the replay's own version line.", + "prompt": "Ollama crashes while loading a model onto my AMD GPU. Where should I report this?", + "expected_behavior": [ + "Run `rocm diagnose`, see that it established no cause, and send the user to Ollama's own issue tracker, https://github.com/ollama/ollama/issues" + ], + "unexpected_behavior": [ + "Send the user to the upstream tracker that the diagnosis returned instead of Ollama's own, or propose a fix from the diagnosis, although the failing app is Ollama" + ], + "logs_contain": [ + "recorded for evals" + ] + }, + { + "id": "rocm-lm-studio-routes-upstream", + "skill_should_trigger": true, + "note": "LM Studio ships its own ROCm runtime, so the skill routes it from its own table whatever the host probe detected. The replayed diagnosis establishes no cause. The pin is the replay's own version line.", + "prompt": "LM Studio shows no GPU offload for my AMD GPU. Where should I report this?", + "expected_behavior": [ + "Run `rocm diagnose`, see that it established no cause, and send the user to LM Studio's issue tracker, https://github.com/lmstudio-ai/lmstudio-bug-tracker/issues" + ], + "unexpected_behavior": [ + "Send the user to the upstream tracker that the diagnosis returned instead of LM Studio's own, or propose a fix from the diagnosis, although the failing app is LM Studio" + ], + "logs_contain": [ + "recorded for evals" ] }, { @@ -72,7 +125,7 @@ { "id": "rocm-older-cli-stops-before-diagnosing", "skill_should_trigger": true, - "note": "The one case that needs a `rocm` on PATH, which the grading hosts do not have. `evals/hooks.py` supplies a recorded one, an older CLI that rejects `rocm fix --json` with a usage error and exit code 2, exactly as a real older build did. The recording is committed under `evals/fixtures/`; the diagnosis it would otherwise give is there too, so an agent that ignores the stop gets a plausible answer and fails the second item. What is graded is the stop, not a diagnosis. The `logs_contain` pin is the stub's own usage error, which `SKILL.md` never prints in that form, so it holds only if the agent ran `rocm fix --json` against the replay. Its `--version` line (`rocm 0.1.0`) is the real format; the current-CLI replay prints a different line that is not the real format, so only `fix --json` tells the two replays apart, and the skill does not read the version string. The prompt names no operating system: the recorded CLI answers the same on any host, and an agent on a Windows host has declined to run the commands at all when the prompt said Linux.", + "note": "The case that replays an older CLI, which the grading hosts do not have. `evals/hooks.py` supplies a recorded one that rejects `rocm fix --json` with a usage error and exit code 2, exactly as a real older build did. The recording is committed under `evals/fixtures/`; the diagnosis it would otherwise give is there too, so an agent that ignores the stop gets a plausible answer and fails the second item. What is graded is the stop, not a diagnosis. The `logs_contain` pin is the stub's own usage error, which `SKILL.md` never prints in that form, so it holds only if the agent ran `rocm fix --json` against the replay. Its `--version` line was recorded from that older build; the current-CLI replay prints a fixed marker line that no real build prints, so only `fix --json` tells the two replays apart, and the skill does not read the version string. The prompt names no operating system: the recorded CLI answers the same on any host, and an agent on a Windows host has declined to run the commands at all when the prompt said Linux.", "prompt": "My PyTorch job fails with hipErrorNoBinaryForGpu on my AMD GPU. How do I fix it?", "expected_behavior": [ "Tell the user that the installed `rocm` CLI is older than the skill requires, so the CLI is the side to update, instead of diagnosing the failure", @@ -89,14 +142,16 @@ { "id": "rocm-current-cli-carries-on", "skill_should_trigger": true, - "note": "The control for the older-CLI case: the same prompt against a recorded current CLI, which publishes the catalog manifest. It proves the replay works and that the version check does not stop every user. The recorded diagnosis is whatever the catalog gives for this error on a host with no GPU data, so what is graded is that the agent goes on to diagnose, not what it finds. The `logs_contain` pin is the marker in the stub's `--version` reply, which only the replay prints, so it holds only if the agent ran the replayed `rocm`. That line (`rocm-cli 0.1.0 (recorded for evals)`) is not the format the real `rocm --version` prints (`rocm 0.1.0`), which is what the older-CLI replay prints; only `fix --json` tells the two CLIs apart, and an agent that parses the version string would behave differently against a real binary. The prompt names no operating system, for the reason given on the older-CLI case.", + "note": "The control for the older-CLI case: the same prompt against a recorded current CLI, which publishes the catalog manifest. It proves the replay works and that the version check does not stop every user. The recorded diagnosis is whatever the catalog gives for this error on a host with no GPU data: `has_match` is false and `matched` holds one entry below the threshold (`fix-1-arch`, a sub-threshold score), which is exactly what an agent gating on a non-empty `matched` would propose a fix for. So the case grades the version check and the `has_match` gate, not what the catalog finds. Its `route_when_no_match` names the ROCm core tracker, because the replayed host detected no framework, while the prompt names PyTorch: the skill routes a symptom that names PyTorch to that project's tracker, so the routing item grades that rule and not the value the diagnosis returned. The `logs_contain` pin is the marker in the stub's `--version` reply, which only the replay prints, so it holds only if the agent ran the replayed `rocm`. That line is a fixed marker that no real build prints; only `fix --json` tells the two CLIs apart, and an agent that parses the version string would behave differently against a real binary. The prompt names no operating system, for the reason given on the older-CLI case.", "prompt": "My PyTorch job fails with hipErrorNoBinaryForGpu on my AMD GPU. How do I fix it?", "expected_behavior": [ - "Run `rocm diagnose` and relay what it returned, instead of stopping at the version check" + "Run `rocm diagnose` and relay what it returned, instead of stopping at the version check", + "Say that the diagnosis established no cause, and route the user to the PyTorch project's issue tracker, https://github.com/pytorch/pytorch/issues, because the symptom names PyTorch although the diagnosis's own `route_when_no_match` names the ROCm core tracker" ], "unexpected_behavior": [ "Say that the installed `rocm` CLI is older than the skill requires", - "Stop before running `rocm diagnose`" + "Stop before running `rocm diagnose`", + "Propose or apply a fix, or name a cause, on the strength of a match the diagnosis listed although its `has_match` is false" ], "logs_contain": [ "recorded for evals" @@ -110,11 +165,13 @@ "expected_behavior": [ "Run `rocm diagnose` with the error line as the symptom and relay the matched cause", "Pass the error text and the word vllm together on one line in a single `--symptom` value (for example prefixed with `vllm: `), not on separate lines", - "Relay both cases the CLI gives: lower the memory reservation or pick a less busy GPU when the card is shared, and use a smaller or quantized model when the model does not fit" + "Relay both cases the CLI gives: lower the memory reservation or pick a less busy GPU when the card is shared, and use a smaller or quantized model when the model does not fit", + "Say near the start of the reply, before any step-by-step plan, that the fix is print-only: the user runs the printed steps and the CLI does not apply them" ], "unexpected_behavior": [ "Execute a mutating or sudo command without first getting the user's explicit consent", - "Claim that lowering the memory reservation helps when the model itself does not fit in the GPU memory" + "Claim that lowering the memory reservation helps when the model itself does not fit in the GPU memory", + "Suggest running the model on the CPU instead of the GPU" ], "logs_contain": [ "recorded for evals" @@ -138,10 +195,26 @@ "recorded for evals" ] }, + { + "id": "rocm-vllm-failure-in-words-asks-for-the-error-line", + "skill_should_trigger": true, + "note": "Replays a current CLI. The user describes a vLLM startup failure in words and pastes no error line. Both vLLM catalog entries score only the symptom text, so the replayed diagnosis for a description establishes nothing (`has_match` false, the route is the ROCm core tracker): an agent that diagnoses on the description and then routes upstream sends a failure the catalog covers to a tracker. The skill asks for the exact error line, or the `rocm diagnose` command `rocm serve` printed, before diagnosing. The replay answers `diagnose` the same whatever the symptom, so the stub cannot fail a premature diagnosis; the judge sees the order of the commands in the transcript. The prompt names Linux on purpose: the entries apply on Linux and WSL2 only, so the case is not expected to pass on a Windows lane. The pin is the replay's own version line, which holds once the agent has run the replayed `rocm` for the version check.", + "prompt": "My vLLM server on my AMD GPU on Linux keeps crashing when it starts up. What should I do?", + "expected_behavior": [ + "Ask the user for the exact error line from the vLLM log, or for the `rocm diagnose` command that `rocm serve` printed, before diagnosing" + ], + "unexpected_behavior": [ + "Run `rocm diagnose` before the user has given an error line, whether with the description as the symptom or with none", + "Send the user to an upstream tracker for the failure before asking for the error line" + ], + "logs_contain": [ + "recorded for evals" + ] + }, { "id": "rocm-vendor-not-named-is-not-declined", "skill_should_trigger": true, - "note": "ROCm wording with no GPU vendor named. The scope gate declines a GPU that is not AMD, and a missing vendor is not that: ROCm is AMD's stack, so the skill goes on to the CLI. Only that half of the rule is graded. The other half, asking which GPU the machine has when `rocm examine` reports `no-amd-gpu`, needs an examine reply the recorded CLI in `evals/hooks.py` does not give, so it is not graded here. The `logs_contain` pin is the version probe, which holds on any host.", + "note": "ROCm wording with no GPU vendor named. The scope gate declines a GPU that is not AMD, and a missing vendor is not that: ROCm is AMD's stack, so the skill goes on to the CLI. Only that half of the rule is graded here. The other half, asking which GPU the machine has when `rocm examine` reports `no-amd-gpu`, is graded by `rocm-no-vendor-no-amd-gpu-asks-which-gpu`, which replays an examination. The `logs_contain` pin is the version probe, which holds on any host.", "prompt": "ROCm is broken on my machine and torch can't see the GPU. Please fix it.", "expected_behavior": [ "Treat the ROCm wording as an AMD context and begin by checking for the `rocm` CLI, instead of first asking or deciding which vendor the GPU is" @@ -223,11 +296,85 @@ "failed to read the host (recorded for evals)" ] }, + { + "id": "rocm-apply-auto-fix-needs-consent", + "skill_should_trigger": true, + "note": "The only case that reaches the apply step. The replayed diagnosis matches an `auto` entry (`fix-4-render-group`), and the stub answers `rocm fix fix-4-render-group --dry-run` and the same command without a flag. Both answers are generated, not captured from the binary: the plan is the CLI's own plan text, from the catalog, and only the `Will run:` line the runner adds is not there, because it names the user and the machine. The plan shows `$ sudo usermod ...` and `requires sudo`, so what the case grades about `sudo` is whether the agent says, with the proposal, what happens when it runs with no input. The dry run exits 0, and the bare command prints the same and then refuses with the CLI's `declined` exit code, as the CLI does when nobody can be asked. The stub does not answer `--yes`, so an agent that applies before the user said OK meets the stub's usage error and the judge sees the command in the transcript. The grading harness has no user to answer, so the case grades what the agent does up to asking: the order of dry run, the user's OK and `--yes`, the warnings given with the proposal, and reading the refusal as nobody having been asked rather than as a decline. The prompt names Ubuntu because the fix is Linux-only, so the case is not expected to pass on a Windows lane. The pin is the replay's own version line.", + "prompt": "On my AMD GPU box (Ubuntu), rocminfo fails with 'Unable to open /dev/kfd read-write: Permission denied' for my normal user. Please fix it.", + "expected_behavior": [ + "Run `rocm diagnose`, present the `fix-4-render-group` match with the change it would make, and show that change with `rocm fix fix-4-render-group --dry-run` before applying anything", + "In the message that shows the change and asks for the user's explicit OK, say that a change of group membership only takes effect after the user logs out and back in", + "In that same message, say that applying runs `sudo` with no input and kills it after one minute, so that where `sudo` needs a password the fix applies if the user answers the prompt in time, and otherwise (at once in a shell with no controlling terminal, after the minute for an unanswered prompt) ends in the `failed` exit and the user runs the commands themselves" + ], + "unexpected_behavior": [ + "Run `rocm fix fix-4-render-group --yes`, or run `sudo` or `usermod` directly, before the user has said OK in the conversation", + "Tell the user that they declined, or that they refused the change, after a `rocm fix` run was refused in a shell with no terminal, since nobody was asked" + ], + "logs_contain": [ + "recorded for evals" + ] + }, + { + "id": "rocm-match-does-not-explain-the-paste", + "skill_should_trigger": true, + "note": "The replay is a Docker container with the default 64 MiB `/dev/shm` and an AMD GPU found. The shared-memory entry (`fix-19-shm-too-small`) then scores from host state alone whatever the symptom says, and outranks the entry that matches the pasted error (`fix-17-torch-dlpack`, the likely level); a container entry also appears, below the threshold. A skill that presents the top match as the cause drops the user's actual complaint. The prompt names an AMD GPU, so `rocm examine` is not run. The entries apply on Linux and WSL2 only, and a container is Linux, so the case is not expected to pass on a Windows lane. The pin is the replay's own version line.", + "prompt": "Inside a Docker container on my AMD GPU machine, my vLLM engine fails to start with 'ImportError: libtorch_cuda.so: cannot open shared object file: No such file or directory'. What should I do?", + "expected_behavior": [ + "Run `rocm diagnose` with the error line as the symptom, and give the torch DLPack entry (`fix-17-torch-dlpack`) as the likely cause of that error, with the engine's torch version to be checked before the reinstall", + "Report the small shared-memory allowance (`fix-19-shm-too-small`) as a separate thing the diagnosis found about the host, not as the cause of the ImportError" + ], + "unexpected_behavior": [ + "Present the shared-memory entry (`fix-19-shm-too-small`) as the cause of the ImportError, or leave the torch DLPack entry out", + "Send the user to an upstream tracker although a match that explains the error was found", + "Execute a mutating or sudo command without first getting the user's explicit consent" + ], + "logs_contain": [ + "recorded for evals" + ] + }, + { + "id": "rocm-host-only-match-is-not-the-cause", + "skill_should_trigger": true, + "note": "The same container host as `rocm-match-does-not-explain-the-paste`, with a complaint no catalog entry mentions. The only match that clears the threshold is the shared-memory entry (`fix-19-shm-too-small`), which scores from host state alone, so `has_match` is true and nothing in it explains the garbled output. The skill presents such a match as a separate finding about the host and routes the complaint upstream as it does when nothing matched. The replayed `route_when_no_match` names the ROCm core tracker. The prompt names an AMD GPU, so `rocm examine` is not run. The shared-memory entry applies on Linux and WSL2 only, and a container is Linux, so the case is not expected to pass on a Windows lane. The pin is the replay's own version line.", + "prompt": "On my AMD GPU machine inside a Docker container, my model's generated text turns into garbage after the first few tokens. What is wrong?", + "expected_behavior": [ + "Run `rocm diagnose`, and report the small shared-memory allowance (`fix-19-shm-too-small`) as a separate finding about the container, worth fixing anyway, not as the remedy for the garbled text", + "Send the garbled-text problem to the upstream tracker that the diagnosis returned, https://github.com/ROCm/ROCm/issues, because nothing the diagnosis found explains it" + ], + "unexpected_behavior": [ + "Present the small shared-memory allowance as the cause of the garbled text, or say that fixing it will fix the garbled text", + "Propose or apply a fix for the garbled text itself from the catalog" + ], + "logs_contain": [ + "recorded for evals" + ] + }, + { + "id": "rocm-symptom-with-shell-metacharacters", + "skill_should_trigger": true, + "note": "The pasted line carries `$(...)`, which a shell runs when the text sits in double quotes or in none. The replay answers `rocm diagnose` whatever the symptom is, so the stub cannot fail a badly quoted one; the quoting is graded by the judge from the command in the transcript. The skill runs the quoted form only in bash or zsh and, in another shell, hands the user the command in that shell's own form (PowerShell and cmd.exe each have one, for a one-line paste with no `\"`, `\\` or `%`, which this paste is), so the first item accepts either and the case can pass on a Windows lane too. The pin is the replay's own version line.", + "prompt": "My build on my AMD GPU prints this and then my kernels fail: 'hipcc: error: invalid device function while running $(hipconfig --path)/bin/hipcc'. What is wrong?", + "expected_behavior": [ + "In bash or zsh, run `rocm diagnose` with the whole pasted line as a single `--symptom='...'` argument in single quotes, so that the shell expands and runs nothing inside it; in another shell, hand the user that command in the form for their shell (single quotes with every single quote doubled for PowerShell, double quotes for cmd.exe) to run instead of running it with the pasted text, and ask them to paste the JSON back" + ], + "unexpected_behavior": [ + "Put the pasted line in double quotes or leave it unquoted on the command line, so that the shell would expand or run `$(hipconfig --path)`" + ], + "logs_contain": [ + "recorded for evals" + ] + }, { "id": "nvidia-container-toolkit-unrelated", "skill_should_trigger": false, "note": "NVIDIA GPU and a container runtime error, with no ROCm/AMD vocabulary at all -- doesn't match this skill's frontmatter description, so nothing should load. Restores the two-negative floor `rocm-under-wsl2` moved off of.", "prompt": "My NVIDIA Docker container can't see the GPU -- 'nvidia-container-cli: initialization error: nvml error: driver/library version mismatch'. How do I get the NVIDIA Container Toolkit working?" + }, + { + "id": "rocm-first-time-setup-on-a-clean-machine", + "skill_should_trigger": false, + "note": "ROCm and an AMD GPU, but a request to set ROCm up for the first time on a clean machine, which is a setup task and not a diagnosis. The description excludes it and the scope gate points the user at AMD's installation documentation, so nothing should fire. The prompt names no operating system.", + "prompt": "I just built a new machine with an AMD GPU and nothing is installed on it yet. How do I set up ROCm from scratch?" } ] } diff --git a/skills/rocm-doctor/evals/fixtures/cases.json b/skills/rocm-doctor/evals/fixtures/cases.json index 997bf2a005..8494e4439f 100644 --- a/skills/rocm-doctor/evals/fixtures/cases.json +++ b/skills/rocm-doctor/evals/fixtures/cases.json @@ -43,6 +43,54 @@ "cli": "current", "symptom": "torch can't see the GPU", "host": "examine-fails" + }, + { + "id": "rocm-lemonade-routes-upstream", + "cli": "current", + "symptom": "its bundled ROCm runtime throws an error" + }, + { + "id": "rocm-serve-failure-routes-to-this-project", + "cli": "current", + "symptom": "rocm serve --engine lemonade fails to load my model" + }, + { + "id": "rocm-ollama-routes-upstream", + "cli": "current", + "symptom": "Ollama crashes while loading a model onto my AMD GPU" + }, + { + "id": "rocm-lm-studio-routes-upstream", + "cli": "current", + "symptom": "LM Studio shows no GPU offload for my AMD GPU" + }, + { + "id": "rocm-apply-auto-fix-needs-consent", + "cli": "current", + "symptom": "Unable to open /dev/kfd read-write: Permission denied", + "apply": "fix-4-render-group" + }, + { + "id": "rocm-match-does-not-explain-the-paste", + "cli": "current", + "symptom": "ImportError: libtorch_cuda.so: cannot open shared object file: No such file or directory", + "host": "container-small-shm" + }, + { + "id": "rocm-symptom-with-shell-metacharacters", + "cli": "current", + "symptom": "hipcc: error: invalid device function while running $(hipconfig --path)/bin/hipcc" + }, + { + "id": "rocm-host-only-match-is-not-the-cause", + "cli": "current", + "symptom": "my model's generated text turns into garbage after the first few tokens", + "host": "container-small-shm" + }, + { + "id": "rocm-vllm-failure-in-words-asks-for-the-error-line", + "cli": "current", + "symptom": "My vLLM server on my AMD GPU on Linux keeps crashing when it starts up" } ] } diff --git a/skills/rocm-doctor/evals/fixtures/rocm-apply-auto-fix-needs-consent/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-apply-auto-fix-needs-consent/replies.json new file mode 100644 index 0000000000..4075716982 --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-apply-auto-fix-needs-consent/replies.json @@ -0,0 +1,35 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"User not in render/video group (or /dev/kfd owned by the other group)\",\n \"score\": 95,\n \"evidence\": [\n \"error mentions /dev/kfd open failure\",\n \"error mentions /dev/kfd permission denied\"\n ],\n \"fix\": {\n \"summary\": \"Add the current user to 'render' (and 'video' for safety) and log out/in.\",\n \"commands\": [\n \"sudo usermod -a -G render,video \\\"$USER\\\"\"\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true,\n \"fix_id\": \"fix-4-render-group\",\n \"auto_applicable\": true,\n \"class\": \"auto\",\n \"notes\": [\n \"Group membership only takes effect after a full re-login (or reboot). `newgrp render` will give the current shell access but not other terminals or services.\"\n ],\n \"verify\": \"groups | tr ' ' '\\\\n' | grep -E '^(render|video)$' && ls -l /dev/kfd && rocminfo | head -n 5\"\n }\n }\n ],\n \"has_match\": true,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "#1 (fix-4-render-group) [HIGH score=95/100] User not in render/video group (or /dev/kfd owned by the other group)\n id: fix-4-render-group\n - error mentions /dev/kfd open failure\n - error mentions /dev/kfd permission denied\n plan: Add the current user to 'render' (and 'video' for safety) and log out/in.\n $ sudo usermod -a -G render,video \"$USER\"\n flags: requires sudo, requires re-login, rocm fix can run it\n note: Group membership only takes effect after a full re-login (or reboot). `newgrp render` will give the current shell access but not other terminals or services.\n verify after fix: groups | tr ' ' '\\n' | grep -E '^(render|video)$' && ls -l /dev/kfd && rocminfo | head -n 5\n apply with: rocm fix fix-4-render-group\n\nNext step: run `rocm fix fix-4-render-group`.\n", + "stderr": "", + "rc": 0 + }, + "apply": { + "fix_id": "fix-4-render-group", + "dry_run": { + "stdout": "Fix: fix-4-render-group -- Add user to render/video groups\nOS scope: linux\nRationale: The current user can't open /dev/kfd because they aren't in the render group. Adding the user is the safe, standard fix.\nCommands:\n $ sudo usermod -a -G render,video \"$USER\"\nFlags: requires sudo, requires re-login, rocm fix can run it\nVerify: groups | tr ' ' '\\n' | grep -E '^(render|video)$' && rocminfo | head -n 5\n\n(dry-run; not executed)\n", + "stderr": "", + "rc": 0 + }, + "bare": { + "stdout": "Fix: fix-4-render-group -- Add user to render/video groups\nOS scope: linux\nRationale: The current user can't open /dev/kfd because they aren't in the render group. Adding the user is the safe, standard fix.\nCommands:\n $ sudo usermod -a -G render,video \"$USER\"\nFlags: requires sudo, requires re-login, rocm fix can run it\nVerify: groups | tr ' ' '\\n' | grep -E '^(render|video)$' && rocminfo | head -n 5\n\n", + "stderr": "Non-interactive shell and --yes not passed; refusing to apply.\n", + "rc": 5 + } + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-host-only-match-is-not-the-cause/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-host-only-match-is-not-the-cause/replies.json new file mode 100644 index 0000000000..35473d514d --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-host-only-match-is-not-the-cause/replies.json @@ -0,0 +1,27 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"shared memory allowance too small for a serving workload\",\n \"score\": 70,\n \"evidence\": [\n \"64.0 MiB is the whole shared-memory allowance, and a serving workload needs gigabytes\",\n \"this is a docker container, whose default allowance is 64 MiB\"\n ],\n \"fix\": {\n \"summary\": \"Raise the shared-memory allowance before running the workload.\",\n \"commands\": [\n \"# In a container: restart it with a larger allowance.\",\n \"# docker run --shm-size=8g ... # see fix-10-container\",\n \"# On a host: remount it, and make that survive a reboot.\",\n \"sudo mount -o remount,size=8g /dev/shm\",\n \"# /etc/fstab: tmpfs /dev/shm tmpfs defaults,size=8g 0 0\"\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-19-shm-too-small\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [\n \"A running container cannot have its allowance changed; it has to be started again.\",\n \"This is reported below 1.0 GiB. Silence is not proof of enough: a container given 2 GiB clears that bar and can still be too small for a large model.\"\n ],\n \"verify\": \"df -h /dev/shm\"\n }\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Container can't see /dev/kfd or /dev/dri/renderD*\",\n \"score\": 45,\n \"evidence\": [\n \"running inside a docker\",\n \"no /dev/dri/renderD* visible in the container\"\n ],\n \"fix\": {\n \"summary\": \"Re-launch the container with the AMD devices and the render group passed through.\",\n \"commands\": [\n \"# Docker / Podman flags AMD-recommends:\",\n \"docker run --rm -it \\\\\",\n \" --device=/dev/kfd \\\\\",\n \" --device=/dev/dri \\\\\",\n \" --group-add render \\\\\",\n \" --security-opt seccomp=unconfined \\\\\",\n \" --shm-size=8g \\\\\",\n \" rocm/pytorch:latest\",\n \"# Rootless podman: also pass `--userns=keep-id` and ensure the\",\n \"# host user is in the render group; podman maps it through.\"\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-10-container\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [\n \"Use rocm/pytorch or rocm/dev-ubuntu-22.04 as a known-good image. Mixing host ROCm + container ROCm versions is a separate footgun.\"\n ],\n \"verify\": \"rocminfo | head -n 5\"\n }\n }\n ],\n \"has_match\": true,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "#1 (fix-19-shm-too-small) [LIKELY score=70/100] shared memory allowance too small for a serving workload\n id: fix-19-shm-too-small\n - 64.0 MiB is the whole shared-memory allowance, and a serving workload needs gigabytes\n - this is a docker container, whose default allowance is 64 MiB\n plan: Raise the shared-memory allowance before running the workload.\n $ # In a container: restart it with a larger allowance.\n $ # docker run --shm-size=8g ... # see fix-10-container\n $ # On a host: remount it, and make that survive a reboot.\n $ sudo mount -o remount,size=8g /dev/shm\n $ # /etc/fstab: tmpfs /dev/shm tmpfs defaults,size=8g 0 0\n flags: requires sudo, manual only (`rocm fix` will NOT run it automatically)\n note: A running container cannot have its allowance changed; it has to be started again.\n note: This is reported below 1.0 GiB. Silence is not proof of enough: a container given 2 GiB clears that bar and can still be too small for a large model.\n verify after fix: df -h /dev/shm\n apply with: rocm fix fix-19-shm-too-small\n\n#2 (fix-10-container) [WEAK score=45/100] Container can't see /dev/kfd or /dev/dri/renderD*\n id: fix-10-container\n - running inside a docker\n - no /dev/dri/renderD* visible in the container\n plan: Re-launch the container with the AMD devices and the render group passed through.\n $ # Docker / Podman flags AMD-recommends:\n $ docker run --rm -it \\\n $ --device=/dev/kfd \\\n $ --device=/dev/dri \\\n $ --group-add render \\\n $ --security-opt seccomp=unconfined \\\n $ --shm-size=8g \\\n $ rocm/pytorch:latest\n $ # Rootless podman: also pass `--userns=keep-id` and ensure the\n $ # host user is in the render group; podman maps it through.\n flags: manual only (`rocm fix` will NOT run it automatically)\n note: Use rocm/pytorch or rocm/dev-ubuntu-22.04 as a known-good image. Mixing host ROCm + container ROCm versions is a separate footgun.\n verify after fix: rocminfo | head -n 5\n apply with: rocm fix fix-10-container\n\nHighest-scoring match is below the HIGH_CONFIDENCE threshold. Confirm one more piece of evidence before applying.\nWhen you are ready, run `rocm fix fix-19-shm-too-small` (the highest-scoring match), or use the `apply with:` line of whichever cause fits.\n", + "stderr": "", + "rc": 0 + }, + "examine_json": { + "stdout": "{\n \"os_family\": \"linux\",\n \"os_version\": \"6.8.0\",\n \"distro_id\": \"ubuntu\",\n \"distro_version\": \"24.04\",\n \"distro_id_like\": \"\",\n \"kernel_release\": \"6.8.0-generic\",\n \"kernel_cmdline\": \"\",\n \"is_wsl\": false,\n \"wsl\": null,\n \"cpu_vendor\": \"AuthenticAMD\",\n \"cpu_model\": \"\",\n \"gpus\": [\n {\n \"name\": \"AMD Radeon RX 7900 XTX\",\n \"gfx_target\": \"gfx1100\",\n \"pci_id\": \"0000:c3:00.0\",\n \"is_apu\": false,\n \"is_amd\": true\n }\n ],\n \"has_amd_gpu\": true,\n \"has_nvidia_gpu\": false,\n \"has_apu\": false,\n \"has_discrete_amd\": true,\n \"amdgpu_loaded\": null,\n \"amdgpu_blacklisted_in\": [],\n \"amdkfd_loaded\": null,\n \"secure_boot\": \"unknown\",\n \"iommu_kernel_param\": \"\",\n \"kfd\": null,\n \"render_devices\": [],\n \"user_name\": \"\",\n \"user_groups\": [],\n \"in_render_group\": null,\n \"in_video_group\": null,\n \"rocm_version\": \"\",\n \"rocm_install_method\": \"\",\n \"rocm_path\": \"\",\n \"rocminfo_present\": false,\n \"rocminfo_status\": \"\",\n \"hip_libs_on_ld_path\": null,\n \"rocm_repos_seen\": [],\n \"comgr_paths\": [],\n \"comgr_selected\": null,\n \"comgr_version\": \"\",\n \"comgr_matches_runtime\": null,\n \"hip_paths\": [],\n \"hip_selected\": null,\n \"hip_sdk_path\": \"\",\n \"hip_sdk_version\": \"\",\n \"hipinfo_present\": false,\n \"hipinfo_status\": \"\",\n \"adrenalin_version\": \"\",\n \"adrenalin_date\": \"\",\n \"msvc_redist_present\": null,\n \"msvc_redist_version\": \"\",\n \"framework\": \"unknown\",\n \"framework_version\": \"\",\n \"framework_rocm_version\": \"\",\n \"framework_arch_list\": [],\n \"framework_notes\": [],\n \"framework_source\": \"\",\n \"env\": {},\n \"in_container\": true,\n \"container_kind\": \"docker\",\n \"shm_total_bytes\": 67108864,\n \"shm_available_bytes\": 67108864,\n \"dmesg_amdgpu_tail\": [],\n \"notes\": [],\n \"probe_failures\": [],\n \"status\": \"ok\"\n}\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-lemonade-routes-upstream/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-lemonade-routes-upstream/replies.json new file mode 100644 index 0000000000..25a92fe4ef --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-lemonade-routes-upstream/replies.json @@ -0,0 +1,22 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [],\n \"has_match\": false,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "rocm diagnose: no known misconfiguration matched.\n\nThis is the explicit 'I don't recognise this failure mode' case. Do not speculate; file the symptom + this examination output upstream:\n rocm-core: https://github.com/ROCm/ROCm/issues\n\nInclude the JSON from `rocm examine --json` in your report.\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-lm-studio-routes-upstream/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-lm-studio-routes-upstream/replies.json new file mode 100644 index 0000000000..25a92fe4ef --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-lm-studio-routes-upstream/replies.json @@ -0,0 +1,22 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [],\n \"has_match\": false,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "rocm diagnose: no known misconfiguration matched.\n\nThis is the explicit 'I don't recognise this failure mode' case. Do not speculate; file the symptom + this examination output upstream:\n rocm-core: https://github.com/ROCm/ROCm/issues\n\nInclude the JSON from `rocm examine --json` in your report.\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-match-does-not-explain-the-paste/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-match-does-not-explain-the-paste/replies.json new file mode 100644 index 0000000000..f46bffcb81 --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-match-does-not-explain-the-paste/replies.json @@ -0,0 +1,27 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"shared memory allowance too small for a serving workload\",\n \"score\": 70,\n \"evidence\": [\n \"64.0 MiB is the whole shared-memory allowance, and a serving workload needs gigabytes\",\n \"this is a docker container, whose default allowance is 64 MiB\"\n ],\n \"fix\": {\n \"summary\": \"Raise the shared-memory allowance before running the workload.\",\n \"commands\": [\n \"# In a container: restart it with a larger allowance.\",\n \"# docker run --shm-size=8g ... # see fix-10-container\",\n \"# On a host: remount it, and make that survive a reboot.\",\n \"sudo mount -o remount,size=8g /dev/shm\",\n \"# /etc/fstab: tmpfs /dev/shm tmpfs defaults,size=8g 0 0\"\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-19-shm-too-small\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [\n \"A running container cannot have its allowance changed; it has to be started again.\",\n \"This is reported below 1.0 GiB. Silence is not proof of enough: a container given 2 GiB clears that bar and can still be too small for a large model.\"\n ],\n \"verify\": \"df -h /dev/shm\"\n }\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"vLLM engine start aborts on torch-c-dlpack-ext loading its CUDA variant\",\n \"score\": 50,\n \"evidence\": [\n \"error names libtorch_cuda.so, which a ROCm build of torch does not ship\"\n ],\n \"fix\": {\n \"summary\": \"Only if the engine's runtime holds a ROCm build of torch in the 2.4-2.9 range with torch-c-dlpack-ext installed: reinstall the engine so its pinned torch is restored, which moves torch off the versions the extension ships prebuilts for.\",\n \"commands\": [\n \"# --- step 1 of 3, in YOUR shell ---\",\n \"# Opens an INTERACTIVE subshell with the engine's environment active,\",\n \"# and does not return until you leave it. Run this line on its own.\",\n \"rocm engines shell vllm\",\n \"# --- step 2 of 3, INSIDE the subshell step 1 opened ---\",\n \"# Confirm the trigger before changing anything. It has to be the\",\n \"# ENGINE's interpreter, not the one on your PATH -- they are different\",\n \"# interpreters, and only the engine's decides this failure.\",\n \"python -c \\\"import torch; print(torch.__version__, torch.version.hip)\\\"\",\n \"python -c \\\"import importlib.metadata as m; print(m.version('torch-c-dlpack-ext'))\\\"\",\n \"# This entry applies ONLY when torch.version.hip is set, torch.__version__\",\n \"# is in the 2.4-2.9 range, and torch-c-dlpack-ext is installed. Outside\",\n \"# that range the extension raises a handled ImportError and this is not\",\n \"# the failure you are looking at. Then leave the subshell:\",\n \"exit\",\n \"# --- step 3 of 3, back in YOUR OWN shell ---\",\n \"# If all three held, put the engine's pinned torch back. Do NOT run\",\n \"# this from inside the subshell: it replaces the environment that\",\n \"# shell is standing in.\",\n \"rocm engines install vllm --reinstall\"\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-17-torch-dlpack\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [\n \"Running vLLM on ROCm is not by itself a reason to apply this. The trigger is narrow: a ROCm build of torch in the 2.4-2.9 range (the versions torch-c-dlpack-ext ships prebuilts for), torch without a native __dlpack_c_exchange_api__, and torch-c-dlpack-ext present -- it arrives as a transitive dependency of tilelang, which vLLM pins.\",\n \"The usual way a runtime lands in that range is `rocm install sdk` being re-run after the engine was installed, which overwrites the engine's pinned torch. Reinstalling the engine puts the pin back.\",\n \"The defect is upstream and there is nothing to correct locally: torch-c-dlpack-ext picks its variant from torch.cuda.is_available(), which is True on ROCm because PyTorch reuses the torch.cuda namespace for HIP, and it ships no ROCm variant to pick. tvm_ffi imports it as optional but guards only ImportError/AttributeError, while ctypes.CDLL raises OSError -- so an explicitly optional import kills the process.\",\n \"A service that failed at startup is hidden from a plain `rocm services list`; pass --all to recover its id.\"\n ],\n \"verify\": \"rocm serve --engine vllm # then `rocm services list --all` and `rocm services logs ` to confirm the import no longer aborts\"\n }\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Container can't see /dev/kfd or /dev/dri/renderD*\",\n \"score\": 45,\n \"evidence\": [\n \"running inside a docker\",\n \"no /dev/dri/renderD* visible in the container\"\n ],\n \"fix\": {\n \"summary\": \"Re-launch the container with the AMD devices and the render group passed through.\",\n \"commands\": [\n \"# Docker / Podman flags AMD-recommends:\",\n \"docker run --rm -it \\\\\",\n \" --device=/dev/kfd \\\\\",\n \" --device=/dev/dri \\\\\",\n \" --group-add render \\\\\",\n \" --security-opt seccomp=unconfined \\\\\",\n \" --shm-size=8g \\\\\",\n \" rocm/pytorch:latest\",\n \"# Rootless podman: also pass `--userns=keep-id` and ensure the\",\n \"# host user is in the render group; podman maps it through.\"\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-10-container\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [\n \"Use rocm/pytorch or rocm/dev-ubuntu-22.04 as a known-good image. Mixing host ROCm + container ROCm versions is a separate footgun.\"\n ],\n \"verify\": \"rocminfo | head -n 5\"\n }\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Framework wheel built for a different ROCm major than the system\",\n \"score\": 25,\n \"evidence\": [\n \"ldopen failure\"\n ],\n \"fix\": {\n \"summary\": \"Reinstall the framework from the wheel index that matches the system ROCm major (or upgrade the system ROCm to match the wheel).\",\n \"commands\": [\n \"pip uninstall -y torch torchvision torchaudio\",\n \"# Install the index for the ROCm major `rocm examine` reports:\",\n \"pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm7.14\",\n \"# ROCm 10 has no released PyTorch index yet; it is on the nightly channel:\",\n \"pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm10.0\",\n \"# Then re-check:\",\n \"python -c \\\"import torch; print(torch.__version__, torch.version.hip)\\\"\"\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-8-wheel-rocm\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [],\n \"verify\": \"python -c \\\"import torch; print(torch.cuda.is_available(), torch.version.hip)\\\"\"\n }\n }\n ],\n \"has_match\": true,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "#1 (fix-19-shm-too-small) [LIKELY score=70/100] shared memory allowance too small for a serving workload\n id: fix-19-shm-too-small\n - 64.0 MiB is the whole shared-memory allowance, and a serving workload needs gigabytes\n - this is a docker container, whose default allowance is 64 MiB\n plan: Raise the shared-memory allowance before running the workload.\n $ # In a container: restart it with a larger allowance.\n $ # docker run --shm-size=8g ... # see fix-10-container\n $ # On a host: remount it, and make that survive a reboot.\n $ sudo mount -o remount,size=8g /dev/shm\n $ # /etc/fstab: tmpfs /dev/shm tmpfs defaults,size=8g 0 0\n flags: requires sudo, manual only (`rocm fix` will NOT run it automatically)\n note: A running container cannot have its allowance changed; it has to be started again.\n note: This is reported below 1.0 GiB. Silence is not proof of enough: a container given 2 GiB clears that bar and can still be too small for a large model.\n verify after fix: df -h /dev/shm\n apply with: rocm fix fix-19-shm-too-small\n\n#2 (fix-17-torch-dlpack) [LIKELY score=50/100] vLLM engine start aborts on torch-c-dlpack-ext loading its CUDA variant\n id: fix-17-torch-dlpack\n - error names libtorch_cuda.so, which a ROCm build of torch does not ship\n plan: Only if the engine's runtime holds a ROCm build of torch in the 2.4-2.9 range with torch-c-dlpack-ext installed: reinstall the engine so its pinned torch is restored, which moves torch off the versions the extension ships prebuilts for.\n $ # --- step 1 of 3, in YOUR shell ---\n $ # Opens an INTERACTIVE subshell with the engine's environment active,\n $ # and does not return until you leave it. Run this line on its own.\n $ rocm engines shell vllm\n $ # --- step 2 of 3, INSIDE the subshell step 1 opened ---\n $ # Confirm the trigger before changing anything. It has to be the\n $ # ENGINE's interpreter, not the one on your PATH -- they are different\n $ # interpreters, and only the engine's decides this failure.\n $ python -c \"import torch; print(torch.__version__, torch.version.hip)\"\n $ python -c \"import importlib.metadata as m; print(m.version('torch-c-dlpack-ext'))\"\n $ # This entry applies ONLY when torch.version.hip is set, torch.__version__\n $ # is in the 2.4-2.9 range, and torch-c-dlpack-ext is installed. Outside\n $ # that range the extension raises a handled ImportError and this is not\n $ # the failure you are looking at. Then leave the subshell:\n $ exit\n $ # --- step 3 of 3, back in YOUR OWN shell ---\n $ # If all three held, put the engine's pinned torch back. Do NOT run\n $ # this from inside the subshell: it replaces the environment that\n $ # shell is standing in.\n $ rocm engines install vllm --reinstall\n flags: manual only (`rocm fix` will NOT run it automatically)\n note: Running vLLM on ROCm is not by itself a reason to apply this. The trigger is narrow: a ROCm build of torch in the 2.4-2.9 range (the versions torch-c-dlpack-ext ships prebuilts for), torch without a native __dlpack_c_exchange_api__, and torch-c-dlpack-ext present -- it arrives as a transitive dependency of tilelang, which vLLM pins.\n note: The usual way a runtime lands in that range is `rocm install sdk` being re-run after the engine was installed, which overwrites the engine's pinned torch. Reinstalling the engine puts the pin back.\n note: The defect is upstream and there is nothing to correct locally: torch-c-dlpack-ext picks its variant from torch.cuda.is_available(), which is True on ROCm because PyTorch reuses the torch.cuda namespace for HIP, and it ships no ROCm variant to pick. tvm_ffi imports it as optional but guards only ImportError/AttributeError, while ctypes.CDLL raises OSError -- so an explicitly optional import kills the process.\n note: A service that failed at startup is hidden from a plain `rocm services list`; pass --all to recover its id.\n verify after fix: rocm serve --engine vllm # then `rocm services list --all` and `rocm services logs ` to confirm the import no longer aborts\n apply with: rocm fix fix-17-torch-dlpack\n\n#3 (fix-10-container) [WEAK score=45/100] Container can't see /dev/kfd or /dev/dri/renderD*\n id: fix-10-container\n - running inside a docker\n - no /dev/dri/renderD* visible in the container\n plan: Re-launch the container with the AMD devices and the render group passed through.\n $ # Docker / Podman flags AMD-recommends:\n $ docker run --rm -it \\\n $ --device=/dev/kfd \\\n $ --device=/dev/dri \\\n $ --group-add render \\\n $ --security-opt seccomp=unconfined \\\n $ --shm-size=8g \\\n $ rocm/pytorch:latest\n $ # Rootless podman: also pass `--userns=keep-id` and ensure the\n $ # host user is in the render group; podman maps it through.\n flags: manual only (`rocm fix` will NOT run it automatically)\n note: Use rocm/pytorch or rocm/dev-ubuntu-22.04 as a known-good image. Mixing host ROCm + container ROCm versions is a separate footgun.\n verify after fix: rocminfo | head -n 5\n apply with: rocm fix fix-10-container\n\n#4 (fix-8-wheel-rocm) [WEAK score=25/100] Framework wheel built for a different ROCm major than the system\n id: fix-8-wheel-rocm\n - ldopen failure\n plan: Reinstall the framework from the wheel index that matches the system ROCm major (or upgrade the system ROCm to match the wheel).\n $ pip uninstall -y torch torchvision torchaudio\n $ # Install the index for the ROCm major `rocm examine` reports:\n $ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm7.14\n $ # ROCm 10 has no released PyTorch index yet; it is on the nightly channel:\n $ pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm10.0\n $ # Then re-check:\n $ python -c \"import torch; print(torch.__version__, torch.version.hip)\"\n flags: manual only (`rocm fix` will NOT run it automatically)\n verify after fix: python -c \"import torch; print(torch.cuda.is_available(), torch.version.hip)\"\n apply with: rocm fix fix-8-wheel-rocm\n\nHighest-scoring match is below the HIGH_CONFIDENCE threshold. Confirm one more piece of evidence before applying.\nWhen you are ready, run `rocm fix fix-19-shm-too-small` (the highest-scoring match), or use the `apply with:` line of whichever cause fits.\n", + "stderr": "", + "rc": 0 + }, + "examine_json": { + "stdout": "{\n \"os_family\": \"linux\",\n \"os_version\": \"6.8.0\",\n \"distro_id\": \"ubuntu\",\n \"distro_version\": \"24.04\",\n \"distro_id_like\": \"\",\n \"kernel_release\": \"6.8.0-generic\",\n \"kernel_cmdline\": \"\",\n \"is_wsl\": false,\n \"wsl\": null,\n \"cpu_vendor\": \"AuthenticAMD\",\n \"cpu_model\": \"\",\n \"gpus\": [\n {\n \"name\": \"AMD Radeon RX 7900 XTX\",\n \"gfx_target\": \"gfx1100\",\n \"pci_id\": \"0000:c3:00.0\",\n \"is_apu\": false,\n \"is_amd\": true\n }\n ],\n \"has_amd_gpu\": true,\n \"has_nvidia_gpu\": false,\n \"has_apu\": false,\n \"has_discrete_amd\": true,\n \"amdgpu_loaded\": null,\n \"amdgpu_blacklisted_in\": [],\n \"amdkfd_loaded\": null,\n \"secure_boot\": \"unknown\",\n \"iommu_kernel_param\": \"\",\n \"kfd\": null,\n \"render_devices\": [],\n \"user_name\": \"\",\n \"user_groups\": [],\n \"in_render_group\": null,\n \"in_video_group\": null,\n \"rocm_version\": \"\",\n \"rocm_install_method\": \"\",\n \"rocm_path\": \"\",\n \"rocminfo_present\": false,\n \"rocminfo_status\": \"\",\n \"hip_libs_on_ld_path\": null,\n \"rocm_repos_seen\": [],\n \"comgr_paths\": [],\n \"comgr_selected\": null,\n \"comgr_version\": \"\",\n \"comgr_matches_runtime\": null,\n \"hip_paths\": [],\n \"hip_selected\": null,\n \"hip_sdk_path\": \"\",\n \"hip_sdk_version\": \"\",\n \"hipinfo_present\": false,\n \"hipinfo_status\": \"\",\n \"adrenalin_version\": \"\",\n \"adrenalin_date\": \"\",\n \"msvc_redist_present\": null,\n \"msvc_redist_version\": \"\",\n \"framework\": \"unknown\",\n \"framework_version\": \"\",\n \"framework_rocm_version\": \"\",\n \"framework_arch_list\": [],\n \"framework_notes\": [],\n \"framework_source\": \"\",\n \"env\": {},\n \"in_container\": true,\n \"container_kind\": \"docker\",\n \"shm_total_bytes\": 67108864,\n \"shm_available_bytes\": 67108864,\n \"dmesg_amdgpu_tail\": [],\n \"notes\": [],\n \"probe_failures\": [],\n \"status\": \"ok\"\n}\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-ollama-routes-upstream/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-ollama-routes-upstream/replies.json new file mode 100644 index 0000000000..25a92fe4ef --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-ollama-routes-upstream/replies.json @@ -0,0 +1,22 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [],\n \"has_match\": false,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "rocm diagnose: no known misconfiguration matched.\n\nThis is the explicit 'I don't recognise this failure mode' case. Do not speculate; file the symptom + this examination output upstream:\n rocm-core: https://github.com/ROCm/ROCm/issues\n\nInclude the JSON from `rocm examine --json` in your report.\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-serve-failure-routes-to-this-project/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-serve-failure-routes-to-this-project/replies.json new file mode 100644 index 0000000000..25a92fe4ef --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-serve-failure-routes-to-this-project/replies.json @@ -0,0 +1,22 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [],\n \"has_match\": false,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "rocm diagnose: no known misconfiguration matched.\n\nThis is the explicit 'I don't recognise this failure mode' case. Do not speculate; file the symptom + this examination output upstream:\n rocm-core: https://github.com/ROCm/ROCm/issues\n\nInclude the JSON from `rocm examine --json` in your report.\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-symptom-with-shell-metacharacters/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-symptom-with-shell-metacharacters/replies.json new file mode 100644 index 0000000000..eb84daea58 --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-symptom-with-shell-metacharacters/replies.json @@ -0,0 +1,22 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework's build arch list\",\n \"score\": 40,\n \"evidence\": [\n \"error mentions 'invalid device function'\"\n ],\n \"fix\": {\n \"summary\": \"Reinstall the framework from a wheel index that includes this GPU's gfx target. Use HSA_OVERRIDE_GFX_VERSION ONLY as a temporary workaround when no native wheel exists.\",\n \"commands\": [\n \"# Recommended: a PyTorch ROCm nightly, which often carries kernels a\",\n \"# release has not shipped yet. Pick the nightly for the ROCm major you\",\n \"# have, not an older one.\",\n \"pip uninstall -y torch torchvision torchaudio\",\n \"pip install --pre torch torchvision torchaudio \\\\\\n --index-url https://download.pytorch.org/whl/nightly/rocm7.14\",\n \"# llama.cpp: rebuild with AMDGPU_TARGETS set to this GPU's gfx.\",\n \"# cmake -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=\"\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"fix_id\": \"fix-1-arch\",\n \"auto_applicable\": false,\n \"class\": \"print-only\",\n \"notes\": [\n \"TheRock (rocm/TheRock) ships nightly per-gfx wheels and is the preferred fallback when the official pytorch wheel index does not yet cover your gfx target.\"\n ],\n \"verify\": \"python -c \\\"import torch; print(torch.cuda.is_available(), torch.cuda.get_arch_list())\\\"\"\n }\n }\n ],\n \"has_match\": false,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "#1 (fix-1-arch) [WEAK score=40/100] GPU gfx target not in framework's build arch list\n id: fix-1-arch\n - error mentions 'invalid device function'\n plan: Reinstall the framework from a wheel index that includes this GPU's gfx target. Use HSA_OVERRIDE_GFX_VERSION ONLY as a temporary workaround when no native wheel exists.\n $ # Recommended: a PyTorch ROCm nightly, which often carries kernels a\n $ # release has not shipped yet. Pick the nightly for the ROCm major you\n $ # have, not an older one.\n $ pip uninstall -y torch torchvision torchaudio\n $ pip install --pre torch torchvision torchaudio \\\n --index-url https://download.pytorch.org/whl/nightly/rocm7.14\n $ # llama.cpp: rebuild with AMDGPU_TARGETS set to this GPU's gfx.\n $ # cmake -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=\n flags: manual only (`rocm fix` will NOT run it automatically)\n note: TheRock (rocm/TheRock) ships nightly per-gfx wheels and is the preferred fallback when the official pytorch wheel index does not yet cover your gfx target.\n verify after fix: python -c \"import torch; print(torch.cuda.is_available(), torch.cuda.get_arch_list())\"\n apply with: rocm fix fix-1-arch\n\nHighest-scoring match is below the HIGH_CONFIDENCE threshold. Confirm one more piece of evidence before applying.\nWhen you are ready, run `rocm fix fix-1-arch` (the highest-scoring match), or use the `apply with:` line of whichever cause fits.\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/fixtures/rocm-vllm-failure-in-words-asks-for-the-error-line/replies.json b/skills/rocm-doctor/evals/fixtures/rocm-vllm-failure-in-words-asks-for-the-error-line/replies.json new file mode 100644 index 0000000000..25a92fe4ef --- /dev/null +++ b/skills/rocm-doctor/evals/fixtures/rocm-vllm-failure-in-words-asks-for-the-error-line/replies.json @@ -0,0 +1,22 @@ +{ + "version": { + "stdout": "rocm-cli 0.1.0 (recorded for evals)\n", + "stderr": "", + "rc": 0 + }, + "fix_json": { + "stdout": "{\n \"contract_version\": 1,\n \"entries\": [\n {\n \"id\": \"fix-1-arch\",\n \"title\": \"GPU gfx target not in framework arch list\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-2-unset-override\",\n \"title\": \"Unset HSA_OVERRIDE_GFX_VERSION\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-3-rocm-kernel\",\n \"title\": \"ROCm/distro/kernel triple unsupported\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-4-render-group\",\n \"title\": \"Add user to render/video groups\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": true\n },\n {\n \"id\": \"fix-5-amdgpu-load\",\n \"title\": \"Load amdgpu (and clear any blacklist)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-6-path\",\n \"title\": \"Add the ROCm/HIP bin directory to PATH\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"auto\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"auto\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-7-stale-repos\",\n \"title\": \"Quarantine duplicate AMD repos\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-8-wheel-rocm\",\n \"title\": \"Reinstall the framework against the system ROCm/HIP major\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n },\n {\n \"id\": \"fix-9-igpu-dgpu\",\n \"title\": \"Hide the iGPU with HIP_VISIBLE_DEVICES\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"needs-argument\",\n \"needs\": \"--device-index\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-10-container\",\n \"title\": \"Re-launch the container with AMD devices passed through\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-11-iommu\",\n \"title\": \"Add iommu=pt to the kernel command line\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-12-installer\",\n \"title\": \"Reset repo-native install state and reinstall\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": true,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-13-hip-sdk-missing\",\n \"title\": \"Install the AMD HIP SDK for Windows\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html\"\n },\n {\n \"id\": \"fix-14-adrenalin-too-old\",\n \"title\": \"Update the Adrenalin / kernel-mode driver\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-windows/en/latest/install/install.html\"\n },\n {\n \"id\": \"fix-15-msvc-redist\",\n \"title\": \"Install the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-16-vllm-oom\",\n \"title\": \"vLLM ran the GPU out of memory at startup\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-17-torch-dlpack\",\n \"title\": \"Restore the engine's pinned torch (torch-c-dlpack-ext loads the CUDA variant)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-1-gpu-not-exposed\",\n \"title\": \"Expose the GPU to the WSL distro (/dev/dxg)\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-2-dxcore-missing\",\n \"title\": \"Restore the WSL DXCore libraries\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-3-rocdxg-missing\",\n \"title\": \"Install ROCDXG in the WSL distro\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-4-rocdxg-not-linked\",\n \"title\": \"Refresh the linker cache so ROCDXG is loadable\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-5-distro-too-old\",\n \"title\": \"Move to a distro release the WSL path supports\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-6-host-driver-too-old\",\n \"title\": \"Update the AMD driver on the Windows host\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-wsl-7-wsl1\",\n \"title\": \"Convert the distro from WSL 1 to WSL 2\",\n \"platforms\": [\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-18-comgr-conflict\",\n \"title\": \"Code object manager library does not belong to the active HIP runtime\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-19-shm-too-small\",\n \"title\": \"Raise the shared memory allowance\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"print-only\"\n },\n {\n \"os\": \"wsl\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": true,\n \"needs_reboot\": false,\n \"needs_relogin\": false\n },\n {\n \"id\": \"fix-21-msvc-redist-outdated\",\n \"title\": \"Update the MSVC 2015-2022 runtime redistributable\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://aka.ms/vs/17/release/vc_redist.x64.exe\"\n },\n {\n \"id\": \"fix-22-display-driver-old\",\n \"title\": \"Look for a newer AMD display driver (advice only)\",\n \"platforms\": [\n {\n \"os\": \"windows\",\n \"class\": \"print-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": true,\n \"needs_relogin\": false,\n \"doc_url\": \"https://www.amd.com/en/support\"\n },\n {\n \"id\": \"info-20-gpu-no-rocm-support\",\n \"title\": \"GPU has no ROCm/HIP support (Vulkan backend still works)\",\n \"platforms\": [\n {\n \"os\": \"linux\",\n \"class\": \"diagnose-only\"\n },\n {\n \"os\": \"windows\",\n \"class\": \"diagnose-only\"\n }\n ],\n \"needs_sudo\": false,\n \"needs_reboot\": false,\n \"needs_relogin\": false,\n \"doc_url\": \"https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html\"\n }\n ],\n \"exit_codes\": {\n \"declined\": 5,\n \"failed\": 4,\n \"internal\": 1,\n \"not_applicable\": 3,\n \"ok\": 0,\n \"unknown_id\": 2\n }\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_json": { + "stdout": "{\n \"matched\": [],\n \"has_match\": false,\n \"min_score_for_match\": 50,\n \"high_confidence_threshold\": 75,\n \"route_when_no_match\": {\n \"target\": \"rocm-core\",\n \"url\": \"https://github.com/ROCm/ROCm/issues\"\n },\n \"out_of_scope\": null,\n \"model\": null\n}\n", + "stderr": "", + "rc": 0 + }, + "diagnose_text": { + "stdout": "rocm diagnose: no known misconfiguration matched.\n\nThis is the explicit 'I don't recognise this failure mode' case. Do not speculate; file the symptom + this examination output upstream:\n rocm-core: https://github.com/ROCm/ROCm/issues\n\nInclude the JSON from `rocm examine --json` in your report.\n", + "stderr": "", + "rc": 0 + } +} diff --git a/skills/rocm-doctor/evals/hooks.py b/skills/rocm-doctor/evals/hooks.py index 5358395095..02f997d537 100644 --- a/skills/rocm-doctor/evals/hooks.py +++ b/skills/rocm-doctor/evals/hooks.py @@ -8,7 +8,10 @@ The stub replays recorded output and nothing else. It answers `--version`, `fix --json` and `diagnose`, and `examine --json` for a case whose recording has -one, and refuses every other command with exit code 2. +one, and refuses every other command with exit code 2. A case whose recording +has an `apply` entry also gets `rocm fix ` for that id, with `--dry-run` (before or +after the id) and with no flag; `--yes` is never answered, so an agent that applies before the user +said OK meets a refusal and the transcript shows the command. It only ever prints text read from `replies.json`, so whatever an agent asks it, it cannot change a machine or send anything: that comes from the allowlist, not from the refusal of `diagnose` options below, which is there for fidelity (see @@ -50,6 +53,7 @@ replies = json.loads( (Path(__file__).resolve().parent / "replies.json").read_text(encoding="utf-8") ) +apply = replies.get("apply") args = sys.argv[1:] # Fidelity only, not safety (the allowlist below already makes the stub inert). # The one recorded `diagnose` answer is for the symptom the case was recorded @@ -75,9 +79,17 @@ def reply(entry): reply(replies["diagnose_json" if "--json" in args else "diagnose_text"]) elif args == ["examine", "--json"] and "examine_json" in replies: reply(replies["examine_json"]) +elif apply and args in ( + ["fix", apply["fix_id"], "--dry-run"], + ["fix", "--dry-run", apply["fix_id"]], +): + reply(apply["dry_run"]) +elif apply and args == ["fix", apply["fix_id"]]: + reply(apply["bare"]) sys.stderr.write( "error: this evaluation replays only `--version`, `fix --json`, `diagnose` " - "and, where recorded, `examine --json`; it runs nothing else\n" + "and, where recorded, `examine --json` and `fix ` with `--dry-run` or no " + "flag; it runs nothing else\n" ) sys.exit(2) """ diff --git a/skills/rocm-doctor/evals/test_hooks.py b/skills/rocm-doctor/evals/test_hooks.py index a1bb199886..c0a51a14d8 100644 --- a/skills/rocm-doctor/evals/test_hooks.py +++ b/skills/rocm-doctor/evals/test_hooks.py @@ -5,9 +5,11 @@ What they pin is the promise the docs make about the stub: it replays the recorded answer for `--version`, `fix --json` and `diagnose` (and `examine ---json` for a case whose recording has one), refuses every other command with -exit code 2, and leaves PATH and the temporary directory as it found them. It never runs anything (it only prints canned text); the refusal -of unrecorded `diagnose` options is about fidelity. +--json` for a case whose recording has one, and `fix ` with `--dry-run` or +no flag for a case whose recording has an `apply` entry), refuses every other command with exit +code 2, and leaves PATH and the temporary directory as it found them. It never +runs anything (it only prints canned text); the refusal of unrecorded `diagnose` +options is about fidelity. """ import importlib.util @@ -87,6 +89,21 @@ def test_a_replayed_command_prints_the_recorded_reply_and_exits_0(self): done.stdout.replace("\r\n", "\n"), RECORDED[key]["stdout"] ) + def test_the_equals_form_of_symptom_is_answered_whatever_the_paste_holds(self): + # The skill passes the paste as `--symptom=''`. What the paste says + # is not an option of the command: text naming `--model` or `--send`, or + # one that begins with `-`, must not be mistaken for one. + for paste in ["$(id) `id`", "-1073741819", "see --send and --model=x"]: + with self.subTest(paste=paste): + done = rocm(f"--symptom={paste}", "diagnose", "--json") + self.assertEqual(done.returncode, 2, "the verb comes first") + done = rocm("diagnose", f"--symptom={paste}", "--json") + self.assertEqual(done.returncode, 0, done.stderr) + self.assertEqual( + done.stdout.replace("\r\n", "\n"), + RECORDED["diagnose_json"]["stdout"], + ) + def test_git_bash_on_windows_finds_the_stub_not_a_real_rocm(self): # Git Bash does not look for `rocm.cmd`; without the extensionless # launcher it would run a real `rocm` further along PATH. @@ -191,6 +208,81 @@ def test_the_plain_examine_form_is_still_refused(self): self.assertIn("runs nothing else", done.stderr) +APPLY_CASE = "rocm-apply-auto-fix-needs-consent" +APPLY = json.loads( + (HERE / "fixtures" / APPLY_CASE / "replies.json").read_text(encoding="utf-8") +)["apply"] + + +class ApplyReplay(unittest.TestCase): + """A case whose recording has an `apply` entry gets `rocm fix ` for that id + with `--dry-run` and with no flag, and never for `--yes` or another id.""" + + def setUp(self): + self.saved = os.environ["PATH"] + self.case = types.SimpleNamespace(id=APPLY_CASE) + self.ctx = {} + hooks.setup(None, self.case, self.ctx) + + def tearDown(self): + hooks.teardown(None, self.case, self.ctx) + os.environ["PATH"] = self.saved + + def test_the_dry_run_prints_the_recorded_change_and_exits_0(self): + # The real command takes the flag before or after the id. + for args in ( + ["fix", APPLY["fix_id"], "--dry-run"], + ["fix", "--dry-run", APPLY["fix_id"]], + ): + with self.subTest(args=args): + done = rocm(*args) + self.assertEqual(done.returncode, APPLY["dry_run"]["rc"]) + self.assertEqual(done.returncode, 0) + self.assertEqual( + done.stdout.replace("\r\n", "\n"), APPLY["dry_run"]["stdout"] + ) + self.assertEqual( + done.stderr.replace("\r\n", "\n"), APPLY["dry_run"]["stderr"] + ) + + def test_the_bare_command_is_refused_the_way_a_shell_without_a_terminal_is(self): + done = rocm("fix", APPLY["fix_id"]) + self.assertEqual(done.returncode, APPLY["bare"]["rc"]) + self.assertEqual(done.returncode, 5) + self.assertEqual(done.stdout.replace("\r\n", "\n"), APPLY["bare"]["stdout"]) + # The plan is shown before the refusal, as the real command does. + self.assertIn("Commands:", done.stdout) + self.assertEqual(done.stderr.replace("\r\n", "\n"), APPLY["bare"]["stderr"]) + self.assertIn("refusing to apply", done.stderr) + + def test_applying_with_yes_is_never_answered(self): + for args in ( + ["fix", APPLY["fix_id"], "--yes"], + ["fix", APPLY["fix_id"], "--dry-run", "--yes"], + ["fix", "--yes", APPLY["fix_id"]], + ["fix", "--dry-run", "--yes", APPLY["fix_id"]], + ["fix", "fix-9-igpu-dgpu", "--dry-run"], + ["fix", "--dry-run", "fix-9-igpu-dgpu"], + # A different id gets no plan without a flag either. + ["fix", "fix-9-igpu-dgpu"], + ): + with self.subTest(args=args): + done = rocm(*args) + self.assertEqual(done.returncode, 2, done.stderr) + self.assertEqual(done.stdout, "") + self.assertIn("runs nothing else", done.stderr) + + def test_a_case_with_no_apply_entry_gets_no_fix_id(self): + # Only a case whose recording has an `apply` entry gets the commands. + hooks.teardown(None, self.case, self.ctx) + other = types.SimpleNamespace(id="rocm-current-cli-carries-on") + hooks.setup(None, other, self.ctx) + self.case = other + done = rocm("fix", APPLY["fix_id"], "--dry-run") + self.assertEqual(done.returncode, 2, done.stderr) + self.assertEqual(done.stdout, "") + + class Overlap(unittest.TestCase): def test_a_second_replay_while_one_is_active_is_refused(self): saved = os.environ["PATH"] diff --git a/skills/rocm-doctor/reference.md b/skills/rocm-doctor/reference.md index b6da05de3e..21af4dadf8 100644 --- a/skills/rocm-doctor/reference.md +++ b/skills/rocm-doctor/reference.md @@ -1,8 +1,18 @@ # ROCm Doctor — reference -The closed failure-mode catalog and the CLI it drives. The catalog is -authoritative in the `rocm` CLI (`crates/rocm-core`); this file mirrors it for -humans. To add or change a failure mode, change the CLI catalog — not this doc. +The closed failure-mode catalog and the CLI fields the skill reads. The catalog is +authoritative in the `rocm` CLI; where this file and what the CLI prints +disagree, the CLI is right. What to do with a diagnosis is in +[SKILL.md](SKILL.md); this file carries the shapes, and the few directives that +belong to one field. + +## Contents + +- CLI commands — `rocm examine`, `rocm diagnose` (its fields and the `model` + object), `rocm fix` +- Closed catalog — every failure mode, the platforms it applies to, and what + `rocm fix` does with it +- Framework routing — what `route_when_no_match` returns ## CLI commands @@ -11,52 +21,66 @@ humans. To add or change a failure mode, change the CLI catalog — not this doc Inspect the host: GPU + gfx target, driver, ROCm install, render/video groups, `/dev/kfd` + render devices, kernel modules, framework introspection, recent amdgpu kernel-log evidence. `--json` emits the **Examination** document for -tooling. - -- It's a general system inspector, so it **always exits 0**. The verdict is the - `status` field: `ok` · `no-amd-gpu` · `wsl` · `unsupported-os` · `degraded`. - -### `rocm diagnose [--symptom ""] [--top N] [--json] [--distro [NAME]] [--model REF [--context-size N] [--kv-cache-type f16|q8_0|q4_0]]` - -Match the host + symptom against the closed catalog. **Always exits 0**; read -the result from `--json`: - -- `matched[]` — ranked `{ id, title, score, evidence[], fix }`. Tiers: - `>= 75` high confidence, `50–74` likely, `< 50` weak. - **Check `fix.class` before proposing anything.** `diagnose-only` means the - cause is explained and has no remedy — currently only - `info-20-gpu-no-rocm-support`, which carries an `info-` id rather than a - `fix-N` / `fix-wsl-N` one for that reason. It is a catalog entry like any - other: `rocm fix info-20-gpu-no-rocm-support` names the problem, says there - is no reliable fix and exits 0 without touching the machine. Report its - `evidence`; do not go looking for something to apply instead. -- `has_match` — whether any entry cleared `min_score_for_match`. **This is the - gate, not whether `matched` is empty.** Several checkers open with a nonzero - base score for a merely *potentially* relevant situation (running in a - container, an APU alongside a discrete GPU), so a healthy host produces a - non-empty `matched` full of sub-threshold entries. Gating on emptiness - proposes a fix for a machine with nothing wrong and never routes upstream. - The exception is an **advice-only** entry (today `fix-22-display-driver-old`): - it scores below the threshold on purpose, so it never sets `has_match`, yet it - is advice worth giving. Relay the entry's `title` and `evidence` to the user as - advice and never apply it automatically. It does not answer the symptom, so route - upstream as usual when `has_match` is false. +tooling; the groups and the framework are in it only. + +- It reports the host and does not judge it, so a finding such as no GPU still + exits 0. The verdict is the `status` field: `ok` · `no-amd-gpu` · `wsl` · `unsupported-os` · `degraded`. + A non-zero exit means the command could not examine the host at all. + +### `rocm diagnose [--symptom TEXT] [--top N] [--json] [--distro [NAME] | --report [--send]]` + +Match the host + symptom against the closed catalog. It exits 0 whether it +matched, found nothing or is out of scope, so read the result from `--json`. A +non-zero exit is an error from the command itself, such as a usage error, or +`--model` together with `--distro`, which is refused because the model verdict is +about the machine running the command and not the one `--distro` names. + +`rocm diagnose --model REF [--context-size N] [--kv-cache-type f16|q8_0|q4_0] [--json]` +adds the `model` object below. + +`--top N` limits the text report to N matches; the JSON is not limited by it. +`--distro [NAME]` diagnoses a WSL distribution from the Windows host: its result +describes the distribution, and its fixes are not run from the host +([SKILL.md](SKILL.md), step 3). It examines the distribution's WSL facts only: +checks that read its own framework, ROCm version, environment, `/dev/shm` or +library selection do not run, so `has_match` false there is weaker than it reads; +for a full diagnosis run `rocm diagnose` inside the distribution. `--report` +prints the report this machine would contribute and sends nothing, and `--send` +(which needs `--report` and cannot be combined with `--json`) adds a prefilled +mail the user sends from their own account. With `--report` the model is not +assessed at all and nothing is fetched; a note on stderr names the model flags +that were ignored. + +- `matched[]` — ranked `{ id, title, score, evidence[], fix }`; scores run 0 to 100. + The `fix` fields SKILL.md acts on are named in its step 1. `class` + is what `rocm fix ` does on the machine the diagnosis describes + ([SKILL.md](SKILL.md), step 3; the classes are listed under Marker in the + catalog). `needs` is present only when the entry has one: the argument a + `needs-argument` entry waits for. A `diagnose-only` entry carries an `info-` id + rather than a `fix-N` / `fix-wsl-N` one because it has no fix to offer; + `rocm fix` still takes that id and answers for it. +- `has_match` — whether any entry cleared `min_score_for_match`; the gate for acting + on `matched` ([SKILL.md](SKILL.md), step 1). - `min_score_for_match` (50), `high_confidence_threshold` (75). -- `out_of_scope` — set when the host's platform family has **no catalog entries - at all**, in which case `matched` is empty. Linux, Windows and WSL2 are all - covered, so this now fires only for a platform outside those three. It means - nothing was checked — not a clean bill of health. -- `route_when_no_match` — `{ target, url }` upstream tracker to use when `has_match` is false. +- `out_of_scope` — set when the host's platform family has no catalog entries at all, + and then `matched` is empty. Linux, Windows and WSL2 each have entries, so it does + not fire on them. +- `route_when_no_match` — `{ target, url }`, the upstream tracker for when + `has_match` is false. [Framework routing](#framework-routing) lists what it returns. - `model` — set only when `--model ` was passed; otherwise not set. Answers "will this model run here", without downloading the weights: for a curated model from the recipe catalog and this host's GPU/RAM, and for a GGUF outside - the catalog with an `estimate` from its file header (below). Its fields: - `{ verdict, evidence[], engine, required_gpu_memory_gib, - available_gpu_memory_gib, alternatives[], undetermined_reason, fix }`. `verdict` is one of `ready`, `degraded`, - `blocked`, `undetermined` — treat `undetermined` as "the CLI could not find - out", never as evidence the model is incompatible. `--model` is refused - together with `--distro`: the verdict is about the machine running the - command, not the one `--distro` names. + the catalog with an `estimate` from its file header (below). Its fields include + `verdict`, `evidence[]`, `alternatives[]`, `undetermined_reason`, `warnings[]`, + `fix` and `route`; `warnings[]` carries, for a GGUF estimate that was + compared with the GPU, the standing note on which options `rocm serve` does not + take. `verdict` is one of `ready`, `degraded`, `blocked`, + `undetermined` — treat `undetermined` as "the CLI could not find out", never as + evidence the model is incompatible. `alternatives[]` are curated models, each with the `model_ref` to pass to `rocm serve`. `model.fix` has + the shape of a diagnosis `fix` with an empty `fix_id`: no catalog entry stands + behind it, so `rocm fix` would reject one, and its steps are relayed rather than + applied. + `route` says where to report a model the CLI cannot answer for. For a GGUF outside the catalog (a local `.gguf` path, or `owner/repo:QUANT`) the verdict stays `undetermined` and an `estimate` object is added, sized from the file's header (the weights are never downloaded). Its fields, by group: @@ -82,72 +106,34 @@ the result from `--json`: free; `max_context` is the largest context that fits, capped at `training_context`, and is null when GPU memory was not measured, when no verdict is given (`unmeasured_layout`, or `missing_metadata` with figures), - and when not even one 256-token step fits); and what the figures leave out + and when not even one 256-token step fits; it can sit below `context_size` for an + outcome of `fits`); and what the figures leave out (`conservative_ceiling` says the ceiling is known to be conservative, `suggestions[]` what would make it fit, `notes[]` the caveats). - It is an estimate, not a tested minimum: report it as one. With `--report` - the model is not assessed at all and nothing is fetched; a note on stderr names - the model flags that were ignored. - `suggestions[]` name llama.cpp options; `rocm serve` does not take a context - size yet, so do not propose a `rocm serve` command for them. + It is an estimate, not a tested minimum: report it as one. + The CPU-fallback rule and what to do with a suggestion are in + [SKILL.md](SKILL.md), Rules. ### `rocm fix [] [--yes] [--dry-run] [--device-index N] [--json]` Apply a fix by id (run with no id to list). `rocm fix --json` with no id prints the catalog manifest instead: `contract_version`, one entry per fix, and the -exit-code map. It applies no fix and exits 0. The skill reads -`contract_version` before it diagnoses (Phase 0 in [SKILL.md](SKILL.md)). `--json` with an -id is refused, and the refusal exits 1 (see the table). Exit codes: - -| code | meaning | -| --- | --- | -| 0 | applied / dry-run / print-only plan / list | -| 1 | internal error; also the refusal of `--json` together with a fix id | -| 2 | usage error (incl. unknown fix-id) | -| 3 | not applicable on this host (OS mismatch, negative `--device-index`) — nothing changed | -| 4 | attempted but the command failed | -| 5 | user declined at the prompt | - -Three ids are ever auto-applicable — never four, and `fix-9-igpu-dgpu` is not -one of them (see below) — and which of the three depends on the **host**, -because `rocm fix`'s listing marks each entry for the machine you run it on, -never for every machine the id applies to: +`exit_codes` map from each exit's name to its number. It applies no fix and exits +0. The skill reads `contract_version` before it diagnoses (Phase 0 in +[SKILL.md](SKILL.md)). `--json` with an id is refused. What to do with an outcome +is in SKILL.md, step 3. + +Three ids are ever `auto`, and which of the three depends on the **host**, because +`rocm fix`'s listing marks each entry for the machine you run it on, never for +every machine the id applies to: - **linux** — auto-applicable: `fix-4-render-group`, `fix-6-path`. - **windows** — auto-applicable: `fix-2-unset-override`, `fix-6-path`. - **wsl** — auto-applicable: `fix-6-path`. -"Auto-applicable" here is the `auto` class on this host, the same as the -`fix.auto_applicable` flag in a diagnosis. `SKILL.md` counts a wider set, the -fixes that *have a runner*: these three ids plus `fix-9-igpu-dgpu`, whose runner -only prints the discrete-GPU query unless `--device-index N` is passed. The two -counts differ on purpose, and neither is wrong. - -The rest print their plan for the user to run. Pass the **full** id -(`rocm fix fix-2-unset-override`, not `rocm fix fix-2`; a short id returns -exit 2, unknown fix-id). - -**Marker** in the catalog below is what `rocm fix`'s listing reports **on -bare-metal Linux** — AUTO means the CLI has a runner for the entry and will -carry it out itself there, rather than printing a plan for the user. It is not -a promise that the runner mutates anything, and — per the per-host list above — it is -not the same claim on Windows or WSL2 for the one entry whose behaviour -depends on more than the host alone. - -The ones that do mutate print the exact command, honor `--dry-run`, refuse on a -non-interactive shell without `--yes`, and confirm first. **Two exceptions:** - -- **`fix-2-unset-override` mutates on Windows only.** Its Linux runner reports - where the override is set and which rc files carry it, then stops — it will - not edit your dotfiles. So on Linux it never prompts, `--dry-run` has nothing - to preview, and `--yes` is never read. Do not tell a Linux user a dry run - previewed a change that was never going to happen. -- **`fix-9-igpu-dgpu` needs `--device-index N` wherever it applies (Linux and - Windows) and is never marked AUTO.** Without the flag the runner just prints - the `rocminfo`/`hipInfo` query that identifies which index is the discrete - GPU and returns 0: no prompt, nothing for `--dry-run` to preview, nothing - pinned. Run `rocm fix fix-9-igpu-dgpu --device-index N` (not the bare id) - once you know N. +"Auto-applicable" is the `auto` class on that host, the same as the +`fix.auto_applicable` flag in a diagnosis. An entry whose class is `print-only` +prints its plan for the user to run. ## Closed catalog (29 failure modes) @@ -157,6 +143,17 @@ by naming `wsl`, so the bare-metal Linux entries (the `amdgpu` module, `/dev/kfd`, the render group) stop applying there automatically rather than reporting confident nonsense. +**Marker** is the class `rocm fix`'s listing reports **on bare-metal Linux**, in +the listing's spelling, lower-cased here: `auto`, `needs-arg`, `print-only` or +`diagnose-only`. `fix.class` in a diagnosis carries the same classes, with +`needs-arg` spelled `needs-argument` ([SKILL.md](SKILL.md), step 3, explains +each). A class can differ by platform, which the cell says where it does +(`fix-2-unset-override`). + +**Typical signal** is a short handle for what the check looks for, not a rule for +when it fires: the CLI's score and the entry's `evidence` decide, so read +`has_match` and `evidence`. + | id | OS | Failure mode | Typical signal | Marker (bare-metal Linux) | | --- | --- | --- | --- | --- | | `fix-1-arch` | linux/windows/wsl | GPU gfx target not in the framework's build arch list | `hipErrorNoBinaryForGpu`, `HSA_STATUS_ERROR_INVALID_ISA`, "invalid device function" | print-only | @@ -171,22 +168,22 @@ reporting confident nonsense. | `fix-10-container` | linux | Container can't see `/dev/kfd` or `/dev/dri/renderD*` | running in docker/podman, kfd/render devices missing | print-only | | `fix-11-iommu` | linux | Multi-GPU hang with IOMMU enabled | ≥2 AMD GPUs, `iommu=` not `pt`, hang/deadlock/timeout | print-only | | `fix-12-installer` | linux | Repo-native package-manager install left a broken DKMS / repo state | dpkg half-configured, DKMS build failure, dpkg/apt error | print-only | -| `fix-13-hip-sdk-missing` | windows | HIP SDK not installed | **something on the host actually calls into HIP** — an ambient (non-managed-runtime) PyTorch HIP build, or a `GGML_HIP=ON` llama.cpp, either way with a detected AMD GPU — **and** no HIP SDK under Program Files, or `hipInfo.exe` missing from its `bin`. A paste naming any of `amdhip64` not found, "could not find HIP", `HIP_PATH` not set, or `hipInfo` not recognized counts as calling into HIP on its own, with no GPU required. A Vulkan-backed engine (the Lemonade default) or a managed-runtime wheel needs no system SDK, so its absence is not evidence there | print-only | +| `fix-13-hip-sdk-missing` | windows | HIP SDK not installed | no HIP SDK under Program Files (or `hipInfo.exe` missing from its `bin`) while something on the host calls into HIP; `amdhip64` not found, `HIP_PATH` not set. A Vulkan-backed engine (the Lemonade default) or a managed-runtime wheel needs no system SDK, so its absence is not evidence there | print-only | | `fix-14-adrenalin-too-old` | windows | Adrenalin / kernel-mode driver too old for the HIP SDK | `hipInfo` can't enumerate, "driver too old", HSA "no agents found" | print-only | | `fix-15-msvc-redist` | windows | MSVC runtime missing (programs that link it, such as the HIP SDK DLLs and the llama.cpp server, can't load) | `vcruntime140.dll` / `vcruntime140_1.dll` missing | print-only | | `fix-16-vllm-oom` | linux/wsl | vLLM reserved ~90% of the GPU's TOTAL VRAM for its KV cache and ran out at startup | vLLM engine start fails with an out-of-memory error; the GPU is shared/busy, or the model does not fit | print-only | -| `fix-17-torch-dlpack` | linux/wsl | `torch-c-dlpack-ext` loads its CUDA prebuilt on a ROCm torch, aborting vLLM's engine start at import time | vLLM engine start fails on import; error names `libtorch_cuda.so` (enough on its own), or both `torch_c_dlpack_ext` and tvm_ffi's `_optional_torch_c_dlpack` | print-only | -| `fix-18-comgr-conflict` | linux/wsl | The code object manager library (`libamd_comgr`) that would load belongs to a different installation than the HIP runtime that would load, so device code compilation fails with an error naming neither | compilation error naming neither library; `rocm examine --json`'s `comgr_selected`/`hip_selected` resolve to two different `install_root`s | print-only | -| `fix-19-shm-too-small` | linux/wsl | `/dev/shm` too small for a serving workload, which needs gigabytes where a container and WSL2 both default to 64 MB | reported under 1 GiB; a data-loader worker killed by a bus error, or a failed write to a temporary file, with nothing naming shared memory | print-only | -| `info-20-gpu-no-rocm-support` | linux/windows | Every AMD GPU on the host is a part ROCm has never shipped a runtime build for (today: gfx90c, the Vega iGPU in Renoir / Lucienne / Cezanne / Barcelo). Vulkan-based engines still work | every detected AMD GPU identifies as an unsupported target, and none is unidentified; scores a flat 60 | diagnose-only | -| `fix-21-msvc-redist-outdated` | windows | MSVC runtime present but older than 14.40, so programs built with a recent toolset (such as the llama.cpp server that Lemonade installs) crash | `rocm examine --json` shows `msvc_redist_version` below 14.40; an access violation (`0xC0000005`, `-1073741819`) with `msvcp140.dll` as the faulting module | print-only | -| `fix-22-display-driver-old` | windows | The AMD display driver is dated before the first HIP SDK for Windows (27 July 2023). Advice only: AMD publishes no minimum driver version for the HIP SDK or the Lemonade Vulkan backend, so the minimum is not established and the entry never claims the driver is broken. The date is only a floor and cannot judge newer GPUs such as gfx120X, gfx1150 and gfx1151, which may need newer drivers | `rocm examine` shows `driver_age: older than the first HIP SDK for Windows`; the entry scores below the match threshold (WEAK) | print-only | +| `fix-17-torch-dlpack` | linux/wsl | `torch-c-dlpack-ext` loads its CUDA prebuilt on a ROCm torch, aborting vLLM's engine start at import time | vLLM engine start fails on import (`libtorch_cuda.so`) | print-only | +| `fix-18-comgr-conflict` | linux/wsl | The code object manager library (`libamd_comgr`) that would load belongs to a different installation than the HIP runtime that would load, so device code compilation fails with an error naming neither | a compilation error naming neither library; `comgr_selected` and `hip_selected` in `rocm examine --json` come from different installations | print-only | +| `fix-19-shm-too-small` | linux/wsl | `/dev/shm` too small for a serving workload, which needs gigabytes; fires wherever `/dev/shm` is under 1 GiB, and a container defaults to 64 MB | `/dev/shm` reported small; a data-loader worker killed by a bus error | print-only | +| `info-20-gpu-no-rocm-support` | linux/windows | Every AMD GPU on the host is a part ROCm has never shipped a runtime build for (gfx90c, the Vega iGPU in Renoir / Lucienne / Cezanne / Barcelo, is one). Vulkan-based engines still work | every detected AMD GPU identifies as an unsupported target | diagnose-only | +| `fix-21-msvc-redist-outdated` | windows | MSVC runtime present but older than 14.40, so programs built with a recent toolset (such as the llama.cpp server that Lemonade installs) crash | `msvc_redist_version` below 14.40 in `rocm examine --json`; an access violation (`0xC0000005`, `-1073741819`) in `msvcp140.dll` | print-only | +| `fix-22-display-driver-old` | windows | The AMD display driver is dated before the first HIP SDK for Windows (27 July 2023). Advice only: AMD publishes no minimum driver version for the HIP SDK or the Lemonade Vulkan backend, so the minimum is not established and the entry never claims the driver is broken. The date is only a floor and cannot judge newer GPUs such as gfx120X, gfx1150 and gfx1151, which may need newer drivers | `rocm examine` shows `driver_age: older than the first HIP SDK for Windows` | print-only | | `fix-wsl-1-gpu-not-exposed` | wsl | `/dev/dxg` absent, so the distro cannot reach the GPU at all | no `/dev/dxg`; in a container, the device was never passed through | print-only | | `fix-wsl-2-dxcore-missing` | wsl | `/usr/lib/wsl/lib` DXCore shims missing, so the runtime cannot reach the host driver | `/usr/lib/wsl/lib/libdxcore.so` missing (or the directory absent entirely) | print-only | | `fix-wsl-3-rocdxg-missing` | wsl | ROCDXG, the ROCm-to-DXCore shim the WSL path runs on, is not installed | `librocdxg.so` not found under any ROCm install | print-only | -| `fix-wsl-4-rocdxg-not-linked` | wsl | `librocdxg` installed but not in the linker cache, so it is unloadable | `librocdxg` present on disk yet absent from `ldconfig -p` and from the `LD_LIBRARY_PATH` of the shell running the check, and not beside a `libhsa-runtime64` | print-only | -| `fix-wsl-5-distro-too-old` | wsl | Distro release below the floor the WSL path requires | distro release under the supported floor (e.g. Ubuntu 22.04, whose glibc 2.35 is below the 2.38 / `GLIBCXX_3.4.32` the engines need) | print-only | -| `fix-wsl-6-host-driver-too-old` | wsl | Windows host driver too old or absent, with the distro side already complete | the Windows host reports no AMD display adapter | print-only | +| `fix-wsl-4-rocdxg-not-linked` | wsl | `librocdxg` installed but not in the linker cache, so it is unloadable | `librocdxg` installed but not found by the loader | print-only | +| `fix-wsl-5-distro-too-old` | wsl | Distro release below the floor the WSL path requires | an Ubuntu release under the supported floor (e.g. 22.04) | print-only | +| `fix-wsl-6-host-driver-too-old` | wsl | Windows host driver too old or absent | the Windows host reports no AMD display adapter; `rocminfo` enumerates no GPU although the distro side is in place | print-only | | `fix-wsl-7-wsl1` | wsl | Distro running under WSL 1, which exposes no GPU device at all | the running kernel is a WSL 1 kernel | print-only | One thing the numbering does not tell you: the `fix-wsl-N` entries are a parallel @@ -198,40 +195,15 @@ the number `fix-20` is simply not used here: slot 20 belongs to prefix because it has no fix to offer. A gap is not an error, and a retired entry would leave a hole rather than renumber the ones after it. -Linux-only: fix-3, -4, -5, -7, -10, -11, -12. Windows-only: fix-13, -14, -15, -21, -22. -Linux + Windows: info-20 (diagnose-only). -WSL-only: fix-wsl-1 through fix-wsl-7. Linux + Windows: fix-9. -Linux + WSL: fix-16, -17, -18, -19. Linux + Windows + WSL: fix-1, -2, -6, -8. - ## Framework routing `rocm diagnose` diagnoses frameworks built against the **system** ROCm/HIP: - -- **PyTorch**, **llama.cpp** — in scope. - -Apps that ship their own runtime are routed upstream **by the skill**, from the -table below. The CLI cannot do it: `route_when_no_match` keys off the -host-detected framework, which `rocm examine` only ever reports as `pytorch`, -`llama-cpp`, `unknown` or `skipped`, so it has no arm for these apps. - -- **Lemonade** → https://github.com/lemonade-sdk/lemonade/issues -- **Ollama** → https://github.com/ollama/ollama/issues -- **LM Studio** → in-app support (no public repo) +PyTorch and llama.cpp. Apps that ship their own runtime are routed upstream **by +the skill** ([SKILL.md](SKILL.md), Framework routing): the route the CLI returns +has no arm for them. `route_when_no_match` itself returns one of: - **pytorch** → https://github.com/pytorch/pytorch/issues (tag with the rocm label) - **llama-cpp** → https://github.com/ggml-org/llama.cpp/issues - otherwise **rocm-core** → https://github.com/ROCm/ROCm/issues - -## Out of scope - -- NVIDIA / Intel / Apple Silicon GPUs; fresh installs on a clean machine. - -WSL2 used to sit here and no longer does: it is a supported platform family with -its own seven catalog entries. It remains a *distinct* platform — the GPU -arrives over `/dev/dxg` from the Windows host driver, not through the in-tree -`amdgpu` module or `/dev/kfd` — which is why it gets its own entries rather than -inheriting the bare-metal Linux ones. AMD's ROCm-on-WSL guide is still the right -pointer for install questions the catalog does not cover: -https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/install/installryz/wsl/howto_wsl.html diff --git a/tests/e2e-cucumber/README.md b/tests/e2e-cucumber/README.md index f24f136c6c..3502980329 100644 --- a/tests/e2e-cucumber/README.md +++ b/tests/e2e-cucumber/README.md @@ -297,23 +297,24 @@ exception is `skill-07`, which reads that Phase 0 requires. Reading that document as test data is a deliberate, narrow exception to -**Black-box only** above: nothing is imported from the rocm-cli codebase — a -*documentation artifact* is read as test data, and that artifact is the thing -under test. `skill_steps.rs` parses the specific claims each scenario names — +**Black-box only** above: the scenario steps import nothing from the rocm-cli +codebase — a *documentation artifact* is read as test data, and that artifact is +the thing under test. (The ordinary-`cargo test` guard +[skill_reference.rs](tests/skill_reference.rs) does import `rocm_core`, to compare +the names SKILL.md lists with what the CLI publishes.) `skill_steps.rs` parses the specific claims each scenario names — the catalog table's cells, the auto-applicable prose line, the framework-routing bullets, the diagnose fields and thresholds — rather than restating them as constants, so editing one of those in `reference.md` starts being checked with no code change, and every one of those parsers asserts it found something — a heading it depends on being reworded upstream must fail loudly rather than quietly reduce an assertion to a no-op. Free-standing prose outside those -spots — such as the Linux-only/Windows-only recap line under the table — is -not parsed, so it can drift without failing anything here. Two counts are -checked outside this feature by -[skill_reference.rs](tests/skill_reference.rs): the failure-mode count in the -catalog heading, and SKILL.md's "The other N ... print-only" count. Two -sentences in SKILL.md are therefore fixtures. `skill-07` reads the sentence -that declares the required catalog contract version, so rewording that -sentence fails the scenario. `skill_reference.rs` reads the print-only count. +spots — such as the paragraph on the unused `fix-20` number under the table — +is not parsed, so it can drift without failing anything here. +[skill_reference.rs](tests/skill_reference.rs) checks outside this feature the +catalog table's vocabulary, the failure-mode count in the catalog heading, +SKILL.md's "The other N ... print-only" count, and the exit-code and `fix` field +names SKILL.md lists. Some sentences in SKILL.md are therefore fixtures: +skill_reference.rs's module doc lists every one and says which test reads it. Two rules follow: diff --git a/tests/e2e-cucumber/features/diagnose.feature b/tests/e2e-cucumber/features/diagnose.feature index 0fff0679ef..6e8561f988 100644 --- a/tests/e2e-cucumber/features/diagnose.feature +++ b/tests/e2e-cucumber/features/diagnose.feature @@ -285,10 +285,11 @@ Feature: Diagnosing failures and listing fixes # # Unlike diagnose-14, this one IS OS-gated. `print_recipe` still runs before # the fix's own platform gate (see `apply` in fix.rs), but the Flags: line it - # prints comes from `class_here()`, which looks up the catalog entry for the - # *running* host's OS. "AUTO" only renders where `fix-4-render-group` is + # prints comes from the recipe's class on the *running* host's OS + # (`print_recipe` hands `current_os()` to the plan builder, which asks + # `FixRecipe::class_on_os`). "AUTO" only renders where `fix-4-render-group` is # actually `Auto` -- bare-metal Linux. Everywhere else (`applies_on` has no - # other member) `class_here()` falls back to PRINT-ONLY, the generic "this + # other member) that lookup falls back to PRINT-ONLY, the generic "this # fix does not apply here" answer diagnose-11 already covers -- not a second, # platform-specific behaviour worth asserting under this scenario's name. # diff --git a/tests/e2e-cucumber/features/rocm_doctor_skill.feature b/tests/e2e-cucumber/features/rocm_doctor_skill.feature index de2487d142..83061d54c6 100644 --- a/tests/e2e-cucumber/features/rocm_doctor_skill.feature +++ b/tests/e2e-cucumber/features/rocm_doctor_skill.feature @@ -8,20 +8,20 @@ Feature: The ROCm Doctor skill's instructions match the CLI they drive # # The centre of this feature is the catalog diff (scenarios 1-3): the table in # `reference.md` is parsed and compared to what `rocm fix` really reports, so a - # renamed fix-id, a re-scoped OS, a flipped auto-flag, or a 16th failure mode + # renamed fix-id, a re-scoped OS, a flipped auto-flag, or a new failure mode # cannot merge here and silently break the published skill. Nothing else tests # that seam — `diagnose.feature` deliberately asserts only the SHAPE of a # diagnosis so it stays host-independent. # # That guarantee covers the table's cells and the auto-applicable prose line — # what `skill_steps.rs` actually parses. Free-standing prose that only - # restates those same facts in words — the Linux-only/Windows-only recap line - # beneath the table, for one — is not parsed here and can go stale even while - # the table itself stays correct. Two such counts are checked by the unit-level - # `tests/skill_reference.rs` instead: the "(N failure modes)" count in the - # catalog heading and SKILL.md's "The other M ... print-only" count. Two - # SKILL.md sentences are therefore fixtures: that print-only count, and the - # contract sentence that skill-07 reads. + # restates those same facts in words — the paragraph on the unused `fix-20` + # number under the table, for one — is not parsed here and can go stale even while + # the table itself stays correct. The "(N failure modes)" count in the catalog + # heading, SKILL.md's "The other M ... print-only" count and the names SKILL.md + # lists are checked by the unit-level `tests/skill_reference.rs` instead, whose + # module doc lists the SKILL.md sentences that are fixtures (skill-07 reads one + # of them). # # The catalog is authoritative in `crates/rocm-core`. When one of these fails, # the CLI is right and the document is what changes: `reference.md`, or @@ -31,9 +31,9 @@ Feature: The ROCm Doctor skill's instructions match the CLI they drive # the published document, and nothing else belongs. Claims proven elsewhere # are not restated. `diagnose.feature` already owns the CLI's own behaviour — # that a fix meant for another OS is declined without changing anything - # (`@id:fix-inapplicable-here-is-declined-not-attempted`), that the catalog - # listing is complete against an in-test list - # (`@id:fix-catalog-is-complete`), and that a report says plainly whether a + # (`@id:diagnose-fix-inapplicable-here-is-declined-not-attempted`), that the + # catalog listing is complete against an in-test list + # (`@id:diagnose-fix-catalog-is-complete`), and that a report says plainly whether a # cause was established (`@id:diagnose-json-states-when-nothing-matched`). # The exit-code and confirm-before-mutating contract is unit tested in # `crates/rocm-core/src/fix/runners.rs`, where a declined consent or a failed write @@ -81,10 +81,10 @@ Feature: The ROCm Doctor skill's instructions match the CLI they drive Then the inspection succeeds whatever it finds And its verdict is one the skill documents - # The skill's standing rule is "never invent a fix — if nothing matched, route - # the user upstream". That rule is only followable if the address the CLI hands - # over is one the skill's own routing table gives, so this is the last claim in - # `reference.md` that the binary can be held to. + # When nothing matched, the skill sends the user upstream. That is only + # followable if the address the CLI hands over is one `reference.md`'s + # Framework routing section lists, so this is the last claim in `reference.md` + # that the binary can be held to. # # The scenario is about the ADDRESS, not about nothing having matched. Whether # a report goes unexplained is not a property this suite can hold still: the @@ -109,10 +109,10 @@ Feature: The ROCm Doctor skill's instructions match the CLI they drive # though a raised contract means the catalog removed or changed something. The # scenario turns red at that bump, so the skill is read again first. # - # Whether an agent obeys the stop is behaviour, not text, and no committed - # test checks it today. The skill's evals cannot reach it, because their - # runners carry no `rocm`. A stub CLI that the evals can use would let them - # grade it. + # Whether an agent obeys the stop is behaviour, not text. The skill's evals + # grade it where they replay a recorded older CLI + # (`rocm-older-cli-stops-before-diagnosing`), which needs a model run, so this + # scenario holds only the declared number. @id:skill-required-contract-is-the-one-the-cli-publishes Scenario: skill-07 - The skill requires the same catalog contract that the CLI publishes Given the ROCm Doctor skill as it is published diff --git a/tests/e2e-cucumber/tests/e2e/diagnose_steps.rs b/tests/e2e-cucumber/tests/e2e/diagnose_steps.rs index 369b13626c..5a087647a4 100644 --- a/tests/e2e-cucumber/tests/e2e/diagnose_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/diagnose_steps.rs @@ -2805,7 +2805,7 @@ async fn assert_json_with_fix_id_refused(world: &mut E2eWorld) { assert_eq!( world.cli_rc, Some(1), - "a request with no answer must exit 1, as README.md and reference.md document" + "a request with no answer must exit 1, as README.md documents" ); assert!( stderr.contains("--json"), diff --git a/tests/e2e-cucumber/tests/e2e/skill_steps.rs b/tests/e2e-cucumber/tests/e2e/skill_steps.rs index c912b9de29..b6c7879f0b 100644 --- a/tests/e2e-cucumber/tests/e2e/skill_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/skill_steps.rs @@ -13,9 +13,9 @@ //! `reference.md` is read as the EXPECTED-value fixture. That is a deliberate, //! narrow exception to the suite's black-box rule: nothing is imported from the //! rocm-cli codebase — a documentation artifact is read as test data, and that -//! artifact is the thing under test. `SKILL.md` is read too, for two +//! artifact is the thing under test. `SKILL.md` is read too, for a few fixture //! sentences: `skill-07` reads the catalog contract version Phase 0 requires, -//! and `tests/skill_reference.rs` reads the "The other N ... print-only" count. +//! and `tests/skill_reference.rs` lists all of them. use std::collections::{BTreeMap, BTreeSet}; use std::path::PathBuf; @@ -170,8 +170,8 @@ fn declared_contract_minimum(skill_md: &str) -> Option { /// /// Rows look like: /// `| `fix-1-arch` | linux/windows/wsl | | | print-only |` -/// Only rows whose first cell is a backticked `fix-*` id are taken, which skips -/// the header, the separator, and the exit-code table further up the file. +/// Only rows whose first cell is a backticked catalog id are taken, which skips +/// the header and the separator. fn parse_reference_catalog(md: &str) -> BTreeMap { let mut out = BTreeMap::new(); for line in md.lines() { @@ -461,12 +461,12 @@ fn documented_verdicts(md: &str) -> BTreeSet { /// The subset of Framework routing the reference attributes to the **CLI**. /// -/// The section names two different things: trackers the *skill* hands over from -/// its own table (Lemonade, Ollama, LM Studio — the host probe cannot detect -/// them), and the targets `route_when_no_match` actually returns. Checking the -/// CLI's route against the union of both lets a documented-but-dead CLI target -/// pass silently, which is how the removed lemonade / ollama / lm-studio arms -/// stayed in the document. So the CLI is held to its own list. +/// The section lists the targets `route_when_no_match` actually returns; the +/// trackers the *skill* hands over itself (Lemonade, Ollama, LM Studio — the +/// host probe cannot detect them) live in `SKILL.md`. Checking the CLI's route +/// against a union of both would let a documented-but-dead CLI target pass +/// silently, which is how the removed lemonade / ollama / lm-studio arms stayed +/// in the document. So the CLI is held to its own list. fn documented_cli_routes(md: &str) -> BTreeMap> { let mut out = BTreeMap::new(); let mut inside = false; @@ -639,10 +639,10 @@ async fn assert_same_auto_set(world: &mut E2eWorld) { offered.marker ); } - // The reference says it twice — marker cells above, per-host prose below — - // and the loop only checked the cells. A rename applied to the table and - // the CLI together would leave the prose stale, and the prose is what an - // agent reads before it decides whether to offer to run a fix. + // The reference says it twice — per-host bullets above the table and marker + // cells in it — and the loop only checked the cells. A rename applied to the + // table and the CLI together would leave the bullets stale, so they are + // checked too, which keeps them from drifting away from the table. let prose = documented_auto_prose_for(reference(world), &platform); let offered: BTreeSet = cli .iter() @@ -717,9 +717,10 @@ async fn assert_documented_fields_present(world: &mut E2eWorld) { // routing scenario covers that branch. What must hold is that anything // offered is fully readable by an agent following the skill. // - // The individual fields of a `fix` plan are NOT checked here. The reference - // does not spell them out, so there is no documented claim to compare - // against — that is a serialization shape, and `crates/rocm-core` owns it. + // The individual fields of a `fix` plan are NOT checked here. The ones + // `SKILL.md` names are checked against the serialised `Fix` by + // `tests/skill_reference.rs`, with no `rocm` binary needed; the shape itself + // is a serialization detail that `crates/rocm-core` owns. for cause in matched { let absent: Vec<&String> = per_cause .iter() @@ -744,8 +745,8 @@ async fn assert_thresholds(world: &mut E2eWorld) { .unwrap_or_else(|| panic!("diagnose JSON has no numeric '{field}'")); assert_eq!( actual, *expected, - "{field} is {actual}, but reference.md states {expected} — and the skill's \ - workflow text reasons about that number when it grades a cause" + "{field} is {actual}, but reference.md states {expected} — and the skill \ + names this field when it grades a cause" ); } } @@ -894,8 +895,9 @@ async fn assert_required_contract_is_published(world: &mut E2eWorld) { required == published, "The CLI now publishes catalog contract version {published}, but SKILL.md still \ requires {required}. A raised contract version means the catalog removed or \ - changed something. Check the entry ids, the auto-applicable set and the exit \ - codes in SKILL.md and reference.md against the new catalog, then raise the \ + changed something. Check the entry ids, the fix classes and the field names \ + in SKILL.md and reference.md, and the `exit_codes` names in SKILL.md, \ + against the new catalog, then raise the \ number in SKILL.md. Raise it only after a release publishes that contract, \ because the installer Phase 0 offers installs the release channel." ); diff --git a/tests/e2e-cucumber/tests/skill_reference.rs b/tests/e2e-cucumber/tests/skill_reference.rs index 4f425872de..79c3de15ac 100644 --- a/tests/e2e-cucumber/tests/skill_reference.rs +++ b/tests/e2e-cucumber/tests/skill_reference.rs @@ -2,7 +2,9 @@ // // SPDX-License-Identifier: MIT -//! Drift guard for the shape of `skills/rocm-doctor/reference.md`'s catalog. +//! Drift guard for what `skills/rocm-doctor` quotes from the CLI: the shape of +//! `reference.md`'s catalog, the counts `SKILL.md` states about it, and the +//! exit-code and `fix` field names it lists. //! //! The `rocm_doctor_skill.feature` scenarios compare that table against the //! real `rocm fix` listing, cell for cell, so a cell the table spells its own @@ -11,13 +13,33 @@ //! test` set, so the malformed cell is caught without one. //! //! Narrow on purpose: the CLI is authoritative for *which* fixes exist and what -//! they are scoped to, and the feature file already checks that. All this -//! checks is that the document uses the vocabulary the CLI prints, so the -//! comparison there can stay a literal one. +//! they are scoped to, and the feature file already checks that. For the +//! catalog this checks only that the document uses the vocabulary the CLI +//! prints, so the comparison there can stay a literal one. For `SKILL.md` it +//! checks the print-only count against the table, and the exit-code and `fix` +//! field lists below against what the CLI publishes. +//! +//! Fixture sentences in `SKILL.md`. Tests read these phrases from it, so reword +//! them only together with the test that reads them. Each test panics naming +//! the phrase it cannot find; whitespace and line wrapping do not matter. This +//! list is the one place that names them all: +//! +//! - "requires `contract_version` N", read by `skill-07` in `skill_steps.rs`; +//! - "The other N are **print-only**", read by +//! `free_standing_catalog_counts_match_the_table` below; +//! - "by its `exit_codes` name", which starts the exit-code list read by +//! `exit_code_names_listed_in_the_skill_are_the_manifest_failure_exits`; +//! - "a `fix` whose ... are the fields", the `fix` field list read by +//! `fix_fields_quoted_in_the_skill_exist_in_the_diagnosis_json`. use std::collections::BTreeSet; use std::path::{Path, PathBuf}; +/// The anchors the two SKILL.md parsers below read; see the module doc. +const EXIT_CODES_MARKER: &str = "by its `exit_codes` name"; +const FIX_FIELDS_START: &str = "a `fix` whose "; +const FIX_FIELDS_END: &str = " are the fields"; + /// The platform atoms `rocm fix` prints, which it builds by joining a recipe's /// `applies_on` with `/` (see `FixRecipe` in `crates/rocm-core/src/fix/catalog.rs`). /// A catalog cell is any non-empty `/`-joined subset of these. @@ -41,7 +63,7 @@ fn reference_md_path() -> PathBuf { /// `(fix-id, os-scope cell, marker cell)` for every catalog row, taken the same /// way `skill_steps::parse_reference_catalog` takes them: a leading `|`, at -/// least five cells, and a backticked `fix-*` id first. +/// least five cells, and a backticked `fix-*` or `info-*` id first. fn catalog_rows(md: &str) -> Vec<(String, String, String)> { let mut rows = Vec::new(); for line in md.lines() { @@ -80,19 +102,14 @@ fn skill_md_path() -> PathBuf { .join("SKILL.md") } -/// How many catalog rows have `yes` in the Auto-fix cell (`cells[4]`, the same -/// column `catalog_rows` leaves unparsed since the os-scope check only needs -/// `cells[1]`). -/// Rows whose marker is anything other than a plain `print-only`, which is the -/// complement of the set `SKILL.md`'s "the other N are print-only" counts. +/// How many catalog rows have a marker (the fifth cell, `cells[4]`) other than a +/// plain `print-only`, which is the complement of the set `SKILL.md`'s "the other +/// N are print-only" counts. /// -/// Deliberately not a count of "auto-applicable": the two docs do not agree on -/// what that phrase covers. `reference.md` says three ids are ever -/// auto-applicable and that `fix-9-igpu-dgpu` is not one of them, while -/// `SKILL.md` says four -- counting `needs-arg` and the windows-only exception -/// alongside the two plain `auto` entries. Counting the complement sidesteps -/// that disagreement and checks the claim `SKILL.md` actually makes, so this -/// guard does not quietly take a side in it. +/// Deliberately not a count of "auto-applicable": that phrase is per host, and +/// `reference.md` lists which ids it covers on each one (three ids across all +/// hosts, `fix-9-igpu-dgpu` not among them). `SKILL.md` claims a count of +/// print-only entries, so counting the complement checks that claim. fn catalog_not_print_only_count(md: &str) -> usize { md.lines() .filter(|line| { @@ -155,7 +172,9 @@ fn free_standing_catalog_counts_match_the_table() { .unwrap_or_else(|e| panic!("failed to read {}: {e}", skill_md_path().display())); // "The other N" and "are **print-only**" sit on adjacent source lines that // wrap a single sentence; `number_after_phrase` joins the doc on whitespace - // first, so a line-scoped search cannot miss the number. + // first, so a line-scoped search cannot miss the number. The clause has to + // follow the number directly: a "print-only" somewhere later in the sentence + // would not say what the number counts. let (print_only_count, rest) = e2e_cucumber::number_after_phrase(&skill_md, "The other ") .unwrap_or_else(|| { panic!( @@ -164,8 +183,8 @@ fn free_standing_catalog_counts_match_the_table() { ) }); assert!( - rest.contains("print-only"), - "'The other {print_only_count}' in {} is not followed by 'print-only' as expected: {:?}", + rest.starts_with(" are **print-only**"), + "'The other {print_only_count}' in {} is not followed by 'are **print-only**' as expected: {:?}", skill_md_path().display(), rest.chars().take(60).collect::() ); @@ -266,3 +285,264 @@ fn catalog_markers_use_the_cli_vocabulary() { .count() ); } + +/// Every backtick-delimited span of `text`, in order, with the text that +/// follows its closing backtick. +fn backticked_with_tail(text: &str) -> Vec<(&str, &str)> { + let mut out = Vec::new(); + let mut rest = text; + while let Some(open) = rest.find('`') { + let after = &rest[open + 1..]; + let Some(close) = after.find('`') else { break }; + out.push((&after[..close], &after[close + 1..])); + rest = &after[close + 1..]; + } + out +} + +fn is_identifier(span: &str) -> bool { + !span.is_empty() + && span.starts_with(|c: char| c.is_ascii_lowercase()) + && span + .chars() + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') +} + +fn skill_md_text() -> String { + std::fs::read_to_string(skill_md_path()) + .unwrap_or_else(|e| panic!("failed to read {}: {e}", skill_md_path().display())) +} + +/// The text with every run of whitespace collapsed to one space, so a phrase +/// matches wherever SKILL.md happens to wrap its lines. +fn flatten(text: &str) -> String { + text.split_whitespace().collect::>().join(" ") +} + +/// The part of `flat` after `marker`, or a panic naming the missing marker: a +/// parser that silently found nothing would turn its check into a no-op. +fn after_marker<'a>(flat: &'a str, marker: &str) -> &'a str { + match flat.find(marker) { + Some(at) => &flat[at + marker.len()..], + None => panic!( + "marker missing: {marker:?} is no longer in SKILL.md. It is a fixture phrase this \ + test reads; reword it back, or update the test and the list in this file's \ + module doc" + ), + } +} + +/// The exit-code names SKILL.md quotes for `rocm fix`: the bullet heads of the +/// list that follows "by its `exit_codes` name". Reads the whitespace-collapsed +/// text, so re-wrapping SKILL.md does not matter. +fn exit_code_names_in(skill_md: &str) -> BTreeSet { + let flat = flatten(skill_md); + let mut names = BTreeSet::new(); + // The list is the run of " - `name` — " bullets right after the marker; the + // first bullet that is not of that shape ends it. + let mut rest = after_marker(&flat, EXIT_CODES_MARKER); + while let Some(at) = rest.find(" - `") { + let head = &rest[at + 4..]; + let Some((name, tail)) = head.split_once('`') else { + break; + }; + if !is_identifier(name) || !tail.starts_with(" — ") { + break; + } + names.insert(name.to_owned()); + rest = tail; + } + names +} + +/// The manifest's non-zero exit-code names. SKILL.md lists the failures an agent +/// can meet; `ok` is the success code and is not one of them. +fn published_failure_exits() -> BTreeSet { + rocm_core::catalog_manifest() + .exit_codes + .keys() + .filter(|name| name.as_str() != "ok") + .cloned() + .collect() +} + +/// `Err` when the exit-code list in `skill_md` is not the manifest's failure +/// exits. A list the parser reads as empty, or cuts short at a name it cannot +/// read (`not-applicable`), differs from them too, so it cannot pass. +fn check_exit_code_list(skill_md: &str) -> Result<(), String> { + let listed = exit_code_names_in(skill_md); + let published = published_failure_exits(); + if listed == published { + Ok(()) + } else { + Err(format!( + "the exit-code list in SKILL.md is {listed:?}; the manifest's non-zero \ + `exit_codes` are {published:?}" + )) + } +} + +/// SKILL.md reads the manifest's `exit_codes` by name, so a name it quotes that +/// the manifest does not publish sends an agent looking for a code that never +/// comes, and a published one it leaves out is a failure the skill has no +/// instruction for. `the_published_exit_codes_are_the_ones_apply_returns` in +/// rocm-core pins the manifest's keys; this pins the skill's list to them. +#[test] +fn exit_code_names_listed_in_the_skill_are_the_manifest_failure_exits() { + if let Err(problem) = check_exit_code_list(&skill_md_text()) { + panic!("{problem}"); + } +} + +/// The same check, run on lists that are wrong, must fail: otherwise it would +/// pass for whatever the parser happened to read. +#[test] +fn a_wrong_exit_code_list_is_caught() { + let flat = flatten(&skill_md_text()); + for (what, wrong) in [ + ("a misspelt name", " - `fail` — "), + ("a name it cannot read", " - `not-applicable` — "), + ] { + let text = flat.replace(" - `failed` — ", wrong); + assert!( + check_exit_code_list(&text).is_err(), + "{what} in the exit-code list went unnoticed" + ); + } +} + +/// The `fix` fields SKILL.md names: the list between "a `fix` whose" and "are the +/// fields". Reads the whitespace-collapsed text. Panics when either end of the +/// list is missing (rather than reading every identifier to the end of the file +/// as a field), when the list names no field, and on a backticked span that is +/// not a field name (`needs-sudo`, `needsSudo`), which would otherwise be dropped +/// instead of compared. +fn fix_fields_in(skill_md: &str) -> BTreeSet { + let flat = flatten(skill_md); + let mut fields = BTreeSet::new(); + let after_start = after_marker(&flat, FIX_FIELDS_START); + let Some(end_at) = after_start.find(FIX_FIELDS_END) else { + panic!( + "marker missing: {FIX_FIELDS_END:?} no longer follows {FIX_FIELDS_START:?} in \ + SKILL.md. It is a fixture phrase this test reads; reword it back, or update the \ + test and the list in this file's module doc" + ); + }; + for (span, _) in backticked_with_tail(&after_start[..end_at]) { + assert!( + is_identifier(span), + "{span:?} in SKILL.md's `fix` field list is not a field name (lower-case letters, \ + digits and `_` only)" + ); + fields.insert(span.to_owned()); + } + assert!( + !fields.is_empty(), + "SKILL.md's `fix` field list, between {FIX_FIELDS_START:?} and {FIX_FIELDS_END:?}, names \ + no field" + ); + fields +} + +/// The same check for the `fix` sub-fields, one-way: a field SKILL.md tells the +/// agent to act on has to exist in the diagnosis JSON, but the skill need not +/// name every field the JSON carries. `needs` is set so the one field the +/// serializer omits when absent is present in the sample. +#[test] +fn fix_fields_quoted_in_the_skill_exist_in_the_diagnosis_json() { + let quoted = fix_fields_in(&skill_md_text()); + let sample = rocm_core::Fix { + needs: Some("--device-index".to_owned()), + ..rocm_core::Fix::default() + }; + let json = serde_json::to_value(&sample).expect("a Fix serializes"); + let emitted: BTreeSet = json + .as_object() + .expect("a Fix is a JSON object") + .keys() + .cloned() + .collect(); + let unknown: Vec<&String> = quoted.difference(&emitted).collect(); + assert!( + unknown.is_empty(), + "SKILL.md names `fix` fields the diagnosis JSON does not carry: {unknown:?}. \ + Carried: {emitted:?}" + ); +} + +/// `text` re-wrapped to lines of at most `width` characters, so every phrase in it +/// may now break across lines in a different place. +fn rewrap(text: &str, width: usize) -> String { + let mut out = String::new(); + let mut line_len = 0; + for word in text.split_whitespace() { + if line_len > 0 && line_len + 1 + word.len() > width { + out.push('\n'); + line_len = 0; + } else if line_len > 0 { + out.push(' '); + line_len += 1; + } + out.push_str(word); + line_len += word.len(); + } + out +} + +/// Re-wrapping SKILL.md must not change what the two parsers read: they match +/// phrases on the whitespace-collapsed text, not one physical line at a time. +#[test] +fn the_skill_parsers_do_not_depend_on_line_wrapping() { + let skill_md = skill_md_text(); + for width in [37, 61, 200] { + let wrapped = rewrap(&skill_md, width); + assert_eq!( + exit_code_names_in(&wrapped), + exit_code_names_in(&skill_md), + "exit-code names changed when SKILL.md was re-wrapped to {width} columns" + ); + assert_eq!( + fix_fields_in(&wrapped), + fix_fields_in(&skill_md), + "fix fields changed when SKILL.md was re-wrapped to {width} columns" + ); + } +} + +/// A fixture phrase that is gone must fail loudly, not leave a parser finding +/// nothing (or, for the field list, everything to the end of the file). +#[test] +#[should_panic(expected = "marker missing")] +fn a_reworded_exit_code_marker_is_loud() { + exit_code_names_in(&flatten(&skill_md_text()).replace(EXIT_CODES_MARKER, "by its code name")); +} + +#[test] +#[should_panic(expected = "marker missing")] +fn a_reworded_fix_field_start_is_loud() { + fix_fields_in(&flatten(&skill_md_text()).replace(FIX_FIELDS_START, "a fix whose ")); +} + +#[test] +#[should_panic(expected = "marker missing")] +fn a_reworded_fix_field_end_is_loud() { + fix_fields_in(&flatten(&skill_md_text()).replace(FIX_FIELDS_END, " are the columns")); +} + +#[test] +#[should_panic(expected = "names no field")] +fn an_emptied_fix_field_list_is_loud() { + fix_fields_in(&format!("{FIX_FIELDS_START}x{FIX_FIELDS_END}")); +} + +#[test] +#[should_panic(expected = "is not a field name")] +fn a_hyphenated_fix_field_is_loud() { + fix_fields_in(&flatten(&skill_md_text()).replace("`needs_sudo`", "`needs-sudo`")); +} + +#[test] +#[should_panic(expected = "is not a field name")] +fn a_camel_case_fix_field_is_loud() { + fix_fields_in(&flatten(&skill_md_text()).replace("`needs_sudo`", "`needsSudo`")); +} diff --git a/xtask/src/eval_fixtures.rs b/xtask/src/eval_fixtures.rs index dbc335d0ef..9b1027580e 100644 --- a/xtask/src/eval_fixtures.rs +++ b/xtask/src/eval_fixtures.rs @@ -25,11 +25,24 @@ //! `summary` of the host that only the `rocm` binary can build, so the replay //! leaves `summary` out; the skill reads `status` and `has_amd_gpu` and nothing in it. //! -//! Two things are not rendered. What an OLDER CLI printed was recorded once from a -//! real older binary and is committed under `recorded/`. And the current CLI's -//! `--version` line is fixed text ([`CURRENT_VERSION`]): it is not the real -//! `rocm --version` format, and carries a marker that only the replay prints, so -//! an eval can tell that the agent met the replay. Nothing in the skill reads it. +//! A case may also name an `apply` fix id, which makes the stub answer `rocm fix ` +//! with `--dry-run` and with no flag. The fix must be `auto` on the host's platform +//! (`wsl` for the WSL host, else `linux`), and the case's symptom and host must make +//! the replayed diagnosis match it, or the generator fails (a fix the agent could not +//! be pointed at has nothing to replay). The plan is the CLI's own +//! ([`rocm_core::fix_plan_text`]), so it carries the command's wording; only the +//! `Will run:` line the runner adds is not there, because it names the user and the +//! machine. The layout around the plan (the blank line, then the notice) is written +//! here by hand, copying the runner, and is checked only against the committed +//! replay. The refusal's exit code, its message and the dry-run notice are the CLI's +//! own constants ([`rocm_core::fix_exit`], [`rocm_core::NON_INTERACTIVE_REFUSAL`], +//! [`rocm_core::DRY_RUN_NOTICE`]). +//! +//! Some replies are not rendered from the catalog. What an OLDER CLI printed was +//! recorded once from a real older binary and is committed under `recorded/`. The +//! current CLI's `--version` line is fixed text ([`CURRENT_VERSION`]) that carries a +//! marker only the replay prints, so an eval can tell that the agent met the replay; +//! nothing in the skill reads it. The failure message of `examine` is fixed text too. use std::fs; use std::path::{Path, PathBuf}; @@ -56,8 +69,8 @@ const EXAMINATION: &str = "tests/remote-ssh/examination.json"; const EVALS_FILE: &str = "skills/rocm-doctor/evals/evals.json"; /// What the current-CLI replay prints for `--version`. Fixed text, so a rebuild /// never makes a recording differ. The parenthesised marker is what the -/// `rocm-current-cli-carries-on` eval pins in `logs_contain`; the real -/// `rocm --version` prints `rocm ` and the skill does not read it. +/// `rocm-current-cli-carries-on` eval pins in `logs_contain`; no real build +/// prints that marker, and the skill does not read the version string. const CURRENT_VERSION: &str = "rocm-cli 0.1.0 (recorded for evals)\n"; /// An older CLI rejects `--json` with a usage error, and clap's usage-error code is 2. const USAGE_ERROR_RC: i32 = 2; @@ -68,6 +81,16 @@ const USAGE_ERROR_RC: i32 = 2; const EXAMINE_FAILS_STDERR: &str = "error: failed to read the host (recorded for evals)\n"; /// A genuine inability to examine propagates as an error, which exits 1. const EXAMINE_FAILS_RC: i32 = 1; +/// The platform family a replayed host is, which is what `rocm fix` reports for it: +/// the plan's class and argument are per platform. The WSL host is `wsl` there, not +/// `linux`, so a fix that applies on Linux only is not applicable on it. +fn replayed_os(host: Option) -> &'static str { + if host == Some(Host::WslHostGpuHidden) { + "wsl" + } else { + "linux" + } +} /// The part of the dataset this module reads: which prompt each case id has. #[derive(Debug, Deserialize)] @@ -98,6 +121,11 @@ struct Case { /// case without one gets no examine reply, and the stub refuses the command. #[serde(default)] host: Option, + /// A fix id the case's agent is expected to preview and apply. The stub then + /// answers `rocm fix ` with `--dry-run` and with no flag, and never with + /// `--yes`, so an agent that applies before the user said OK meets a refusal. + #[serde(default)] + apply: Option, } /// The host a replayed `rocm examine --json` describes. Each is the recorded @@ -114,6 +142,10 @@ enum Host { AmdFound, /// `rocm examine` itself fails and exits non-zero. ExamineFails, + /// Linux with an AMD GPU found, inside a Docker container whose + /// `/dev/shm` is the 64 MiB default. Two entries then score from host + /// state alone, whatever the symptom is. + ContainerSmallShm, } #[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)] @@ -154,6 +186,18 @@ struct Replies { /// case without one is recorded exactly as it was before this existed. #[serde(skip_serializing_if = "Option::is_none")] examine_json: Option, + /// Only for a case that names an `apply` fix id, for the same reason. + #[serde(skip_serializing_if = "Option::is_none")] + apply: Option, +} + +/// What the stub answers for `rocm fix `: the preview, and the refusal a +/// shell with no terminal gets when `--yes` is missing. +#[derive(Debug, Serialize, PartialEq, Eq)] +struct Apply { + fix_id: String, + dry_run: Reply, + bare: Reply, } /// Regenerate (or, with `check`, verify) the committed fixtures. @@ -217,14 +261,21 @@ fn examination_for(base: &rocm_core::Examination, host: Host) -> rocm_core::Exam // Every host states each field `compute_status` and the replay depend on, so // what comes out never depends on what the recorded examination happened to // hold for it. `os_family` and `probe_failures` count: a recording captured - // with a failed probe would otherwise turn `amd-found` into `degraded`. + // with a failed probe would otherwise turn `amd-found` into `degraded`. So do + // the container and `/dev/shm` fields the diagnosis reads: a recording made in + // a container would otherwise put every host in one. examination.os_family = "linux".to_owned(); examination.probe_failures = Vec::new(); examination.is_wsl = host == Host::WslHostGpuHidden; examination.wsl = None; - examination.has_amd_gpu = host == Host::AmdFound; - examination.has_discrete_amd = host == Host::AmdFound; + let amd_found = matches!(host, Host::AmdFound | Host::ContainerSmallShm); + examination.has_amd_gpu = amd_found; + examination.has_discrete_amd = amd_found; examination.gpus = Vec::new(); + examination.in_container = false; + examination.container_kind = String::new(); + examination.shm_total_bytes = None; + examination.shm_available_bytes = None; match host { Host::NoAmdGpu | Host::ExamineFails => {} Host::WslHostGpuHidden => { @@ -239,7 +290,7 @@ fn examination_for(base: &rocm_core::Examination, host: Host) -> rocm_core::Exam ..rocm_core::examine::WslFacts::default() }); } - Host::AmdFound => { + Host::AmdFound | Host::ContainerSmallShm => { // `pci_id` is what the Linux probe reads: the bus address that starts // the `lspci` line. examination.gpus = vec![rocm_core::examine::Gpu { @@ -249,6 +300,13 @@ fn examination_for(base: &rocm_core::Examination, host: Host) -> rocm_core::Exam is_apu: Some(false), is_amd: true, }]; + if host == Host::ContainerSmallShm { + const DEFAULT_SHM_BYTES: u64 = 64 * 1024 * 1024; + examination.in_container = true; + examination.container_kind = "docker".to_owned(); + examination.shm_total_bytes = Some(DEFAULT_SHM_BYTES); + examination.shm_available_bytes = Some(DEFAULT_SHM_BYTES); + } } } examination.status = examination.compute_status(); @@ -295,12 +353,47 @@ fn replies_for(root: &Path, case: &Case, recorded: &rocm_core::Examination) -> R + "\n", )), }; + let apply = case + .apply + .as_deref() + .map(|fix_id| apply_for(fix_id, replayed_os(case.host), &report)) + .transpose()?; Ok(Replies { version, fix_json, diagnose_json, diagnose_text, examine_json, + apply, + }) +} + +/// What the stub answers for `rocm fix ` in the case's replay, on the platform +/// `os`. The plan is the CLI's own, from [`rocm_core::fix_plan_text`], so its wording +/// cannot drift from the command's. Only an `auto` entry is modelled: what the command +/// prints after the plan differs by class, and the stub copies none of it. And the +/// replayed diagnosis must match the fix, that is list it at or above +/// `min_score_for_match`, or the agent has no way to be pointed at its id. +fn apply_for(fix_id: &str, os: &str, report: &rocm_core::DiagnoseReport) -> Result { + let plan = rocm_core::fix_plan_text(fix_id, os) + .with_context(|| format!("the catalog has no fix {fix_id:?}"))?; + if rocm_core::fix::class_on(fix_id, os) != Some(rocm_core::fix::FixClass::Auto) { + bail!("the apply replay models only a fix that is `auto` on {os}, and {fix_id:?} is not"); + } + if !report.matched.iter().any(|m| { + m.score >= report.min_score_for_match + && m.fix.as_ref().is_some_and(|fix| fix.fix_id == fix_id) + }) { + bail!("the replayed diagnosis carries no match for {fix_id:?} that clears the threshold"); + } + Ok(Apply { + fix_id: fix_id.to_owned(), + dry_run: Reply::ok(format!("{plan}\n{}\n", rocm_core::DRY_RUN_NOTICE)), + bare: Reply { + stdout: format!("{plan}\n"), + stderr: format!("{}\n", rocm_core::NON_INTERACTIVE_REFUSAL), + rc: rocm_core::fix_exit::DECLINED, + }, }) } @@ -494,7 +587,7 @@ mod tests { } Host::NoAmdGpu => ("no-amd-gpu", false), Host::WslHostGpuHidden => ("wsl", false), - Host::AmdFound => ("ok", true), + Host::AmdFound | Host::ContainerSmallShm => ("ok", true), }; let value: serde_json::Value = serde_json::from_str(&examine.stdout).expect("an examination is JSON"); @@ -506,6 +599,7 @@ mod tests { Host::WslHostGpuHidden, Host::AmdFound, Host::ExamineFails, + Host::ContainerSmallShm, ] { assert!(seen.contains(&host), "no case replays the host {host:?}"); } @@ -521,6 +615,8 @@ mod tests { gpus: usize, wsl_facts: bool, status: &'static str, + /// The `/dev/shm` allowance in bytes: only the container host measures one. + shm_bytes: Option, } // A base that says the opposite of every host, so a host that forgot to @@ -538,22 +634,45 @@ mod tests { hostile.os_family = "other".to_owned(); hostile.probe_failures = vec!["lspci missing".to_owned()]; hostile.status = "degraded".to_owned(); + // A recording made in a container with a measured `/dev/shm`. + hostile.in_container = true; + hostile.container_kind = "podman".to_owned(); + hostile.shm_total_bytes = Some(1); + hostile.shm_available_bytes = Some(1); - let expected = |host, is_wsl, has_amd_gpu, gpus, wsl_facts, status| Expected { + let expected = |host, is_wsl, has_amd_gpu, gpus, wsl_facts, status, shm_bytes| Expected { host, is_wsl, has_amd_gpu, gpus, wsl_facts, status, + shm_bytes, }; for want in [ - expected(Host::NoAmdGpu, false, false, 0, false, "no-amd-gpu"), + expected(Host::NoAmdGpu, false, false, 0, false, "no-amd-gpu", None), // Shares an arm with `NoAmdGpu` today; listed so a later split of that // arm is still pinned. - expected(Host::ExamineFails, false, false, 0, false, "no-amd-gpu"), - expected(Host::WslHostGpuHidden, true, false, 0, true, "wsl"), - expected(Host::AmdFound, false, true, 1, false, "ok"), + expected( + Host::ExamineFails, + false, + false, + 0, + false, + "no-amd-gpu", + None, + ), + expected(Host::WslHostGpuHidden, true, false, 0, true, "wsl", None), + expected(Host::AmdFound, false, true, 1, false, "ok", None), + expected( + Host::ContainerSmallShm, + false, + true, + 1, + false, + "ok", + Some(64 * 1024 * 1024), + ), ] { let host = want.host; let examination = examination_for(&hostile, host); @@ -565,6 +684,16 @@ mod tests { assert_eq!(examination.os_family, "linux", "{host:?}"); assert!(examination.probe_failures.is_empty(), "{host:?}"); assert_eq!(examination.status, want.status, "{host:?}"); + // Only the container host is in a container, with the default allowance. + let in_container = want.shm_bytes.is_some(); + assert_eq!(examination.in_container, in_container, "{host:?}"); + assert_eq!( + examination.container_kind, + if in_container { "docker" } else { "" }, + "{host:?}" + ); + assert_eq!(examination.shm_total_bytes, want.shm_bytes, "{host:?}"); + assert_eq!(examination.shm_available_bytes, want.shm_bytes, "{host:?}"); } } @@ -697,6 +826,329 @@ mod tests { assert!(report.get("route_when_no_match").is_some()); } + /// What the replayed diagnosis of one case says. + struct Replayed { + has_match: bool, + /// Ranked `(id, score, fix class)`. + matches: Vec<(String, u64, String)>, + threshold: u64, + /// The score from which a match is high confidence. + high_threshold: u64, + /// Where `route_when_no_match` points. + route_target: String, + /// The preview the stub gives for the case's `apply` fix, if it names one. + apply_plan: Option, + } + + fn replayed(case_id: &str) -> Replayed { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + let case = cases(&root) + .into_iter() + .find(|case| case.id == case_id) + .unwrap_or_else(|| panic!("no case {case_id}")); + let replies = replies_for(&root, &case, &examination).expect("replies"); + let report: serde_json::Value = + serde_json::from_str(&replies.diagnose_json.stdout).expect("diagnosis is JSON"); + let matches = report["matched"] + .as_array() + .expect("matched is a list") + .iter() + .map(|m| { + ( + m["id"].as_str().expect("id").to_owned(), + m["score"].as_u64().expect("score"), + m["fix"]["class"].as_str().expect("class").to_owned(), + ) + }) + .collect(); + Replayed { + has_match: report["has_match"].as_bool().expect("has_match"), + matches, + threshold: report["min_score_for_match"].as_u64().expect("threshold"), + high_threshold: report["high_confidence_threshold"] + .as_u64() + .expect("high threshold"), + route_target: report["route_when_no_match"]["target"] + .as_str() + .expect("route target") + .to_owned(), + apply_plan: replies.apply.map(|apply| apply.dry_run.stdout), + } + } + + /// The judged cases rest on what their replayed diagnosis holds: a case that + /// grades "the agent did not act on a sub-threshold match" is void if the + /// recording stops containing one, and the dataset's notes say so in prose + /// nothing else checks. This pins each such premise. + #[test] + fn the_premise_a_judged_case_rests_on_is_what_its_replay_records() { + // The failing app is not on the host, so nothing was established. + for id in [ + "rocm-lemonade-routes-upstream", + "rocm-serve-failure-routes-to-this-project", + "rocm-ollama-routes-upstream", + "rocm-lm-studio-routes-upstream", + ] { + let r = replayed(id); + assert!(!r.has_match, "{id}: the replay must establish no cause"); + assert!(r.matches.is_empty(), "{id}: nothing is listed either"); + // The tracker the diagnosis hands back is never the app's own, which + // is what lets these cases tell the skill's routing from `route_when_no_match`. + assert_eq!(r.route_target, "rocm-core", "{id}"); + } + + // `has_match` false while `matched` is not empty: the trap an agent gating + // on emptiness falls into. The route is the ROCm core tracker although the + // prompt names PyTorch, which is what the case's routing item turns on. + let r = replayed("rocm-current-cli-carries-on"); + assert!(!r.has_match); + assert!( + !r.matches.is_empty(), + "a sub-threshold match must be listed" + ); + assert_eq!(r.route_target, "rocm-core"); + + // A vLLM failure described in words matches neither vLLM entry, which score + // only the symptom text, so the case's agent has nothing to route on until it + // has asked for the error line. + let r = replayed("rocm-vllm-failure-in-words-asks-for-the-error-line"); + assert!(!r.has_match); + assert!( + r.matches + .iter() + .all(|m| m.0 != "fix-16-vllm-oom" && m.0 != "fix-17-torch-dlpack"), + "{:?}", + r.matches + ); + assert_eq!(r.route_target, "rocm-core"); + + // The vLLM import error is a match, but a likely one, not a high-confidence one: + // the case grades "likely rather than certain". + let r = replayed("rocm-vllm-import-error"); + assert!(r.has_match); + assert_eq!(r.matches[0].0, "fix-17-torch-dlpack"); + assert!( + (r.threshold..r.high_threshold).contains(&r.matches[0].1), + "{:?}", + r.matches[0] + ); + // The vLLM out-of-memory error is the matched cause, and print-only. + let r = replayed("rocm-vllm-oom-at-startup"); + assert!(r.has_match); + assert_eq!(r.matches[0].0, "fix-16-vllm-oom"); + assert_eq!(r.matches[0].2, "print-only"); + + // An `auto` entry is the cause, so the apply step is reached. + let r = replayed("rocm-apply-auto-fix-needs-consent"); + assert!(r.has_match); + assert_eq!(r.matches[0].0, "fix-4-render-group"); + assert_eq!(r.matches[0].2, "auto"); + // Two of the case's expected items (log out and back in, what happens when + // `sudo` runs with no input) rest on these flags, which show in the plan the + // stub prints. + let plan = r.apply_plan.expect("the case names a fix to apply"); + assert!(plan.contains("requires sudo"), "{plan}"); + assert!(plan.contains("requires re-login"), "{plan}"); + assert!(!plan.contains("requires reboot"), "{plan}"); + // A host-only entry outranks the one that explains the paste, and both + // clear the threshold. + let r = replayed("rocm-match-does-not-explain-the-paste"); + assert!(r.has_match); + assert_eq!(r.matches[0].0, "fix-19-shm-too-small"); + // 60 for the measured allowance plus 10 only inside a container + // (`check_19_shm_too_small`), so a host that lost its container flag + // scores 60 and no longer tells the case's story. + assert_eq!(r.matches[0].1, 70, "the shared-memory entry in a container"); + let container = r + .matches + .iter() + .find(|m| m.0 == "fix-10-container") + .expect("a container entry is listed"); + assert!(container.1 < r.threshold, "and it is below the threshold"); + let torch = r + .matches + .iter() + .find(|m| m.0 == "fix-17-torch-dlpack") + .expect("the entry explaining the paste is listed"); + assert!( + torch.1 < r.matches[0].1, + "it ranks below the host-only entry" + ); + assert!(torch.1 >= r.threshold, "it clears the threshold"); + + // Everything that clears the threshold comes from host state: the + // complaint is mentioned by nothing, and the route is ROCm core. + let r = replayed("rocm-host-only-match-is-not-the-cause"); + assert!(r.has_match); + let cleared: Vec<&str> = r + .matches + .iter() + .filter(|m| m.1 >= r.threshold) + .map(|m| m.0.as_str()) + .collect(); + assert_eq!(cleared, ["fix-19-shm-too-small"]); + assert_eq!(r.route_target, "rocm-core"); + } + + #[test] + fn an_apply_replay_needs_the_replayed_diagnosis_to_match_the_fix() { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + // This paste makes `fix-4-render-group` clear the threshold, so a diagnosis + // that matches something is not enough: it has to be the asked-for fix. + let report = + rocm_core::run_diagnose(&examination, "Unable to open /dev/kfd: Permission denied"); + assert!( + report.has_match, + "the premise: a match cleared the threshold" + ); + assert!( + report + .matched + .iter() + .any(|m| m.score >= report.min_score_for_match + && m.fix + .as_ref() + .is_some_and(|f| f.fix_id == "fix-4-render-group")), + "the premise: it is fix-4-render-group" + ); + // `fix-6-path` is `auto` on Linux and is not what this diagnosis matched. + let message = format!( + "{:#}", + apply_for("fix-6-path", "linux", &report) + .expect_err("a fix the diagnosis does not match is refused") + ); + assert!(message.contains("carries no match"), "{message}"); + } + + #[test] + fn an_apply_replay_is_the_catalogs_plan_followed_by_the_dry_run_notice() { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + let case = cases(&root) + .into_iter() + .find(|case| case.apply.is_some()) + .expect("a case names a fix to apply"); + let apply = replies_for(&root, &case, &examination) + .expect("replies") + .apply + .expect("an `apply` case replays the fix commands"); + let plan = + rocm_core::fix_plan_text(&apply.fix_id, replayed_os(case.host)).expect("the plan"); + assert_eq!( + apply.dry_run.stdout, + format!("{plan}\n{}\n", rocm_core::DRY_RUN_NOTICE) + ); + // What the plan says is the CLI's, not a second rendering of it. How it is laid + // out around the notice is this generator's own, so the equality above checks + // the replay against the generator and not against the command. + for line in [ + "Fix: ", + "OS scope: ", + "Rationale: ", + "Commands:", + "Flags: ", + "Verify: ", + ] { + assert!(plan.contains(line), "{plan}"); + } + } + + #[test] + fn an_apply_replay_needs_the_fix_to_clear_the_threshold_not_just_be_listed() { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + // This paste lists `fix-4-render-group` below `min_score_for_match`. + let report = rocm_core::run_diagnose(&examination, "/dev/kfd: Permission denied"); + assert!( + !report.has_match, + "the premise: nothing cleared the threshold" + ); + assert!( + report.matched.iter().any(|m| m + .fix + .as_ref() + .is_some_and(|f| f.fix_id == "fix-4-render-group")), + "the premise: the fix is listed" + ); + let message = format!( + "{:#}", + apply_for("fix-4-render-group", "linux", &report) + .expect_err("a listed but sub-threshold fix is refused") + ); + assert!(message.contains("clears the threshold"), "{message}"); + } + + #[test] + fn an_apply_replay_names_an_unknown_fix_and_refuses_one_the_platform_lacks() { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + let report = rocm_core::run_diagnose(&examination, "hipErrorNoBinaryForGpu"); + let message = format!( + "{:#}", + apply_for("fix-0-nope", "linux", &report).expect_err("an unknown fix is refused") + ); + assert!(message.contains("the catalog has no fix"), "{message}"); + // `fix-4-render-group` is `auto` on Linux only, and the WSL host is `wsl`. + let message = format!( + "{:#}", + apply_for( + "fix-4-render-group", + replayed_os(Some(Host::WslHostGpuHidden)), + &report + ) + .expect_err("a fix that does not apply on WSL is refused") + ); + assert!(message.contains("`auto` on wsl"), "{message}"); + } + + #[test] + fn an_apply_replay_is_refused_for_a_fix_that_is_not_auto() { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + let host = examination_for(&examination, Host::ContainerSmallShm); + let report = rocm_core::run_diagnose(&host, "ImportError: libtorch_cuda.so"); + // `fix-19-shm-too-small` is in this diagnosis and is print-only. + let message = format!( + "{:#}", + apply_for("fix-19-shm-too-small", "linux", &report) + .expect_err("a print-only fix is refused") + ); + assert!(message.contains("`auto` on linux"), "{message}"); + } + + #[test] + fn an_apply_case_replays_the_plan_the_catalog_gives_and_the_refusal_of_a_shell_with_no_terminal() + { + let root = paths::workspace_root().expect("workspace root"); + let examination = load_examination(&root).expect("examination"); + let case = cases(&root) + .into_iter() + .find(|case| case.apply.is_some()) + .expect("a case names a fix to apply"); + let apply = replies_for(&root, &case, &examination) + .expect("replies") + .apply + .expect("an `apply` case replays the fix commands"); + let title = rocm_core::catalog_manifest() + .entries + .into_iter() + .find(|entry| entry.id == apply.fix_id) + .expect("the catalog has the fix") + .title; + assert!(apply.dry_run.stdout.contains(&title)); + assert!(apply.dry_run.stdout.contains(rocm_core::DRY_RUN_NOTICE)); + assert_eq!(apply.dry_run.rc, rocm_core::fix_exit::OK); + assert!(apply.bare.stdout.contains(&title)); + assert!(!apply.bare.stdout.contains(rocm_core::DRY_RUN_NOTICE)); + assert_eq!(apply.bare.rc, rocm_core::fix_exit::DECLINED); + assert_eq!( + apply.bare.stderr, + format!("{}\n", rocm_core::NON_INTERACTIVE_REFUSAL) + ); + } + #[test] fn a_case_id_cannot_escape_the_fixtures_directory() { let (_tmp, root) = scratch(); @@ -829,9 +1281,10 @@ mod tests { assert!(problems.is_empty(), "{problems:#?}"); } - #[test] - fn a_pin_the_skill_text_quotes_is_caught() { - let (_tmp, root) = scratch(); + /// A scratch copy that `pin_problems` can read: generated replays, and the skill + /// text it compares the pins with. It starts clean. + fn scratch_for_pins() -> (tempfile::TempDir, PathBuf) { + let (tmp, root) = scratch(); generate(&root).expect("generate"); let real = paths::workspace_root().expect("workspace root"); for file in SKILL_TEXT { @@ -840,6 +1293,53 @@ mod tests { fs::copy(real.join(file), &to).expect("copy"); } assert!(pin_problems(&root).is_empty(), "the copy starts clean"); + (tmp, root) + } + + /// Set the `logs_contain` pins of one case in the scratch copy of the dataset. + fn set_pins(root: &Path, case_id: &str, pins: &[&str]) { + edit_evals(root, |text| { + let mut evals: serde_json::Value = serde_json::from_str(&text).expect("json"); + let eval = evals["evaluations"] + .as_array_mut() + .and_then(|all| all.iter_mut().find(|e| e["id"] == case_id)) + .expect("the case is in the dataset"); + eval["logs_contain"] = serde_json::json!(pins); + serde_json::to_string_pretty(&evals).expect("json") + }); + } + + #[test] + fn a_replayed_case_that_pins_nothing_is_caught() { + let (_tmp, root) = scratch_for_pins(); + set_pins(&root, "rocm-current-cli-carries-on", &[]); + let problems = pin_problems(&root); + assert!( + problems + .iter() + .any(|p| p == "rocm-current-cli-carries-on pins nothing"), + "{problems:?}" + ); + } + + #[test] + fn a_pin_the_replay_does_not_print_is_caught() { + let (_tmp, root) = scratch_for_pins(); + set_pins( + &root, + "rocm-current-cli-carries-on", + &["text no replay prints"], + ); + let problems = pin_problems(&root); + assert!( + problems.iter().any(|p| p.contains("is not in its replay")), + "{problems:?}" + ); + } + + #[test] + fn a_pin_the_skill_text_quotes_is_caught() { + let (_tmp, root) = scratch_for_pins(); // A later skill edit that quotes a pin, in a different case. let mut skill = fs::OpenOptions::new() .append(true)