Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Honor the Vulkan opt-in for sd.cpp on Windows Intel GPUs (#17528)

Lee Jacksona5522c09990a
diff --git a/studio/backend/core/inference/diffusion_engine_router.py b/studio/backend/core/inference/diffusion_engine_router.py
index d0ca6530f88..da35e86825c 100644
--- a/studio/backend/core/inference/diffusion_engine_router.py
+++ b/studio/backend/core/inference/diffusion_engine_router.py
@@ -237,8 +237,8 @@ def _reachable_intel_arc_render_node() -> bool:
def _vulkan_gpu_for_cpu_torch() -> bool:
"""True when torch is CPU-only but the host has a GPU the Vulkan sd.cpp build can render on:
- an AMD card (Vega, RDNA1 and Polaris get no ROCm wheel) or an Intel Arc. Never beside NVIDIA,
- which Vulkan could enumerate first, nor under a mask Vulkan does not read (#13666)."""
+ an AMD card, an Intel Arc, or any Intel GPU once the llama.cpp backend is set to Vulkan. Never
+ beside NVIDIA, which Vulkan could enumerate first, nor under a mask Vulkan does not read (#13666)."""
if not sd_cpp_vulkan_fallback_enabled():
return False
if (sys.platform, platform.machine().lower()) not in _VULKAN_SD_CPP_PLATFORMS:
@@ -255,13 +255,24 @@ def _vulkan_gpu_for_cpu_torch() -> bool:
if any(d.get("vendor") == "nvidia" for d in devices) or _nvidia_adapter_present():
return False
+ from utils.prebuilt.llama_backend import environment_backend_override
+
+ # A non-Arc iGPU can render slower than the CPU build, so only an explicit Vulkan request takes it.
+ vulkan_requested = (
+ environment_backend_override(
+ os.environ.get("UNSLOTH_LLAMA_CPP_BACKEND"), os.environ.get("UNSLOTH_FORCE_VULKAN")
+ )
+ == "vulkan"
+ )
+
def _renders(device: dict) -> bool:
if device.get("vendor") == "amd":
return True
if device.get("vendor") != "intel":
return False
- # Arc only: a UHD iGPU renders slower than the CPU build. Linux carries the PCI class,
- # the Windows registry only the name.
+ if vulkan_requested:
+ return True
+ # Linux carries the PCI class, the Windows registry only the name.
if "xpu_class" in device:
return device.get("xpu_class") is True
return "arc" in str(device.get("name") or "").lower().replace("(tm)", " ").split()
@@ -376,8 +387,8 @@ def _cuda_gpu_for_cpu_torch() -> bool:
def image_install_accelerator(backend: str) -> str:
"""The sd.cpp build the IMAGE engine wants: the off-torch card's when one is set, else torch's,
- else Vulkan for a CPU torch beside an AMD or Arc GPU, or CUDA beside an NVIDIA card llama.cpp
- already renders on. Video keeps ``_install_accelerator_for``, since torch places its loads."""
+ else Vulkan for an eligible AMD or Intel GPU, or CUDA beside an NVIDIA card llama.cpp already
+ renders on. Video keeps ``_install_accelerator_for``, since torch places its loads."""
off_torch = off_torch_sd_cpp_device(backend)
if off_torch is not None:
return off_torch.accelerator
diff --git a/studio/backend/tests/test_sd_cpp_vulkan_cpu_torch.py b/studio/backend/tests/test_sd_cpp_vulkan_cpu_torch.py
index f904350c0cd..26e447d6b4b 100644
--- a/studio/backend/tests/test_sd_cpp_vulkan_cpu_torch.py
+++ b/studio/backend/tests/test_sd_cpp_vulkan_cpu_torch.py
@@ -28,6 +28,8 @@ _ENVS = (
"UNSLOTH_DIFFUSION_ENGINE",
"UNSLOTH_DIFFUSION_SD_CPP",
"UNSLOTH_DIFFUSION_SD_CPP_DEVICE",
+ "UNSLOTH_FORCE_VULKAN",
+ "UNSLOTH_LLAMA_CPP_BACKEND",
"UNSLOTH_DIFFUSION_SD_CPP_VULKAN_FALLBACK",
"ROCR_VISIBLE_DEVICES",
"HIP_VISIBLE_DEVICES",
@@ -40,6 +42,7 @@ _VEGA = {"vendor": "amd", "index": 0, "name": None, "source": "sysfs-drm"}
_ARC_LINUX = {"vendor": "intel", "index": 0, "name": None, "xpu_class": True}
_UHD_LINUX = {"vendor": "intel", "index": 0, "name": None, "xpu_class": False}
_ARC_WINDOWS = {"vendor": "intel", "index": 0, "name": "Intel(R) Arc(TM) A770 Graphics"}
+_IRIS_WINDOWS = {"vendor": "intel", "index": 0, "name": "Intel(R) Iris(R) Xe Graphics"}
_UHD_WINDOWS = {"vendor": "intel", "index": 0, "name": "Intel(R) UHD Graphics 770"}
_RTX = {"vendor": "nvidia", "index": 0, "name": "NVIDIA GeForce RTX 3060"}
@@ -96,13 +99,40 @@ def test_cpu_torch_vulkan_follows_the_cards(monkeypatch, devices, expected):
assert r.image_install_accelerator("cpu") == expected
[email protected]("device,expected", [(_ARC_WINDOWS, "vulkan"), (_UHD_WINDOWS, "auto")])
+ "device,expected", [(_ARC_WINDOWS, "vulkan"), (_UHD_WINDOWS, "auto"), (_IRIS_WINDOWS, "auto")]
+)
def test_windows_intel_is_read_by_name(monkeypatch, device, expected):
_platform(monkeypatch, "win32", "AMD64")
monkeypatch.setattr(r, "_physical_inventory", lambda: _host(device))
assert r.image_install_accelerator("cpu") == expected
+ "system,machine,device", [("win32", "AMD64", _IRIS_WINDOWS), ("linux", "x86_64", _UHD_LINUX)]
+)
+ "env,expected",
+ [
+ ({"UNSLOTH_FORCE_VULKAN": "1"}, "vulkan"),
+ ({"UNSLOTH_LLAMA_CPP_BACKEND": "vulkan"}, "vulkan"),
+ ({"UNSLOTH_LLAMA_CPP_BACKEND": "cpu", "UNSLOTH_FORCE_VULKAN": "1"}, "auto"),
+ ({"UNSLOTH_LLAMA_CPP_BACKEND": "auto", "UNSLOTH_FORCE_VULKAN": "1"}, "auto"),
+ ({"UNSLOTH_FORCE_VULKAN": "0"}, "auto"),
+ ({"UNSLOTH_FORCE_VULKAN": "1", "ZE_AFFINITY_MASK": "0"}, "auto"),
+ ({"UNSLOTH_FORCE_VULKAN": "1", "UNSLOTH_DIFFUSION_SD_CPP_VULKAN_FALLBACK": "0"}, "auto"),
+ ],
+)
+def test_vulkan_request_opts_in_a_non_arc_intel_gpu(
+ monkeypatch, system, machine, device, env, expected
+):
+ _platform(monkeypatch, system, machine)
+ monkeypatch.setattr(r, "_physical_inventory", lambda: _host(device))
+ for name, value in env.items():
+ monkeypatch.setenv(name, value)
+ assert r.image_install_accelerator("cpu") == expected
+
+
@pytest.mark.parametrize(
"inventory",
[_host(_VEGA, unanswered = ["nvidia"]), _host(unknown = True)],