diff --git a/README.md b/README.md index 313a7f4ee1..e14962be5b 100644 --- a/README.md +++ b/README.md @@ -450,6 +450,7 @@ hardware, not something an install or a setting can put right. rocm install sdk [--channel release|nightly] [--format wheel|tarball] [--version x.y.z | --build-date YYYY-MM-DD] [--family gfx110X-all] [--prefix PATH] [--devel] [--dry-run] + [--python-version X.Y] [--approve-replacing-active-default] [--yes] rocm install driver [--dkms] [--yes] [--dry-run] [--reconcile] @@ -533,10 +534,40 @@ already there no longer runs its own Python, it is removed outright and rebuilt. The approval prompt doesn't cover this, because it asks only about changing the active default runtime, not about what a named prefix loses. +#### Which Python `install sdk` uses + +ROCm CLI picks the Python from the ROCm version it installs. ROCm 7.14 installs +use Python 3.12. ROCm 10 and newer use Python 3.14 by default, because vLLM, +flash-attn and amd-aiter for ROCm 10 are published for 3.14 only. The ROCm 10 +SDK and PyTorch wheels are also published for 3.10 to 3.14, so an install that +doesn't need vLLM can choose one: + +``` +rocm install sdk --version 10.1.0 --family gfx1200 --python-version 3.12 +``` + +With a Python other than 3.14, the SDK and PyTorch install and run, but vLLM +doesn't: the engine install that normally follows an SDK install on a vLLM GPU +is skipped with a note, and `rocm engines install vllm` refuses that runtime. +Re-run the install without `--python-version` to move it to 3.14. An update +keeps the Python the runtime was installed with. + +`--python-version` applies to ROCm 10 and newer wheel installs only. A ROCm 7 +install is built for Python 3.12 and refuses any other. A Python that doesn't +match the install is refused rather than used, so `ROCM_CLI_PYTHON` (an +interpreter of your own) and `ROCM_CLI_MANAGED_PYTHON_VERSION` (the version +ROCm CLI prepares itself) must name a Python the install accepts. + +If you see Python 3.14 without asking for it, the install resolved to ROCm 10 +or newer. That happens with `--version 10.x.y`, and also when the channel's +newest build is ROCm 10, as the nightly channel's is today. The install prints +which Python it chose, and `--dry-run` shows it without changing anything. + #### ROCm 10 and newer ROCm 10 and newer ship from a different source layout. You opt in by pinning the -version with `--version`. These versions select their device payload by exact +version with `--version` (an unpinned nightly install also gets ROCm 10 while +that channel's newest build is one, from the nightly sources as before). These versions select their device payload by exact GPU arch, so when ROCm CLI can't resolve one for this computer (it detects only a family of GPUs, or none), or you want to target a different GPU, also pass `--family` with the raw `gfx` code instead of a family label: @@ -577,8 +608,9 @@ dependency metadata alongside the pinned torchaudio. Before it creates or changes a managed runtime, it validates that every selected framework package carries the same ROCm build identifier. -Nothing about this happens on its own. Without a `--version` of 10 or newer, -`install sdk` resolves the same release and nightly sources as before. It doesn't +Nothing about this happens on its own on the release channel. Without a +`--version` of 10 or newer, `install sdk` resolves the same release and nightly +sources as before. It doesn't quietly retry against the ROCm 10 sources when a lookup finds nothing; it tells you what it couldn't find instead. diff --git a/apps/rocm/src/cli.rs b/apps/rocm/src/cli.rs index ff922a0664..f7c2fd7511 100644 --- a/apps/rocm/src/cli.rs +++ b/apps/rocm/src/cli.rs @@ -779,7 +779,8 @@ pub(crate) enum InstallTarget { rocm install sdk\n \ rocm install sdk --channel nightly --build-date 2025-01-15\n \ rocm install sdk --family gfx110X-all --dry-run\n \ -rocm install sdk --devel")] +rocm install sdk --devel\n \ +rocm install sdk --version 10.0.0 --python-version 3.12")] Sdk { /// Package channel to install, such as release or nightly. #[arg(long, default_value = "release")] @@ -805,6 +806,17 @@ rocm install sdk --devel")] /// install sdk` reports the same refusal when it detects such a GPU. #[arg(long)] family: Option, + /// Python version for a ROCm 10 or newer install, one of 3.10 to 3.14. + /// + /// ROCm 10 installs use Python 3.14 unless you name another, because + /// vLLM, flash-attn and amd-aiter for ROCm 10 are published for 3.14 + /// only. With another version the SDK and PyTorch install and run, but + /// the vLLM engine does not: the engine install that follows an SDK + /// install on a vLLM GPU is skipped, and `rocm engines install vllm` + /// refuses that runtime. Re-run without this flag to switch it to 3.14. + /// Wheel installs only; a ROCm 7 install is built for Python 3.12. + #[arg(long, value_name = "X.Y")] + python_version: Option, /// Also install the ROCm compiler, headers, and static libraries for /// building GPU code. Roughly doubles the wheel download; already /// included by `--format tarball`. diff --git a/apps/rocm/src/install_cmd.rs b/apps/rocm/src/install_cmd.rs index f7174945cd..1230258395 100644 --- a/apps/rocm/src/install_cmd.rs +++ b/apps/rocm/src/install_cmd.rs @@ -73,6 +73,7 @@ pub(crate) const fn sdk_install_request<'a>( prefix: Option, version_selector: Option, family_override: Option<&'a str>, + python_version: Option<&'a str>, dry_run: bool, devel: bool, consent: therock::SdkInstallConsent, @@ -83,6 +84,7 @@ pub(crate) const fn sdk_install_request<'a>( prefix, version_selector, family_override, + python_version, dry_run, include_devel: devel, consent, @@ -100,6 +102,7 @@ pub(crate) fn install(target: InstallTarget) -> Result<()> { version, build_date, family, + python_version, dry_run, yes, approve_replacing_active_default, @@ -125,6 +128,7 @@ pub(crate) fn install(target: InstallTarget) -> Result<()> { prefix, version_selector, family.as_deref(), + python_version.as_deref(), dry_run, devel, consents.replace_active_default, @@ -301,6 +305,7 @@ mod tests { None, None, None, + None, false, devel, therock::SdkInstallConsent::Ask, @@ -318,6 +323,7 @@ mod tests { None, None, None, + None, true, false, therock::SdkInstallConsent::Ask, @@ -348,6 +354,7 @@ mod tests { None, None, None, + None, false, devel, therock::SdkInstallConsent::Ask, diff --git a/apps/rocm/src/runtime_install_finalize.rs b/apps/rocm/src/runtime_install_finalize.rs index 8e69c8124d..4f53e4fd23 100644 --- a/apps/rocm/src/runtime_install_finalize.rs +++ b/apps/rocm/src/runtime_install_finalize.rs @@ -58,6 +58,11 @@ pub(crate) struct SdkInstallFinalization { family: String, pub(crate) previous_runtime_key: Option, services: runtime_services::RuntimeServiceReconciliation, + /// The Python the installed runtime was built on, for a ROCm 10+ runtime and + /// `None` for any other (see [`therock::recorded_python_version`]). Read from + /// the installed manifest rather than the `--python-version` text, so a ROCm 7 + /// install that was handed a redundant `3.12` is not mistaken for a moved one. + sdk_python_version: Option<&'static str>, } pub(crate) fn print_sdk_install_success(finalized: &SdkInstallFinalization) { @@ -117,6 +122,27 @@ impl SdkInstallConsents { } } +/// Why `engine` cannot be installed onto a ROCm 10+ SDK runtime built on +/// `sdk_python_version` (`rocm install sdk --python-version`), or `None` when it can +/// (including `None` for a runtime of any other layout). +/// +/// Only vLLM has a Python of its own: for ROCm 10 it is published for +/// [`therock::NEXT_MANAGED_PYTHON_VERSION`] alone, so installing it onto a runtime +/// the user moved off that Python would fail. The line names the flag that clears +/// the condition: repeating the install with that Python moves the runtime back. +fn engine_skipped_for_sdk_python(engine: &str, sdk_python_version: Option<&str>) -> Option { + let version = sdk_python_version?; + if engine != "vllm" || version == therock::NEXT_MANAGED_PYTHON_VERSION { + return None; + } + Some(format!( + "note: vLLM for ROCm 10 needs Python {}, and this runtime uses Python {version}; \ + re-run this `rocm install sdk` with --python-version {} to move it there and install vLLM", + therock::NEXT_MANAGED_PYTHON_VERSION, + therock::NEXT_MANAGED_PYTHON_VERSION + )) +} + pub(crate) fn maybe_auto_install_sdk_preferred_engine( paths: &AppPaths, finalized: &SdkInstallFinalization, @@ -133,6 +159,11 @@ pub(crate) fn maybe_auto_install_sdk_preferred_engine( ); println!(" engine: {engine}"); println!(" runtime_id: {}", finalized.runtime_key); + if let Some(note) = engine_skipped_for_sdk_python(engine, finalized.sdk_python_version) { + println!(" status: skipped"); + println!(" {note}"); + return Ok(()); + } ensure_openmpi_for_vllm(approved)?; @@ -964,6 +995,7 @@ pub(crate) fn finalize_successful_sdk_install( Ok(Some(SdkInstallFinalization { runtime_key: activation.runtime_key, + sdk_python_version: therock::recorded_python_version(&manifest), install_root: manifest.install_root, family: manifest.family, previous_runtime_key: activation.previous_runtime_key, @@ -1317,6 +1349,7 @@ pub(crate) mod tests { family: "gfx94X-dcgpu".to_owned(), previous_runtime_key: None, services: runtime_services::RuntimeServiceReconciliation::default(), + sdk_python_version: None, } } @@ -1336,6 +1369,51 @@ pub(crate) mod tests { (result, finalized) } + /// vLLM is the one engine with a Python of its own: for ROCm 10 it exists for 3.14 + /// only, so an SDK the user moved off 3.14 cannot take it. The note names the + /// command that clears the condition, and every other row has no note. + #[test] + fn engine_is_skipped_only_for_vllm_on_an_sdk_moved_off_the_vllm_python() { + let note = engine_skipped_for_sdk_python("vllm", Some("3.12")) + .expect("vLLM cannot be installed onto a Python 3.12 ROCm 10 runtime"); + assert!( + note.contains("--python-version 3.14") && note.contains("Python 3.14"), + "{note}" + ); + assert_eq!(engine_skipped_for_sdk_python("vllm", Some("3.14")), None); + assert_eq!(engine_skipped_for_sdk_python("vllm", None), None); + assert_eq!( + engine_skipped_for_sdk_python("lemonade", Some("3.12")), + None + ); + } + + /// The note is a promise that the engine install does not run, so the entry + /// point is held to it: on a vLLM family and a runtime on 3.12 it returns + /// without an engine request, which would otherwise fail here (no engine + /// binary exists in this test). + /// + /// Native Windows never prefers vLLM (`preferred_serve_engine_for_host_gpu_summary`), + /// so the skip path is unreachable there and the precondition below cannot hold. + #[cfg_attr( + windows, + ignore = "vLLM is never the preferred engine on native Windows" + )] + #[test] + fn auto_install_skips_vllm_on_an_sdk_moved_off_its_python() { + let (_root, paths) = test_paths("auto-engine-skipped-for-python"); + let finalized = SdkInstallFinalization { + sdk_python_version: Some("3.12"), + ..sdk_install_finalization() + }; + assert_eq!( + preferred_engine_for_sdk_family(&finalized.family), + Some("vllm") + ); + maybe_auto_install_sdk_preferred_engine(&paths, &finalized, false) + .expect("the engine install is skipped, not attempted"); + } + #[test] fn render_sdk_install_success_includes_service_reconciliation_section() { // Verify that the reconciliation section is printed even when no services diff --git a/apps/rocm/src/therock.rs b/apps/rocm/src/therock.rs index 75bccb49b5..38434f6dc1 100644 --- a/apps/rocm/src/therock.rs +++ b/apps/rocm/src/therock.rs @@ -40,8 +40,10 @@ pub(crate) use self::probe::{ probe_runtime_devices, probe_torch_alignment, requirement_pinned_version, split_local_version, }; use self::process::{extract_tarball_and_discard_archive, progress_line, run_uv_progress_command}; +pub(crate) use self::python::NEXT_MANAGED_PYTHON_VERSION; use self::python::{ ensure_uv_venv, managed_python_version, python_for_install, python_requirement, + python_requirement_for_version, }; use self::resolve::{ AggregateDeviceTarget, PipRuntimePlan, canonical_auto_select_needs_next_python, @@ -56,8 +58,8 @@ use self::source::{ requested_source_layout, select_source_layout, }; pub(crate) use self::update::{ - RuntimeUpdatePlan, maybe_refresh_startup_update_check, render_update_json, - render_update_report, runtime_update_check, runtime_update_plan, + RuntimeUpdatePlan, maybe_refresh_startup_update_check, recorded_python_version, + render_update_json, render_update_report, runtime_update_check, runtime_update_plan, }; pub(crate) use self::version::runtime_version_display; use self::version::{ @@ -143,6 +145,9 @@ struct InstallSourceOverride<'a> { family: Option<&'a str>, device_target: Option<&'a str>, layout: Option, + /// `--python-version`: the interpreter a ROCm 10+ install runs on in place + /// of the layout's default. + python_version: Option<&'a str>, } /// What to install, as resolved from the `rocm install sdk` arguments. @@ -157,6 +162,9 @@ pub(crate) struct SdkInstallRequest<'a> { pub prefix: Option, pub version_selector: Option, pub family_override: Option<&'a str>, + /// `--python-version`: the Python a ROCm 10+ install runs on, when not the + /// default one. Only a wheel install has a Python to choose. + pub python_version: Option<&'a str>, pub dry_run: bool, /// Install the compiler and headers alongside the runtime libraries. pub include_devel: bool, @@ -177,6 +185,7 @@ impl Default for SdkInstallRequest<'_> { prefix: None, version_selector: None, family_override: None, + python_version: None, dry_run: false, include_devel: false, // Withholding consent is the safe default: a caller that leaves it @@ -198,11 +207,15 @@ pub(crate) fn install_sdk( prefix, version_selector, family_override, + python_version, dry_run, include_devel, consent, } = request; let channel = TheRockChannel::parse(channel)?; + if python_version.is_some() && format != "wheel" { + bail!("--python-version applies only to wheel installs; a tarball install uses no Python"); + } ensure_install_format_supported(format)?; match format { "wheel" => install_wheel_runtime( @@ -211,6 +224,7 @@ pub(crate) fn install_sdk( prefix, InstallSourceOverride { family: family_override, + python_version, ..InstallSourceOverride::default() }, version_selector.as_ref(), @@ -268,6 +282,7 @@ pub(crate) fn install_sdk_for_update( device_target: Option<&str>, source_layout_generation: Option<&str>, include_devel: bool, + python_version: Option<&str>, dry_run: bool, activate_after_install: bool, ) -> Result { @@ -286,22 +301,28 @@ pub(crate) fn install_sdk_for_update( family: Some(family), device_target, layout, + python_version, }, None, dry_run, include_devel, consent, ), - "tarball" => install_tarball_runtime( - paths, - channel, - None, - Some(family), - None, - layout, - dry_run, - consent, - ), + "tarball" => { + if python_version.is_some() { + bail!("a tarball install uses no Python, so it has no --python-version"); + } + install_tarball_runtime( + paths, + channel, + None, + Some(family), + None, + layout, + dry_run, + consent, + ) + } other => bail!("unsupported install format: {other}"), } } @@ -334,6 +355,7 @@ fn install_wheel_runtime( family: family_override, device_target: device_target_override, layout: layout_override, + python_version: python_version_override, } = source_override; // `device_target_override` (an update apply's exact recorded arch) is only // otherwise consulted after `resolve_pip_runtime` returns — too late for the @@ -359,16 +381,20 @@ fn install_wheel_runtime( // the canonical/nightly feed's own "latest" has rotated past that major on // its own, with no `Next` routing involved. `canonical_auto_select_needs_next_python` // peeks the channel's own `rocm` listing to catch that case. - let python_requirement = match requested_source_layout(layout_override, version_selector) { - SourceLayout::Next => python_requirement(SourceLayout::Next), + let python_layout = match requested_source_layout(layout_override, version_selector) { + SourceLayout::Next => SourceLayout::Next, SourceLayout::Canonical => { if canonical_auto_select_needs_next_python(paths, channel, version_selector)? { - python_requirement(SourceLayout::Next) + SourceLayout::Next } else { - python_requirement(SourceLayout::Canonical) + SourceLayout::Canonical } } }; + let python_requirement = match python_version_override { + Some(version) => python_requirement_for_version(python_layout, version)?, + None => python_requirement(python_layout), + }; // A preview promises nothing here: whether a Python would be prepared, and // which, is only known once the search below has run (a version override can // make the answer a refusal), and is reported then. @@ -1081,6 +1107,35 @@ mod tests { use super::test_support::{test_paths, test_runtime_manifest}; use super::*; + /// `--format tarball` installs no Python, so a Python choice cannot be honoured + /// and is refused before anything is resolved or downloaded. The refusal comes + /// ahead of the platform's tarball check so it reads the same on every host. + #[test] + fn python_version_is_refused_for_a_tarball_install() { + let (_root, paths) = test_paths("tarball-python-version-refused"); + let error = install_sdk( + &paths, + SdkInstallRequest { + channel: "release", + format: "tarball", + prefix: None, + version_selector: None, + family_override: None, + python_version: Some("3.12"), + dry_run: true, + include_devel: false, + consent: SdkInstallConsent::Ask, + }, + ) + .expect_err("a tarball install has no Python to choose"); + assert!( + error + .to_string() + .contains("--python-version applies only to wheel installs"), + "{error}" + ); + } + #[test] fn download_space_requirement_includes_the_safety_margin() { let archive = 2 * 1024 * 1024 * 1024; diff --git a/apps/rocm/src/therock/python.rs b/apps/rocm/src/therock/python.rs index 3ca1ff1a55..9dbb3b4e2c 100644 --- a/apps/rocm/src/therock/python.rs +++ b/apps/rocm/src/therock/python.rs @@ -35,7 +35,7 @@ const DEFAULT_MANAGED_PYTHON_VERSION: &str = "3.12"; /// Interpreter `uv` provisions for a [`SourceLayout::Next`] install. See /// [`python_requirement`] for why this differs from the canonical default. -const NEXT_MANAGED_PYTHON_VERSION: &str = "3.14"; +pub(crate) const NEXT_MANAGED_PYTHON_VERSION: &str = "3.14"; #[derive(Debug, Clone)] pub(super) struct WheelCompatibility { @@ -244,8 +244,8 @@ fn managed_python_bootstrap_disabled() -> bool { /// [`THEROCK_NEXT_MIN_MAJOR`]: super::source::THEROCK_NEXT_MIN_MAJOR #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub(super) struct PythonRequirement { - tag: &'static str, - version: &'static str, + pub(super) tag: &'static str, + pub(super) version: &'static str, } /// The interpreter required to install from `layout`. @@ -274,6 +274,88 @@ pub(super) const fn python_requirement(layout: SourceLayout) -> PythonRequiremen } } +/// The CPython versions a ROCm 10+ install can run on when nothing needs vLLM: +/// the SDK device wheels are `py3-none` and the torch stack is published for +/// each of these. [`NEXT_MANAGED_PYTHON_VERSION`] stays the default because +/// vLLM, flash-attn and amd-aiter for ROCm 10 exist for it alone. +const NEXT_SDK_PYTHONS: [PythonRequirement; 5] = [ + PythonRequirement { + tag: "cp310", + version: "3.10", + }, + PythonRequirement { + tag: "cp311", + version: "3.11", + }, + PythonRequirement { + tag: "cp312", + version: "3.12", + }, + PythonRequirement { + tag: "cp313", + version: "3.13", + }, + PythonRequirement { + tag: "cp314", + version: NEXT_MANAGED_PYTHON_VERSION, + }, +]; + +/// The interpreter `layout` requires when the user asked for `version` +/// (`rocm install sdk --python-version`). +/// +/// Only a [`SourceLayout::Next`] install has a choice; the canonical stream is +/// published for one interpreter, so naming anything else for it is refused +/// instead of ignored. +pub(super) fn python_requirement_for_version( + layout: SourceLayout, + version: &str, +) -> Result { + let version = version.trim(); + match layout { + SourceLayout::Next => NEXT_SDK_PYTHONS + .iter() + .copied() + .find(|candidate| candidate.version == version) + .with_context(|| { + let supported = NEXT_SDK_PYTHONS + .iter() + .map(|candidate| candidate.version) + .collect::>() + .join(", "); + format!( + "--python-version {version} is not one ROCm 10 and newer is published for; use one of {supported}" + ) + }), + SourceLayout::Canonical => { + let required = python_requirement(layout); + if version == required.version { + return Ok(required); + } + bail!( + "--python-version applies only to ROCm 10 and newer installs; this install uses Python {}", + required.version + ) + } + } +} + +/// The requirement a runtime installed from `layout` was built for, read from +/// the wheel `tag` of the interpreter it recorded. `None` for a tag the layout +/// is not published for, so the caller falls back to the layout's default. +pub(super) fn python_requirement_for_tag( + layout: SourceLayout, + tag: &str, +) -> Option { + match layout { + SourceLayout::Next => NEXT_SDK_PYTHONS + .iter() + .copied() + .find(|candidate| candidate.tag == tag), + SourceLayout::Canonical => None, + } +} + fn managed_python_version_override() -> Option { std::env::var("ROCM_CLI_MANAGED_PYTHON_VERSION").ok() } @@ -1105,6 +1187,75 @@ exit 1 assert_eq!(DEFAULT_MANAGED_PYTHON_VERSION, "3.12"); } + /// `--python-version` is a choice among the interpreters the layout is + /// published for. ROCm 10 takes 3.10 to 3.14 (each with its own wheel tag and + /// the version `uv` is asked for); the canonical layout takes only its own 3.12; + /// everything else is refused with the allowed set named, not ignored. + #[test] + fn python_version_is_a_choice_among_the_layouts_published_pythons() { + for (version, tag) in [ + ("3.10", "cp310"), + ("3.11", "cp311"), + ("3.12", "cp312"), + ("3.13", "cp313"), + ("3.14", "cp314"), + (" 3.12 ", "cp312"), + ] { + let requirement = python_requirement_for_version(SourceLayout::Next, version) + .unwrap_or_else(|error| panic!("{version} must be accepted: {error:#}")); + assert_eq!(requirement.tag, tag, "{version}"); + assert_eq!(requirement.version, version.trim(), "{version}"); + } + for version in ["3.9", "3.15", "3", "3.12.1", "cpython-3.12", ""] { + let error = python_requirement_for_version(SourceLayout::Next, version) + .expect_err("an unpublished Python must be refused"); + let rendered = format!("{error:#}"); + assert!( + rendered.contains("3.10, 3.11, 3.12, 3.13, 3.14"), + "{version}: {rendered}" + ); + } + + assert_eq!( + python_requirement_for_version(SourceLayout::Canonical, "3.12") + .expect("the canonical layout's own Python is accepted"), + python_requirement(SourceLayout::Canonical) + ); + let error = python_requirement_for_version(SourceLayout::Canonical, "3.13") + .expect_err("the canonical layout has one Python"); + let rendered = format!("{error:#}"); + assert!( + rendered.contains("applies only to ROCm 10 and newer installs") + && rendered.contains("this install uses Python 3.12"), + "{rendered}" + ); + } + + /// An update keeps the interpreter a ROCm 10 runtime was built on. The tag + /// recorded in the runtime maps back to the requirement it came from for every + /// published Python, a tag the layout is not published for maps to none (so the + /// update falls back to the layout's default), and the canonical layout never + /// reads one. + #[test] + fn a_recorded_wheel_tag_maps_back_to_the_requirement_it_came_from() { + for requirement in NEXT_SDK_PYTHONS { + assert_eq!( + python_requirement_for_tag(SourceLayout::Next, requirement.tag), + Some(requirement) + ); + } + assert_eq!(python_requirement_for_tag(SourceLayout::Next, "cp39"), None); + assert_eq!( + python_requirement_for_tag(SourceLayout::Canonical, "cp313"), + None + ); + // The default stays the one vLLM needs, so a flag-less install is unchanged. + assert_eq!( + python_requirement(SourceLayout::Next), + python_requirement_for_tag(SourceLayout::Next, "cp314").expect("cp314 is published") + ); + } + /// ROCm 10.x framework wheels (vLLM, flash-attn, amd-aiter) are published /// cp314-only, so the next layout must provision 3.14 while everything else /// stays on 3.12. diff --git a/apps/rocm/src/therock/update.rs b/apps/rocm/src/therock/update.rs index a006fece71..1f0972ba3b 100644 --- a/apps/rocm/src/therock/update.rs +++ b/apps/rocm/src/therock/update.rs @@ -31,15 +31,16 @@ use super::family::family_override_or_recovered_arch; use super::process::SuppressProgressOutput; use super::python::{ - PythonLauncher, PythonSource, plan_python_launcher, python_launcher_install_ready, - python_requirement, resolve_python_launcher, wheel_compatibility_for_python, + PythonLauncher, PythonRequirement, PythonSource, plan_python_launcher, + python_launcher_install_ready, python_requirement, python_requirement_for_tag, + resolve_python_launcher, wheel_compatibility_for_python, }; use super::resolve::{ AggregateDeviceTarget, resolve_pip_runtime_with_timeout, resolve_tarball_artifact_with_timeout, wheel_runtime_composition, }; -use super::source::{SourceLayout, TheRockChannel}; -use super::version::{runtime_version_display, version_relation}; +use super::source::{SourceLayout, THEROCK_NEXT_MIN_MAJOR, TheRockChannel}; +use super::version::{parse_version, runtime_version_display, version_relation}; use super::{runtime_key, wheel_runtime_key}; use crate::runtime_registry::{ InstalledRuntimeManifest, WheelRuntimeComposition, load_runtime_manifests, @@ -476,6 +477,66 @@ fn manifest_wheel_family_override(manifest: &InstalledRuntimeManifest) -> String family_override_or_recovered_arch(&manifest.family, recorded_arch) } +/// The layout whose interpreters `manifest`'s runtime was built against. +/// +/// The recorded source layout is not enough: an unpinned or build-date nightly +/// install records the canonical layout even when the channel's newest build is +/// ROCm 10 and the install went on the ROCm 10 Python (see +/// `canonical_auto_select_needs_next_python`). The recorded ROCm version is the +/// other half of the answer, so a ROCm 10+ runtime counts as `Next` whichever +/// layout it was read from. +fn python_layout_of(manifest: &InstalledRuntimeManifest, layout: SourceLayout) -> SourceLayout { + let rocm_10_or_newer = parse_version(&manifest.version) + .is_some_and(|parsed| parsed.major >= THEROCK_NEXT_MIN_MAJOR); + if layout == SourceLayout::Next || rocm_10_or_newer { + SourceLayout::Next + } else { + SourceLayout::Canonical + } +} + +/// The interpreter an update of `manifest` goes on with. +/// +/// A ROCm 10+ runtime installed with `--python-version` keeps the Python it was +/// built on, so an update does not silently move it to the layout's default +/// (which would also leave it unable to carry the packages it was chosen for). +/// Anything else follows the layout. +fn recorded_python_requirement( + manifest: &InstalledRuntimeManifest, + layout: SourceLayout, +) -> PythonRequirement { + let tag = manifest + .python_executable + .as_deref() + .map(PathBuf::from) + .filter(|path| path.is_file()) + .and_then(|path| wheel_compatibility_for_python(&path).ok()) + .map(|compatibility| compatibility.python_tag); + requirement_for_recorded_tag(manifest, layout, tag.as_deref()) +} + +/// [`recorded_python_requirement`] once the recorded interpreter's wheel tag has +/// been read (`None` when it is missing or unreadable), so the decision runs +/// without a Python on disk. +fn requirement_for_recorded_tag( + manifest: &InstalledRuntimeManifest, + layout: SourceLayout, + tag: Option<&str>, +) -> PythonRequirement { + let layout = python_layout_of(manifest, layout); + tag.and_then(|tag| python_requirement_for_tag(layout, tag)) + .unwrap_or_else(|| python_requirement(layout)) +} + +/// The `--python-version` an update of `manifest` reinstalls with: the one the +/// runtime was built on, for a ROCm 10+ wheel runtime, and none for any other (a +/// tarball runtime has no Python of its own to carry over). +pub(crate) fn recorded_python_version(manifest: &InstalledRuntimeManifest) -> Option<&'static str> { + let layout = manifest_source_layout(manifest).ok()?; + (manifest.format == "wheel" && python_layout_of(manifest, layout) == SourceLayout::Next) + .then(|| recorded_python_requirement(manifest, layout).version) +} + fn resolve_latest_for_manifest( paths: &AppPaths, manifest: &InstalledRuntimeManifest, @@ -490,7 +551,7 @@ fn resolve_latest_for_manifest( // interpreter, so the recorded one is re-checked rather than trusted // on `is_file()` alone; otherwise a canonical cp312 venv would carry // into a next-layout update and resolve nothing. - let requirement = python_requirement(layout); + let requirement = recorded_python_requirement(manifest, layout); let manifest_python = manifest .python_executable .as_deref() @@ -771,6 +832,66 @@ mod tests { assert_eq!(manifest_wheel_family_override(&manifest), "gfx120X-all"); } + /// The engine auto-install skip reads this: a ROCm 7 (canonical) runtime has no + /// recorded Python choice even when it was installed with a redundant + /// `--python-version 3.12`, so vLLM is never skipped on it. + #[test] + fn recorded_python_version_is_only_reported_for_a_rocm_10_runtime() { + let mut manifest = test_runtime_manifest("runtime-key", "therock-release:gfx94X-dcgpu", 0); + assert_eq!(recorded_python_version(&manifest), None); + + manifest.source_layout_generation = Some("next-v1".to_owned()); + manifest.format = "wheel".to_owned(); + assert_eq!( + recorded_python_version(&manifest), + Some(super::super::NEXT_MANAGED_PYTHON_VERSION) + ); + + manifest.format = "tarball".to_owned(); + assert_eq!(recorded_python_version(&manifest), None); + } + + /// An unpinned nightly install that resolved to ROCm 10 records the canonical + /// layout, yet it runs on the ROCm 10 Python; the chosen interpreter must still + /// be carried over, and a ROCm 7 runtime on the same layout must not. + #[test] + fn nightly_rocm_10_runtime_recorded_as_canonical_keeps_its_chosen_python() { + let mut manifest = test_runtime_manifest("runtime-key", "therock-nightly:gfx94X-dcgpu", 0); + manifest.channel = "nightly".to_owned(); + manifest.version = "10.0.0a20261105".to_owned(); + manifest.source_layout_generation = Some("multi-arch-v2".to_owned()); + assert_eq!( + manifest_source_layout(&manifest).unwrap(), + SourceLayout::Canonical + ); + + let layout = SourceLayout::Canonical; + assert_eq!( + requirement_for_recorded_tag(&manifest, layout, Some("cp312")).version, + "3.12" + ); + assert_eq!( + requirement_for_recorded_tag(&manifest, layout, Some("cp314")).version, + super::super::NEXT_MANAGED_PYTHON_VERSION + ); + // Interpreter missing or unreadable: the ROCm 10 default, not cp312. + assert_eq!( + requirement_for_recorded_tag(&manifest, layout, None).version, + super::super::NEXT_MANAGED_PYTHON_VERSION + ); + assert_eq!( + recorded_python_version(&manifest), + Some(super::super::NEXT_MANAGED_PYTHON_VERSION) + ); + + manifest.version = "7.13.0a20260416".to_owned(); + assert_eq!(recorded_python_version(&manifest), None); + assert_eq!( + requirement_for_recorded_tag(&manifest, layout, Some("cp312")).tag, + "cp312" + ); + } + /// An installed runtime must keep resolving the stream it came from, and a /// manifest written before the field existed must still be readable. #[test] diff --git a/apps/rocm/src/update_cmd.rs b/apps/rocm/src/update_cmd.rs index c329c90d9f..37d953593b 100644 --- a/apps/rocm/src/update_cmd.rs +++ b/apps/rocm/src/update_cmd.rs @@ -349,6 +349,7 @@ fn apply_runtime_update_with( plan.device_target.as_deref(), plan.source_layout_generation.as_deref(), source.includes_devel(), + therock::recorded_python_version(source), true, activate, )?; @@ -374,6 +375,7 @@ fn apply_runtime_update_with( // Reinstall what the user originally chose rather than silently // adding or dropping the compiler toolchain on update. source.includes_devel(), + therock::recorded_python_version(source), false, activate, )?; diff --git a/docs/architecture.md b/docs/architecture.md index 93dca4dc8d..48a658cb9f 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -115,7 +115,7 @@ Each per-crate module inventory lists one file per line. Flat inventories (every - [`therock/fetch.rs`](../apps/rocm/src/therock/fetch.rs) — full domain extraction, a child of `therock.rs` that depends on rocm-core's [`atomic_write.rs`](../crates/rocm-core/src/atomic_write.rs) for atomic writes and on `slugify` in the parent for cache file names (split out of `therock.rs`): HTTP fetching for installs. `download_text_cached` is the metadata GET with its on-disk etag cache (`CachedHttp*`) and detached-signature verification (`MetadataSignaturePolicy`, `PINNED_METADATA_PUBLIC_KEY_PEM`, the unset trust root that `cargo xtask verify-pinned-keys` checks against the canonical published key, so its path is pinned in `xtask`); `download_file` is the streaming artifact download; `head_content_length` and `preflight_tarball_space` size the download and check free space first; `http_get` is the shared request. `truthy_env` is `pub(crate)` and re-exported by `therock.rs` for [`driver_plan/rocdxg.rs`](../apps/rocm/src/driver_plan/rocdxg.rs); `download_text_cached`, `download_file`, `preflight_tarball_space` and the `CachedHttpText` struct (with its `text` field) that `download_text_cached` returns are `pub(super)` for the install and resolution code that stays in `therock.rs`; everything else is private. - [`therock/source.rs`](../apps/rocm/src/therock/source.rs) — full domain extraction, a child of `therock.rs` that depends only on `therock/version.rs` (split out of `therock.rs`): where an install reads from. `TheRockChannel` (release or nightly) and `SourceLayout` (the canonical stream, or ROCm 10's separately hosted next layout) are the two axes; `resolve_source` maps a pair to the `ResolvedSource` wheel-index and tarball-catalog bases, honouring a `ROCM_CLI_THEROCK_*_BASE` override only behind the explicit opt-in (`therock_base_override_allowed`, `select_base_override`, `env_override_base`); `select_source_layout`, `requested_source_layout` and `next_layout_requested` decide the layout from a pin; `RuntimeVersionSelector` is the version or build date a user pins (`pub(crate)`, re-exported by `therock.rs`). `FamilyResolution` lives here rather than in `therock/family.rs` because choosing the layout reads it; that keeps the dependency one-way, with `family.rs` building on this file. `TheRockChannel`, `SourceLayout`, `ResolvedSource` and `FamilyResolution` (with their methods and fields), `RuntimeVersionSelector`'s `describe` and `matches_version`, `resolve_source`, the three layout functions, and the `THEROCK_SOURCE_LAYOUT_GENERATION` and `THEROCK_NEXT_MIN_MAJOR` constants are `pub(super)` for `therock.rs` and its siblings; the base-override helpers and the other constants (the per-channel and next-layout base URLs, and the next layout's generation tag) are private to this file. - [`therock/family.rs`](../apps/rocm/src/therock/family.rs) — full domain extraction, a child of `therock.rs` that builds on `therock/source.rs` for `TheRockChannel` and `FamilyResolution` (split out of `therock.rs`): which package family a request targets. `resolve_family` picks it from `--family`, `ROCM_CLI_THEROCK_FAMILY`, a managed runtime or the host GPU, in that order, and refuses a GPU with no ROCm build (`unsupported_host_gpu_message`, `unsupported_requested_target_message`) instead of substituting another family; `family_override_or_recovered_arch` and `raw_arch_agreeing_with_family` recover the exact arch behind a grouped family; `family_resolution_hint` is the recovery text appended when no runtime is found. `resolve_family`, `family_override_or_recovered_arch` and `family_resolution_hint` are `pub(super)`; the rest is private. -- [`therock/python.rs`](../apps/rocm/src/therock/python.rs) — full domain extraction, a child of `therock.rs` that builds on `therock/io.rs`, `therock/process.rs` and `therock/source.rs` (split out of `therock.rs`): the Python an install runs on. `python_requirement` maps a `SourceLayout` to the interpreter the layout needs (`PythonRequirement`: wheel tag and `uv` version), which is why `source.rs` had to move first; `resolve_python_launcher` finds one in order of an explicit `ROCM_CLI_PYTHON`, `PATH`, the saved managed Python, then `ensure_managed_python`, which installs one through `uv` and records it in the managed-Python manifest; the resolver reads its environment through `PythonResolverEnv`, so tests steer it with a thread-local override (`OverridePythonResolverEnv`) rather than rewriting `PATH`; `wheel_compatibility_for_python` and `current_platform_wheel_tags` report the wheel tags an interpreter and platform accept (`WheelCompatibility`); `ensure_uv_venv` creates, or recreates when the interpreter tag no longer matches, the runtime's virtual environment. `plan_python_launcher` is the same lookup for a caller that must change nothing, an install preview or an update check: it returns a `PlannedPython`, either `Ready` with the interpreter a real install would pick or `WouldPrepareManaged` with the managed Python a real install would prepare and this caller did not, and it raises the refusals the real resolution raises before that step. `python_for_install` is the install's one choice between that and `resolve_python_launcher`, and prints the progress line that names the interpreter; `PlannedPython` also writes the `python_note:` line from the decision itself, `note` for an install preview and `update_note` for an update check, so a note cannot name a version the install will not prepare. `venv_python_path` stays in `therock.rs` for good, with the other keys and roots helpers, and this module reads it from there. The items `therock.rs` reaches, `plan_python_launcher` with `PlannedPython`'s `wheel_compatibility` and `update_note`, which `therock/update.rs` reads, and `split_runtime_path`, which `therock/probe.rs` reads, are `pub(super)`; the rest is private, including `ensure_managed_python` and `resolve_python_launcher_in` (the resolver's entry point that takes its environment as an argument). Its Unix-only tests drive fake interpreters and `uv` scripts. +- [`therock/python.rs`](../apps/rocm/src/therock/python.rs) — full domain extraction, a child of `therock.rs` that builds on `therock/io.rs`, `therock/process.rs` and `therock/source.rs` (split out of `therock.rs`): the Python an install runs on. `python_requirement` maps a `SourceLayout` to the interpreter the layout needs (`PythonRequirement`: wheel tag and `uv` version), which is why `source.rs` had to move first; `python_requirement_for_version` narrows it to the interpreter `rocm install sdk --python-version` asked for (a ROCm 10 layout takes 3.10 to 3.14, the canonical layout only its own), and `python_requirement_for_tag` maps a runtime's recorded wheel tag back to its requirement so an update keeps it; `resolve_python_launcher` finds one in order of an explicit `ROCM_CLI_PYTHON`, `PATH`, the saved managed Python, then `ensure_managed_python`, which installs one through `uv` and records it in the managed-Python manifest; the resolver reads its environment through `PythonResolverEnv`, so tests steer it with a thread-local override (`OverridePythonResolverEnv`) rather than rewriting `PATH`; `wheel_compatibility_for_python` and `current_platform_wheel_tags` report the wheel tags an interpreter and platform accept (`WheelCompatibility`); `ensure_uv_venv` creates, or recreates when the interpreter tag no longer matches, the runtime's virtual environment. `plan_python_launcher` is the same lookup for a caller that must change nothing, an install preview or an update check: it returns a `PlannedPython`, either `Ready` with the interpreter a real install would pick or `WouldPrepareManaged` with the managed Python a real install would prepare and this caller did not, and it raises the refusals the real resolution raises before that step. `python_for_install` is the install's one choice between that and `resolve_python_launcher`, and prints the progress line that names the interpreter; `PlannedPython` also writes the `python_note:` line from the decision itself, `note` for an install preview and `update_note` for an update check, so a note cannot name a version the install will not prepare. `venv_python_path` stays in `therock.rs` for good, with the other keys and roots helpers, and this module reads it from there. The items `therock.rs` reaches, `plan_python_launcher` with `PlannedPython`'s `wheel_compatibility` and `update_note`, which `therock/update.rs` reads, and `python_requirement_for_tag`, which `therock/update.rs` reads, and `split_runtime_path`, which `therock/probe.rs` reads, are `pub(super)`; the rest is private, including `ensure_managed_python` and `resolve_python_launcher_in` (the resolver's entry point that takes its environment as an argument). Its Unix-only tests drive fake interpreters and `uv` scripts. - [`therock/probe.rs`](../apps/rocm/src/therock/probe.rs) — full domain extraction, a child of `therock.rs` that builds on `therock/process.rs` and `therock/python.rs` (split out of `therock.rs`): asking an installed runtime about itself through its own interpreter. `probe_rocm_sdk_runtime` runs `ROCM_SDK_PROBE_SCRIPT` and parses what `rocm_sdk` reports into the `RocmSdkPythonProbe` that [`runtime_registry.rs`](../apps/rocm/src/runtime_registry.rs) owns and validates; `probe_runtime_devices` runs `RUNTIME_DEVICE_PROBE_SCRIPT` to count the devices the runtime's torch can open and whether one can run a kernel (`RuntimeDeviceProbe`); `probe_torch_alignment` reads the installed torch and the one an engine pins from distribution metadata without importing torch (`TorchAlignmentProbe`); and `split_local_version`, `requirement_pinned_version` and `install_pinned_package` are the torch-pin helpers [`runtime_install_finalize.rs`](../apps/rocm/src/runtime_install_finalize.rs) uses to put the SDK's torch back after an engine install. The `pub(crate)` items are re-exported by `therock.rs` for [`runtime_install_finalize.rs`](../apps/rocm/src/runtime_install_finalize.rs) and [`runtimes_cmd.rs`](../apps/rocm/src/runtimes_cmd.rs); `probe_rocm_sdk_runtime_for_target`, which `install_wheel_runtime` calls with the device payload it just chose, is `pub(super)`. - [`therock/resolve.rs`](../apps/rocm/src/therock/resolve.rs) — a child of `therock.rs` that holds no logic (split out of `therock.rs`): only the `mod` declarations for the artifact-resolution modules under `therock/resolve/` and the `pub(super) use` lines through which `therock.rs` reads them. It is the parent the `resolve/` files hang from, so a module there is `pub(in crate::therock)` for the items `therock.rs` reaches and private otherwise. - [`therock/resolve/tarball.rs`](../apps/rocm/src/therock/resolve/tarball.rs) — full domain extraction, a child of `therock/resolve.rs` that builds on `therock/fetch.rs`, `therock/family.rs`, `therock/source.rs` and `therock/version.rs` (split out of `therock.rs`): resolving the SDK tarball a request installs. `resolve_tarball_artifact` (and `resolve_tarball_artifact_with_timeout`, which takes the metadata download timeout) resolves the family and source layout, downloads the catalog through the cached metadata fetch, and returns the `TarballArtifact` it chose; `parse_tarball_index_html` reads the catalog's embedded file list into `TarballIndexFile`s and `validate_tarball_file_name` refuses an entry that is not a plain file name; `select_tarball_candidate` picks the newest archive the request can install, with `tarball_family_token` spelling the family the way the next layout's catalog does. `platform_tarball_token`, which names the archives' platform, stays in `therock.rs` for good, with the other keys and roots helpers, and this module reads it from there. Only `resolve_tarball_artifact*` and `TarballArtifact` are visible beyond this file. diff --git a/docs/manual-testing.md b/docs/manual-testing.md index 0a4aaacc9b..bb0892a11d 100644 --- a/docs/manual-testing.md +++ b/docs/manual-testing.md @@ -194,6 +194,19 @@ Expected result: with the install's own message. Its output before the failure states only what was found (for example that the `PATH` Python is not usable) and never says a real install would prepare or use a managed Python. +- `rocm install sdk --version 10.0.0 --family gfx1200 --python-version 3.12 + --dry-run` plans Python 3.12 (`python_wheel_tag: cp312`, and a managed Python + 3.12 in the note on a host with none), and nothing in the plan says 3.14. + `--python-version 3.13` on an unpinned ROCm 7 install is refused, naming + Python 3.12 as the one that install uses, and `--python-version 3.9` on a + ROCm 10 install is refused naming 3.10 to 3.14. A real ROCm 10 install on a + vLLM GPU family with `--python-version 3.12` skips the engine auto-install + with a note, while a real ROCm 7 install on that family with `--python-version + 3.12` (the redundant, accepted value) still auto-installs vLLM. +- On the ROCm 10 runtime installed on Python 3.12 (including an unpinned + nightly install that resolved to ROCm 10), `rocm engines install vllm` names + the wheel tag it needs, and `rocm update` of that runtime builds the new one + on Python 3.12 again. - rocm-cli creates or reuses a rocm-cli managed Python venv. - pip installs pinned `rocm`, `torch`, and `torchvision` requirements with exactly one `device-` extra (`rocm` also requests diff --git a/docs/testing.md b/docs/testing.md index a14998ac39..46fe6f79dd 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -892,6 +892,18 @@ order and the interpreter probes, whose stand-ins are shell scripts as in the other resolver tests, and no end-to-end run covers the Windows preview, so the Windows search order (`python`, `python3`, `py` with `PATHEXT`) is not covered by any test. +`rocm install sdk --python-version` is covered by scenarios `runtime-29` (a ROCm +10 preview plans the requested Python and its wheel tag, and not 3.14) and +`runtime-30` (a version the canonical layout is not published for is refused, +preparing nothing; the ROCm 10 refusal is unit-tested only). The rest is unit-tested in [python.rs](../apps/rocm/src/therock/python.rs): +`python_version_is_a_choice_among_the_layouts_published_pythons` is the matrix of +layout against requested version, and +`a_recorded_wheel_tag_maps_back_to_the_requirement_it_came_from` is what lets an +update keep a runtime's Python. That a ROCm 10 runtime on another Python skips the vLLM +auto-install is `auto_install_skips_vllm_on_an_sdk_moved_off_its_python` in +[runtime_install_finalize.rs](../apps/rocm/src/runtime_install_finalize.rs), and that a ROCm 7 runtime never does (whatever `--python-version` it was given) is `recorded_python_version_is_only_reported_for_a_rocm_10_runtime` in [update.rs](../apps/rocm/src/therock/update.rs); a tarball install refusing the flag is `python_version_is_refused_for_a_tarball_install` in [therock.rs](../apps/rocm/src/therock.rs). A real +install and an update on a non-default Python are not covered by a scenario: they +need a ROCm 10 SDK download. `a_dry_runs_whole_python_output_follows_one_decision_in_every_state` in [python.rs](../apps/rocm/src/therock/python.rs) is the state matrix: every combination of `PATH` Python (usable, unusable, absent), saved Python (usable, diff --git a/docs/vllm.md b/docs/vllm.md index 2e535af97e..f8b07d36cd 100644 --- a/docs/vllm.md +++ b/docs/vllm.md @@ -78,9 +78,15 @@ so there is no fixed filename to pin in the adapter. The wheel's own tag shows the other thing that changes on this route: ROCm 10.x's vLLM, flash-attn, and amd-aiter are published for **`cp314` only**, unlike every earlier ROCm SDK version's `cp312` wheels. ROCm CLI provisions a matching -interpreter for a 10.x install automatically. A Python already on `PATH`, or -already installed as ROCm CLI's managed Python, is rejected if it is not -`cp314`, with a message naming the required tag. +interpreter for a 10.x install automatically. By default, a Python already on +`PATH`, or already installed as ROCm CLI's managed Python, is rejected if it is +not `cp314`, with a message naming the required tag; with `--python-version` +(below) the tag it names is the one you chose. +That 3.14 is the default for a ROCm 10.x SDK install, not a limit of the SDK: the +SDK and torch wheels are published for 3.10 to 3.14, and `rocm install sdk +--python-version` picks one of them for an install that does not need vLLM. The +vLLM install then refuses that runtime; re-running the install with +`--python-version 3.14` moves it back. This route is selected by `major.minor`, so `10.0.0` and `10.1.0` discover through *different* rows: they pin different vLLM minors and read vLLM from diff --git a/tests/e2e-cucumber/features/runtime_setup.feature b/tests/e2e-cucumber/features/runtime_setup.feature index 35be0b0678..e1a375cbe6 100644 --- a/tests/e2e-cucumber/features/runtime_setup.feature +++ b/tests/e2e-cucumber/features/runtime_setup.feature @@ -634,3 +634,39 @@ Feature: Runtime configuration And a host with no uv and no usable Python When the user previews a wheel SDK install for arch gfx1200 pinned to ROCm 10.0.0 Then the preview says it did not resolve the ROCm 10 package versions, as it says + + # ROCm 10 installs use Python 3.14 because vLLM, flash-attn and amd-aiter for + # ROCm 10 exist for it alone, but the SDK and PyTorch wheels are published for + # older Pythons too. `--python-version` lets an install that does not need vLLM + # pick one. The preview must plan what the install would do with it: the + # requested interpreter and its wheel tag, not the default's, with the same + # resolution as runtime-27. Only the plan is asserted here; no scenario runs + # resolution with the chosen interpreter. + # + # Linux only, for the same empty-`PATH` host as runtime-23. + @id:runtime-install-preview-of-rocm-10-honours-python-version @requires-os:linux + Scenario: runtime-29 - Previewing a ROCm 10 SDK install with --python-version plans that Python and not the default + Given a canonical release pip index fixture and a ROCm 10 pip index fixture + And a host with no usable Python and a recording uv + And the recording uv answers uv pip compile with the ROCm 10 fixture's versions + When the user previews a wheel SDK install for arch gfx1200 pinned to ROCm 10.0.0 on Python 3.12 + Then the preview plans Python 3.12 and its cp312 wheel tag and not the default + + # The flag is a choice among the interpreters the layout is published for, so a + # request for one it is not published for is refused instead of ignored: a + # canonical (ROCm 7) install, whose one interpreter is 3.12. This scenario covers + # that refusal; the ROCm 10 refusal (a Python the index has no wheels for) is + # unit-tested only. The refusal names the Python that is allowed, and nothing is + # prepared on the way to it. + # + # Linux only, for the same empty-`PATH` host as runtime-23. Each combination of + # layout and version is also unit-tested on every platform + # (`python_version_is_a_choice_among_the_layouts_published_pythons` in + # `apps/rocm/src/therock/python.rs`). + @id:runtime-install-refuses-python-version-it-cannot-honour @requires-os:linux + Scenario: runtime-30 - Previewing an SDK install with a --python-version the layout is not published for is refused + Given a canonical release pip index fixture + And a host with no usable Python and a recording uv + When the user tries to preview a wheel SDK install for arch gfx1200 with no version pin on Python 3.13 + Then the install fails + And the preview is refused because the layout has no wheels for that Python, and prepared none diff --git a/tests/e2e-cucumber/tests/e2e/therock_steps.rs b/tests/e2e-cucumber/tests/e2e/therock_steps.rs index ed2d54a65d..56067cb1b9 100644 --- a/tests/e2e-cucumber/tests/e2e/therock_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/therock_steps.rs @@ -1015,6 +1015,82 @@ async fn preview_pinned_wheel_install(world: &mut E2eWorld) { ); } +#[when( + "the user previews a wheel SDK install for arch gfx1200 pinned to ROCm 10.0.0 on Python 3.12" +)] +async fn preview_pinned_wheel_install_on_python_312(world: &mut E2eWorld) { + preview_ok( + world, + &[ + "install", + "sdk", + "--channel", + "release", + "--format", + "wheel", + "--family", + RAW_ARCH, + "--version", + NEXT_ROCM_VERSION, + "--python-version", + "3.12", + "--dry-run", + ], + ); +} + +#[when( + "the user tries to preview a wheel SDK install for arch gfx1200 with no version pin on Python 3.13" +)] +async fn try_preview_unpinned_wheel_install_on_python_313(world: &mut E2eWorld) { + preview( + world, + &[ + "install", + "sdk", + "--channel", + "release", + "--format", + "wheel", + "--family", + RAW_ARCH, + "--python-version", + "3.13", + "--dry-run", + ], + ); +} + +/// The plan names the requested interpreter and its tag. The default's tag is +/// checked absent too: a plan that printed both would pass the first two checks. +#[then("the preview plans Python 3.12 and its cp312 wheel tag and not the default")] +async fn preview_plans_requested_python(world: &mut E2eWorld) { + assert_contains( + world, + "would use uv to install managed Python 3.12", + "python note", + ); + assert_contains(world, "python_wheel_tag: cp312", "python wheel tag"); + let out = stdout(world); + assert!( + !out.contains("cp314") && !out.contains("Python 3.14"), + "the default Python must not appear in the plan:\n{out}" + ); +} + +#[then( + "the preview is refused because the layout has no wheels for that Python, and prepared none" +)] +async fn preview_refused_for_unpublished_python(world: &mut E2eWorld) { + let stderr = world.cli_stderr.clone().unwrap_or_default(); + assert!( + stderr.contains("--python-version applies only to ROCm 10 and newer installs") + && stderr.contains("this install uses Python 3.12"), + "expected the refusal to name the Python that is allowed:\n{stderr}" + ); + assert_no_python_prepared(world); +} + #[when( "the user previews a wheel SDK install for arch gfx1200 pinned to ROCm 10.0.0 with the toolchain" )]