Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

sycl: setup picks the Intel card by PCI id and configures Alchemist

duncanmcqueenedff903d7a66
diff --git a/sycl/setup_intel.py b/sycl/setup_intel.py
index 86df7c67e..05521ea4e 100644
--- a/sycl/setup_intel.py
+++ b/sycl/setup_intel.py
@@ -47,6 +47,12 @@ INTEL_ARC = {"e223": ("Arc Pro B70", 32.0), "e221": ("Arc Pro B60", 24.0), "e211
"56a0": ("Arc A770", 16.0), "56a1": ("Arc A750", 8.0), "56a2": ("Arc A580", 8.0),
"56a5": ("Arc A380", 6.0), "56a6": ("Arc A310", 4.0), "5690": ("Arc A770M", 16.0)}
+# Alchemist (DG2, the A-series) has no FP64 hardware and carries the driver's FP64 emulation. On i915 (the A750) a
+# single sycl::malloc_host past ~3 GiB also fails, so the experts load into a CPU-computed RAM arena instead of the
+# pinned mirror (--mmap-experts + STRATA_VERIFY_NO_HOST=0 - docs/INTEL.md, "Arc A750"). On xe (the A770) the mirror is
+# built in chunks past that limit and the A-series uses the ordinary streamed path; see to_sycl().
+ALCHEMIST_IDS = frozenset({"56a0", "56a1", "56a2", "56a5", "56a6", "5690"})
+
def intel_gpus():
"""Intel discrete GPUs from sysfs: vendor 0x8086 under the xe or i915 driver, named by PCI device id. VRAM comes
@@ -75,7 +81,8 @@ def intel_gpus():
vram = (int(end, 16) - int(start, 16) + 1) / 2**30
except (OSError, IndexError, ValueError):
vram = 0.0
- found.append({"index": len(found), "name": f"Intel {name}", "vram_gb": vram, "arch": driver, "driver": driver})
+ found.append({"index": len(found), "name": f"Intel {name}", "vram_gb": vram, "arch": driver, "driver": driver,
+ "devid": devid})
return found
@@ -124,15 +131,21 @@ def small_card(vram_gb: float, driver: str) -> bool:
return 0 < vram_gb < SMALL_CARD_GB or driver == "i915"
-def to_sycl(cfg: dict, exe: Path, ram: float, keep: dict, vram_gb: float = 0.0, driver: str = "xe") -> dict:
+def to_sycl(cfg: dict, exe: Path, ram: float, keep: dict, vram_gb: float = 0.0, driver: str = "xe",
+ devid: str = "") -> dict:
"""setup's config (written for its HIP path) -> the SYCL port's: the container's paths, experts streamed from the
GGUF into VRAM (--stream-experts: the engine reads them from the GGUF and keeps what does not fit in a pinned RAM
mirror; the VRAM reserve is the smallest that leaves the KV and the prompt buffers room - docs/INTEL.md), KV
streaming from 64K up when the RAM holds the KV (the B70 at 256K decodes at 40+ tok/s with it, 4-9 without).
- A reserve the user asked for (--vram-reserve-mib) is kept. An i915 card (Alchemist, the A-series) cannot do that:
- a single pinned host allocation above a few GB fails there, so the mirror cannot hold what the card does not, and
- the config loads the experts into a RAM arena instead (no --stream-experts, --ple-io ram, and the device-built
- verify plan's NO_HOST switch off - docs/INTEL.md, "Arc A750")."""
+ A reserve the user asked for (--vram-reserve-mib) is kept.
+
+ An Alchemist card (the A-series, i915 or xe) has no FP64 hardware, so its config carries the driver's FP64
+ emulation (a kernel on the sampled path declares double). On i915 (the A750) the experts load into a RAM arena
+ and the CPU computes the ones the card does not hold (--ple-io ram, STRATA_VERIFY_NO_HOST=0 - docs/INTEL.md,
+ "Arc A750"). On xe (the A770) the experts are streamed into VRAM like any other Arc; the mirror is built in
+ chunks so DG2's >3 GiB single pinned-host allocation limit is not hit, and the build passes
+ -ze-opt-greater-than-4GB-buffer-required so the prompt path is correct past the cache's 4 GiB (docs/INTEL.md,
+ "Kernels misread memory more than 4 GiB into an allocation")."""
args = list(cfg["args"])
for f in ("--resident-experts", "--mmap-experts"): # setup's low-RAM mode is the CUDA engine's
drop(args, f)
@@ -151,8 +164,10 @@ def to_sycl(cfg: dict, exe: Path, ram: float, keep: dict, vram_gb: float = 0.0,
drop(args, "--vram-reserve-mib", True)
reserve = asked_reserve or (str(SMALL_RESERVE_MIB) if small_card(vram_gb, driver) else
"1024" if ctx <= 32768 else "2048")
- host_arena = driver == "i915"
- if host_arena:
+ alchemist = driver == "i915" or devid in ALCHEMIST_IDS
+ if driver == "i915":
+ # Arc A-series on i915 (the A750): the experts load into an ordinary RAM arena and the CPU computes the ones
+ # the card does not hold; the n-gram table is kept in RAM (setup's rotational-disk rule) and no mirror is built.
if "--ple-io" not in args:
args += ["--ple-io", "ram"]
args += ["--vram-reserve-mib", reserve]
@@ -166,8 +181,11 @@ def to_sycl(cfg: dict, exe: Path, ram: float, keep: dict, vram_gb: float = 0.0,
out = {k: v for k, v in cfg.items() if k not in ("lib_dirs", "env", "vision", "gpus")}
out.update({"backend": "sycl", "exe": str(SYCL_WRAPPER), "args": args, "sycl_root": str(MOUNT)})
env = {}
- if host_arena:
- env["STRATA_VERIFY_NO_HOST"] = "0" # strata-sycl.sh sets 1 unless told otherwise (xe, every expert in VRAM)
+ if alchemist:
+ if driver == "i915":
+ # on i915 the CPU computes the misses and the GPU waits for them at every layer (NO_HOST=0). On xe the
+ # experts are streamed and the mirror is used, so strata-sycl.sh's NO_HOST=1 default stands.
+ env["STRATA_VERIFY_NO_HOST"] = "0"
# an Alchemist has no FP64 hardware: a kernel that declares double (one is on the sampled path) is refused at its
# first launch - "'double' is not supported in ... device", the engine dies on the first request with a
# temperature - unless the driver emulates it (docs/INTEL.md)
@@ -208,22 +226,24 @@ def install(argv) -> None:
say = S.say
fake_ram = max(real_ram, 1024.0)
+ alch = intel[0]["driver"] == "i915" or intel[0].get("devid") in ALCHEMIST_IDS
def say_intel(msg=""):
"""setup's words for its AMD path and its RAM rule, said for the Intel card."""
msg = str(msg).replace("(AMD, experimental: docs/AMD_HIP.md)", "(Intel Arc: the SYCL port, docs/INTEL.md)")
msg = msg.replace("Your AMD GPUs:", "Your Intel GPUs:").replace("just run ./setup.sh", "just run ./setup.sh --backend sycl")
msg = re.sub(r"\b(xe|i915) \(AMD: docs/AMD_HIP\.md\)", r"\1 driver (Intel Arc: docs/INTEL.md)", msg)
- where = ("the experts are loaded into RAM, the card computes the ones it holds" if intel[0]["driver"] == "i915"
+ where = ("the experts the card does not hold are computed on the CPU" if alch
else "the experts are streamed into VRAM")
msg = msg.replace(f"RAM: {fake_ram:.0f} GB", f"RAM: {real_ram:.0f} GB ({where})")
if re.match(r"\s+\S+\s+needs ~\d+ GB RAM:", msg): # --check's CUDA verdicts: replaced by the Intel one
m = msg.split()[0]
d = S.MODELS.get(m, {})
shard1 = d.get("download_gb", 0) - 28.8 # all but the per-layer lookup table (read from disk)
- room = intel[0]["vram_gb"] - 3 + max(0.0, real_ram - 10) # VRAM, plus a pinned host mirror
+ room = intel[0]["vram_gb"] - 3 + max(0.0, real_ram - 10) # VRAM, plus a pinned host mirror (or the CPU)
msg = (f" {m:8s} ~{shard1:.0f} GB of weights: " +
("fits in VRAM" if shard1 <= intel[0]["vram_gb"] - 1.5 else
+ "fits, the experts the card does not hold are computed on the CPU (slower)" if alch and shard1 <= room else
"fits with part of its experts mirrored in RAM (slower)" if shard1 <= room else "does not fit"))
say(msg)
S.say = say_intel
@@ -247,11 +267,26 @@ def install(argv) -> None:
def write_run_script(model, cfg_path, port, open_browser=True): # setup.write_run_script's signature (#870)
cfg = json.loads(Path(cfg_path).read_text(encoding="utf-8"))
- cfg = to_sycl(cfg, exe, real_ram, keep.get(Path(cfg_path).name, {}), intel[0]["vram_gb"], intel[0]["driver"])
+ # the card setup selected (--gpu / the first usable), not intel[0]: on a PC with two Arcs the config must match
+ # the chosen one (docs/INTEL.md, "Two cards"). intel_gpus() lists them in sysfs card order and cfg["gpu"] is
+ # that index (setup.py's amd path); a layer split writes a list, and then every listed card is used.
+ gsel = cfg.get("gpu")
+ split = isinstance(gsel, list)
+ idx = gsel if isinstance(gsel, int) and 0 <= gsel < len(intel) else 0
+ sel = intel[idx]
+ cfg = to_sycl(cfg, exe, real_ram, keep.get(Path(cfg_path).name, {}), sel["vram_gb"], sel["driver"],
+ sel.get("devid", ""))
+ if len(intel) > 1: # pin the SYCL device(s)
+ # the Level Zero order followed the sysfs card order on the tested machines; a machine where it does not
+ # needs an explicit ONEAPI_DEVICE_SELECTOR (kept if the user set one)
+ selector = "level_zero:*" if split else f"level_zero:{idx}"
+ cfg.setdefault("env", {}).setdefault("ONEAPI_DEVICE_SELECTOR", selector)
need = S.MODELS.get(model, {}).get("ram_gb", 0)
- if intel[0]["driver"] == "i915" and need and real_ram < need:
- S.warn(f"{model} on this Arc loads its experts into RAM (about {need} GB; this PC has {real_ram:.0f} GB): "
- "the start will be slow or fail - a smaller model (--model) fits better (docs/INTEL.md)")
+ sel_alch = sel["driver"] == "i915" or sel.get("devid") in ALCHEMIST_IDS
+ if sel_alch and need and real_ram < need:
+ S.warn(f"{model} on this Arc computes the experts the card does not hold on the CPU (about {need} GB of "
+ f"weights; this PC has {real_ram:.0f} GB of RAM): the start will be slow or fail - a smaller model "
+ "(--model) fits better (docs/INTEL.md)")
Path(cfg_path).write_text(json.dumps(cfg, indent=1), encoding="utf-8")
script = write(model, cfg_path, port, open_browser)
script.write_text(script.read_text().replace(str(ROOT / "serve" / "server.py"), str(SERVER)))