Repository navigation
refactor(vllm): derive launch-time discover detection from the one discover-build table - #911
Conversation
… for them The vllm engine reads its ROCm discover-build versions in two places: install routing walks `VLLM_ROCM_DISCOVER_BUILD_TABLE`, and launch-time environment setup matches `ROCM_DISCOVER_BUILD_VERSIONS`. Today the only thing holding the two together is `vllm_rocm_discover_build_table_matches_the_discover_version_list`. Add the tests a later consolidation of the two will be held to, written against the current code first: - `discover_build_table_pins_the_versions_it_serves_in_order` pins the table's versions and their order, so changing which versions are served is a deliberate edit of a literal list instead of an unnoticed one. - `every_discover_row_routes_installs_and_launch_env_the_same_way` is a characterisation test. For every table row, in four spellings a real probe produces, it asserts that the install lookup, the install route, the launch environment check and the static-pin fallback all agree the runtime is a discover build and that the static pin fails closed. It also asserts the same four answers for versions outside the table (an unlisted 10.x line, 7.2.3, an unknown major, unparsable text, and no recorded version). Both pass on the current code. Dropping `ROCM_SDK_10_1` from the launch list, or changing or reordering a table row, turns them (and the existing comparison test) red. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Pure move, no behaviour change. The ROCm 10.x discover-build table, its row type, the `DiscoverVersion` constraint, the row lookup and the `major.minor` matcher move out of `wheel_builds.rs` and `runtime.rs` into a new `discover_builds.rs` that imports no other module of the crate, along with the `ROCM_SDK_10_0` / `ROCM_SDK_10_1` constants the table rows use. The table has to sit below both of its readers to be shared between them: `runtime.rs` (launch-time environment setup) and `wheel_builds.rs` (install routing) read the same rows today but could only do so through two separately kept copies of the versions, because neither may import the other's discover-build code. A leaf both import adds no `runtime` to `install` edge and no module cycle: `discover_builds` imports nothing, `runtime`, `wheel_builds` and `install` import it, and `wheel_builds` no longer imports `runtime` at all outside its tests. Moved with it, with their leaf names unchanged: `discover_build_table_pins_the_versions_it_serves_in_order`, `vllm_rocm_discover_build_looks_up_known_and_unknown_versions`, `discover_version_renders_series_and_exact_requirements` and `discover_rows_select_their_own_indexes`. `VLLM_ROCM_DISCOVER_BUILD_TABLE` becomes `pub(crate)` so `wheel_builds.rs` can still walk it for the fail-closed static-pin fallback. `docs/architecture.md` describes the new module. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…scover-build table The ROCm 10.x discover-build versions were kept as two pieces of data: the `VLLM_ROCM_DISCOVER_BUILD_TABLE` rows that install routing walks, and a separate `ROCM_DISCOVER_BUILD_VERSIONS` list that launch-time environment setup (`runtime_has_discover_build`) matched against. They agreed only because a test compared them. A version in the table but not the list would be installed by discovery and then launched without the discovery environment. Delete the list and the two `ROCM_SDK_10_*` constants that fed it. The table is the single list; `runtime_has_discover_build` now asks the same row lookup that install routing uses (`vllm_rocm_discover_build`), so the two readers cannot disagree. The table won because it already carries everything else and is what the install route, the fail-closed static-pin fallback and `verified_torchaudio_release` read; the list was only a projection of its version column. Values, order and the `major.minor` matching are unchanged, so no engine id, version string, launch environment or install route changes for any input; `every_discover_row_routes_installs_and_launch_env_the_same_way` (added earlier in this series against the old code) pins that. Replaces `vllm_rocm_discover_build_table_matches_the_discover_version_list`, which compared the list with the table and has nothing left to compare, with `discover_build_table_pins_the_versions_it_serves_in_order`: it pins which versions the table serves and in what order, so changing them is a deliberate, reviewed edit of a literal list. `docs/architecture.md` and the module docs now describe the single list. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the refactor consolidating vLLM discovery-build metadata into a shared table.
No open issues 🎉
What changed in this PR
Consolidates vLLM discovery-build metadata into one shared table so install routing and launch-time environment setup cannot drift apart. The refactor preserves existing version matching, wheel selections, and public exports.
Changes:
- Moves the discovery table, types, lookup, and version matcher into a dependency-free leaf module.
- Replaces the separate launch-time version list with the shared table lookup.
- Adds characterization tests, pins supported versions and order, and updates architecture documentation.
| File | Description |
|---|---|
engines/vllm/src/wheel_builds.rs |
Uses shared discovery metadata and tests agreement between install and launch decisions. |
engines/vllm/src/runtime.rs |
Derives discovery detection from the shared lookup instead of a separate version list. |
engines/vllm/src/lib.rs |
Registers the private discover_builds module. |
engines/vllm/src/install.rs |
Updates imports to use the extracted discovery module. |
engines/vllm/src/discover_builds.rs |
Houses discovery recipes, matching helpers, and focused tests. |
docs/architecture.md |
Documents the shared table and revised module responsibilities. |
Review effort: Balanced
juhovainio
left a comment
There was a problem hiding this comment.
I read through the diff and found nothing blocking. runtime_has_discover_build still matches the same two keys via rocm_sdk_series_matches, the new leaf module imports nothing (no cycle), the moved code is unchanged apart from paths and visibility, and the old constants have no remaining references. The pin test is a clear improvement over the list-vs-table comparison it replaces.
Two small notes, neither blocking:
- One inline comment on the test helper in
wheel_builds.rs. - The intra-doc link in
discover_builds.rsnow points atvllm_install_target(it used to sayresolve_vllm_install_target); worth confirming it resolves undercargo doc.
This is based on reading the diff only; I did not build or run the tests. The two Strix Halo Ubuntu e2e lanes (nightly/current and release/current) were red when I looked, and MI300X/W7900 were still pending. Since the change is behaviour-neutral they look like lane flakes, but please confirm with a rerun before merging.
| use super::*; | ||
| use crate::runtime::ROCM_DISCOVER_BUILD_VERSIONS; | ||
|
|
||
| fn runtime_recording_sdk_version(version: Option<&str>) -> crate::runtime::VllmRuntime { |
There was a problem hiding this comment.
This helper builds every VllmRuntime field by hand in a module unrelated to runtime.rs, so any new field on the struct breaks it. A shared test constructor next to the struct would be sturdier. Non-blocking.
There was a problem hiding this comment.
Added a #[cfg(test)] VllmRuntime::for_test() next to the struct in runtime.rs and switched this helper to it with struct-update syntax, so a new field is defaulted in one place. I applied the same change to the other test modules that built the struct by hand (runtime.rs, state.rs, process.rs; 14 sites). No test was added, removed or renamed and all 134 still pass; removing the rocm_sdk_version override from this helper turns the characterisation test red (cc726d3).
Several test modules assembled every VllmRuntime field by hand, so adding a field to the struct meant editing each of them, including modules unrelated to runtime.rs such as wheel_builds. Add a cfg(test) VllmRuntime::for_test() next to the struct and have those tests override only the fields they are about with struct-update syntax. Values each test sees are unchanged and no test is added, removed or renamed. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
The doc comments that moved into discover_builds.rs referred to VLLM_ROCM_BUILD_TABLE and verified_torchaudio_release by bare name, which resolved while they sat beside those items in wheel_builds.rs. Under cargo doc --document-private-items they no longer resolve. Point the verified_torchaudio_release link at its module path and name the private table in plain code formatting, since a module-private const cannot be linked from a sibling module. Comment-only change. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
|
Thanks for the approval. Pushed cc726d3 (the shared test constructor from your inline note) and 388dd85. On the intra-doc link: |
Summary
The vllm engine decides whether a ROCm SDK version is installed by live wheel discovery in two places, and until now each place kept its own copy of the answer. Install routing walks
VLLM_ROCM_DISCOVER_BUILD_TABLE(inwheel_builds.rs), and launch-time environment setup matched a separateROCM_DISCOVER_BUILD_VERSIONSlist (inruntime.rs). The two agreed only because a test,vllm_rocm_discover_build_table_matches_the_discover_version_list, compared them. A runtime whose version was in the table but missing from the list would be installed through discovery and then launched without the discovery environment (a wrong-wheel failure far from the cause), and the test was the only guard. This change leaves one list: the table. Launch-time setup now asks the same row lookup install routing uses.This is part of the Phase 8.4-H follow-up work. It is intended to be behaviour-neutral, but because both the install path and the launch path read the data it is reviewed as a behaviour change, so the first commit pins the behaviour before anything moves.
Which copy wins and why
The table wins. It is the richer one (wheel indexes, version prefixes, interpreter tag, torchaudio pin) and it is what install routing, the fail-closed static-pin fallback and
verified_torchaudio_release(read byrocm install sdkthroughlib.rs) already depend on, whereas the list was only a projection of the table's version column. I compared the two on current main before changing anything: same values (10.0.0,10.1.0), same order, and the table's rows already took their version fields from the list's two constants, so they had not diverged. The only readers of the list wereruntime_has_discover_buildand the comparison test. The ticket's paths are stale: the table now lives inwheel_builds.rs, notinstall.rs.Deriving the table from the list is not possible (a list of strings cannot carry the rows), and deriving the list from the table with the table left in
wheel_builds.rswould makeruntime.rsimportwheel_builds.rs, which already importsruntime.rs. So the table moves down into a new leaf module and the list is not derived at all: the one reader of it asks the table's lookup instead.What changed
Three commits, meant to be read in order.
test(vllm): pin the discover-build versions and every reader's answer for themadds two tests against the unchanged code.discover_build_table_pins_the_versions_it_serves_in_orderpins the table's versions and order.every_discover_row_routes_installs_and_launch_env_the_same_wayis a characterisation test: for every table row, in four spellings a real probe produces (exact, a patch, a dev suffix, a.dev0+localsuffix), the row lookup, the install route, the launch-environment check and the static-pin fallback all agree it is a discover build and that the static pin fails closed; for an unlisted 10.x line, 7.2.3, an unknown major, unparsable text and no recorded version they all agree it is not. It passes on current main and on this branch.refactor(vllm): move the discover-build table into its own leaf moduleis a pure move intoengines/vllm/src/discover_builds.rs: the table,VllmRocmDiscoverBuild,DiscoverVersion,vllm_rocm_discover_build,rocm_sdk_series_matchesand the two version constants, with four tests that test them (leaf names unchanged).docs/architecture.mddescribes the module.refactor(vllm): derive launch-time discover detection from the one discover-build tabledeletesROCM_DISCOVER_BUILD_VERSIONS,ROCM_SDK_10_0andROCM_SDK_10_1and makesruntime_has_discover_buildcallvllm_rocm_discover_build(version).is_some(). It also deletesvllm_rocm_discover_build_table_matches_the_discover_version_list, which compared the list with the table and is meaningless once there is one list.discover_build_table_pins_the_versions_it_serves_in_orderreplaces it: it pins the served versions and their order, so changing them is a deliberate edit of a literal list instead of an unnoticed one.Module edges inside the crate after the change (the
use crate::lines):discover_buildsimports nothing;runtimeimportsdiscover_builds;wheel_buildsimportsdiscover_builds(andruntimeonly in its tests, forVllmRuntime);installimportsdiscover_builds,repair,runtime,stateandwheel_buildsas before;processimportsruntime,startup_diagnosticsand the crate root as before. Noruntimetoinstalledge, no new cycle, andwheel_buildsno longer depends onruntimein non-test code. Items kept at unchanged paths:rocm_engine_vllm::verified_torchaudio_release(the only symbol other crates read, vialib.rsandapps/rocm/src/therock/resolve/wheel.rs) and everything inwheel_builds.rsthatinstall.rsandlib.rsuse (vllm_install_route,vllm_install_target,VllmInstallRoute,VllmInstallTarget,verified_torchaudio_release).install.rsimports the moved types fromdiscover_buildsinstead ofwheel_builds, which is the one path change, and it is crate-private.Verification
Ran (Linux, target dir private to this work):
cargo fmt --all --check;cargo clippy -p rocm-engine-vllm --all-targets -- -D warnings;cargo test -p rocm-engine-vllm --no-fail-fast(135 tests passed after the first commit and after the move, 134 after the consolidation);cargo xtask manifest --check;cargo xtask check-crate-edges;cargo xtask lychee; the leaf-name test list against main, which differs by exactly the intended replacement (two added: the pin and the characterisation test; one removed: the list-versus-table comparison); a leak scan ofgit diff origin/main...HEAD. Not run: clippy for--target x86_64-pc-windows-msvc, which stops in a dependency's build script (failed to find tool "lib.exe"from cc-rs) on this Linux host; the change touches nocfg(windows)code, only crate-privateuselines and a new module with no platform gates, so I expect it to be unaffected, but CI's Windows job is what verifies that. Nothing inapps/reads the discover-build data apart fromverified_torchaudio_release, whose own tests (verified_torchaudio_release_is_only_an_exact_row_pin, and therocm_engine_vllm::verified_torchaudio_releaseassertions inapps/rocm/src/therock/resolve/wheel.rs) are untouched, so I did not run therocmpackage tests or the workspace gate,cargo xtask e2eorscripts/smoke_local.py; CI carries those.Mutation proof. Against the unchanged code (first commit): dropping
ROCM_SDK_10_1from the launch list, which is exactly the divergence this removes, turns the characterisation test, the old comparison test andruntime_has_discover_build_matches_both_discover_linesred; changing a table row's key or swapping the two rows' keys turns the pin test (and the old comparison test) red. After the consolidation: makingruntime_has_discover_builda second, narrower rule (version.starts_with("10.0") && ...) turnsevery_discover_row_routes_installs_and_launch_env_the_same_wayandruntime_has_discover_build_matches_both_discover_linesred; swapping the two rows' keys turns the pin test,discover_rows_select_their_own_indexesand one install test red. Each mutation was reverted by a targeted reverse edit.User-visible behaviour
None, so no new Gherkin scenario. The engine ids, version strings, the environment a launched vLLM process receives and the install route chosen for any input are unchanged, which the characterisation test and the existing
apply_therock_env_dispatches_to_discover_env_for_a_discover_rocm_sdk_version,vllm_install_route_*andunknown_rocm10_line_still_fails_closedtests exercise. No CLI output, exit code or file the CLI creates changes. No Windows-only code is touched.Notes for reviewers
Reading order is the commit order above; the second commit is mechanical (move with
git diff -Mor--color-moved), the third is the whole behaviour-relevant change and is small. The only deliberate difference in logic:runtime_has_discover_buildused to test the version against a list of keys withrocm_sdk_series_matches, and now callsvllm_rocm_discover_build, which tests it against the table's keys with the same function, so the predicates are identical while the two key sets are identical, and cannot differ afterwards.Open PRs that touch the same files: none touch
runtime.rs,wheel_builds.rsorinstall.rsof the vllm engine. Three (#724, #695, #202) add lines toengines/vllm/src/lib.rsand may conflict trivially with the addedmod discover_builds;line; #724, #695 and #202 also editprocess.rs, which this change does not.docs/architecture.mdis edited by many open PRs, so expect a textual conflict there; the edit is confined to theengines/vllmbullet list.