Skip to content

Studio: support Vulkan GPU selection and explicit Vulkan installation - #7188

Merged
danielhanchen merged 130 commits into
unslothai:mainfrom
InfoSage05:fix/gguf-gpu-memory-mode
Jul 29, 2026
Merged

danielhanchen merged 130 commits into
unslothai:mainfrom
InfoSage05:fix/gguf-gpu-memory-mode

Conversation

@InfoSage05

@InfoSage05 InfoSage05 commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Studio already has a GPU picker for GGUF models. This PR makes that existing picker work with Vulkan devices and makes explicit Vulkan installation reliable.

PR #7373 added explicit Vulkan installer routing and the Windows AMD fallback when no compatible HIP prebuilt exists. This PR preserves those behaviors, consolidates the backend environment setting onto the preexisting UNSLOTH_LLAMA_CPP_BACKEND selector, and completes the Studio GPU-selection integration.

Vulkan GPU selection

  • Exposes Vulkan device ordinals, hardware names, and memory data through /api/system for the existing Studio GGUF GPU picker.
  • Shows those Vulkan devices in the existing GGUF GPU picker.
  • Applies a selection with llama.cpp device names such as --device Vulkan0,Vulkan1.
  • Tags saved GPU selections as physical IDs or Vulkan ordinals, so a selection saved under one namespace is not reused under another.
  • Removes conflicting --device, --main-gpu, LLAMA_ARG_DEVICE, and LLAMA_ARG_MAIN_GPU values when the picker owns device placement.
  • Rejects GPU pins that the installed llama.cpp build cannot apply instead of reporting a pin while running on CPU.
  • Keeps DiffusionGemma on its CUDA or ROCm physical-ID path because its separate runner cannot translate Vulkan ordinals.
  • Applies Vulkan-aware memory budgeting while training and inference run together.
  • Keeps a separately loaded MTP draft model on the same effective Vulkan device pool as the main model, including an automatically narrowed fit pool.
  • Preserves remembered GPU selections while Vulkan device discovery is temporarily unavailable.

Vulkan installation

  • Extends the preexisting UNSLOTH_LLAMA_CPP_BACKEND selector with vulkan instead of retaining the competing UNSLOTH_LLAMA_BACKEND setting introduced by Installer: opt-in Vulkan llama.cpp backend (and fallback when no AMD card is HIP-supported) #7373.
  • Keeps UNSLOTH_FORCE_VULKAN compatible and accepts on in addition to its existing truthy values.
  • Installs Vulkan from the manifest-backed bundles published by unslothai/llama.cpp instead of redirecting to the upstream ggml-org/llama.cpp packages.
  • Preserves the selected Unsloth release pin and the bundled DiffusionGemma visual-server executable.
  • Validates that a published Vulkan bundle contains the required runtime components before accepting it.
  • Restricts prebuilt resolution to Vulkan assets when Vulkan is explicitly requested.
  • Filters published Vulkan bundles by host architecture, so ARM64 hosts never install an x64 Vulkan bundle.
  • Fails clearly if the requested Vulkan build cannot be installed instead of silently substituting CUDA, ROCm, or CPU.
  • Detects versioned Vulkan shared libraries such as libggml-vulkan.so.0 during backend detection and probing.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for explicit GPU selection and GGUF memory placement modes (auto, pinned, resident) in the inference backend. It updates the LlamaCppBackend to manage these as first-class fields, ensures they are correctly handled during model loading and state comparison, and adds validation for GGUF GPU selection. The changes include updates to the inference models, route logic for model loading, and comprehensive test coverage. I have provided feedback on simplifying redundant conditional checks in the inference route.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread studio/backend/routes/inference.py Resolved
@InfoSage05 InfoSage05 changed the title feat(studio): support GGUF gpu_ids and memory placement mode (#7164) feat(studio): Support GPU selection and memory placement for GGUF models (#7164) Jul 16, 2026
@InfoSage05
InfoSage05 marked this pull request as ready for review July 16, 2026 17:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae20549d06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

requested_gpu_ids = effective_gpu_ids,

P2 Badge Keep GGUF GPU pins out of the HF balanced guard

When training is active and a GGUF load supplies gpu_ids, this passes the list into can_load_chat_during_training, whose explicit-GPU branch applies the HF device_map="balanced" per-GPU floor even though the GGUF loader treats the list as a candidate set and _select_gpus may choose only the fitting card. A request such as gpu_ids=[0, 1] with enough free VRAM on GPU 0 but little on GPU 1 can be rejected with 409 before llama.cpp can select GPU 0; pass these IDs as a GGUF candidate pool or make the guard skip the balanced floor when is_gguf is true.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad14c67fe8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c781ecf87e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19c34043d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19c34043d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad75de784f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f3511d295

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/models/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 700aa81821

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/models/inference.py Resolved
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f565d2c95d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/models/inference.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee76caa79f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f9ffe5292

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread studio/backend/routes/inference.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: ab72faa8fa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@oobabooga

Copy link
Copy Markdown
Member

Finally :)

This PR exposes complexity in Unsloth internals that should be simplified/refactored; I'll leave that for a follow-up and merge the behavior improvements here once unslothai/llama.cpp#42 is merged and compiled for the first time.

As a design choice, I removed the options for mlock/no-mmap, as those are relatively niche and Unsloth's UI currently hand-picks what options to display, and restricted the PR's scope to Vulkan improvements. To support further model loading options, maybe we should add an "extra flags" text field in Manual mode rather than adding more and more dropdowns/checkboxes.

danielhanchen and others added 5 commits July 28, 2026 21:56
The availability check imported the module purely for its side effect, so
the import-hoist verifier flagged it as an added-but-unused import and
failed Source lint. find_spec answers the same question without binding a
name.
find_spec raises ValueError on a module already in sys.modules whose
__spec__ is None, which is what a bare types.ModuleType stub is. Check
sys.modules first so anything already present, real or stubbed, is left
untouched and only a genuinely absent package gets stubbed.
# Conflicts:
#	studio/backend/routes/inference.py
#	studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
#	studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
Three of the tests added for the llama.cpp backend selector asserted on the
same two helpers with the same inputs, and two more differed only in whether
the backend arrived from the environment or from --llama-backend. Fold them
into the parametrized cases that already covered those helpers:

- test_llama_cpp_backend_env_requests_vulkan,
  test_llama_cpp_backend_auto_does_not_trigger_vulkan and
  test_hip_backend_env_opts_out_of_vulkan become rows on
  test_force_vulkan_requested_accepts_public_selector_and_legacy_alias, which
  now also asserts llama_backend_from_env() alongside force_vulkan_requested().
  The unset case and the whitespace-padded HIP/ROCM values keep their coverage
  as new rows.
- test_explicit_non_vulkan_backend_suppresses_intel_auto_route and
  test_non_vulkan_backend_argument_suppresses_intel_auto_route become one test
  parametrized over the env and argument paths.
- test_unclassified_gguf_without_pin_keeps_the_torch_budget and
  test_unclassified_gguf_with_pin_refuses_to_budget shared the same four
  patches and differed only in the pin, so they become subtests of one case.

No source changes and no assertion is dropped. Each behaviour was re-checked by
reverting the source hunk it guards and confirming the surviving test fails on
a value.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e0b078a3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

}
return {
...config,
gpuMemoryMode: "auto",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the standing GPU mode for diffusion loads

When the standing GPU Memory preference is Manual, reloading an active DiffusionGemma or applying a previously manual per-model config reaches this branch and converts the config to an explicit gpuMemoryMode: "auto". applyPerModelConfigToRuntime then writes that value into the live standing preference, while persistGpuMemoryModeOnLoad intentionally skips diffusion responses, so the session remains on Auto and the next ordinary GGUF without its own override silently loses the user's Manual preference. Omit the mode from the sanitized diffusion config or explicitly preserve the standing mode when applying it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 090b5f6.

Traced the leak: withoutUnsupportedDiffusionSettings rewrites the config to an explicit gpuMemoryMode "auto", applyPerModelConfigToRuntime writes that straight into the runtime store, and persistGpuMemoryModeOnLoad skips diffusion responses, so nothing writes the standing Manual back. A later ordinary GGUF picked from the sidebar reaches stageOrLoad with selection.config ?? rememberedConfigFor(selection) == null, so selectModel gets no config, applyPerModelConfigToRuntime never runs, loadGpuMemoryMode falls back to stateBeforeUnload.gpuMemoryMode (the stale "auto"), and persistGpuMemoryModeOnLoad then saves it over the user's Manual.

Fixed at the single point that writes the store rather than in the sanitizer, so the load request still sends "auto" for diffusion as intended:

gpuMemoryMode: options.isDiffusion
  ? readPersistedGpuMemoryMode()
  : (config.gpuMemoryMode ?? readPersistedGpuMemoryMode()),

This mirrors the tensorParallel: options.isDiffusion ? false : ... line right above it. Covered by tests/studio/test_model_picker_contracts.py::test_diffusion_load_keeps_the_standing_gpu_memory_mode, which also pins the is_gguf && !is_diffusion persist guard and the sanitizer call so the two halves cannot drift apart.

if published_repo != UPSTREAM_REPO:
published_release_tag = ""
return host, UPSTREAM_REPO, published_release_tag, persist_backend
return host, published_repo, published_release_tag, persist_backend

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retain the upstream Vulkan fallback for Linux ARM64

With UNSLOTH_LLAMA_CPP_BACKEND=vulkan on Linux ARM64 and the default published repository, this now keeps planning against the Unsloth manifest, whose architecture filter rejects its x64-only Vulkan artifact; strict Vulkan filtering then removes the ARM64 CPU attempt and the setup exits without installing anything. The direct upstream resolver already supports llama-*-bin-ubuntu-vulkan-arm64.tar.gz, and the previous implementation routed Vulkan requests there, so Linux ARM64 Vulkan installations that previously worked now fail unless the user manually overrides the repository. Route this unsupported manifest/architecture combination back to upstream or publish a matching ARM64 bundle.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and reproduced before fixing. In 090b5f6.

With UNSLOTH_LLAMA_CPP_BACKEND=vulkan on Linux ARM64 and the default fork repo, _route_to_vulkan_prebuilt now returns published_repo, so resolve_simple_install_release_plans takes the fork-manifest branch. published_asset_choice_for_kind's architecture filter drops the x64-only Vulkan artifact for an ARM64 host, so _linux_published_attempts yields only linux-arm64, and _vulkan_only_release_plans then strips that and raises PrebuiltFallback:

fork attempts: ['linux-arm64']
strict vulkan RAISED: PrebuiltFallback no Vulkan prebuilt bundle attempts were available

Upstream still serves this host: direct_upstream_release_plan on the same routed host returns llama-b9925-bin-ubuntu-vulkan-arm64.tar.gz first.

Fix routes only that combination back to UPSTREAM_REPO, at the end of _route_to_vulkan_prebuilt, and drops the fork pin because the two repos use different tag namespaces (fork b9596-mix- vs upstream b9596). Windows arm64 still exits earlier via _has_no_vulkan_prebuilt and macOS via the Metal branch, Linux x86_64 keeps the fork bundle so it still gets the DiffusionGemma visual server, and an explicit --published-repo override is left alone.

Four tests in studio/backend/tests/test_install_resolve_prebuilt.py cover the reroute, the end-to-end "fork yields only linux-arm64, upstream yields the Vulkan bundle" path, the explicit-repo override, and the x86_64 no-change case.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 987f224142

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

…rness doubling --force-cpu

test_non_vulkan_backend_suppresses_intel_auto_route ran on Linux x86_64, where
dropping the explicit_backend guard changes only a log line, so the test passed
either way. Move it to Linux ARM64 + Intel GPU, the host where the guard decides
the routed repo, and assert that value.

_run_ps1 composed the --force-cpu snippet twice: it is already inside the
normalized block the helper extracts. The substring assertion hid the duplicate.
Compose it once and compare the whole argv. setup.ps1 appends the flag once and
is unchanged.
@danielhanchen

Copy link
Copy Markdown
Member

Two test-quality fixes from an idempotency audit. Both are test-only; the product code was correct in both cases.

1. A test that could not fail. test_non_vulkan_backend_suppresses_intel_auto_route drove a Linux x86_64 + Intel GPU host. On that host the explicit_backend is None guard in _route_to_vulkan_prebuilt changes only a log line: the auto-route branch rewrites neither the host nor the repo, so reverting the guard left the whole file green. The guard is not dead code, though. It is observable on Linux ARM64 + Intel GPU with an explicit --llama-backend hip, where the auto-route falls through to the ARM64 fork to upstream reroute. Moved the case to that host and asserted the routed repo value. Negative control: with the guard removed the test now fails with ggml-org/llama.cpp where it expects unslothai/llama.cpp, across all six hip/rocm/cpu x env/argument combinations. Guard restored, product file untouched.

2. A helper that emitted a flag twice. _run_ps1 in test_setup_llama_cpp_backend.py extracted the normalized backend block from setup.ps1 and then separately extracted the --force-cpu append and appended it again. The append already lives inside the normalized block, so the harness produced ARGS:--force-cpu,--force-cpu. The assert "--force-cpu" in out check passed regardless, hiding it. setup.ps1 itself appends the flag exactly once (one occurrence in the file), so only the harness was wrong. Composed the snippet once, added an assertion that the extracted block still contains the append exactly once, and tightened the test to compare the whole argv (out.strip() == "ARGS:--force-cpu") instead of a substring. Negative control: that assertion fails against the old double-composing helper with ARGS:--force-cpu,--force-cpu.

Test counts unchanged: tests/studio 1905 passed / 3 skipped, and test_install_resolve_prebuilt.py + test_setup_llama_cpp_backend.py + test_gpu_selection.py 316 passed. Across all of studio/backend/tests the failing set is the same pre-existing RAG / sqlite-vec / test_studio_api / test_web_rank node ids as before, and neither touched file appears in it.

unslothai#7549 taught Test-VCRedistInstalled to consult the host architecture before
trusting the System32 DLL. The Pester suite dot-sources a fixed list of
functions out of setup.ps1 one at a time, and that list did not gain the
helper, so the two clean-box cases (registry miss, and an old sub-14.20
redist) throw "Get-HostMachineArch is not recognized" instead of returning
false. The registry hit returns early, which is why the other cases pass.

unslothai#7597 made exactly this fix to the sibling list in the VC++ round-trip job
but left the Pester suite alone. Verified with pwsh 7.6 + Pester: 3 failed
before, 31 passed 0 failed after.
@danielhanchen

Copy link
Copy Markdown
Member

Merged main (the branch was 21 commits behind) and fixed the setup.ps1 Pester job.

The Windows failures were not a routing problem in this branch. CI builds the PR merged into main, so the merged studio/setup.ps1 does contain Get-HostMachineArch. The Pester suite dot-sources a fixed list of functions out of setup.ps1 one at a time, and #7549 taught Test-VCRedistInstalled to consult that helper without adding it to the list. The registry hit returns early, so only the two clean-box cases (registry miss, and a sub-14.20 redist) reach the call and fail with "Get-HostMachineArch is not recognized". #7597 made exactly this fix to the sibling list in the VC++ round-trip job but left tests/studio_setup_ps1 alone, so that job stayed red. Adding the helper to the Pester list takes it from 3 failed to 31 passed, 0 failed on pwsh 7.6. The merge also picks up #7597 itself, which clears both VC++ round-trip jobs.

Local results after the merge, against the pre-merge baselines:

  • tests/studio: 2076 passed, 3 skipped, 1 failed (was 1905 passed, 3 skipped). The 172 tests main brought in all pass.
  • test_install_resolve_prebuilt.py + test_setup_llama_cpp_backend.py + test_gpu_selection.py: 316 passed, unchanged.
  • studio/backend/tests: failing set goes from 92 node ids to 93.

Two remaining reds are main's rather than this branch's:

Both want a fix on main rather than in this PR.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0573a0e0f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

# Fork and upstream use different tag namespaces (fork b9596-mix-<sha> vs
# upstream b9596), so carrying a fork pin over would make the upstream
# resolver query a release that does not exist.
return host, UPSTREAM_REPO, "", persist_backend

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the diffusion runner on ARM64 Vulkan installs

On Linux ARM64 with the default repository and an explicit/automatic Vulkan route, this switches the install to ggml-org/llama.cpp, whose bundle does not contain the Unsloth-only DiffusionGemma visual server. The later backfill cannot recover it: ensure_diffusion_visual_server queries the Unsloth repository using the upstream plan's differently namespaced release tag and checksum manifest, then quietly leaves the install valid without the runner, so DiffusionGemma loads fail unless DG_VISUAL_BIN is supplied manually. Fresh evidence beyond the earlier general Vulkan-runner report is this newly added ARM64-only upstream fallback; either publish an ARM64 fork bundle or resolve a matching verified runner separately.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this against origin/main and it is not a regression this PR introduces.

main's _route_to_vulkan_prebuilt already ends with an unconditional return host, UPSTREAM_REPO, published_release_tag, persist_backend, so on main every Vulkan route installs the ggml-org bundle and has no visual server. The new clause narrows that to Linux ARM64 only. Running _route_to_vulkan_prebuilt on both trees with the same synthetic hosts:

origin/main cf9628882                      this branch 5bfd46316
arm64 forced -> ggml-org   (no runner)     arm64 forced -> ggml-org   (no runner)
arm64 auto   -> ggml-org   (no runner)     arm64 auto   -> ggml-org   (no runner)
x64   forced -> ggml-org   (no runner)     x64   forced -> unslothai  (ships the runner)
x64   auto   -> ggml-org   (no runner)     x64   auto   -> unslothai  (ships the runner)

Linux ARM64 is unchanged; x86_64 and Windows are the platforms that gain the runner back. The fork publishes no linux-arm64-vulkan bundle at all (41 assets in b10107-mix-1911198, only linux-x64-vulkan and windows-x64-vulkan), which is exactly why ARM64 has to keep planning against upstream, and without the reroute a forced-Vulkan ARM64 host resolves to nothing at all, so there is no diffusion runner there to keep.

On the backfill: ensure_diffusion_visual_server cannot recover the binary for anyone, not just ARM64. unslothai/llama.cpp ships no standalone llama-diffusion-gemma-visual-server asset in any recent release (0 of 41 in each of the last three), so the lookup logs "not found in the published release" even with a correctly namespaced fork tag. The runner only ever arrives inside an app bundle via runtime_patterns_for_choice; I unpacked app-b10107-mix-1911198-linux-x64-vulkan.tar.gz, -linux-x64-cpu.tar.gz and -linux-arm64-cpu.tar.gz and each contains ./llama-diffusion-gemma-visual-server.

Publishing an ARM64 fork Vulkan bundle is a release-side change, not something this PR can make. Same conclusion as the earlier report on this surface.

 landed

This branch carried a local fix for the same Pester dot-source gap that
unslothai#7606 has since merged to main (f21b280). Keeping both leaves the PR
diff with an unrelated, now-duplicated change, so drop the branch copy
and take main's.
@danielhanchen
danielhanchen merged commit dbfae7d into unslothai:main Jul 29, 2026
3 of 61 checks passed
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbfae7d92c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

bundles explicitly, while ``hip``/``rocm`` opt out of automatic Vulkan routing.
"""
return _normalized_llama_backend(os.environ.get("UNSLOTH_LLAMA_BACKEND"))
return _normalized_llama_backend(os.environ.get("UNSLOTH_LLAMA_CPP_BACKEND"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the legacy backend environment variable

When an existing installation sets only UNSLOTH_LLAMA_BACKEND (for example, UNSLOTH_LLAMA_BACKEND=vulkan), this now returns None and silently resumes automatic backend selection; before this commit that variable was the explicit selector. This can replace a deliberately selected Vulkan/CPU/HIP backend with a different detected backend during setup or updates. Fall back to UNSLOTH_LLAMA_BACKEND when the new UNSLOTH_LLAMA_CPP_BACKEND does not contain a recognized explicit choice.

Useful? React with 👍 / 👎.

Comment on lines +5477 to +5480
if host.has_intel_gpu and not host.has_physical_nvidia:
vulkan_choice = published_asset_choice_for_kind(bundle, "linux-vulkan", host = host)
if vulkan_choice is not None:
attempts.append(vulkan_choice)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the HIP opt-out in the Intel Linux planner

On a Linux x86_64 host where Intel graphics are detected, setting UNSLOTH_LLAMA_CPP_BACKEND=hip or rocm does not actually opt out of automatic Vulkan installation. _route_to_vulkan_prebuilt correctly declines its auto-route for an explicit backend, but returns the unchanged Intel-marked host, and this planner independently prepends the Vulkan bundle solely from has_intel_gpu. Consequently setup can install Vulkan despite the explicit HIP/ROCm choice; propagate the selector into planning or suppress this Intel branch when a non-Vulkan backend was explicitly selected.

Useful? React with 👍 / 👎.

danielhanchen added a commit that referenced this pull request Jul 30, 2026
…lpers (#7645)

#7188 added three bare exits to studio/setup.sh and three to studio/setup.ps1
for the explicit-Vulkan paths. Bare exits skip setup_fail / Exit-SetupFailure,
so the [TAURI:ERROR] line that #7529 added never reaches Studio desktop and a
Vulkan install failure shows up there with no actionable context.

tests/sh/test_tauri_retry_failure_context.sh already asserts that each setup
script has exactly one explicit exit and that it lives inside the helper. That
assertion was failing, but the failure was invisible: Backend CI skips the
Shell installer tests step whenever the auto-discovered pytest step fails
first, and it had been failing on an unrelated encoding assertion until #7642.

Exit codes are unchanged: setup_fail 1 and Exit-SetupFailure both exit 1, and
the Tauri line is still emitted only when UNSLOTH_TAURI_MODE is set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants