Repository navigation
Studio: keep an AMD dGPU and a Vulkan choice through install and update - #11442
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Simulation reportRan the full before/after/what-else-moved pass on this branch against merge base
Is the change real
What else movedEnumerated every changed predicate over its full input space, all 1- and 2-device permutations of every shadowing, discrete and
Every changed cell is the intended repick. No input that previously found an arch stops finding one. Detection is only reachable from the installer, with one exception: Defects found
Release safety4320 marker shapes compared, and none that lack the new field reads differently, so every existing install is untouched. An older build reading a new marker does not raise, the unknown key is ignored, and its own self-consistency check sends it down the full install path once, rewriting the marker. One extra reinstall on a downgrade, then consistent, no loop. The request and flag are written together through a temp file and atomic replace, so an interruption cannot leave half the pair. Cross platform, with base arms
macOS is structural and outlives this PR: Windows I am not calling yet. 34 of the 43 are Local: What I could not proveThe reporter's throughput recovery and their desktop glitches, which need that hardware. Any of this on real AMD silicon: every routing claim is a control-flow reproduction over spoofed probe output. The |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
d125e63 to
c4b788f
Compare
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Cross-platform follow-up: the Windows leg is resolvedThe simulation report above left one leg undetermined, because the The baseline arm was built as base code with the head tests, and I verified that rather than assuming it:
On Windows both arms fail the same 43 tests. Sorting the two name sets and diffing them gives an empty result in both directions, so nothing regressed and nothing was masked. 34 of the 43 are So the verdict is now unconditional rather than conditional on that leg. |
Two defects behind the same report on #11143, where a Fedora host with an integrated GPU driving the desktop and a discrete RX 9060 XT (gfx1200) kept using the iGPU and ROCm even though the discrete card and Vulkan were selected. _pick_rocm_gfx_target honoured HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES and CUDA_VISIBLE_DEVICES and then ended "return _tokens[0]", so with no mask set a leading integrated GPU decided the arch for the whole install and stranded the discrete card. Apply the same preference install.sh uses for #7776, reusing the SHADOWING_INTEGRATED_GFX table already in this file rather than adding a second copy, and only when the arch that would be picked is itself a shadowing iGPU. An explicit mask still wins outright, including one that cannot be resolved, so masking a device stays the documented workaround from #7624 and #7669. persisted_marker_backend_request recorded "auto" whenever the request and the landed bundle disagreed, so a Vulkan choice that fell back to the ROCm bundle was erased from disk. Every later update then re-detected, and on an AMD host detection means ROCm, so the setting could not survive. Record the request verbatim and mark the shortfall separately with backend_request_unsatisfied. Absent means satisfied, so markers written before this change read exactly as they do today. Preserving the request in that one function was not enough on its own: the BackendUnavailable handler reassigns backend = "auto" before the marker is written, which destroyed the request a second time. Capture it first and persist the unhonoured name. Retry policy, also in a comment at the check: a request named by this run is re-asserted immediately, while one read off the marker is retried only when a check below it fails, such as a new release tag, changed hardware or a bundle that no longer covers the card. Retrying unconditionally would pay the release listing and re-validation cost on every update forever on a host that cannot serve the choice; never retrying would wedge it. Two supporting changes outside the installer, both required rather than cosmetic. _selection_applied treated any concrete request as applied by definition, which was true only while the installer refused to record an unhonoured one; with the request preserved, _plan_llama_phase would have answered already_selected and a user re-picking Vulkan in Settings could never retry it. marker_backend_was_chosen now reports a flagged marker as detected, because the bundle on disk is the one detection picked, which keeps crash recovery reading exactly as it did before the request was preserved. Three existing tests asserted the erasing behaviour and are updated: the assertion they made is the defect.
Found by simulating the discrete-GPU preference in the previous commit against the release manifest's real arch coverage, rather than against the pairs the tests happened to name. published_rocm_choice_for_host matched only host.rocm_gfx_target, and returned None so the caller source-builds when no bundle covered it. That was safe while the active arch was whatever enumerated first. Now that the preference moves it onto the discrete card, a host whose discrete arch this release does not build loses a bundle it used to get: among the shadowing arches only gfx1103 is served, by the gfx110X family, so a gfx1103 APU beside an RDNA1 gfx1010 to gfx1012, or a gfx1152, went from a working prebuilt to a source build. Four such pairs over the published coverage, and a source build is slower and can fail outright. Try the preferred arch first, then the host's remaining physical arches, and source build only when NO physical arch is served, which is the case the None return exists for. The selection log names the fallback and the arch that had no bundle, so a host running the iGPU's bundle says why. This only adds attempts where there were none, so it cannot narrow: over every shadowing-iGPU and discrete pair, hosts served a published bundle go from 12 to 60 of 84, and no pair loses one.
…he fast path Simulating the previous commit surfaced three defects, two of them in that commit. Revert the published_rocm_choice_for_host fallback. It tried the host's other physical arches when no bundle covered the preferred one, and it was wrong twice over. _kept_install_covers_host reads only host.rocm_gfx_target, so the bundle the fallback had just installed was rejected on every later run, three consecutive checks returning False. And it ignored the visibility masks: with HIP_VISIBLE_DEVICES=1 pinning the discrete card it chose a bundle for the masked off iGPU, which contradicts the rule the repick itself follows. Patching the three downstream consumers to match was the wrong trade. The case the fallback existed for is a gfx1103 APU beside a discrete arch this release does not build, and test_rdna1_unsupported_message_8529 already records that CPU is the correct outcome on RDNA1. Quietly running the iGPU while the discrete card sits idle is the complaint in #11143, not the fix for it. The trade-off is pinned by a test that says so, so moving it later is a decision rather than an accident. install_prebuilt passed the fast path its route but not override_has_rocm or override_rocm_gfx. An unsatisfied recorded request re-derives that route as "auto" inside existing_install_current_without_plan, so without them it rebuilt the host profile from a bare probe. On every Linux AMD host, and setup.sh always forwards --rocm-gfx, the rebuilt profile then cannot match the one the install recorded, the fast path fails, and every update pays the whole release listing plus re-validation. That is the cost the recorded-request retry policy exists to avoid, so it was defeating itself on exactly the hosts this PR is about. Canonicalise an explicit backend_request_unsatisfied of false away on reuse. Absent is meant to be the only spelling of satisfied, and leaving a false behind gave readers two ways to say one thing. tests/studio/install plus the llama backend suites: 7423 passed, 60 skipped.
On macOS the universal Metal bundle is the only build, and "metal" is kept out of
REQUESTABLE_BACKENDS for exactly that reason, so a recorded "cpu" or "vulkan"
there can never become the installed backend. Preserving it left Settings holding
a selection the picker has no option for: resolve_backends_payload iterates
("auto",) on macOS, _selection_applied reports the stored request as unapplied,
and the Apply it offers is then refused as backend_unavailable. Permanently, with
no later release able to resolve it.
Record detection in that case, as the erasing rule did. The test is the landed
backend not being requestable at all, rather than a macOS check, because that is
the actual condition: a platform that publishes one build cannot owe a request.
marker_backend_request_was_satisfied agrees, so no flag is written either.
Preservation is untouched where a later release could still honour the request,
which is the case this PR exists for: vulkan landing on linux-rocm is still
recorded as vulkan and still flagged unsatisfied.
tests/studio/install plus the llama backend suites: 7425 passed, 60 skipped.
Comment and docstring only, no code change.
17f2f5a to
7e70239
Compare
…te (unslothai#11442) Two changes, both from the unslothai#11143 follow-up. _pick_rocm_gfx_target() ended at the first enumerated arch, so on a hybrid host an integrated GPU that enumerated first decided the llama.cpp bundle for the whole machine. It now prefers the first arch that is neither in SHADOWING_INTEGRATED_GFX nor gfx906, the same rule the shells apply. An explicit visibility mask is never second-guessed at any value, and an all-integrated host keeps its own arch. persisted_marker_backend_request() recorded "auto" whenever the request and the bundle that landed disagreed, which erased the choice permanently: every later update re-detected, and on an AMD host detection means ROCm, so a configured Vulkan install kept coming back as ROCm with Settings showing Automatic. The request is now recorded verbatim with backend_request_unsatisfied alongside it, so a later update can retry it. Markers written before this field read as satisfied by absence, so no existing install changes. Single-build platforms still record detection, since a named backend there could never be offered or applied. Also carries the routing tests, the marker back-compat tests, and before/after UI evidence for the Settings backend row in the description.
Stacked on #11437 (base branch is that PR's branch, so review that one first). Same report on #11143: a Fedora host with an integrated GPU driving the desktop plus a discrete RX 9060 XT (
gfx1200) kept using the iGPU and ROCm despite the discrete card and Vulkan being selected. #11437 fixed thestudio/setup.shentry point; these are the two defects inside the installer itself.1.
_pick_rocm_gfx_targetendedreturn _tokens[0]It honoured
HIP_VISIBLE_DEVICES,ROCR_VISIBLE_DEVICESandCUDA_VISIBLE_DEVICES, then fell back to whatever enumerated first. With no mask set, a leading integrated GPU decided the arch for the whole install and stranded the discrete card.Applied the same preference
install.shuses for #7776, reusing theSHADOWING_INTEGRATED_GFXtable already in this file rather than adding a second copy, and only when the arch that would be picked is itself a shadowing iGPU. An explicit mask still wins outright, including one that cannot be resolved (UUID, out of range), so masking a device remains the documented workaround from #7624 and #7669.gfx1036,gfx1200gfx1036gfx1200gfx1200,gfx1036gfx1200gfx1200gfx1036alonegfx1036gfx1036gfx1036,gfx1033(all integrated)gfx1036gfx1036gfx1036,gfx906gfx1036gfx1036gfx1036,gfx906,gfx1100gfx1036gfx1100gfx1151,gfx1100(Strix, not shadowing)gfx1151gfx1151-1or emptyNoneNone2. A Vulkan choice was erased when the install fell back
persisted_marker_backend_requestrecorded"auto"whenever the request and the landed bundle disagreed. So a Vulkan choice that fell back to the ROCm bundle was erased from disk; every later update then re-detected, and on an AMD host detection means ROCm. The setting could not survive, which is exactly what the reporter described.The request is now recorded verbatim, with the shortfall marked separately as
backend_request_unsatisfied. Absent means satisfied, so every marker written before this change reads exactly as it does today.Preserving it in that one function was not enough: the
BackendUnavailablehandler reassignsbackend = "auto"before the marker is written, destroying the request a second time. Without also capturing it there the fix is inert on the reported path.Retry policy (also in a comment at the check): a request named by this run via
--llama-backend,UNSLOTH_LLAMA_CPP_BACKENDor Settings is re-asserted immediately; one read off the marker is retried only when a check below it fails, such as a new release tag, changed hardware, or a bundle that no longer covers the card. Retrying unconditionally would pay the release listing plus re-validation cost on every update forever on a host that cannot serve the choice. Never retrying would wedge it.Two supporting changes outside the installer
Both required, not cosmetic:
_selection_appliedtreated any concrete request as applied by definition, which held only while the installer refused to record an unhonoured one. With the request preserved,_plan_llama_phasewould have answeredalready_selected, and a user re-picking Vulkan in Settings could never retry it.marker_backend_was_chosennow reports a flagged marker as detected, because the bundle on disk is the one detection picked. This keeps crash recovery reading exactly as it did before the request was preserved.Tests
tests/studio/install/test_amd_hybrid_igpu_routing_11143.pyis new (18 tests), plus 4 added totest_install_llama_prebuilt_logic.py. Confirmed failing at the merge base in a detached worktree, including:Nine of the new tests pass at the merge base by design: they are the must-not-move guards (mask wins, empty and unresolvable masks, all-integrated host, non-shadowing first arch, satisfied-request recording), not demonstrators.
Full runs on this branch:
tests/studio/install6882 passed, 59 skipped, 0 failed.studio/backend/tests/test_llama_backend_{selection,marker,switch}.pyplustest_llama_cpp_update.pyandtest_setup_llama_cpp_backend.py302 passed.ruff==0.15.12clean.Three existing tests changed deliberately
test_only_a_request_the_install_honours_is_recorded(renamedtest_the_request_is_recorded_verbatim) andtest_a_recorded_choice_this_host_cannot_serve_falls_back_to_detectionasserted the old erasing behaviour. The assertion they made is the defect: erasing the choice at the re-detect is what made a configured Vulkan install return as ROCm on every subsequent update.test_a_marker_whose_request_and_backend_disagree_is_not_currentneeded no assertion change, since an unflagged disagreement is still rejected as a foreign marker; only its docstring was updated.Limits
I could not reproduce the reporter's throughput recovery or their desktop glitches, which need that hardware. The GPU pin handling and the integrated-GPU ranking at load time are a further follow-up.
Before and after, in the UI
_selection_appliedfeeds the Compute backend row in Settings > Resources, so the change is visible there. Both halves are separate Studio installs built withinstall.sh --local, BEFORE from this PR's merge base and AFTER from its head.The install event put to both sides is the same one: the user asked for Vulkan, and the install landed something else. Each side then computed its own marker by importing its own
install_llama_prebuilt.pyand callingpersisted_marker_backend_request("vulkan", <a linux-rocm bundle>), so the two halves differ only because the two installers answer differently.autovulkanbackend_request_unsatisfiedTrueselection_appliedtruefalseThat is the reported complaint in one frame: the choice is gone and there is no control left to retry it. After the change the row still names what is actually running, and Apply is offered so the request can be re-asserted.
Both halves report the same landed backend, which is the point: only the recorded request moved. That backend is this host's real CUDA install rather than the reporter's ROCm one, since no hybrid AMD machine was available. The mechanism does not depend on which backend landed, only on its differing from the request.