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.

Studio: XPU native bf16 no longer depends on intel-ocloc (#13527)

Daniel Hanf6ed46d0a0f4
diff --git a/studio/backend/core/training/diffusion_train_common.py b/studio/backend/core/training/diffusion_train_common.py
index 27525596d80..3c67a344067 100644
--- a/studio/backend/core/training/diffusion_train_common.py
+++ b/studio/backend/core/training/diffusion_train_common.py
@@ -713,7 +713,7 @@ def xpu_native_bf16_probe() -> Optional[bool]:
if not callable(fn):
return None
try:
- return bool(fn(including_emulation = False))
+ return bool(fn(including_emulation = False)) or _xpu_is_known_bf16_part(torch)
except TypeError:
# A torch predating the including_emulation parameter: its answer is the only one there is.
try:
@@ -724,6 +724,25 @@ def xpu_native_bf16_probe() -> Optional[bool]:
return None
+def _xpu_is_known_bf16_part(torch) -> bool:
+ """Whether the current XPU is an Arc / Data Center part, read from its PCI id. Never raises.
+
+ The SYCL runtime answers ``has_bfloat16_conversions`` through libocloc (the intel-ocloc
+ package, which the torch-xpu wheels do not ship), so without it the strict probe is False on
+ every device, BMG and PVC included; with it, True on every device. The PCI id does not depend
+ on the install."""
+ try:
+ props = torch.xpu.get_device_properties()
+ device_id = getattr(props, "device_id", None)
+ if isinstance(device_id, int) and device_id > 0:
+ from utils.hardware.hardware import _is_intel_xpu_pci_id
+ return _is_intel_xpu_pci_id(device_id)
+ # A torch without device_id: the marketing name is the only signal left.
+ return bool(re.search(r"\bArc\b|Data Center GPU", str(getattr(props, "name", "") or "")))
+ except Exception: # noqa: BLE001 -- unprobeable keeps the strict answer
+ return False
+
+
def native_bf16_supported_xpu() -> bool:
"""``xpu_native_bf16_probe`` collapsed for the trainer child, which runs ON the device: there an
unprobeable capability is a refusal, matching ``native_bf16_supported`` on the CUDA side."""
diff --git a/studio/backend/tests/test_diffusion_xpu_training.py b/studio/backend/tests/test_diffusion_xpu_training.py
index 062715c6c76..62ef9e0df7b 100644
--- a/studio/backend/tests/test_diffusion_xpu_training.py
+++ b/studio/backend/tests/test_diffusion_xpu_training.py
@@ -124,6 +124,67 @@ def test_an_xpu_without_a_usable_bf16_probe_is_refused(host, probe):
assert native_bf16_supported_xpu() is False
+def _xpu_without_ocloc(**props):
+ """has_bfloat16_conversions is False on every device when libocloc is missing (real driver)."""
+ return _fake_xpu(
+ is_available = lambda: True,
+ is_bf16_supported = lambda including_emulation = True: bool(including_emulation),
+ get_device_properties = lambda *a: types.SimpleNamespace(**props),
+ )
+
+
+ "device_id",
+ [0x56A0, 0x56C0, 0xE20B, 0xE211, 0x0BD5, 0x64A0, 0xB080],
+ ids = ["A770", "Flex170", "B580", "B60", "Max1550", "LNL", "PTL"],
+)
+def test_an_arc_or_data_center_xpu_is_native_without_libocloc(host, device_id):
+ from core.training.diffusion_train_common import bf16_unsupported_reason
+
+ host(cuda = False, xpu = _xpu_without_ocloc(device_id = device_id, name = "Intel(R) Graphics"))
+ assert native_bf16_supported_xpu() is True
+ assert bf16_unsupported_reason("krea-2") is None
+
+
+ "device_id",
+ [0x4905, 0x7DD5, 0x9A49],
+ ids = ["DG1", "MTL-non-Arc", "TGL"],
+)
+def test_a_non_arc_xpu_without_libocloc_is_still_refused(host, device_id):
+ host(cuda = False, xpu = _xpu_without_ocloc(device_id = device_id, name = "Intel(R) Arc(TM) A770"))
+ assert native_bf16_supported_xpu() is False
+
+
+ ("name", "native"),
+ [
+ ("Intel(R) Arc(TM) B580 Graphics", True),
+ ("Intel(R) Data Center GPU Max 1550", True),
+ ("Intel(R) Iris(R) Xe Graphics", False),
+ ("Intel(R) Graphics [0xe20b]", False),
+ ],
+)
+def test_a_torch_without_device_id_falls_back_to_the_name(host, name, native):
+ host(cuda = False, xpu = _xpu_without_ocloc(name = name))
+ assert native_bf16_supported_xpu() is native
+
+
+def test_unreadable_device_properties_keep_the_strict_answer(host):
+ def _raise(*a):
+ raise RuntimeError("no device")
+
+ host(
+ cuda = False,
+ xpu = _fake_xpu(
+ is_available = lambda: True,
+ is_bf16_supported = lambda including_emulation = True: bool(including_emulation),
+ get_device_properties = _raise,
+ ),
+ )
+ assert native_bf16_supported_xpu() is False
+
+
def _dit_cfg():
return DiffusionLoraConfig(
base_model = "black-forest-labs/FLUX.1-dev",
diff --git a/studio/backend/utils/hardware/hardware.py b/studio/backend/utils/hardware/hardware.py
index 4b3de1f21ed..93c96032baf 100644
--- a/studio/backend/utils/hardware/hardware.py
+++ b/studio/backend/utils/hardware/hardware.py
@@ -468,6 +468,13 @@ _INTEL_XPU_PCI_IDS = frozenset((
)) # fmt: skip
+def _is_intel_xpu_pci_id(device_id: int) -> bool:
+ """Whether an Intel PCI device ID is an XPU-capable family."""
+ return device_id in _INTEL_XPU_PCI_IDS or any(
+ lo <= device_id <= hi for lo, hi in _INTEL_XPU_PCI_ID_RANGES
+ )
+
+
def _intel_pci_device_is_xpu_class(device_dir: str) -> Optional[bool]:
"""Whether the card's PCI device ID is an XPU-capable family; None if unreadable."""
try:
@@ -475,9 +482,7 @@ def _intel_pci_device_is_xpu_class(device_dir: str) -> Optional[bool]:
device_id = int(fh.read().strip(), 16)
except (OSError, ValueError):
return None
- return device_id in _INTEL_XPU_PCI_IDS or any(
- lo <= device_id <= hi for lo, hi in _INTEL_XPU_PCI_ID_RANGES
- )
+ return _is_intel_xpu_pci_id(device_id)
def _linux_drm_sysfs_records(*, distinguish_failure: bool = False) -> "list[Dict[str, Any]] | None":