okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge main (87dfca0e7) into f-own-int: the 0.2.14 app branch, fixtures and CI fixes, the Qwen4-readiness tools, the shape-engine build scriptsffb3d9b31

main
4.4 KiB76 linesraw
1"""The Intel Arc card in the desktop app (the model setup of Strata Control, tools/strata_mcp.py and setup.py in their CONTROL mode).
2
3The Terminal (`strata launch`) sets an Arc up in two steps (strata_cli/launch/runner.py adopt_prepared_files): `setup.py --prepare-pack` makes the pack
4from the model's GGUF files, and strata_cli/launch/adopt.py writes the run config, with the engine named as the component (`component:strata-engine`).
5Intel cards do not download models: the files must be on the computer. The app's install job did neither step: it ran setup.py's normal NVIDIA / AMD
6path, which stops with "no NVIDIA GPU found (nvidia-smi did not answer)" (0.2.13 and 0.2.12, found by QAGUI-LIN on an Arc A750).
7
8This module is the part both tools/strata_mcp.py (which engine the install is for; the card list) and setup.py (`--backend sycl` in CONTROL mode)
9share. NVIDIA and AMD are never touched: an Arc is added to the card list only when this PC has no usable NVIDIA or AMD card, and the engine
10Strata Control itself would pick (strata_control/engine_component.py detect_backend) is the Intel one.
11"""
12
13from __future__ import annotations
14
15import sys
16
17#: 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
18#: download models yet", in the app's words: the picker's entry is "Use your own GGUF…").
19NO_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 "
20               ".gguf files; Strata prepares them for this card.")
21
22#: 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.
23def families() -> tuple:
24    from strata_cli.launch import adopt
25    return tuple(adopt.FAMILIES)
26
27
28def can_set_up(family: str, family_def: dict | None = None) -> bool:
29    """An Arc run config can be written for this family: one of families(), or a model of the signed feed (Qwen4 day: strata_control/feed_models.py)."""
30    return family in families() or bool((family_def or {}).get("feed"))
31
32
33def model_files_in(folder, family: str, family_def: dict | None = None) -> list:
34    """The model's GGUF files in `folder` when the whole set is there (every shard; Gyro: its one file; a feed model: its shards or its one file), else []."""
35    from pathlib import Path
36    from strata_cli.launch import adopt
37    folder = Path(folder)
38    if not folder.is_dir():
39        return []
40    return adopt.model_files(folder, family, family_def)
41
42
43def supported_here(platform: str | None = None) -> bool:
44    """Intel Arc engines ship for Linux x86_64 only (no Windows or Mac package in the feed)."""
45    return (platform or sys.platform).startswith("linux")
46
47
48def arc_cards(root: str = "/sys/class/drm") -> list[dict]:
49    """The Intel Arc cards in this Linux computer, as the Terminal lists them (strata_cli/launch/catalog.py intel_arc_cards): vendor "intel", name,
50    vram_gb (the card's own, from its PCI id), usable True."""
51    from strata_cli.launch.catalog import intel_arc_cards
52    return intel_arc_cards(root)
53
54
55def engine_is_intel() -> bool:
56    """Is the engine this computer's Strata Control would use the Intel one (SYCL)? The same decision the engine download makes (strata_control/
57    engine_component.py detect_backend: STRATA_ENGINE_BACKEND, the saved choice, then the cards)."""
58    from strata_control import engine_component as ec
59    return ec.detect_backend()[0] == "sycl"
60
61
62def cards_to_add(nvidia: list[dict], amd: list[dict], *, platform: str | None = None, cards=None, intel_engine=None) -> list[dict]:
63    """The Arc cards to put in the hardware report beside `nvidia` and `amd`: none when either make has a usable card (those PCs are exactly what they
64    were), none off Linux, none when the engine is not the Intel one. Never raises: a probe that fails adds nothing."""
65    if not supported_here(platform):
66        return []
67    if any(g.get("usable") for g in nvidia) or any(g.get("usable") for g in amd):
68        return []
69    cards, intel_engine = cards or arc_cards, intel_engine or engine_is_intel
70    try:
71        found = cards()
72        if not found or not intel_engine():
73            return []
74    except Exception:                                          # noqa: BLE001 - the hardware page never breaks over this
75        return []
76    return [dict(c) for c in found]