Merge f-ling32-qwenwin (33974a5be1): Intel Arc downloads what is missing (Terminal and app), plain decode for the Windows IQ2_XS / IQ3_S packs

This commit is contained in:
Niko1221 committed 2026-12-03 07:07:53 +01:00
commit 269e35441b
11 files changed
+436 -41

No files matched your search

+63 -28
View File
@@ -9597,6 +9597,32 @@ def _select_sycl_cards(a, cards: list[dict]) -> list[dict]:
return list(cards[:1])
INTEL_GGUF_MIN_RAM_GB = 24 # an Arc run of a Qwen size keeps about 20 GB of the PC's RAM busy (QFN-B70, the B70 box with 32 GB: 20 GB free at the lowest with IQ3_S): said, not refused
def intel_download_gguf(a, family: str, fam: dict, model: str, model_dir: Path) -> list:
"""The files of a GGUF model for an Intel Arc card are not on the computer: check the disk (what is still missing plus the pack and a margin) and the RAM (said, not refused), then download them the way an
NVIDIA / AMD install does (fetch_gguf_shards: the pinned sources, SHA-256 and finish marks, resumable). Returns the shards (intel_app.model_files_in), [] when they are still not there."""
from strata_control import intel_app
if getattr(a, "models_dir", None) is None:
a.models_dir = str(model_dir.parent)
shards = [model_dir / model_file(fam, model, i) for i in range(1, model_shards(fam, model) + 1)]
model_dir.mkdir(parents=True, exist_ok=True)
on_disk = sum(f.stat().st_size for s in shards for f in (s, s.with_name(s.name + ".part")) if f.is_file()) / 1e9 # a download that resumes needs room only for what is still missing
to_fetch = max(MODELS[model]["download_gb"] - on_disk, 0.0)
pack_dir = model_dir.parent.parent / "packs" / run_tag(a, family, fam, model).lower()
problem = disk_room_problem(model_dir, pack_dir, to_fetch + 8, 0.0, (f" ({on_disk:.0f} GB of the model is already there)" if on_disk >= 1 else "")) # 8 GB: the pack and working room
if problem:
fail(*problem, kind="no_space", path=str(model_dir), free_bytes=int(free_gb(model_dir) * 1e9), needed_bytes=int((to_fetch + 8) * 1e9))
ram = ram_gb()
if ram and ram < INTEL_GGUF_MIN_RAM_GB:
warn(f"this computer has {ram:.0f} GB of RAM: a {model} run on an Intel Arc card keeps about 20 GB of it busy, so it may run slowly or not start")
step(2, f"downloading {fam['title']} {model} ({to_fetch:.0f} GB)")
fetch_gguf_shards(a, family, fam, model, shards, model_dir)
check_shards(shards)
return intel_app.model_files_in(model_dir, family, fam)
def intel_control_setup(a) -> int:
"""`--backend sycl` in the app's CONTROL mode (tools/strata_mcp.py passes it for an Intel Arc PC): what the Terminal does for an Arc
(strata_cli/launch/runner.py adopt_prepared_files): the pack from the model's GGUF files (`--prepare-pack`'s step), then the run config
@@ -9610,7 +9636,7 @@ def intel_control_setup(a) -> int:
family = a.family or "qwen"
kind = "inkling" if family in INKLING_FAMILIES else "hy4" if family in HY4_FAMILIES else "qwen"
if not intel_app.route_here(kind, model=a.model if kind == "qwen" else None, family=family if kind == "qwen" else None):
fail("this model has no Intel Arc engine for this computer yet", "Linux runs every Intel route; Windows runs Ling-3.2-Air and Inkling-2-Mini; there is no Mac Intel engine")
fail("this model has no Intel Arc engine for this computer yet", "Linux runs every Intel route; Windows runs Ling-3.2-Air, Inkling-2-Mini and the Qwen3.8-Flash-Next Coder IQ1_M, IQ2_XS and IQ3_S sizes; there is no Mac Intel engine")
if family in HY4_FAMILIES or family in INKLING_FAMILIES:
cards = intel_app.arc_cards()
if not cards:
@@ -9639,6 +9665,8 @@ def intel_control_setup(a) -> int:
if model_dir.is_file():
model_dir = model_dir.parent
shards = intel_app.model_files_in(model_dir, family, fam)
if not shards and not a.gguf_dir and intel_app.can_download(family, model, fam):
shards = intel_download_gguf(a, family, fam, model, model_dir)
if not shards:
fail(intel_app.NO_DOWNLOAD)
ok(f"model files: {model_dir} ({len(shards)} file{'s' if len(shards) != 1 else ''})")
@@ -12493,6 +12521,39 @@ def mac_ling32_setup(a) -> int:
return install_ling32_air(a, a.family or ling32_family.FAMILY, gpu, False, False, None, False, a.port or 8080, ram, None)
def fetch_gguf_shards(a, family: str, fam: dict, model: str, shards: list, models_dir: Path) -> None:
"""Step 5 of an install of a GGUF model (Qwen, Swift, Coder, Gyro, Unsloth): download the shards that are not on the disk yet, each into `shards`' own place, with the finish mark of a
download that completed (done() / mark()), from the pinned sources (Hugging Face at the pinned revision, or ModelScope with its own hashes); the original's shard 2, the same file for all its
sizes and the Coder, is linked from a size that is already here. Used by main() (NVIDIA / AMD) and by intel_control_setup() (an Intel Arc card). `a.models_dir` is the folder of the sizes."""
missing = [s.name for s in shards if not (s.exists() and done(s))]
if missing: # #495: files downloaded by hand go here, or --gguf-dir
say(f" The model files go in {models_dir}")
say(f" Files you already have: put them here with their original names ({', '.join(missing)}), or use "
"--gguf-dir <their folder>.")
if model_source() == "modelscope":
say(f" Downloading from ModelScope ({ms_endpoint()}); --source huggingface downloads from Hugging Face")
warn("ModelScope serves the repositories' current files, not the pinned revisions: each file is checked "
"against the SHA-256 ModelScope itself publishes (self-attested); the MTP tensors against the "
"pinned checkpoint's own hashes")
elif hf_endpoint() != HF_DEFAULT:
say(f" Downloading from {hf_endpoint()} (HF_ENDPOINT)")
for s in shards:
if s.exists() and done(s):
ok(f"{s.name} already downloaded")
continue
# the original's shard 2 is the same file for all its sizes and the Coder: reuse one that is already here
other = [p for p in Path(a.models_dir).glob("*/Qwen3.8-Flash-Next-GSQ-RCO-*-00002-of-00002.gguf") if done(p)]
if family in ("qwen", "coder") and s.name.endswith("00002-of-00002.gguf") and other and not s.exists():
try:
os.link(other[0], s)
mark(s)
ok(f"{s.name} shared with {other[0].parent.name} (identical file)")
continue
except OSError:
pass
download(model_hf(fam, model) + s.name, s)
def main() -> int:
try: # the engine programs setup runs start no debugger on a user's machine (strata_control/childenv.py)
from strata_control.childenv import quiet_crash_env
@@ -13514,33 +13575,7 @@ def main() -> int:
warn("these packs are on Hugging Face only: downloading them from " + hf_endpoint())
ready_fetch(model, models_dir)
elif not a.gguf_dir:
missing = [s.name for s in shards if not (s.exists() and done(s))]
if missing: # #495: files downloaded by hand go here, or --gguf-dir
say(f" The model files go in {models_dir}")
say(f" Files you already have: put them here with their original names ({', '.join(missing)}), or use "
"--gguf-dir <their folder>.")
if model_source() == "modelscope":
say(f" Downloading from ModelScope ({ms_endpoint()}); --source huggingface downloads from Hugging Face")
warn("ModelScope serves the repositories' current files, not the pinned revisions: each file is checked "
"against the SHA-256 ModelScope itself publishes (self-attested); the MTP tensors against the "
"pinned checkpoint's own hashes")
elif hf_endpoint() != HF_DEFAULT:
say(f" Downloading from {hf_endpoint()} (HF_ENDPOINT)")
for s in shards:
if s.exists() and done(s):
ok(f"{s.name} already downloaded")
continue
# the original's shard 2 is the same file for all its sizes and the Coder: reuse one that is already here
other = [p for p in Path(a.models_dir).glob("*/Qwen3.8-Flash-Next-GSQ-RCO-*-00002-of-00002.gguf") if done(p)]
if family in ("qwen", "coder") and s.name.endswith("00002-of-00002.gguf") and other and not s.exists():
try:
os.link(other[0], s)
mark(s)
ok(f"{s.name} shared with {other[0].parent.name} (identical file)")
continue
except OSError:
pass
download(model_hf(fam, model) + s.name, s)
fetch_gguf_shards(a, family, fam, model, shards, models_dir)
if not ready:
check_shards(shards)
for s in ([] if ready else shards): # the Unsloth files: pinned sizes and SHA-256
+1
View File
@@ -244,6 +244,7 @@ def run(a) -> int:
needed = drafting.needs_pack(**want, **sig) or drafting.needs_tuned(**want, **sig) # (the tuned drafter is a download of its own, where the set and the card use it)
tuned_needed = drafting.needs_tuned(**want, **sig)
mtp_needed = drafting.needs_mtp(**want, **sig) or (not needed and want["mtp_here"] is False and drafting.normalize(want["mode"]) != "off"
and not drafting.intel_plain(want["backend"], want["model_name"])
and drafting.decide(**want, **sig).drafter == "off") # the start's safety net (runner.fetch_missing_drafter): never no drafter unless Off was chosen
if a.drafting_command == "plan":
decision = drafting.decide(**want, **sig)
+40 -6
View File
@@ -1481,13 +1481,15 @@ class Runner:
args += ["--drafter", "off"]
if self.is_inkling() and s.parallel and int(s.parallel) > 1:
args += ["--parallel", str(int(s.parallel))] # setup plans the experts in graphics memory with room for these slots
if self.is_native_strata_family() and (not WINDOWS or self.is_ling32()) and sys.platform != "darwin": # (Windows: Ling-3.2-Air only; the Inkling / Hy4 Intel engines are Linux packages)
if self.is_native_strata_family() and (not WINDOWS or self.intel_route_here()) and sys.platform != "darwin": # (Windows: the families with a Windows Intel engine, intel_app.route_here)
try:
from strata_control import engine_component
if engine_component.detect_backend()[0] == "sycl":
args += ["--backend", "sycl"] # #6691: route Inkling-2-Mini & Hy4-Flash through setup.py's Intel SYCL control path
except Exception: # noqa: BLE001
pass
elif self.intel_chosen() and self.intel_downloads(): # a GGUF model for an Intel Arc card whose files are not here: setup's Intel path downloads, prepares and writes the settings (intel_control_setup)
args += ["--backend", "sycl"]
if fam in ("qwen", "coder"):
args += ["--experimental-speed-projection", "off"]
if s.draft_vocab and fam in modelstate.HELPER_FAMILIES:
@@ -1833,7 +1835,7 @@ class Runner:
adopted = self.adopt_prepared_files("no Mac model installer in this Terminal")
if adopted is not None:
return adopted
if self.intel_chosen():
if self.intel_chosen() and not self.intel_downloads():
adopted = self.adopt_prepared_files("", chosen=True)
if adopted is not None:
return adopted
@@ -1977,10 +1979,42 @@ class Runner:
except (OSError, ValueError):
return None
def intel_route_here(self) -> bool:
"""Does this model's Intel Arc route run on this PC (strata_control/intel_app.py route_here: Linux every family and pack, Windows the families with a gated engine and their gated packs). Never raises."""
try:
from strata_control import intel_app
s = self.s
fd = self.catalog.tables()[1].get(s.family or "", {})
kind = intel_app.family_kind({"ling32": self.is_ling32(), "inkling": self.is_inkling(), "hy4": self.is_hy4()} if self.is_native_strata_family() else fd)
return bool(intel_app.route_here(kind, model=str(s.model) if kind == "qwen" else None, family=str(s.family) if kind == "qwen" else None))
except Exception: # noqa: BLE001
return False
def intel_downloads(self) -> bool:
"""An Intel Arc launch of a GGUF model whose files are not on this computer and that Strata downloads there (intel_app.can_download): the installer runs (setup.py --backend sycl) instead of the prepared-files path."""
try:
from strata_cli.launch import adopt
from strata_control import intel_app
s, cat = self.s, self.catalog
if s.model_path or s.custom_id or s.custom_label: # the person's own files
return False
_models, families, _ctx, _src = cat.tables()
fam = families.get(s.family or "", {})
if not intel_app.can_download(s.family or "", str(s.model), fam):
return False
data_dir = Path(s.data_dir) if s.data_dir else cat.data_dir()
model_dir = data_dir / "models" / (fam.get("tag", "") + str(s.model))
files = adopt.model_files(model_dir, s.family or "", fam) if fam.get("feed") else adopt.find_shards(model_dir)
return not files
except Exception: # noqa: BLE001
return False
def intel_chosen(self) -> bool:
"""The engine for this launch is the Intel Arc one (chosen with --backend intel, saved, or the only make here), and the model is one
the built-in downloader sets up for NVIDIA and AMD only: Strata prepares the model files itself instead (adopt_prepared_files)."""
if self.is_native_strata_family() or sys.platform == "darwin" or WINDOWS:
if self.is_native_strata_family() or sys.platform == "darwin":
return False
if WINDOWS and not self.intel_route_here(): # Windows: only the Qwen packs that were gated on a Windows Arc (intel_app.QWEN_SYCL_WINDOWS_PACKS)
return False
try:
from strata_control import engine_component
@@ -3395,7 +3429,7 @@ class Runner:
try:
cfg = read_config(base_path)
want = self.drafting_inputs(cfg)
if not cfg or drafting.normalize(want["mode"]) == "off" or want.get("mtp_here") is not False or self.feed_without_draft_layer() \
if not cfg or drafting.normalize(want["mode"]) == "off" or drafting.intel_plain(want["backend"], want["model_name"]) or want.get("mtp_here") is not False or self.feed_without_draft_layer() \
or self.s.family not in modelstate.HELPER_FAMILIES or drafting.decide(**want, **self.drafting_signals(cfg, want)).drafter != "off":
return base_path
except Exception: # noqa: BLE001 - a question asked early is never a reason to stop a launch
@@ -3446,8 +3480,8 @@ class Runner:
try:
cfg = read_config(base_path)
want = self.drafting_inputs(cfg)
if drafting.normalize(want["mode"]) == "off" or drafting.decide(**want, **self.drafting_signals(cfg, want)).drafter != "off":
return # Off was chosen, or another drafter runs: nothing to say
if drafting.normalize(want["mode"]) == "off" or drafting.intel_plain(want["backend"], want["model_name"]) or drafting.decide(**want, **self.drafting_signals(cfg, want)).drafter != "off":
return # Off was chosen (or is what Auto means on this Intel pack), or another drafter runs: nothing to say
except Exception: # noqa: BLE001 - a note is never a reason to stop a launch
return
self._mtp_offline_said = True
+24
View File
@@ -1547,6 +1547,26 @@ def canonical_pack(args: list[Any] | None = None) -> bool:
return False
#: Intel Arc (the SYCL engine), Qwen3.8-Flash-Next IQ2_XS and IQ3_S: Auto is NO drafter, the plain decode QFN-B70 gated on the B70. With DFlash2 (Auto's pick wherever the engine has it) the Windows run starts with
#: `--spec 6` and the drafter (decode 77-114 tok/s, about twice plain, acceptance 90 %), which was not gated: speculation with this pack is not bit-equal to plain decode (near-tie flips from token 56 to 185 with spec 2).
#: ONE switch: set False and Auto is DFlash2 on Intel again if the owner chooses speed over exact answers (the person can name a drafter in Settings either way).
INTEL_PLAIN_BY_DEFAULT = True
#: The platforms it applies to (sys.platform prefixes). Windows only for now: that is where the B70 gate measured it and where the app's Load put DFlash2 on without a gate. Linux Arc keeps its tuned
#: DFlash2 default for IQ3_S (CLASS_DEFAULTS, tests/terminal/test_drafting_tuned.py); add "linux" here, and update those tests, if the owner wants the plain decode there too.
INTEL_PLAIN_PLATFORMS = ("win",)
INTEL_PLAIN_PACKS = re.compile(r"^qwen3\.8-flash-next-(iq2_xs|iq3_s)$")
def _host_platform() -> str:
return sys.platform
def intel_plain(backend: str | None, model_name: str | None) -> bool:
"""Does Auto mean no drafter for this model on this engine (INTEL_PLAIN_BY_DEFAULT): the SYCL engine, one of INTEL_PLAIN_PACKS, on a platform of INTEL_PLAIN_PLATFORMS."""
return bool(INTEL_PLAIN_BY_DEFAULT and str(backend or "").strip().lower() == "sycl" and _host_platform().startswith(INTEL_PLAIN_PLATFORMS)
and INTEL_PLAIN_PACKS.match(str(model_name or "").strip().lower()))
def choice_of(mode: Any, *, model_name: str | None = None, family: str | None = None, backend: str | None = None, archs: Any = None,
args: list[Any] | None = None, vram_mib: float | None = None, canonical: bool | None = None) -> str:
"""The drafter the choice means for this model on this computer, before anything is looked up on disk: ``dflash2``, ``mtp`` or ``off``. Auto is DFlash2 wherever
@@ -1558,6 +1578,8 @@ def choice_of(mode: Any, *, model_name: str | None = None, family: str | None =
return "off"
if asked == "mtp":
return "mtp"
if asked == "auto" and intel_plain(backend, model_name):
return "off" # Intel Arc IQ2_XS / IQ3_S: the plain decode that was gated (INTEL_PLAIN_BY_DEFAULT)
if asked == "auto" and str(backend or "").strip().lower() != "metal" and (canonical_pack(args) if canonical is None else canonical):
return "mtp" # the canonical pack (the AVX-512 Q2_0): DFlash2 would end the start (#7090)
entry = default_for(backend, model_name)
@@ -1583,6 +1605,8 @@ def decide(mode: Any, *, klass: str = "other", model_name: str | None = None, fa
asked = normalize(mode)
if asked == "off":
return Decision(asked, "off")
if asked == "auto" and intel_plain(backend, model_name):
return Decision(asked, "off") # no drafter, no note: it is what Auto means here
want = choice_of(asked, model_name=model_name, family=family, backend=backend, archs=archs, args=args, vram_mib=vram_mib)
have_mtp = mtp_here is not False
# DFlash2 stands in for a missing MTP layer wherever it may run on this card: also where Auto picks the MTP for the card class (the 12 GB card with IQ3_S), so a
+19 -1
View File
@@ -16,7 +16,7 @@ import sys
#: What the install says when an Arc card is chosen and the model's files are not on the computer (the Terminal's own sentence, "Intel cards do not
#: download models yet", in the app's words: the picker's entry is "Use your own GGUF…").
NO_DOWNLOAD = ("Strata can't download models for an Intel Arc card yet. Choose \"Use your own GGUF…\" and pick the folder that holds the model's "
NO_DOWNLOAD = ("Strata can't download this model for an Intel Arc card on this computer yet. Choose \"Use your own GGUF…\" and pick the folder that holds the model's "
".gguf files; Strata prepares them for this card.")
#: The families the run config can be written for (strata_cli/launch/adopt.py FAMILIES): the Qwen3.8-Flash-Next sizes, Swift, Coder, Gyro and Unsloth's sets.
@@ -41,6 +41,24 @@ def model_files_in(folder, family: str, family_def: dict | None = None) -> list:
return adopt.model_files(folder, family, family_def)
def can_download(family: str, model: str | None = None, family_def: dict | None = None, platform: str | None = None) -> bool:
"""Does Strata download this model's files for an Intel Arc card on this PC. Ling-3.2-Air, Inkling-2-Mini and Hy4-Flash download through their own installs (setup.py install_ling32_air / install_inkling2 /
install_hy4_flash, the same steps as for NVIDIA and AMD) wherever their Arc route runs. The GGUF families (Qwen3.8-Flash-Next, Swift, Coder, Gyro, Unsloth) download from the pinned sources of setup.py
(fetch_gguf_shards) where their Arc route runs for this pack: Linux every pack, Windows the gated ones (QWEN_SYCL_WINDOWS_PACKS, only the qwen and coder families); a model of the signed feed has no such
source here and stays on "use your own files". Never raises."""
try:
fd = family_def or {}
kind = ("ling32" if family == "ling-3.2-air" or fd.get("ling32") else "inkling" if family == "inkling-2-mini" or fd.get("inkling")
else "hy4" if family == "hy4-flash" or fd.get("hy4") else "qwen")
if kind != "qwen":
return route_here(kind, platform)
if fd.get("feed"):
return False
return route_here("qwen", platform, model, family)
except Exception: # noqa: BLE001
return False
def supported_here(platform: str | None = None) -> bool:
"""The Intel Arc engines of the Qwen families ship for Linux x86_64 only (no Windows or Mac package in the feed)."""
return (platform or sys.platform).startswith("linux")
@@ -28,6 +28,8 @@
"131072",
"--vision",
"no",
"--backend",
"sycl",
"--drafter",
"dflash2",
"--data-dir",
@@ -28,6 +28,8 @@
"131072",
"--vision",
"no",
"--backend",
"sycl",
"--drafter",
"dflash2",
"--data-dir",
@@ -148,11 +148,14 @@ class WindowsIntel(unittest.TestCase):
class Recommendation(unittest.TestCase):
def test_an_arc_is_a_sycl_pc_and_says_there_is_no_download(self):
def test_an_arc_is_a_sycl_pc_and_says_there_is_no_download_only_where_there_is_none(self):
s = M.Strata(ROOT)
rec = s.recommend({"ram_gb": 64.0, "gpus": [dict(A750)], "engine_vendor": "intel", "cpu": {"avx2": True}})
self.assertEqual(rec["backend"], "sycl")
self.assertIn(intel_app.NO_DOWNLOAD, rec["notes"])
self.assertNotIn(intel_app.NO_DOWNLOAD, rec["notes"]) # Linux: the Qwen sizes download (setup.py fetch_gguf_shards), so nothing says "can't download"
with mock.patch.object(intel_app, "can_download", lambda *a, **k: False):
rec = s.recommend({"ram_gb": 64.0, "gpus": [dict(A750)], "engine_vendor": "intel", "cpu": {"avx2": True}})
self.assertIn(intel_app.NO_DOWNLOAD, rec["notes"]) # a model that does not (a pack not gated on a Windows Arc, a feed model): the block stays, with its words
self.assertTrue(rec["setup_command"].endswith(" --backend sycl"))
def test_nvidia_and_amd_recommendations_are_unchanged(self):
@@ -207,9 +210,11 @@ class InstallPlan(unittest.TestCase):
with tempfile.TemporaryDirectory() as t:
data = Path(t) / "Strata-data"
data.mkdir()
with self.assertRaises(M.ToolError) as raised:
with mock.patch.object(intel_app, "can_download", lambda *a, **k: False), self.assertRaises(M.ToolError) as raised: # not downloadable: the block, with its words
self.plan([A750], data_dir=str(data))
self.assertEqual(str(raised.exception), intel_app.NO_DOWNLOAD)
plan, args = self.plan([A750], data_dir=str(data)) # downloadable (Linux, every Qwen size): the install goes on and setup downloads
self.assertEqual(args[-2:], ["--backend", "sycl"])
shards(data / "models" / "Q2_0") # the files are where the Terminal looks (<data>/models/<tag>)
plan, args = self.plan([A750], data_dir=str(data))
self.assertEqual(args[-2:], ["--backend", "sycl"])
@@ -0,0 +1,222 @@
"""Models for an Intel Arc card are downloaded (0.2.25): the GGUF families download from setup.py's pinned sources (fetch_gguf_shards, the step NVIDIA and AMD installs run) where their Arc route runs for
the pack (Linux every pack, Windows the gated ones: intel_app.QWEN_SYCL_WINDOWS_PACKS), Ling-3.2-Air, Inkling-2-Mini and Hy4-Flash through their own installs; a model without such a route keeps the
block with its words (intel_app.NO_DOWNLOAD). What these tests pin:
* intel_app.can_download for every family, pack and platform;
* fetch_gguf_shards (moved out of main() step 5): downloads what is missing from the pinned URL, skips finished shards, links the original's shard 2 from a size that is already there;
* setup.intel_download_gguf and intel_control_setup: the disk is checked first (nothing is downloaded when it does not fit), the RAM is said, the shards are fetched, then the pack and the run config as before;
* the block stays for a pack that is not gated on a Windows Arc (with its words), and the Terminal's launcher runs the installer (setup --backend sycl) for a download and the prepared-files path otherwise.
Offline: nothing is downloaded, the download function is replaced."""
from __future__ import annotations
import json
import sys
import tempfile
import types
import unittest
from pathlib import Path
from unittest import mock
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
sys.path.insert(0, str(ROOT / "tools"))
import setup # noqa: E402
from strata_control import intel_app # noqa: E402
A750 = {"vendor": "intel", "name": "Intel Arc A750", "vram_gb": 8.0, "usable": True, "index": 0}
WIN = types.SimpleNamespace(platform="win32")
class CanDownload(unittest.TestCase):
def test_the_families_and_packs_that_download(self):
win = lambda *a, **k: intel_app.can_download(*a, platform="win32", **k) # noqa: E731
lin = lambda *a, **k: intel_app.can_download(*a, platform="linux", **k) # noqa: E731
for pack, fam in (("IQ1_M", "coder"), ("IQ2_XS", "qwen"), ("IQ3_S", "qwen")):
self.assertTrue(win(fam, pack), pack) # the gated Windows packs
for pack, fam in (("Q2_0", "qwen"), ("IQ3_XXS", "qwen"), ("IQ3_S", "swift"), ("IQ3_S", "unsloth"), ("UD-Q4_K_XL", "unsloth")):
self.assertFalse(win(fam, pack), (fam, pack)) # not gated on a Windows Arc: the block, with its words
self.assertTrue(lin(fam, pack), (fam, pack)) # Linux: every GGUF size
self.assertFalse(lin("qwen4", "IQ2_XS", {"feed": True})) # a model of the signed feed has no source here
self.assertTrue(win("ling-3.2-air", "SQ-96") and win("inkling-2-mini", "Q4") and lin("hy4-flash", "x")) # their own installs download
self.assertFalse(intel_app.can_download("hy4-flash", "x", platform="win32")) # (no Windows Intel Hy4 engine: nothing to download for)
with mock.patch.object(intel_app, "QWEN_SYCL_WINDOWS_SHIPPED", False):
self.assertFalse(win("coder", "IQ1_M"))
self.assertFalse(intel_app.can_download("qwen", "IQ2_XS", platform="darwin"))
class Fetch(unittest.TestCase):
def test_only_the_missing_shards_download_and_shard_2_is_shared(self):
fam = setup.FAMILIES["qwen"]
with tempfile.TemporaryDirectory() as t:
t = Path(t)
models = t / "models"
other = models / "iq3_s"
other.mkdir(parents=True)
donor = other / setup.model_file(setup.FAMILIES["qwen"], "IQ3_S", 2)
donor.write_bytes(b"shard two")
setup.mark(donor)
folder = models / "iq2_xs"
folder.mkdir()
shards = [folder / setup.model_file(fam, "IQ2_XS", i) for i in range(1, setup.model_shards(fam, "IQ2_XS") + 1)]
asked = []
def fake_download(url, dst, what=None):
asked.append((url, Path(dst).name))
Path(dst).write_bytes(b"x")
setup.mark(Path(dst))
a = types.SimpleNamespace(models_dir=str(models), gguf_dir=None)
with mock.patch.object(setup, "download", fake_download):
setup.fetch_gguf_shards(a, "qwen", fam, "IQ2_XS", shards, folder)
self.assertEqual([n for _u, n in asked], [shards[0].name]) # shard 1 downloaded; shard 2 linked from the IQ3_S folder
self.assertTrue(shards[1].exists() and setup.done(shards[1]))
asked.clear()
setup.fetch_gguf_shards(a, "qwen", fam, "IQ2_XS", shards, folder)
self.assertEqual(asked, []) # everything is there: nothing downloads
self.assertTrue(asked == [] and shards[0].name.endswith("-00001-of-00002.gguf"))
def test_the_url_is_the_pinned_one(self):
fam = setup.FAMILIES["coder"]
with tempfile.TemporaryDirectory() as t:
t = Path(t)
folder = t / "models" / "coder-iq1_m"
folder.mkdir(parents=True)
shards = [folder / setup.model_file(fam, "IQ1_M", i) for i in range(1, setup.model_shards(fam, "IQ1_M") + 1)]
urls = []
a = types.SimpleNamespace(models_dir=str(t / "models"), gguf_dir=None)
with mock.patch.object(setup, "download", lambda url, dst, what=None: (urls.append(url), Path(dst).write_bytes(b"x"), setup.mark(Path(dst)))):
setup.fetch_gguf_shards(a, "coder", fam, "IQ1_M", shards, folder)
self.assertEqual(urls, [setup.model_hf(fam, "IQ1_M") + s.name for s in shards])
class ArcInstall(unittest.TestCase):
def args(self, **kw):
base = dict(family="qwen", model="IQ2_XS", gguf_dir=None, models_dir=None, data_dir=None, context=32768, kv="int8", port=None, host=None,
api_key=None, browser=None, check=False, yes=True, move_data=False, set_default_data_dir=False, prepare_pack=None)
base.update(kw)
return mock.Mock(**base)
def run_setup(self, a, data, home, *, windows=True, free=500.0, ram=64.0):
self.fetched, self.packed, self.said = [], None, []
def fake_fetch(args, family, fam, model, shards, models_dir):
self.fetched.append((model, [s.name for s in shards]))
for s in shards:
s.parent.mkdir(parents=True, exist_ok=True)
s.write_bytes(b"x")
def fake_pack(args):
pack = Path(args.prepare_pack)
(pack / "tokenizer").mkdir(parents=True, exist_ok=True)
(pack / "tokenizer" / "vocab.json").write_text("{}")
(pack / "index.txt").write_text("x")
self.packed = args.prepare_pack
return 0
def fake_fail(message, hint=None, **kw):
self.said.append(message)
raise SystemExit(1)
patches = [mock.patch.object(setup, "CONTROL", True), mock.patch.object(setup, "_CONTROL_HOME", home), mock.patch.object(setup, "data_folder_for", lambda a: (data, [])),
mock.patch.object(setup, "prepare_pack_only", fake_pack), mock.patch.object(setup, "fetch_gguf_shards", fake_fetch), mock.patch.object(setup, "check_shards", lambda shards: None), mock.patch.object(setup, "fail", fake_fail),
mock.patch.object(setup, "free_gb", lambda p: free), mock.patch.object(setup, "ram_gb", lambda: ram),
mock.patch.object(setup, "warn", lambda m, *a, **k: self.said.append("WARN " + m)),
mock.patch.object(intel_app, "arc_cards", lambda root="", platform=None: [dict(A750)]),
mock.patch("strata_cli.launch.adopt.intel_driver", lambda: "xe"), mock.patch.object(intel_app, "supported_here", lambda platform=None: True)]
if windows:
patches += [mock.patch.object(intel_app, "sys", WIN), mock.patch("strata_cli.launch.adopt.sys", WIN)]
for p in patches:
p.start()
self.addCleanup(p.stop)
return setup.intel_control_setup(a)
def test_a_gated_pack_without_its_files_downloads_prepares_and_writes_the_settings(self):
with tempfile.TemporaryDirectory() as t:
t = Path(t)
data, home = t / "Strata-data", t / "install"
data.mkdir()
home.mkdir()
self.assertEqual(self.run_setup(self.args(), data, home), 0)
self.assertEqual([m for m, _n in self.fetched], ["IQ2_XS"])
self.assertEqual(self.packed, str(data / "packs" / "iq2_xs"))
cfg = json.loads((home / "strata-iq2_xs.json").read_text(encoding="utf-8"))
a = cfg["args"]
self.assertEqual((cfg["backend"], a[a.index("--spec") + 1], a[a.index("--suffix-draft") + 1]), ("sycl", "2", "0")) # IQ2_XS on Windows: plain decode
def test_a_pack_that_is_not_gated_on_windows_keeps_the_block_with_its_words(self):
with tempfile.TemporaryDirectory() as t:
t = Path(t)
data, home = t / "Strata-data", t / "install"
data.mkdir()
home.mkdir()
with self.assertRaises(SystemExit):
self.run_setup(self.args(model="Q2_0"), data, home)
self.assertEqual(self.fetched, [])
self.assertTrue(any("no Intel Arc engine" in m for m in self.said), self.said) # the route check says it first, with the sizes that run on a Windows Arc in its hint
def test_linux_downloads_every_size(self):
with tempfile.TemporaryDirectory() as t:
t = Path(t)
data, home = t / "Strata-data", t / "install"
data.mkdir()
home.mkdir()
self.assertEqual(self.run_setup(self.args(model="Q2_0"), data, home, windows=False), 0)
self.assertEqual([m for m, _n in self.fetched], ["Q2_0"])
def test_the_disk_is_checked_before_anything_downloads_and_the_ram_is_said(self):
with tempfile.TemporaryDirectory() as t:
t = Path(t)
data, home = t / "Strata-data", t / "install"
data.mkdir()
home.mkdir()
with self.assertRaises(SystemExit):
self.run_setup(self.args(), data, home, free=20.0) # 68 GB to fetch, 20 GB free
self.assertEqual(self.fetched, [])
self.assertTrue(any("not enough free disk space" in m for m in self.said), self.said)
self.run_setup(self.args(), data, home, ram=16.0)
self.assertTrue(any(m.startswith("WARN") and "16 GB of RAM" in m for m in self.said), self.said)
def test_files_that_are_there_download_nothing(self):
with tempfile.TemporaryDirectory() as t:
t = Path(t)
data, home = t / "Strata-data", t / "install"
fam = setup.FAMILIES["qwen"]
folder = data / "models" / "IQ2_XS"
folder.mkdir(parents=True)
for i in range(1, setup.model_shards(fam, "IQ2_XS") + 1):
(folder / setup.model_file(fam, "IQ2_XS", i)).write_bytes(b"x")
home.mkdir()
self.assertEqual(self.run_setup(self.args(), data, home), 0)
self.assertEqual(self.fetched, [])
class Terminal(unittest.TestCase):
"""The Terminal's launcher: the installer (setup --backend sycl) for a download, the prepared-files path when the files are there."""
def runner(self, **kw):
from strata_cli.launch import runner as R
from strata_cli.launch import settings as S
r = object.__new__(R.Runner)
r.s = S.LaunchSettings(**kw)
return R, r
def test_the_windows_routes_and_the_download_decision(self):
with tempfile.TemporaryDirectory() as t:
R, r = self.runner(family="qwen", model="IQ2_XS", data_dir=t)
cat = mock.Mock()
cat.tables.return_value = ({}, {"qwen": setup.FAMILIES["qwen"]}, None, None)
cat.data_dir.return_value = Path(t)
with mock.patch.object(R, "WINDOWS", True), mock.patch.object(intel_app, "sys", WIN), mock.patch.object(R.Runner, "catalog", new_callable=mock.PropertyMock, return_value=cat):
self.assertTrue(r.intel_route_here())
self.assertTrue(r.intel_downloads()) # gated pack, files missing
folder = Path(t) / "models" / (setup.FAMILIES["qwen"].get("tag", "") + "IQ2_XS")
folder.mkdir(parents=True)
for i in range(1, setup.model_shards(setup.FAMILIES["qwen"], "IQ2_XS") + 1):
(folder / setup.model_file(setup.FAMILIES["qwen"], "IQ2_XS", i)).write_bytes(b"x")
self.assertFalse(r.intel_downloads()) # files there: the prepared-files path
r.s.model = "Q2_0"
self.assertFalse(r.intel_route_here() or r.intel_downloads()) # not gated on a Windows Arc
if __name__ == "__main__":
unittest.main()
@@ -112,5 +112,56 @@ class WindowsRoute(unittest.TestCase):
self.assertTrue(intel_app.route_here("qwen", "linux", pack), pack) # Linux: every pack
class PlainDecodeOnIntel(unittest.TestCase):
"""IQ2_XS and IQ3_S on the SYCL engine on Windows: Auto drafting is NO drafter (the plain decode QFN-B70 gated), in the app's Load and in the Terminal; one constant (drafting.INTEL_PLAIN_BY_DEFAULT) turns
DFlash2 back on, another (INTEL_PLAIN_PLATFORMS) adds Linux."""
NAMES = ("qwen3.8-flash-next-iq2_xs", "qwen3.8-flash-next-iq3_s")
def setUp(self):
from strata_control import drafting
p = mock.patch.object(drafting, "_host_platform", lambda: "win32")
p.start()
self.addCleanup(p.stop)
def test_auto_means_no_drafter_for_the_two_packs_on_sycl_only(self):
from strata_control import drafting
for name in self.NAMES:
self.assertTrue(drafting.intel_plain("sycl", name), name)
self.assertEqual(drafting.choice_of("auto", model_name=name, backend="sycl"), "off")
d = drafting.decide("auto", model_name=name, backend="sycl", data_dir=None, mtp_here=False)
self.assertEqual((d.drafter, d.note, d.flags), ("off", "", ())) # no drafter, nothing to say, no --spec 6
self.assertFalse(drafting.wants_one_request("auto", model_name=name, backend="sycl")) # no "one request at a time"
self.assertFalse(drafting.needs_pack("auto", model_name=name, backend="sycl", data_dir="x")) # nothing is fetched for it
self.assertFalse(drafting.needs_mtp("auto", model_name=name, backend="sycl", mtp_here=False))
for backend in ("cuda", "hip", "metal", None):
self.assertFalse(drafting.intel_plain(backend, name), (backend, name)) # NVIDIA, AMD and Apple are untouched
for name in ("qwen3.8-flash-next-q2_0", "qwen3.8-flash-next-iq3_xxs", "qwen3.8-flash-next-coder-iq1_m", "qwen3.8-flash-next-unsloth-iq3_s", "swift-iq3_s", None):
self.assertFalse(drafting.intel_plain("sycl", name), name) # the other packs and families keep their rule
def test_linux_keeps_its_rule_until_the_owner_says_otherwise(self):
from strata_control import drafting
with mock.patch.object(drafting, "_host_platform", lambda: "linux"):
for name in self.NAMES:
self.assertFalse(drafting.intel_plain("sycl", name))
self.assertNotEqual(drafting.choice_of("auto", model_name=name, backend="sycl"), "off")
with mock.patch.object(drafting, "INTEL_PLAIN_PLATFORMS", ("win", "linux")), mock.patch.object(drafting, "_host_platform", lambda: "linux"):
self.assertTrue(drafting.intel_plain("sycl", self.NAMES[0])) # one word adds it
def test_a_named_drafter_and_off_are_the_persons_own(self):
from strata_control import drafting
name = self.NAMES[0]
self.assertEqual(drafting.choice_of("mtp", model_name=name, backend="sycl"), "mtp")
self.assertEqual(drafting.choice_of("off", model_name=name, backend="sycl"), "off")
self.assertEqual(drafting.choice_of("dflash2", model_name=name, backend="sycl"), "dflash2") # asked for by name: the person's choice (the engine may still refuse it)
def test_one_constant_turns_dflash2_back_on(self):
from strata_control import drafting
with mock.patch.object(drafting, "INTEL_PLAIN_BY_DEFAULT", False):
for name in self.NAMES:
self.assertFalse(drafting.intel_plain("sycl", name))
self.assertNotEqual(drafting.choice_of("auto", model_name=name, backend="sycl"), "off") # back to the engine's own Auto rule (DFlash2 where it runs, else the MTP)
if __name__ == "__main__":
unittest.main()
+4 -3
View File
@@ -1837,7 +1837,8 @@ class Strata:
notes.append("AMD (experimental): pictures are on; the reader runs on the CPU under 24 GB of VRAM and on the GPU from 24 GB")
if backend == "sycl":
from strata_control import intel_app
notes.append(intel_app.NO_DOWNLOAD)
if not intel_app.can_download(fam, model, families.get(fam)): # Ling, Inkling and the gated Qwen packs download; the rest stay on "use your own files"
notes.append(intel_app.NO_DOWNLOAD)
cmd = (("START-HERE.bat --setup" if WIN else "./setup.sh --setup") +
f" --yes --family {fam} --model {model} --context {ctx}" + (f" --backend {backend}" if backend in ("hip", "sycl") else ""))
return {"family": fam, "model": model, "title": families[fam]["title"] + " " + model, "context": ctx,
@@ -3006,7 +3007,7 @@ class Tools:
have_dir = target / "models" / tag
ready_dir = ready_pack_dir(target, md) # a ready-made pack (NVFP4): setup keeps it under <owner>--<repo>, not under the family tag (#4892)
# An Intel Arc (Linux, the SYCL engine): setup.py's `--backend sycl` in its CONTROL mode prepares the model's files and writes the run config, as the
# Terminal does (strata_control/intel_app.py); it downloads nothing. NVIDIA and AMD never come here.
# Terminal does (strata_control/intel_app.py); it downloads the files that are not there when intel_app.can_download says so (the gated Qwen packs). NVIDIA and AMD never come here.
arc = backend == "sycl" or (backend in (None, "auto") and any(g.get("vendor") == "intel" for g in hw.get("gpus", [])))
if arc:
from strata_control import intel_app
@@ -3021,7 +3022,7 @@ class Tools:
backend = "sycl"
if not md.get("hy4") and not md.get("inkling") and not md.get("ling32"):
vision = "no" # pictures stay off on an Arc for GGUF families (strata_cli/launch/adopt.py)
if not gguf_dir and not intel_app.model_files_in(have_dir, family, families[family]):
if not gguf_dir and not intel_app.model_files_in(have_dir, family, families[family]) and not intel_app.can_download(family, model, families[family]):
raise ToolError(intel_app.NO_DOWNLOAD)
if md.get("hy4") and md.get("gguf"): # AngelSlim's GGUF build: both shards and the picture reader in <models>/hy4-flash; a folder of the person's own files downloads nothing
from strata_control import hy4_gguf