unsloth/studio/backend/utils
Daniel Han 74295d93d8
Vulkan GPUs: real device names and selectable ordinals (rebase of #7356 onto #7476) (#7498)
* Vulkan GPUs: real device names and selectable ordinals

Rebases the durable half of #7356 onto the inference_gpu transport #7476
landed on main. Those two PRs solve an overlapping problem and disagree on
the data model, so merging #7356 as-is would ship two parallel Vulkan
device concepts with different index semantics. This keeps main's transport
and adds what #7356 had that #7476 does not.

- _vulkan_probe.py emits a 5th column, ggml's device description, sanitized
  for the tab protocol and UTF-8 safe. Reader tolerates 4- or 5-column
  output so an older probe still parses.
- llama_cpp gains _run_vulkan_probe (shared parse) and
  vulkan_device_inventory (names + is_igpu + real totals).
- get_vulkan_inference_gpu_info reports the real name and an explicit
  is_igpu instead of "Vulkan<i>" and a total == 0 guess.
- index_kind becomes "vulkan", not "relative", and gpu_ids picks are
  supported on Vulkan builds once the probe enumerated ordinals. The XPU ban
  no longer applies to them: a Vulkan pick is a ggml ordinal, not a torch-xpu
  index, so it works on an Intel host too.
- Frontend picker reads the Vulkan inventory as the pickable set.

Memory deliberately still comes from _get_gpu_memory, not the inventory.
That path applies _apply_igpu_host_reserve_mib and zeroes a shared total;
budgeting an APU off its raw shared total would hand out the whole machine's
RAM with no OS headroom. Identity is joined onto it by ordinal, so a probe
failure degrades to Vulkan<i> names with the memory readings intact.

Dropped from #7356 as superseded: validate_vulkan_gpu_ids (main's
resolve_requested_gpu_ids already rejects duplicates and
_resolve_gguf_gpu_ids_for_request already probes for existence), the
gguf_devices transport, and the iGPU budget fallback in 71619891e, which
main's aggregateGpuMemoryTotalGb handles better by counting a shared pool
once.

Also keeps #7356's removal of the late diffusion raise, so the graceful
gpu_ids drop stays reachable for a GGUF only classified as diffusion after
download. #7415's real guard, _reject_vulkan_diffusion_gpu_ids_before_
teardown, is untouched.

Verified on Windows + Strix Halo: backend Vulkan/GPU-selection suites at the
same 4 pre-existing failures as main, tests/studio 1671 passed with no new
failures, frontend typecheck clean. Hardware confirmation of the underlying
behavior is on #7356 from @Bebiv24 (RX 9070 XT + RX 480).

Co-authored-by: LeoBorcherding <borchborchmail@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: LeoBorcherding <borchborchmail@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-07-27 05:21:48 -07:00
..
datasets Studio: add configurable model download location (#7274) 2026-07-23 01:34:38 -07:00
hardware Vulkan GPUs: real device names and selectable ordinals (rebase of #7356 onto #7476) (#7498) 2026-07-27 05:21:48 -07:00
inference Unsloth run/start: per-model recommended sampling and override flags (#7335) 2026-07-23 20:49:54 -07:00
models Pin utf-8 on shipping-code text I/O instead of the operator locale (#7486) 2026-07-27 02:14:20 -07:00
paths Let a decode failure degrade instead of escaping a fail-closed helper (#7487) 2026-07-27 03:26:08 -07:00
prebuilt Studio: add local speech-to-text dictation engine (#7095) 2026-07-23 01:39:03 -07:00
security Pin utf-8 on shipping-code text I/O instead of the operator locale (#7486) 2026-07-27 02:14:20 -07:00
.gitkeep root studio folder 2026-02-02 09:13:49 +00:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_studio_release_build.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
api_errors.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
cache_cleanup.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
client_ip.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
coding_agents.py feat: detect installed coding agent CLIs in Studio settings (#6909) 2026-07-08 05:26:50 -07:00
cpu_threads.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
downsample.py Formatting: ruff line-length 100, kwarg-spacing passes, drop blank after short local imports (#6079) 2026-06-08 04:24:13 -07:00
embedding_model_settings.py Studio: customizable RAG embedding model with HF search, settings tab reorganization (#6800) 2026-07-02 05:26:33 -07:00
helper_precache_settings.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
hf_cache_settings.py Studio: add configurable model download location (#7274) 2026-07-23 01:34:38 -07:00
hf_token_validation.py Studio: validate Hugging Face tokens before use (#7261) 2026-07-20 14:40:14 +01:00
hf_xet_fallback.py Studio: add configurable model download location (#7274) 2026-07-23 01:34:38 -07:00
hidden_models.py Studio: add local speech-to-text dictation engine (#7095) 2026-07-23 01:39:03 -07:00
host_policy.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
lifespan_shutdown.py Studio: make lifespan shutdown resilient to a dead default executor (#6307) 2026-06-15 22:51:46 -07:00
llama_cpp_freshness.py Studio: add local speech-to-text dictation engine (#7095) 2026-07-23 01:39:03 -07:00
llama_cpp_update.py Studio: fail fast on out-of-disk instead of a doomed llama.cpp source build (#7420) 2026-07-26 00:11:38 -07:00
mlx_repair.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
native_path_leases.py Studio: add configurable model download location (#7274) 2026-07-23 01:34:38 -07:00
node_runtime.py Studio: use an isolated Node.js for the frontend build instead of replacing the system Node/npm (#6533) 2026-06-21 21:17:29 -07:00
openai_auto_switch_settings.py Studio: fix the "No model loaded" error, and optionally auto-download a model named in an API request (#7454) 2026-07-27 05:02:06 -07:00
personalization_settings.py studio: persist personalization (profile, avatar, theme) server-side (#6516) 2026-06-22 04:09:48 -07:00
preview_rate_limit.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
preview_sharing_settings.py Studio: require signed capability tokens for /p preview links (#6666) 2026-06-25 21:40:48 -07:00
preview_token.py Studio: require signed capability tokens for /p preview links (#6666) 2026-06-25 21:40:48 -07:00
process_lifetime.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
ssm_runtime.py Auto-install SSM kernels (causal-conv1d, mamba-ssm) for inference loads (#6535) 2026-06-22 04:48:29 -07:00
studio_version.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
subprocess_compat.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
training_runs.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
transformers_dtype.py Studio: Fix torch_dtype deprecation warning on startup and ASR load (#6999) 2026-07-13 17:34:25 -03:00
transformers_latest.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
transformers_version.py Pin utf-8 on shipping-code text I/O instead of the operator locale (#7486) 2026-07-27 02:14:20 -07:00
update_status.py Studio: make code comments and docstrings more succinct (#6029) 2026-06-08 23:07:28 -07:00
upload_limits.py Studio: add local speech-to-text dictation engine (#7095) 2026-07-23 01:39:03 -07:00
utils.py Let a decode failure degrade instead of escaping a fail-closed helper (#7487) 2026-07-27 03:26:08 -07:00
uv_path_safety.py Make _uv_safe_path space-safe on macOS/Linux (#6503) (#6534) 2026-06-24 04:02:24 -07:00
wheel_utils.py Studio: fix flash-attn and torchao install on Blackwell (sm_100+) GPUs (Closes #6961) (#6970) 2026-07-08 06:38:10 -07:00
whisper_cpp_freshness.py Studio: add local speech-to-text dictation engine (#7095) 2026-07-23 01:39:03 -07:00
whisper_cpp_update.py Studio: add local speech-to-text dictation engine (#7095) 2026-07-23 01:39:03 -07:00