diff --git a/.gitignore b/.gitignore index 90bec59a..c6cfb336 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ build-vision-cuda12.bat # setup.py outputs (engine, downloads) and release builds /engine/ +/engine-sycl/ /engine-cuda12/ /build-release*/ /dist/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 11faf4c4..7ba7ee63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ # below refuses anything older: silently building for a pre-Ampere arch would produce a binary that runs # and is wrong about its own performance, which is the worst of both outcomes. cmake_minimum_required(VERSION 3.24) -project(strata VERSION 0.1.45 LANGUAGES CXX) +project(strata VERSION 0.1.45.3 LANGUAGES CXX) # EXPERIMENTAL: the Intel Arc engine, the SYCL port in sycl/ (PR #423; icpx + oneMKL, docs/INTEL_ARC.md). It is its # own project that takes the unported sources from src/; with this on, nothing below is configured. option(STRATA_ENABLE_SYCL "EXPERIMENTAL: build the Intel Arc (SYCL) engine from sycl/ - docs/INTEL_ARC.md" OFF) diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index c762d736..55f664d1 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -35,7 +35,8 @@ "../../host/package.json": "host/package.json", "resources/node": "node", "resources/control": "control", - "resources/harness": "harness" + "resources/harness": "harness", + "resources/engine-bundle": "engine-bundle" }, "linux": { "appimage": { @@ -43,7 +44,7 @@ } }, "macOS": { - "minimumSystemVersion": "11.0", + "minimumSystemVersion": "15.0", "entitlements": "entitlements.plist" }, "createUpdaterArtifacts": false, @@ -63,7 +64,7 @@ }, "plugins": { "updater": { - "pubkey": "REPLACE-WITH-THE-OWNERS-TAURI-UPDATER-PUBLIC-KEY", + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI2QjA5OTk5MDU1MjFGNUUKUldSZUgxSUZtWm13dHNGRU40N2xOUjdZZGpvcGl0NTB2WGxnS3VTc2RlakpSbnBxUkxndHNFY0oK", "endpoints": [ "https://github.com/Niko1221/Strata/releases/latest/download/latest.json" ], diff --git a/apps/desktop/src-tauri/tauri.release.conf.json b/apps/desktop/src-tauri/tauri.release.conf.json new file mode 100644 index 00000000..d57cd002 --- /dev/null +++ b/apps/desktop/src-tauri/tauri.release.conf.json @@ -0,0 +1,5 @@ +{ + "bundle": { + "createUpdaterArtifacts": true + } +} diff --git a/apps/host/package-lock.json b/apps/host/package-lock.json index 899efda6..d3aa5df3 100644 --- a/apps/host/package-lock.json +++ b/apps/host/package-lock.json @@ -1,12 +1,12 @@ { "name": "strata", - "version": "0.1.0", + "version": "0.2.0-beta", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "strata", - "version": "0.1.0", + "version": "0.2.0-beta", "dependencies": { "html-to-image": "^1.11.13", "pdfjs-dist": "^6.4.299", diff --git a/apps/host/package.json b/apps/host/package.json index 0b8d4c53..7d73c865 100644 --- a/apps/host/package.json +++ b/apps/host/package.json @@ -1,7 +1,7 @@ { "name": "strata", "private": true, - "version": "0.1.0", + "version": "0.2.0-beta", "type": "module", "description": "Strata \u2014 local AI, tuned to one model. Web shell + engine host.", "scripts": { diff --git a/docs/INTEL.md b/docs/INTEL.md index 77fa10ef..915d2379 100644 --- a/docs/INTEL.md +++ b/docs/INTEL.md @@ -772,8 +772,14 @@ is 0.012), first-token KL 0.0017 (floor 0.0005), top-1 agreement 99.7%. HumanEva ## Not done -- Images, on both Intel engines. Strata's vision path encodes with `strata-vision` into embeddings the CUDA - engine reads; neither the SYCL port nor the llama.cpp config wires it yet. +- Images on the llama.cpp config: not wired. On the SYCL port pictures are wired but opt-in (`setup --backend sycl --vision yes`): + setup compiles the portable CPU reader `strata-vision` (the program the AMD packages carry beside their engine) into `engine-sycl/`, + the server runs it on the host, and the engine in the container reads its embeddings from the host's `/dev/shm`, which + `strata-sycl.sh` shares (`STRATA_SYCL_SHM=0` keeps a private one). A SYCL GPU reader does not exist yet, so every Arc reads + pictures on the CPU (a few seconds each). They are not on by default because the first picture request on the Arc Pro B70 + (engine 0.1.45, IQ3_S, 2026-10-19) hung the GPU: the xe driver logged an engine reset and `Fault response: Unsuccessful -EINVAL` + and the request ended 503. Text was not affected by this wiring (the reader and the shared `/dev/shm` are only used for pictures); + the engine's vision path on SYCL needs a look first (`setup_intel.PICTURES_ON_BY_DEFAULT` flips the default). - Speculative decoding on the llama.cpp path (the GGUF carries no draft layer llama.cpp can use). The SYCL port has it (MTP draft layer, `--mtp`). diff --git a/docs/MCP_SERVER.md b/docs/MCP_SERVER.md index 4fc05369..278463f7 100644 --- a/docs/MCP_SERVER.md +++ b/docs/MCP_SERVER.md @@ -128,7 +128,7 @@ Every result is JSON with a one-line `summary`. It is sent both as text and as M - the size setup itself would pick: IQ3_XXS from 60 GB of RAM, Q2_0 from about 44 GB, the Coder from about 28 GB, and the Coder in the low-RAM mode below that when the GPU makes up for the RAM; - the context setup recommends for the GPU's VRAM; -- images off. +- pictures on where the model can read them (the reader runs on the CPU under 24 GB of VRAM and on the GPU from 24 GB, on every make of card; a Mac has none yet). The first call returns the plan: the download size (58-111 GB), the free disk space, the RAM check, and the exact setup command. The assistant should show you the plan and call again with `confirm: true` once you agree. diff --git a/metal/CMakeLists.txt b/metal/CMakeLists.txt index 3e1b38c0..3274dfc6 100644 --- a/metal/CMakeLists.txt +++ b/metal/CMakeLists.txt @@ -108,7 +108,7 @@ file(GLOB STRATA_METAL_ENGINE_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_D add_library(strata_metal_host STATIC ${STRATA_METAL_HOST_SOURCES}) target_include_directories(strata_metal_host PUBLIC ${STRATA_ROOT}/include ${S}/core ${STRATA_ROOT}/third_party/ggml ${STRATA_GGML_DIR}/ggml/include ${STRATA_GGML_DIR}/ggml/src ${STRATA_GGML_DIR}/ggml/src/ggml-cpu) -target_compile_definitions(strata_metal_host PUBLIC STRATA_NATIVE_EXPERTS=1 STRATA_VERSION="0.1.45-metal") +target_compile_definitions(strata_metal_host PUBLIC STRATA_NATIVE_EXPERTS=1 STRATA_VERSION="0.1.45.3-metal") target_compile_options(strata_metal_host PRIVATE -Wno-unused-parameter -Wno-deprecated-declarations) target_link_libraries(strata_metal_host PUBLIC strata_gpu_metal ggml-cpu ggml-base) diff --git a/packaging/UPDATES.md b/packaging/UPDATES.md index d938a11c..14df304b 100644 --- a/packaging/UPDATES.md +++ b/packaging/UPDATES.md @@ -98,13 +98,16 @@ On an offline machine, outside any git checkout: npx tauri signer generate -w D:\strata-keys\tauri-updater.key # asks for a password; prints the public key Back both up (a lost feed key means every installed PC needs a build with a new key; a lost Tauri key means the same for the app). -Then, in git, once, in the commit that ships the first signed release: +Then, in git, once, in the commit that ships the first signed release (done for 0.2.0, key id 5d1bc23abbeffd0d): * the `keys` entry from `feed-key.pub.json` into `strata_control/update_keys.json`; * the Tauri public key into `apps/desktop/src-tauri/tauri.conf.json` (`plugins.updater.pubkey`) and into `update_keys.json` as `app_minisign_public` (the Terminal verifies the app installer with it). -Until then `update_keys.json` is empty and every feed is refused with "this build trusts no update key": a build with no key cannot install anything. +Only release keys live in `update_keys.json`. A tester or local-test key is never added there: it is passed with `STRATA_UPDATE_TRUSTED_KEYS` +(a file of extra public keys; `packaging/make_local_feed.py` writes one as `test-trust.json`), so private tester builds keep working +without their key being part of a release build. A build whose `update_keys.json` is empty (a source checkout from before the keys) refuses every +feed with "this build trusts no update key". A key rotation is a release that carries both public keys; the old private key signs that release, the new one signs the next. ## Releasing (when the owner says go) @@ -112,12 +115,20 @@ A key rotation is a release that carries both public keys; the old private key s python packaging/feed_tool.py sign-package --key python packaging/feed_tool.py pack-engine --out RELEASE/engine python packaging/feed_tool.py pack-control --version V --platform P --out RELEASE/control - TAURI_SIGNING_PRIVATE_KEY= npx tauri build --config tauri.release.conf.json # makes the signed installers + # the app installers carry the engine out of the box: fill apps/desktop/src-tauri/resources/engine-bundle/ with the signed + # engine packages first (the tester builds do the same); tauri.conf.json lists that folder as a resource for every build + TAURI_SIGNING_PRIVATE_KEY= npx tauri build --config src-tauri/tauri.release.conf.json # signed installers + latest.json inputs python packaging/feed_tool.py build-feed --out RELEASE --sequence N --key --engine RELEASE/engine --control RELEASE/control --app-json python packaging/feed_tool.py verify-feed RELEASE --pub -Where the feed is hosted (GitHub release assets, a static host, ...) is the owner's decision; the default address in -`strata_cli/update_cmd.py` is a placeholder until then, and nothing in this tree uploads anything. +The feed is hosted as the files of a GitHub release of `Niko1221/Strata`. The built-in address is +`https://github.com/Niko1221/Strata/releases/latest/download` (`strata_cli/update_cmd.py` `DEFAULT_FEED` adds `/strata-feed.json`; `install.sh` +and `install.ps1` use the folder). GitHub assets are flat, so build the packages with `--url-prefix ""` and upload every file of the release folder +as an asset: `strata-feed.json`, `strata-feed.json.sig`, `install-manifest.txt`, `install.sh`, `install.ps1`, the engine and Control archives and the +app installer with `latest.json` (the Tauri updater endpoint). `STRATA_FEED` (installers) and `--feed` / `STRATA_UPDATE_FEED` (`strata update`) override the +address. Nothing in this tree uploads anything. + +Publish as a normal release (latest): a pre-release is not found by `latest/download`, so the installers, `strata update` and the app updater would get a 404. The `latest` release must carry every file listed above, so a later hotfix release repeats them all. ## Testing locally diff --git a/packaging/install.ps1 b/packaging/install.ps1 index 84afa615..ef63eec9 100644 --- a/packaging/install.ps1 +++ b/packaging/install.ps1 @@ -1,6 +1,6 @@ # Strata Terminal: one-line installer for Windows (PowerShell 5.1 or newer). # -# irm /install.ps1 | iex +# irm https://github.com/Niko1221/Strata/releases/latest/download/install.ps1 | iex # # What it does, in order (and nothing else): # 1. finds out which computer this is (Windows, processor, graphics card); @@ -13,8 +13,8 @@ # The engine and the model are not part of this: `strata launch` fetches the engine for your graphics card the first time you choose # a model, from the same release folder, signed. # -# is where the release folder is hosted; until that is decided this script has no address built in. Set $env:STRATA_FEED to the -# folder (a URL) to use it, for example a local test feed: $env:STRATA_FEED='http://127.0.0.1:8099'; irm http://127.0.0.1:8099/install.ps1 | iex +# is where the release folder is hosted: GitHub Releases of Niko1221/Strata (the "latest" release's files), built in as the default. +# Set $env:STRATA_FEED to another folder (a URL) to use that instead, for example a local test feed: $env:STRATA_FEED='http://127.0.0.1:8099'; irm http://127.0.0.1:8099/install.ps1 | iex # Optional: $env:STRATA_DATA_DIR (default %LOCALAPPDATA%\Strata), $env:STRATA_INSTALL_TEST_TRUST='1' (a test feed: trust only its # test-trust.json for step 4), $env:STRATA_NO_PATH='1' (do not change the user PATH). & { # a child scope: `irm | iex` runs in the caller's scope, and this script's variables must not overwrite the caller's @@ -23,9 +23,9 @@ $ProgressPreference = 'SilentlyContinue' function Die([string]$msg) { [Console]::Error.WriteLine("strata installer: $msg"); throw "strata installer stopped" } -$feed = if ($env:STRATA_FEED) { $env:STRATA_FEED } else { '__FEED__' } +$feed = if ($env:STRATA_FEED) { $env:STRATA_FEED } else { 'https://github.com/Niko1221/Strata/releases/latest/download' } $feed = $feed.TrimEnd('/') -if ($feed -eq ('__FE' + 'ED__') -or -not $feed) { +if (-not $feed) { Die 'this installer does not know where the Strata release folder is. Set $env:STRATA_FEED to its address and run it again, for example: $env:STRATA_FEED=''https://example.org/strata''' } if ([Environment]::OSVersion.Platform -ne 'Win32NT') { Die 'this is the Windows installer; on Linux or macOS use install.sh.' } diff --git a/packaging/install.sh b/packaging/install.sh index 2a17250f..3b582dc3 100644 --- a/packaging/install.sh +++ b/packaging/install.sh @@ -1,7 +1,7 @@ #!/bin/sh # Strata Terminal: one-line installer for Linux and macOS. # -# curl -fsSL /install.sh | sh +# curl -fsSL https://github.com/Niko1221/Strata/releases/latest/download/install.sh | sh # # What it does, in order (and nothing else): # 1. finds out which computer this is (system, processor, graphics card) so it can fetch the right archive; @@ -14,14 +14,14 @@ # The engine (the part that talks to your graphics card) and the model are NOT part of this: `strata launch` fetches the engine for # your card the first time you choose a model, from the same release folder, signed. # -# is where the release folder is hosted; until that is decided this script has no address built in. Set STRATA_FEED to the -# folder (a URL) to use it, for example a local test feed: STRATA_FEED=http://127.0.0.1:8099 sh install.sh +# is where the release folder is hosted: GitHub Releases of Niko1221/Strata (the "latest" release's files), built in as the default. +# Set STRATA_FEED to another folder (a URL) to use that instead, for example a local test feed: STRATA_FEED=http://127.0.0.1:8099 sh install.sh # # Settings (all optional): STRATA_FEED, STRATA_DATA_DIR (default ~/.local/share/strata), STRATA_BIN_DIR (default ~/.local/bin), # STRATA_INSTALL_TEST_TRUST=1 (a test feed: also fetch /test-trust.json and trust only that key for the check in step 4). set -eu -FEED="${STRATA_FEED:-__FEED__}" +FEED="${STRATA_FEED:-https://github.com/Niko1221/Strata/releases/latest/download}" FEED="${FEED%/}" DATA_DIR="${STRATA_DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/strata}" BIN_DIR="${STRATA_BIN_DIR:-$HOME/.local/bin}" @@ -29,9 +29,7 @@ BIN_DIR="${STRATA_BIN_DIR:-$HOME/.local/bin}" say() { printf '%s\n' "$*"; } die() { printf 'strata installer: %s\n' "$*" >&2; exit 1; } -case "$FEED" in - "__FE""ED__"|"") die "this installer does not know where the Strata release folder is. Set STRATA_FEED to its address and run it again, for example: STRATA_FEED=https://example.org/strata sh install.sh" ;; -esac +[ -n "$FEED" ] || die "this installer does not know where the Strata release folder is. Set STRATA_FEED to its address and run it again, for example: STRATA_FEED=https://example.org/strata sh install.sh" # ---- tools if command -v curl >/dev/null 2>&1; then diff --git a/packaging/make_local_feed.py b/packaging/make_local_feed.py index 870d324e..d6d79c45 100644 --- a/packaging/make_local_feed.py +++ b/packaging/make_local_feed.py @@ -30,6 +30,7 @@ import zipfile from pathlib import Path ROOT = Path(__file__).resolve().parents[1] +RELEASE_FEED = "https://github.com/Niko1221/Strata/releases/latest/download" # the address built into install.sh / install.ps1; a local feed bakes its own in its place sys.path.insert(0, str(ROOT / "packaging")) sys.path.insert(0, str(ROOT)) @@ -99,7 +100,7 @@ def main(argv=None) -> int: (out / "install-manifest.txt").write_text("\n".join(manifest_lines) + "\n", encoding="utf-8") base = a.url.rstrip("/") for name in ("install.sh", "install.ps1"): - text = (ROOT / "packaging" / name).read_text(encoding="utf-8").replace("__FEED__", base) + text = (ROOT / "packaging" / name).read_text(encoding="utf-8").replace(RELEASE_FEED, base) (out / name).write_text(text, encoding="utf-8", newline="\n" if name.endswith(".sh") else None) (out / "test-trust.json").write_text((keys / "feed-key.pub.json").read_text(encoding="utf-8"), encoding="utf-8") print(f"feed written to {out}\n serve it: python -m http.server {base.rsplit(':', 1)[-1]} --bind 127.0.0.1 --directory {out}\n" diff --git a/setup.py b/setup.py index 20cadecd..f54d8907 100644 --- a/setup.py +++ b/setup.py @@ -571,7 +571,7 @@ ESP_VECTOR = ROOT / "data" / "experimental-speed-projection" / "Qwen3.8-Flash-Ne # sizes its expert slots around it and the default reserve (700 MiB) is enough; engines before 0.1.2 need more VISION_GPU_SMALL_RESERVE_MIB = 1000 # the tip for images on a <= 12 GB card (the engine's LOW line asked ~1003) VISION = {"gpu": {"max_tokens": 1024, "reserve_mib": 700}, - "cpu": {"max_tokens": 300, "reserve_mib": 700}} + "cpu": {"max_tokens": 300, "reserve_mib": 0}} # the CPU reader takes no VRAM: no reserve (serve/server.py adds 700 only for a GPU reader) EXE = "strata.exe" if WIN else "strata" VEXE = "strata-vision.exe" if WIN else "strata-vision" HVEXE = "strata-vision-hip.exe" if WIN else "strata-vision-hip" # AMD: the picture reader on the GPU (tools/vision, STRATA_VISION_HIP) @@ -2127,20 +2127,15 @@ def unsloth_budget(model, ram, gpu=None, asked=None) -> bool: ram < MODELS[model]["arena_gb"] / 1.073741824 + UNSLOTH_RESIDENT_BESIDE_GB -UNSLOTH_IMAGES_MIN_VRAM_GB = 15.5 # a 16 GB card: the GPU encoder's ~1.4 GB is under a tenth of it +def images_default(model, family, ram, gpu=None) -> bool: + """Is "images on" setup's default answer (the question's Enter, and --yes) for this choice? Owner rule 2026-10-18: pictures are on + wherever the model can read them - the original Flash-Next, Swift and Coder files, Unsloth's, NVFP4 - on every make of card; which + reader runs is strata_control/vision_reader.py's rule (the CPU under 24 GB of VRAM, the GPU from 24 GB). The CPU reader takes no + VRAM (no --vram-reserve-mib), so a small card is no exception.""" + return MODELS.get(model, {}).get("vision", FAMILIES.get(family, {}).get("vision")) is not False -def unsloth_images_default(model, family, ram, gpu=None) -> bool: - """MODEL-UPDATE: is "images on" setup's default answer for this choice: Unsloth's files (the same base model and - image encoder as ISTA's, run end to end on CUDA and on HIP), on an NVIDIA card of 16 GB or more (the GPU encoder - keeps ~1.4 GB free) or, on AMD, wherever every expert stays in RAM (the CPU encoder takes no VRAM). Smaller cards - keep "no" as the default (asked, as for the other families).""" - if family != "unsloth" or not MODELS.get(model, {}).get("budget") or MODELS[model].get("vision") is False: - return False - g = gpu or {} - if str(g.get("arch", "")).startswith("gfx"): - return not unsloth_budget(model, ram, g) and not WIN - return g.get("vram_gb", 0.0) >= UNSLOTH_IMAGES_MIN_VRAM_GB +unsloth_images_default = images_default # the earlier name IMAGES_GPU_ENCODER_MIN_VRAM_GB = 23.5 # = strata_control/vision_reader.py GPU_MIN_VRAM_GB, the one place for the rule; #2406: below this the images answer "yes" gets the CPU encoder (a card of 12-16 GB: the GPU @@ -6075,33 +6070,32 @@ def own_path_size(fam: dict, ram: float) -> str: def own_path_vision(a, fam: dict, gpu: dict, hip: bool) -> str: - """The image encoder for an own-path family (Qwen3.6-35B-A3B): "gpu", "cpu" or "none". The Flash-Next families' rules: - --vision yes|no|gpu|cpu, else a question whose default answer is yes where the GPU encoder costs little - an NVIDIA - card of 16 GB or more (its ~1.4 GB is under a tenth of it) - and, on AMD under Linux, yes with the CPU encoder (it takes - no VRAM; there is no GPU encoder for AMD yet). A smaller NVIDIA card is recommended the CPU encoder (the GPU one takes - room from the experts); what is asked for with --vision gpu is kept, with a note (recommend, never force).""" + """The image encoder for an own-path family (Qwen3.6-35B-A3B): "gpu", "cpu" or "none". Pictures are on by default (owner rule + 2026-10-18) and the reader follows strata_control/vision_reader.py's one rule on every make of card: the CPU encoder under 24 GB of + VRAM (the GPU one takes ~1.4 GB the experts would use), the GPU encoder from 24 GB. --vision yes|no|gpu|cpu, else a question whose + default answer is yes; what is asked for with --vision gpu / cpu is kept, with a note (recommend, never force).""" asked = a.vision vram = float(gpu.get("vram_gb", 0.0)) - big = vram >= UNSLOTH_IMAGES_MIN_VRAM_GB if asked in ("no", "none"): return "none" if asked is None: + from strata_control import vision_reader as VR + mode = VR.default_mode(vram) say() say(f" Images: {fam['title']} can also read pictures (screenshots, photos, scanned pages). This adds a " f"{fam['sha256'][fam['mmproj']][0] / 1e9:.1f} GB download" + ( - "; the encoder runs on the GPU when the engine has the AMD one (about 1 GB of VRAM), else on the CPU." if hip else - " and the image encoder runs on the GPU (~1.4 GB of VRAM kept free, 0.1-0.5 s per picture)." if big else + " and the image encoder runs on the GPU (about 1-1.4 GB of VRAM kept free, a fraction of a second per picture)." + if mode == "gpu" else "; the encoder runs on the CPU (a few seconds per picture), because the GPU encoder would take ~1.4 GB " - "of VRAM from the experts on this card.")) - default = "y" if (big or hip) else "n" - if ask("Do you want images?", ["y", "n"], default, a.yes) != "y": + "of VRAM from the experts on this card (--vision gpu to use it anyway).")) + if ask("Do you want images?", ["y", "n"], "y", a.yes) != "y": return "none" - asked = "yes" if hip else "cpu" if not big else "gpu" + asked = "yes" if hip: return hip_vision(asked, vram) # settled against the engine's readers in hip_reader() (GPU reader, else CPU) if asked == "yes": - asked = "gpu" if big else "cpu" - if asked == "gpu" and not big and vram > 0: + asked = "gpu" if (vram <= 0 or vram >= IMAGES_GPU_ENCODER_MIN_VRAM_GB) else "cpu" + if asked == "gpu" and 0 < vram < IMAGES_GPU_ENCODER_MIN_VRAM_GB: warn(f"the GPU image encoder takes ~1.4 GB of VRAM, which on a {vram:.0f} GB card is room the experts would use: " "--vision cpu reads pictures on the CPU instead (a few seconds each); kept as you chose") return asked @@ -6573,7 +6567,8 @@ def main() -> int: help="KV cache precision above 8K context: int8 (default), q4_0 (half the memory, a little less " "precise) or k8v4 (hybrid: INT8 K + 4-bit V, 816 B/cell)") ap.add_argument("--vision", choices=["yes", "no", "none", "gpu", "cpu"], - help="let the model read images (yes = the encoder on the GPU)") + help="let the model read images (on by default where the model can; yes = the best reader for this card: the CPU " + "under 24 GB of VRAM, the GPU from 24 GB, any make; gpu / cpu = that reader; no = text only)") ap.add_argument("--vision-tokens", type=int, metavar="N", help="the most image tokens a picture becomes (default 1024 with the encoder on the GPU, 300 on " "the CPU): more reads small text and charts better, and takes longer to encode; remembered " @@ -6814,7 +6809,7 @@ def main() -> int: + " (recommended)") say(" 2) AMD: " + ", ".join(f"{g['name']} ({g['vram_gb']:.0f} GB{', unified memory' if g.get('uma') else ''})" for g in amd_ok) - + f" ({'the ready-made AMD engine, no images' if WIN else 'compiled here, images on the CPU'}" + + f" ({'the ready-made AMD engine' if WIN else 'compiled here'}, pictures on" " - docs/AMD_HIP.md)") say(" One engine drives the cards of one make: a model is never split across NVIDIA and AMD cards, and two models at the same") say(" time, one on each, is not supported yet.") @@ -7182,10 +7177,9 @@ def main() -> int: if a.vision not in (None, "no", "none"): warn(f"images are not available with {model} yet: off") elif hip: - # MODEL-UPDATE: Unsloth's files on AMD (Linux) read images with the CPU encoder by default where their experts - # all stay in RAM (it takes no VRAM; measured on an R9700 with UD-Q4_K_XL and UD-Q5_K_XL, docs/QUANTS.md) - vision = hip_vision(a.vision if a.vision is not None or not unsloth_images_default(model, family, ram, gpu) - else "cpu", float((gpu or {}).get("vram_gb") or 0.0)) + # Unsloth's files on AMD: pictures on by default, the reader by the 24 GB rule (hip_vision; docs/QUANTS.md) + vision = hip_vision(a.vision if a.vision is not None or not images_default(model, family, ram, gpu) + else "yes", float((gpu or {}).get("vram_gb") or 0.0)) elif a.vision: vision = flash_vision_encoder(a.vision, gpu) if a.vision != "no" else "none" vision = "none" if vision in ("no", "none") else vision @@ -7200,8 +7194,8 @@ def main() -> int: say(" more on some PCs. --vision gpu if you want pictures in under a second.") else: say(" download and keeps ~1.4 GB of VRAM free for the image encoder, so text is a few % slower.") - # MODEL-UPDATE: on by default for Unsloth's files on a card with room for the encoder (16 GB and more) - default = "y" if unsloth_images_default(model, family, ram, gpu) else "n" + # on by default wherever the model can read pictures (the reader by the 24 GB rule) + default = "y" if images_default(model, family, ram, gpu) else "n" vision = flash_vision_encoder("yes", gpu) if ask("Do you want images?", ["y", "n"], default, a.yes) == "y" else "none" ok("images: " + {"none": "off", "gpu": "on", "cpu": "on (encoder on the CPU)"}[vision]) if vision != "none" and MODELS[model].get("vision_untested"): @@ -7581,7 +7575,9 @@ def main() -> int: "cache: it stays on auto, which may take the room the OS needs (#1715). A smaller " "--resident-budget-gib leaves room") if vision != "none": - args += ["--vision", "--vram-reserve-mib", str(VISION[vision]["reserve_mib"])] + args += ["--vision"] + if VISION[vision]["reserve_mib"]: + args += ["--vram-reserve-mib", str(VISION[vision]["reserve_mib"])] if vision == "gpu" and a.vram_reserve_mib is None and 0 < gpu.get("vram_gb", 0.0) <= 12.5: # a tip only (recommend, never force): on a 12 GB card the encoder's 700 MiB can leave ~200 MiB free print(f" tip: images on a {gpu['vram_gb']:.0f} GB card can leave little VRAM free; if a request stalls, " diff --git a/strata_cli/launch/cmd.py b/strata_cli/launch/cmd.py index f07de151..7275b07e 100644 --- a/strata_cli/launch/cmd.py +++ b/strata_cli/launch/cmd.py @@ -85,8 +85,9 @@ def add_parsers(sp: argparse._SubParsersAction) -> list[argparse.ArgumentParser] g.add_argument("--context", type=_context, metavar="SIZE", help="how much text it remembers at once: 32k, 64k, 128k, 256k or a number of tokens") g.add_argument("--kv", type=_choice("a memory format", S.KV_MODES), metavar="FORMAT", help="conversation memory format: int8 (default), q4_0 (half the memory), k8v4, fp16") g.add_argument("--vision", type=_choice("a picture setting", S.VISION_MODES), metavar="off|on|gpu|cpu", - help="let the model read pictures. Default: on when the model can read pictures and the engine has the picture reader " - "(on the graphics card for NVIDIA and AMD, on the CPU otherwise); off turns it off") + help="let the model read pictures. Default: on when the model can read pictures and the engine has the picture reader. " + "'on' picks the reader by your graphics memory: the CPU reader under 24 GB, the GPU reader from 24 GB (any make); " + "gpu / cpu choose one; off turns pictures off") g.add_argument("--parallel", type=_parallel, metavar="N", help="requests answered at the same time, 1 to 8 (default: fit to your graphics card)") g.add_argument("--gpu", metavar="LIST", help="graphics card numbers to use, e.g. 0 or 0,1 (default: the engine's choice)") g.add_argument("--tune", type=_choice("a tuning mode", S.TUNE_MODES), metavar="quick|thorough|skip", help="find the fastest settings first (default: skip here; the guided screens suggest quick the first time)") diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.py index dd5460a9..142981e8 100644 --- a/strata_cli/launch/runner.py +++ b/strata_cli/launch/runner.py @@ -450,7 +450,7 @@ class Runner: def vision_word(self) -> str: """What setup is told for the picture choice. "on" is setup's "yes": setup (Control mode) picks the CPU encoder on a card under 24 GB - and on AMD, the GPU encoder on a bigger NVIDIA card, and downloads the pinned picture-reader file (mmproj) with the model.""" + and the GPU encoder from 24 GB (any make of card), and downloads the pinned picture-reader file (mmproj) with the model.""" s = self.s self.resolved_vision() if s.vision == "off": diff --git a/strata_cli/monitor_commands.py b/strata_cli/monitor_commands.py index ead6429c..b3bef9f4 100644 --- a/strata_cli/monitor_commands.py +++ b/strata_cli/monitor_commands.py @@ -34,7 +34,7 @@ def add_status(sp: argparse._SubParsersAction) -> None: def add_monitor(sp: argparse._SubParsersAction) -> None: - monitor = sp.add_parser("monitor", help="read-only six-view terminal monitor") + monitor = sp.add_parser("monitor", help="read-only terminal monitor: seven views (Overview ... Logs, Connect), the same as the one strata launch opens") _connection(monitor) monitor.add_argument("--once", action="store_true", help="print one snapshot without starting the TUI") monitor.add_argument("--output", choices=("human", "json"), default="human") @@ -190,17 +190,14 @@ def run(a: argparse.Namespace) -> int: print(render_view(snapshot, "overview", width=80, height=24)) return 0 try: - from strata_cli.monitor import MonitorApp + from strata_cli.launch.monitor_ext import LaunchMonitor except ImportError: return _error("monitor component missing; install the optional terminal UI dependency", 5, machine) - try: # the monitor with its Connect view (key 7); q just detaches here - from strata_cli.launch.monitor_ext import LaunchMonitor - LaunchMonitor(endpoint, None, info={"url": endpoint.base_url, "urls": [endpoint.base_url], "key": endpoint.credential or "", "model": "", - "profile": None, "name": None}, ask_quit=False, interval=a.interval, requests=a.requests, - theme=a.theme, color=a.color, glyphs=a.glyphs).run() - except ImportError: - MonitorApp(endpoint, None, interval=a.interval, requests=a.requests, - theme=a.theme, color=a.color, glyphs=a.glyphs).run() + # the one monitor, with the same seven views as the one `strata launch` opens (Connect is key 7 and works against this --url + # server); q just detaches here: nothing was started by this command, so there is nothing to stop + LaunchMonitor(endpoint, None, info={"url": endpoint.base_url, "urls": [endpoint.base_url], "key": endpoint.credential or "", "model": "", + "profile": None, "name": None}, ask_quit=False, interval=a.interval, requests=a.requests, + theme=a.theme, color=a.color, glyphs=a.glyphs).run() return 0 except ClientError as e: return _error(str(e), e.exit_code, machine) diff --git a/strata_cli/update_cmd.py b/strata_cli/update_cmd.py index 953b4dd9..4bdb089c 100644 --- a/strata_cli/update_cmd.py +++ b/strata_cli/update_cmd.py @@ -20,8 +20,8 @@ import sys import threading from pathlib import Path -#: Where the feed is read when nothing else is set. It is the owner's decision where the feed is hosted; until the public key -#: is shipped in update_keys.json no feed can be verified, so this default cannot install anything by itself. +#: Where the feed is read when nothing else is set: the files of the latest GitHub release of Niko1221/Strata (the same folder the +#: one-line installers use). Only a feed signed with a key in update_keys.json (or STRATA_UPDATE_TRUSTED_KEYS) is accepted. DEFAULT_FEED = "https://github.com/Niko1221/Strata/releases/latest/download/strata-feed.json" ENV_FEED = "STRATA_UPDATE_FEED" ENV_APP_VERSION = "STRATA_APP_VERSION" diff --git a/strata_control/update_keys.json b/strata_control/update_keys.json index c6e1b771..006e30e5 100644 --- a/strata_control/update_keys.json +++ b/strata_control/update_keys.json @@ -1,4 +1,11 @@ { "schema_version": 1, - "keys": [] + "keys": [ + { + "alg": "ed25519", + "key_id": "5d1bc23abbeffd0d", + "public": "KjnXZB0T1r3dmBNot8h+c4rTicRtllg1LH9fUlTw4ZY=" + } + ], + "app_minisign_public": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI2QjA5OTk5MDU1MjFGNUUKUldSZUgxSUZtWm13dHNGRU40N2xOUjdZZGpvcGl0NTB2WGxnS3VTc2RlakpSbnBxUkxndHNFY0oK" } diff --git a/sycl/serve/server_intel.py b/sycl/serve/server_intel.py index baae26c2..8310bc76 100644 --- a/sycl/serve/server_intel.py +++ b/sycl/serve/server_intel.py @@ -47,6 +47,24 @@ def install_xe_reader(): T.gpu_reader = gpu_reader +def install_shared_embeddings(): + """Pictures: the engine runs in a container, and a request's image embeddings reach it as a file named on its GENI line. + serve/server.py writes that file to /dev/shm when that has room, and strata-sycl.sh shares the host's /dev/shm with the + container, so the path means the same on both sides. Anywhere else (a full /dev/shm) the container cannot see the file: + said once, in the log, in plain words.""" + orig = S.combined_embeddings_path + said = [] + + def path(vision_dir, nbytes): + p = orig(vision_dir, nbytes) + if not str(p).startswith("/dev/shm/") and not said: + said.append(1) + print("[strata] /dev/shm has no room for this picture: the engine runs in a container that sees only the host's /dev/shm, so it " + "cannot read the picture. Free /dev/shm (or enlarge it: mount -o remount,size=4G /dev/shm) and send it again.", flush=True) + return p + S.combined_embeddings_path = path + + def model_switcher(url: str, port, model, mode: str = "") -> dict: """The host's model swapper: the models it serves on THIS port, which one holds the card, whether one is loading. With `mode`, asks for that one first; this server is then usually the one stopped, so the web app waits for @@ -308,6 +326,7 @@ def top_logprobs(req: dict): if __name__ == "__main__": install_xe_reader() + install_shared_embeddings() install_narrator() install_switcher(sys.argv[1:]) install_logprobs() diff --git a/sycl/serve/strata-sycl.sh b/sycl/serve/strata-sycl.sh index f579e79c..2f2120a3 100755 --- a/sycl/serve/strata-sycl.sh +++ b/sycl/serve/strata-sycl.sh @@ -7,6 +7,9 @@ # STRATA_SYCL_IMAGE the runtime image (default: strata-sycl-dev) # STRATA_SYCL_BIN the engine binary, relative to the repo (default: build-sycl-aot/strata) # STRATA_SYCL_NAME the container's name (default: strata-sycl-serve) +# STRATA_SYCL_SHM 1 (default): the host's /dev/shm is the container's /dev/shm. Pictures: the server (on the host) writes the +# image embeddings of a request into /dev/shm and names that file on the engine's GENI line, so the engine in +# the container must see the same file. 0: the container keeps a private /dev/shm. # Passed into the container: every variable of this script's environment that starts with STRATA_ (the config's # "env" block arrives that way: the server puts it in the engine's environment), ONEAPI_ (level_zero:* for a # two-card split, #423), UR_, IGC_, SYCL_ or ZES_. The port's own defaults (below) are overridden the same way, @@ -34,9 +37,12 @@ for k in "${!setting[@]}"; do # the engine tests the switches by presence: a value of 0 (or empty) means "not set", so it is not passed on case "${setting[$k]}" in 0|"") ;; *) envs+=(-e "$k=${setting[$k]}") ;; esac done +shm=() +if [ "${STRATA_SYCL_SHM:-1}" != 0 ] && [ -d /dev/shm ]; then shm=(-v /dev/shm:/dev/shm); fi exec docker run --rm -i --name "$name" --device /dev/dri --oom-score-adj 1000 --stop-timeout 30 --no-healthcheck \ --ulimit memlock=-1 \ -v "$root:/work" \ + "${shm[@]}" \ "${envs[@]}" \ "${STRATA_SYCL_IMAGE:-strata-sycl-dev}" \ "cd $repo_in && exec ${STRATA_SYCL_BIN:-build-sycl-aot/strata}$args" diff --git a/sycl/setup_intel.py b/sycl/setup_intel.py index 07a79101..3e327d37 100644 --- a/sycl/setup_intel.py +++ b/sycl/setup_intel.py @@ -7,10 +7,14 @@ it and replaces the few steps that are NVIDIA/AMD-specific, then runs setup's ow model choice, the download, the pack, the tokenizer, the MTP draft layer, the context and KV questions - is setup.py's, unchanged. What is replaced: - - the GPU check: the Intel Arc is offered through setup's AMD path (the one that compiles locally and has no - images), named and sized from sysfs; + - the GPU check: the Intel Arc is offered through setup's AMD path (the one that compiles locally), named and + sized from sysfs; - the engine step: the SYCL build (build-sycl-aot/strata, run in the strata-sycl-dev image by sycl/serve/strata-sycl.sh; docs/INTEL.md) instead of a CUDA/HIP build; + - pictures (opt-in for now, see PICTURES_ON_BY_DEFAULT): read by the portable CPU reader (`strata-vision`, the program the AMD packages carry beside + their engine, compiled here by setup's own step) on the host; it hands the image embeddings to the engine through + /dev/shm, which strata-sycl.sh shares with the container. A SYCL GPU reader does not exist yet, so "gpu" is read as "cpu" + here; --vision no is the off switch; - the RAM rule: the CUDA engine keeps every expert in RAM, the SYCL port streams them from the GGUF into VRAM (--stream-experts), so RAM only bounds the KV streaming; - the config: the container's paths, the SYCL flags, backend "sycl"; the run script starts @@ -20,14 +24,11 @@ When setup.py changes the steps this relies on, this stops with a message rather """ from __future__ import annotations -import atexit import json import os import re -import shutil import subprocess import sys -import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parent.parent @@ -121,6 +122,21 @@ def drop(args, name, value=False): del args[i:i + 1 + int(value)] +# Pictures on an Intel Arc work end to end up to the engine (the CPU reader encodes, the embeddings reach the container through /dev/shm) +# but the first picture request on the Arc Pro B70 (engine 0.1.45 SYCL, IQ3_S, 2026-10-19) hung the GPU: the xe driver logged an engine +# reset (ccs + bcs) and "Fault response: Unsuccessful -EINVAL", and the request ended 503. Until the SYCL engine's vision path is fixed +# pictures stay opt-in here (--vision yes); flip this to True to make them the default like on the other makes of card. +PICTURES_ON_BY_DEFAULT = False + +READER_DIR = ROOT / "engine-sycl" # the folder setup treats as the engine's: BUILD.json and, for pictures, the CPU reader strata-vision + + +def intel_vision(asked, vram_gb: float = 0.0) -> str: + """The picture reader wanted on an Intel Arc: "none" when switched off, else "cpu" (the only reader the SYCL port has; a + SYCL GPU reader is later work). Takes setup.hip_vision's arguments.""" + return "none" if str(asked or "").lower() in ("no", "none", "off") else "cpu" + + SYCL_PROFILE = "expert-profile-sycl.bin" # data/: the xe cards' expert ranking (to_sycl) SMALL_CARD_GB = 12.0 # under this the engine's own advice is --vram-reserve-mib 300 (a 1024 MiB reserve leaves an # 8 GB card no room for even one expert slot) and the English draft vocabulary @@ -222,7 +238,7 @@ def to_sycl(cfg: dict, exe: Path, ram: float, keep: dict, vram_gb: float = 0.0, if flag(args, "--prefill") in (None, "auto", "2048", "4096", "8192"): drop(args, "--prefill", True) args += ["--prefill", str(recommended_prefill(vram_gb, ctx, driver, devid)[0])] - out = {k: v for k, v in cfg.items() if k not in ("lib_dirs", "env", "vision", "gpus")} + out = {k: v for k, v in cfg.items() if k not in ("lib_dirs", "env", "gpus")} # "vision" stays: the CPU reader runs on the host out.update({"backend": "sycl", "exe": str(SYCL_WRAPPER), "args": args, "sycl_root": str(MOUNT)}) env = {} if alchemist: @@ -264,9 +280,13 @@ def install(argv) -> None: keep[p.name] = {k: c[k] for k in ("model_switcher", "sampling") if k in c} except (OSError, ValueError): pass - stub = Path(tempfile.mkdtemp(prefix="strata-sycl-")) # setup reads the engine's BUILD.json; the SYCL build has none - atexit.register(shutil.rmtree, stub, True) - (stub / "BUILD.json").write_text(json.dumps({"version": sycl_version(), "source": "local", "lib_dirs": []})) + stub = READER_DIR # setup reads the engine's BUILD.json; the SYCL build has none. A folder that + stub.mkdir(exist_ok=True) # stays: the picture reader in it is what the run config points at + try: + stamped = json.loads((stub / "BUILD.json").read_text(encoding="utf-8")) # keeps what the reader's build recorded + except (OSError, ValueError): + stamped = {} + (stub / "BUILD.json").write_text(json.dumps({**stamped, "version": sycl_version(), "source": "local", "lib_dirs": []})) say = S.say fake_ram = max(real_ram, 1024.0) @@ -294,8 +314,15 @@ def install(argv) -> None: S.gpus = lambda *a, **k: [] S.amd_gpus = lambda *a, **k: intel S.amd_problem = lambda g: None - S.hip_vision = lambda asked, vram_gb=0.0: "none" # images are not wired on the SYCL port yet - S.build_engine_hip = lambda *a, **k: stub + S.hip_vision = intel_vision # pictures on by default, read on the CPU (setup's hip_reader settles it) + + def build_engine_hip(gpu, llama, vision="none"): + """No engine to compile here (the SYCL build is separate); the picture reader is: the portable CPU reader, once.""" + if vision != "none": + stamp = stub / "BUILD.json" + S.build_vision_cpu(stub, stamp, json.loads(stamp.read_text(encoding="utf-8")), llama, S.source_hash(S.VISION_SOURCES)) + return stub + S.build_engine_hip = build_engine_hip S.hipblaslt_table = lambda *a, **k: None S.ram_gb = lambda: fake_ram # the experts are in VRAM: setup's RAM rule does not apply @@ -376,7 +403,7 @@ def install(argv) -> None: sys.argv = [str(ROOT / "setup.py"), *argv] if "--backend" not in argv: sys.argv += ["--backend", "hip"] - if "--vision" not in argv: + if "--vision" not in argv and not PICTURES_ON_BY_DEFAULT: sys.argv += ["--vision", "none"] if "--low-ram" not in argv: sys.argv += ["--low-ram", "off"] diff --git a/tests/terminal/test_engine_manifest.py b/tests/terminal/test_engine_manifest.py index 209e40aa..2e388b49 100644 --- a/tests/terminal/test_engine_manifest.py +++ b/tests/terminal/test_engine_manifest.py @@ -12,7 +12,7 @@ import unittest from pathlib import Path from unittest import mock -from strata_control import components, engine_component as ec +from strata_control import components, engine_component as ec, signing ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "packaging")) @@ -188,6 +188,9 @@ class Start(unittest.TestCase): self.folder = package_engine.build(make_source(self.root / "src"), "cuda", "0.1.45", HERE, self.out, archs=("sm_86",), min_driver={"nvidia": "580.65"}, build_id="b1") self.addCleanup(ec.register_signature_verifier, None) + patch = mock.patch.object(signing, "BUILTIN_KEYS", self.root / "no-shipped-keys.json") # a build with no shipped key; the real file: test_release_keys + patch.start() + self.addCleanup(patch.stop) def start(self, **kw): with mock.patch.object(ec, "cuda_archs_present", return_value=kw.pop("cards", ["sm_86"])), \ diff --git a/tests/terminal/test_launch.py b/tests/terminal/test_launch.py index 68f9c355..adbec883 100644 --- a/tests/terminal/test_launch.py +++ b/tests/terminal/test_launch.py @@ -648,6 +648,14 @@ class FlagsCommand(unittest.TestCase): self.assertIn("launch", out) self.assertIn("connect", out) + def test_vision_help_says_the_picture_rule(self): + code, out, err = run_cli(["launch", "--help"]) + text = " ".join(out.split()) + self.assertIn("CPU reader under 24 GB", text) + self.assertIn("GPU reader from 24 GB", text) + self.assertIn("off turns pictures off", text) + self.assertNotIn("for NVIDIA and AMD", text) + def test_model_context_parallel_vision_tune_access_port(self): p = self.plan("--model", "iq3_xxs", "--context", "128k", "--parallel", "2", "--vision", "off", "--tune", "quick", "--access", "lan", "--port", "9090") diff --git a/tests/terminal/test_launch_install.py b/tests/terminal/test_launch_install.py index 13dfd712..888a0f26 100644 --- a/tests/terminal/test_launch_install.py +++ b/tests/terminal/test_launch_install.py @@ -18,6 +18,8 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "packaging")) +sys.path.insert(0, str(ROOT)) +import make_local_feed as mlf # noqa: E402 class Scripts(unittest.TestCase): @@ -28,13 +30,15 @@ class Scripts(unittest.TestCase): r = subprocess.run([sh, "-n", str(ROOT / "packaging" / "install.sh")], capture_output=True, text=True) self.assertEqual(r.returncode, 0, r.stderr) text = (ROOT / "packaging" / "install.sh").read_text(encoding="utf-8") - self.assertEqual(text.count("__FEED__"), 1) # the baked address replaces only the default; the guard survives + self.assertNotIn("__FEED__", text) # no placeholder: the GitHub Releases address is the built-in default + self.assertIn(":-" + mlf.RELEASE_FEED + "}", text) # the default a local feed bakes its own address over self.assertIn("Installed. Run: ", text) self.assertNotIn("\r", text) def test_install_ps1_parses_and_guard(self): text = (ROOT / "packaging" / "install.ps1").read_text(encoding="utf-8") - self.assertEqual(text.count("__FEED__"), 1) + self.assertNotIn("__FEED__", text) + self.assertIn("else { '" + mlf.RELEASE_FEED + "' }", text) self.assertIn("Installed. Run: strata launch", text) ps = shutil.which("powershell") or shutil.which("pwsh") if not ps: @@ -44,14 +48,12 @@ class Scripts(unittest.TestCase): r = subprocess.run([ps, "-NoProfile", "-Command", cmd], capture_output=True, text=True) self.assertEqual(r.returncode, 0, r.stdout + r.stderr) - def test_a_script_without_an_address_says_what_to_do(self): - sh = shutil.which("sh") or shutil.which("bash") - if not sh or os.name == "nt": - self.skipTest("POSIX sh only") - env = {k: v for k, v in os.environ.items() if k != "STRATA_FEED"} - r = subprocess.run([sh, str(ROOT / "packaging" / "install.sh")], capture_output=True, text=True, env=env) - self.assertNotEqual(r.returncode, 0) - self.assertIn("Set STRATA_FEED", r.stderr) + def test_the_built_in_address_is_the_default_feed(self): + """install.sh / install.ps1 and `strata update` use the same GitHub Releases folder; STRATA_FEED stays an override.""" + from strata_cli import update_cmd + self.assertEqual(update_cmd.DEFAULT_FEED, mlf.RELEASE_FEED + "/strata-feed.json") + self.assertIn(":-" + mlf.RELEASE_FEED + "}", (ROOT / "packaging" / "install.sh").read_text(encoding="utf-8")) + self.assertIn("$env:STRATA_FEED", (ROOT / "packaging" / "install.ps1").read_text(encoding="utf-8")) class Feed(unittest.TestCase): @@ -89,7 +91,7 @@ class Feed(unittest.TestCase): self.assertEqual(control.stat().st_size, int(line[4])) sh_text = (feed / "install.sh").read_text() self.assertIn("http://127.0.0.1:1", sh_text) - self.assertIn('"__FE""ED__"', sh_text) # the guard was not rewritten + self.assertNotIn(mlf.RELEASE_FEED, sh_text) # the GitHub address was replaced everywhere by the local one self.assertIn("Installed. Run:", (feed / "install.ps1").read_text()) doc = json.loads((feed / "strata-feed.json").read_text()) self.assertEqual(doc["control"]["packages"][0]["sha256"], line[3]) diff --git a/tests/terminal/test_release_config.py b/tests/terminal/test_release_config.py new file mode 100644 index 00000000..aaf5b25c --- /dev/null +++ b/tests/terminal/test_release_config.py @@ -0,0 +1,34 @@ +"""The release app configuration: the engine travels inside every installer, the updater signs, the Mac minimum matches the Metal engine.""" +from __future__ import annotations + +import json +import unittest +from pathlib import Path + +TAURI = Path(__file__).resolve().parents[2] / "apps" / "desktop" / "src-tauri" + + +def load(name: str) -> dict: + return json.loads((TAURI / name).read_text(encoding="utf-8-sig")) + + +class ReleaseConfig(unittest.TestCase): + def test_every_installer_bundles_the_engine(self): + self.assertEqual(load("tauri.conf.json")["bundle"]["resources"]["resources/engine-bundle"], "engine-bundle") + self.assertEqual(load("tauri.tester.conf.json")["bundle"]["resources"]["resources/engine-bundle"], "engine-bundle") # the same place + + def test_the_release_overlay_makes_signed_updater_artifacts(self): + self.assertIs(load("tauri.release.conf.json")["bundle"]["createUpdaterArtifacts"], True) + self.assertIs(load("tauri.conf.json")["bundle"]["createUpdaterArtifacts"], False) # a development build needs no private key + + def test_the_mac_app_needs_the_macos_the_metal_engine_needs(self): + self.assertEqual(load("tauri.conf.json")["bundle"]["macOS"]["minimumSystemVersion"], "15.0") + + def test_the_updater_points_at_github_releases(self): + up = load("tauri.conf.json")["plugins"]["updater"] + self.assertEqual(up["endpoints"], ["https://github.com/Niko1221/Strata/releases/latest/download/latest.json"]) + self.assertNotIn("REPLACE", up["pubkey"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/terminal/test_release_keys.py b/tests/terminal/test_release_keys.py new file mode 100644 index 00000000..8c87afa2 --- /dev/null +++ b/tests/terminal/test_release_keys.py @@ -0,0 +1,49 @@ +"""The keys shipped with a release build (strata_control/update_keys.json): the release feed key and the Tauri app key are there, +the tester / local-test keys are not (they come with STRATA_UPDATE_TRUSTED_KEYS), and a feed is verified against them.""" +from __future__ import annotations + +import json +import os +import tempfile +import unittest +from pathlib import Path +from unittest import mock + +from strata_control import feed as feedmod, signing +from tests.terminal import update_fixture as fx + +ROOT = Path(__file__).resolve().parents[2] +RELEASE_KEY_ID = "5d1bc23abbeffd0d" +TAURI_CONF = ROOT / "apps" / "desktop" / "src-tauri" / "tauri.conf.json" + + +class ShippedKeys(unittest.TestCase): + def test_the_release_feed_key_is_shipped_and_valid(self): + with mock.patch.dict(os.environ, {signing.ENV_EXTRA_KEYS: ""}): + keys = signing.load_trusted_keys() + self.assertEqual(list(keys), [RELEASE_KEY_ID]) # only the release key: no tester or local-test key in a release build + self.assertEqual(signing.key_id_of(keys[RELEASE_KEY_ID]), RELEASE_KEY_ID) + + def test_the_app_key_is_the_one_in_the_tauri_config(self): + shipped = json.loads((ROOT / "strata_control" / "update_keys.json").read_text(encoding="utf-8-sig"))["app_minisign_public"] + conf = json.loads(TAURI_CONF.read_text(encoding="utf-8-sig"))["plugins"]["updater"]["pubkey"] + self.assertEqual(shipped, conf) + key_id, public = signing.minisign_public(shipped) # parses as a real Ed25519 minisign key, not the placeholder + self.assertEqual(len(public), 32) + self.assertEqual(signing.app_public_key if False else shipped, conf) + + def test_a_feed_signed_by_another_key_is_refused_and_a_tester_key_works_through_the_override(self): + other = fx.make_key() + with tempfile.TemporaryDirectory() as t: + extra = Path(t) / "tester-keys.json" + extra.write_text(json.dumps({"keys": [signing.public_part(other)]})) + with mock.patch.dict(os.environ, {signing.ENV_EXTRA_KEYS: ""}): + self.assertNotIn(other["key_id"], signing.load_trusted_keys()) # a tester key is not part of a release build + with mock.patch.dict(os.environ, {signing.ENV_EXTRA_KEYS: str(extra)}): + keys = signing.load_trusted_keys() + self.assertIn(other["key_id"], keys) # private tester builds: their key via the override + self.assertIn(RELEASE_KEY_ID, keys) # ... beside the release key + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/terminal/test_tuiqa_monitor.py b/tests/terminal/test_tuiqa_monitor.py index 16fd7ecf..6d71405c 100644 --- a/tests/terminal/test_tuiqa_monitor.py +++ b/tests/terminal/test_tuiqa_monitor.py @@ -132,6 +132,46 @@ class MonitorViews(unittest.TestCase): self.assertEqual(app.view, 5) self.run_app(MonitorApp, (120, 40), case) + def test_strata_monitor_is_the_same_seven_view_monitor_as_launchs(self): + """`strata monitor --url ...` builds the launch monitor without the quit question: seven views, key 7, Connect points at that server.""" + from strata_cli import monitor_commands + seen = {} + + class Fake: + def __init__(self, endpoint, snapshot, **kw): + seen.update(kw, endpoint=endpoint) + + def run(self): + seen["ran"] = True + + args = monitor_commands.parser().parse_args(["monitor", "--url", "http://127.0.0.1:18765"]) + with mock.patch("strata_cli.launch.monitor_ext.LaunchMonitor", Fake), mock.patch("sys.stdout.isatty", return_value=True), Home(): + self.assertEqual(monitor_commands.run(args), 0) + self.assertTrue(seen.get("ran")) + self.assertFalse(seen["ask_quit"]) # q detaches: this command started nothing + self.assertEqual(seen["info"]["url"], "http://127.0.0.1:18765") # the Connect view's address is the --url server + self.assertIn("seven views", " ".join(monitor_commands.parser().format_help().split())) + + def test_the_monitor_strata_monitor_opens_has_seven_views_and_connect_shows_the_server(self): + async def case(app, pilot): + shown = text_of(app) + self.assertIn("7 Connect", shown) + self.assertNotIn("1-6", shown) + await pilot.press("7") + await pilot.pause(0.2) + self.assertEqual(app.view, 6) + self.assertIn(INFO["url"], text_of(app)) + await pilot.press("escape") + await pilot.pause(0.1) + self.assertEqual(app.view, 0) + async def go(): + app = LaunchMonitor(Source(metrics("idle")), None, info=dict(INFO), interval=30, ask_quit=False) + async with app.run_test(size=(120, 40)) as pilot: + await pilot.pause(0.4) + return await case(app, pilot) + with Home(): + asyncio.run(go()) + def test_the_overview_is_titled_overview(self): async def case(app, pilot): self.assertIn("STRATA Overview", text_of(app)) diff --git a/tests/terminal/test_updater.py b/tests/terminal/test_updater.py index 67d93eda..12025b2f 100644 --- a/tests/terminal/test_updater.py +++ b/tests/terminal/test_updater.py @@ -49,8 +49,20 @@ class UpdaterCase(unittest.TestCase): patch.start() self.addCleanup(patch.stop) self.addCleanup(ec.register_signature_verifier, None) + # the tests sign with throwaway keys that they hand over explicitly: the release key shipped in update_keys.json is not in play here + # (ReleaseKeys below checks the shipped file itself) + patch = mock.patch.object(signing, "BUILTIN_KEYS", self.root / "no-shipped-keys.json") + patch.start() + self.addCleanup(patch.stop) self.key = fx.make_key() self.trusted = fx.trusted_of(self.key) + # the engine a test start runs is a child process: it reads the shipped release key too, so the test key is passed the way a + # tester build passes its key + self.test_keys = self.root / "test-trust.json" + self.test_keys.write_text(json.dumps({"keys": [signing.public_part(self.key)]})) + patch = mock.patch.dict(os.environ, {"STRATA_UPDATE_TRUSTED_KEYS": str(self.test_keys)}) + patch.start() + self.addCleanup(patch.stop) self.hardware = {"platform": PLATFORM, "backend": "cuda", "runtime": None, "nvidia_driver": "610.47", "cuda_archs": ["sm_86"], "gfx": []} self.models = self.root / "models" diff --git a/tools/strata_mcp.py b/tools/strata_mcp.py index ae35b327..21ef92b7 100644 --- a/tools/strata_mcp.py +++ b/tools/strata_mcp.py @@ -1044,7 +1044,7 @@ class Strata: notes.append("this CPU has no AVX2: EXPERIMENTAL and slow - setup compiles the engine on this PC for the " "older CPU (10-20 minutes), and the CPU's share of the experts runs a few times slower") if backend == "hip": - notes.append("AMD (experimental): no GPU picture reader yet") + 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") cmd = (("START-HERE.bat --setup" if WIN else "./setup.sh --setup") + f" --yes --family {fam} --model {model} --context {ctx}" + (" --backend hip" if backend == "hip" else "")) return {"family": fam, "model": model, "title": families[fam]["title"] + " " + model, "context": ctx, @@ -1491,7 +1491,7 @@ def tool_defs(models: dict, families: dict, contexts: list) -> list: "script). Without confirm=true it only returns the plan (what would be downloaded, disk " "space): show it to the user and call again with confirm=true once they agree. Returns at " "once; call it again (no arguments needed) to see the progress, or with cancel=true to stop " - "it (it resumes later). Defaults: the recommended model and context for this PC, images off. " + "it (it resumes later). Defaults: the recommended model and context for this PC, pictures on where the model can read them. " "After it finishes, start the model with strata_start.", "inputSchema": {"type": "object", "additionalProperties": False, "properties": { "family": {"type": "string", "enum": list(families), @@ -1505,8 +1505,10 @@ def tool_defs(models: dict, families: dict, contexts: list) -> list: "context": {"type": "integer", "enum": contexts, "description": "context length in tokens (more needs more VRAM)"}, "vision": {"type": "string", "enum": ["no", "yes", "gpu", "cpu"], - "description": "let the model read images (yes = the encoder on the GPU; ~0.9 GB more " - "download); default no"}, + "description": "let the model read images (~0.9 GB more download). Default yes where the model can " + "read them (not on a Mac): yes = the best reader for this card (the CPU " + "under 24 GB of VRAM, the GPU from 24 GB, any make), gpu / cpu = that " + "reader, no = text only"}, "kv": {"type": "string", "enum": ["int8", "q4_0", "k8v4"], "description": "KV cache precision above 8K context (default int8)"}, "gpu": {"type": "integer", "minimum": 0, "maximum": 63, @@ -1824,16 +1826,11 @@ class Tools: context = 8192 if vram < 14 else 32768 if vision in ("yes", "gpu", "cpu") and md.get("vision", families[family].get("vision")) is False: raise ToolError(f"images are not available with {families[family]['title']} {model} yet: use vision=no") - if vision is not None and backend == "hip" and vision != "no": - # setup.py's hip_vision rules (#990): the AMD backend has no GPU image encoder, but --vision cpu reads - # images on the CPU beside it (Linux; the ready-made Windows AMD engine has no encoder) - if vision == "cpu" and not WIN: - pass - elif vision == "cpu": - raise ToolError("images on the CPU with an AMD card are Linux-only for now: use vision=no") - else: - raise ToolError("the AMD backend has no GPU image encoder yet: use vision=cpu (images on the CPU, " - "Linux) or vision=no") + if vision is None: + # owner rule (2026-10-18): pictures are on by default wherever the model can read them and the engine has a reader; setup picks + # the reader (strata_control/vision_reader.py: the CPU under 24 GB, the GPU from 24 GB, every make of card). A Mac has none yet. + can_read = md.get("vision", families[family].get("vision")) is not False + vision = "yes" if can_read and not mac else "no" target = self.check_data_dir(data_dir) if data_dir else s.data_dir() tag = (families[family].get("tag", "") + model) have_dir = target / "models" / tag diff --git a/tools/test_picture_defaults.py b/tools/test_picture_defaults.py new file mode 100644 index 00000000..0e51f272 --- /dev/null +++ b/tools/test_picture_defaults.py @@ -0,0 +1,76 @@ +"""Owner rule 2026-10-18: pictures are on by default wherever the model and the engine package can read them; the reader runs on the +CPU under 24 GB of VRAM and on the GPU from 24 GB, on every make of card. Checks setup.images_default and the shared rule. + + python -m unittest tools.test_picture_defaults +""" +from __future__ import annotations + +import sys +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT)) +sys.path.insert(0, str(ROOT / "tools")) +import setup # noqa: E402 +from strata_control import vision_reader as VR # noqa: E402 + + +class PictureDefaults(unittest.TestCase): + def test_unsloth_default_is_on_for_every_make_and_size(self): + models = [m for m, d in setup.MODELS.items() if d.get("budget") and d.get("vision") is not False] + self.assertTrue(models) + for m in models: + for gpu in ({"vram_gb": 10.0}, {"vram_gb": 12.0}, {"vram_gb": 16.0}, {"vram_gb": 32.0}, + {"vram_gb": 16.0, "arch": "gfx1201"}, {"vram_gb": 24.0, "arch": "gfx1100"}, {}): + for win in (False, True): + old = setup.WIN + setup.WIN = win + try: + self.assertTrue(setup.images_default(m, "unsloth", 64.0, gpu), (m, gpu, win)) + self.assertTrue(setup.images_default(m, "unsloth", 512.0, gpu), (m, gpu, win)) + finally: + setup.WIN = old + + def test_yes_means_pictures_on_for_qwen_swift_and_coder(self): + """setup --yes (and Enter at the question) on the original Flash-Next, Swift and Coder files: pictures on, the reader by the 24 GB rule, + and no VRAM reserve for the CPU reader.""" + from test_setup_golden import PROFILES, install + for key, gpu in (("64GB-1x32GB", True), ("96GB-1x16GB", False)): # 31.8 GB: the GPU reader; 15.9 GB: the CPU reader + ram, found = PROFILES[key] + for fam, model in (("qwen", "Q2_0"), ("swift", "IQ3_S"), ("coder", "IQ1_M")): + for answers in (None, ""): + code, out, cfg, _ = install(ram, found, ["--family", fam, "--model", model, "--no-start"], answers=answers) + where = (key, fam, model, answers) + self.assertEqual(code, 0, (where, out[-1500:])) + self.assertIn("--vision", cfg["args"], where) + self.assertEqual(cfg["vision"]["gpu"], gpu, where) + self.assertEqual("--vram-reserve-mib" in cfg["args"], gpu, where) # only the GPU reader keeps VRAM free + self.assertIn("images: on", out, where) + + def test_pictures_off_stays_available(self): + from test_setup_golden import PROFILES, install + ram, found = PROFILES["64GB-1x32GB"] + for fam, model in (("qwen", "Q2_0"), ("swift", "IQ3_S"), ("coder", "IQ1_M")): + code, out, cfg, _ = install(ram, found, ["--family", fam, "--model", model, "--no-start", "--vision", "no"]) + self.assertEqual(code, 0, out[-1500:]) + self.assertNotIn("--vision", cfg["args"]) + self.assertNotIn("vision", cfg) + + def test_the_cpu_reader_takes_no_vram_reserve(self): + """So a card of 8 GB is no exception: the reserve is only for the GPU reader.""" + self.assertEqual(setup.VISION["cpu"]["reserve_mib"], 0) + self.assertEqual(setup.VISION["gpu"]["reserve_mib"], 700) + + def test_one_rule_for_the_reader(self): + self.assertEqual(setup.IMAGES_GPU_ENCODER_MIN_VRAM_GB, VR.GPU_MIN_VRAM_GB) + for vram, want in ((8, "cpu"), (16, "cpu"), (23.0, "cpu"), (24, "gpu"), (32, "gpu"), (None, "gpu")): + self.assertEqual(VR.default_mode(vram), want) + self.assertEqual(VR.wanted("yes", vram), want) + self.assertEqual(setup.hip_vision("yes", vram or 0.0), want if vram else "gpu") + self.assertEqual(setup.hip_vision(None, 16.0), "cpu") + self.assertEqual(setup.hip_vision("gpu", 16.0), "gpu") + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/test_setup_choices.py b/tools/test_setup_choices.py index d2d43159..1ecf1797 100644 --- a/tools/test_setup_choices.py +++ b/tools/test_setup_choices.py @@ -443,8 +443,12 @@ class VramReserve(unittest.TestCase): self.assertEqual(a.count("--vram-reserve-mib"), 1) self.assertEqual(a[a.index("--vram-reserve-mib") + 1], "2048") self.assertIn("VRAM kept free for other programs: 2048 MiB", out) - code, out, cfg, _ = self.install() + code, out, cfg, _ = self.install("--vision", "no") self.assertNotIn("--vram-reserve-mib", cfg["args"]) # not given: the engine's default, as before + code, out, cfg, _ = self.install("--vision", "cpu") + self.assertNotIn("--vram-reserve-mib", cfg["args"]) # the CPU reader needs no reserve + code, out, cfg, _ = self.install() + self.assertEqual(cfg["args"][cfg["args"].index("--vram-reserve-mib") + 1], "700") # pictures on by default, GPU reader on a 32 GB card: its 700 MiB def test_with_images_one_value(self): code, out, cfg, _ = self.install("--vision", "cpu", "--vram-reserve-mib", "1500") diff --git a/tools/test_setup_nvfp4.py b/tools/test_setup_nvfp4.py index e7ca4024..9c2d0419 100644 --- a/tools/test_setup_nvfp4.py +++ b/tools/test_setup_nvfp4.py @@ -227,7 +227,7 @@ class MockedInstall(unittest.TestCase): self.assertTrue(self.flag(a, "--embd-gguf").endswith("/token-embd-bf16.gguf")) self.assertNotIn("--mmap-experts", a) # 128 GB: every expert in RAM self.assertNotIn("--resident-experts", a) - self.assertNotIn("vision", cfg) # --yes: images default off, as for every model + self.assertIn("vision", cfg) # --yes: pictures on, as for every model that can read them self.assertEqual(cfg["model_name"], "qwen3.8-flash-next-nvfp4-nvfp4") self.assertIn("Qwen Community License", out) diff --git a/tools/test_setup_older_gpus.py b/tools/test_setup_older_gpus.py index d19fd4bc..72d9a97c 100644 --- a/tools/test_setup_older_gpus.py +++ b/tools/test_setup_older_gpus.py @@ -163,6 +163,7 @@ def fake_prebuilt(calls): (eng / "BUILD.json").write_text(json.dumps({"version": "0.1.39", "source": "release", "archs": [86], "ptx": True, "cuda": "12.9" if toolkit == 12 else "13.0", "vision": "gpu"})) (eng / setup.EXE).write_bytes(b"") + (eng / setup.VEXE).write_bytes(b"") # pictures are on by default: the engine carries the reader return eng return get diff --git a/tools/test_setup_qwen36.py b/tools/test_setup_qwen36.py index 69bdd726..35946db2 100644 --- a/tools/test_setup_qwen36.py +++ b/tools/test_setup_qwen36.py @@ -190,8 +190,8 @@ class InstallOwnPath(unittest.TestCase): a = self.cfg["args"] self.assertEqual(a[a.index("--max-context") + 1], "131072") - def test_images_by_default_on_a_16gb_nvidia_card_use_the_gpu_encoder(self): - rc, out = self.install(model="UD-Q4_K_XL", vram=16.0) # --yes: the question's default answer + def test_images_by_default_on_a_24gb_plus_nvidia_card_use_the_gpu_encoder(self): + rc, out = self.install(model="UD-Q4_K_XL", vram=24.0) # --yes: the question's default answer (yes) self.assertEqual(rc, 0, out) self.assertIn(("engine", "gpu"), self.calls) mm = self.root / "models" / "qwen36-UD-Q4_K_XL" / "mmproj-F16.gguf" @@ -209,9 +209,12 @@ class InstallOwnPath(unittest.TestCase): self.assertIn("images: on", out) def test_a_12gb_card_is_recommended_the_cpu_encoder_never_forced(self): - rc, out = self.install(model="UD-Q4_K_XL", vram=12.0) # the default answer is no + rc, out = self.install(model="UD-Q4_K_XL", vram=12.0) # the default answer is yes, with the CPU encoder self.assertEqual(rc, 0, out) - self.assertNotIn("vision", self.cfg) + self.assertFalse(self.cfg["vision"]["gpu"]) + rc, out = self.install(model="UD-Q4_K_XL", vram=16.0) # the 24 GB rule, not the old 16 GB one + self.assertEqual(rc, 0, out) + self.assertFalse(self.cfg["vision"]["gpu"]) rc, out = self.install(model="UD-Q4_K_XL", vram=12.0, vision="yes") # yes: the CPU encoder, said why self.assertEqual(rc, 0, out) self.assertFalse(self.cfg["vision"]["gpu"]) @@ -253,6 +256,14 @@ class InstallOwnPath(unittest.TestCase): self.assertEqual(rc, 0, out) self.assertTrue(self.cfg["vision"]["gpu"]) + def test_amd_under_24gb_reads_pictures_on_the_cpu_by_default(self): + with mock.patch.object(setup, "WIN", False), mock.patch.object(setup, "VEXE", "strata-vision"), mock.patch.object(setup, "HVEXE", "strata-vision-hip"): + rc, out = self.install(model="UD-Q4_K_XL", vram=16.0, hip=True) + self.assertEqual(rc, 0, out) + self.assertIn("--vision", self.cfg["args"]) + self.assertFalse(self.cfg["vision"]["gpu"]) + self.assertEqual(Path(self.cfg["vision"]["exe"]).name, "strata-vision") + def test_parallel_is_opt_in_and_recommended_where_the_experts_fit(self): fam = setup.OWN_PATH_FAMILIES["qwen36"] # nothing written without --parallel; the recommendation is said @@ -321,7 +332,7 @@ class InstallOwnPath(unittest.TestCase): p.write_text(json.dumps(self.cfg), encoding="utf-8") ch = setup.choices_from_config(p) self.assertEqual((ch["family"], ch["model"], ch["context"]), ("qwen36", "UD-Q6_K_XL", 65536)) - self.assertEqual(ch["vision"], "gpu") # 16 GB NVIDIA, the default answer + self.assertEqual(ch["vision"], "cpu") # 16 GB NVIDIA, the default answer: the CPU encoder under 24 GB self.assertTrue(setup.own_path_config(self.cfg)) self.assertEqual(setup.calibration_targets([p], None, None), []) # the tuning is Flash-Next's diff --git a/tools/test_setup_sycl.py b/tools/test_setup_sycl.py index 1c993a6a..25d1bca5 100644 --- a/tools/test_setup_sycl.py +++ b/tools/test_setup_sycl.py @@ -223,6 +223,56 @@ class ToSycl(unittest.TestCase): self.assertTrue(m.small_card(10.0, "xe")) self.assertFalse(m.small_card(32.0, "xe")) + def test_pictures_asked_for_are_read_on_the_cpu_and_the_vision_section_survives(self): + """Intel Arc: the CPU reader (strata-vision) on the host when asked for (--vision yes); "gpu" is read as "cpu" (no SYCL GPU reader).""" + m = self.mod() + for asked in (None, "yes", "gpu", "cpu", "on"): + self.assertEqual(m.intel_vision(asked, 8.0), "cpu") + self.assertEqual(m.intel_vision(asked, 32.0), "cpu") + for asked in ("no", "none", "off"): + self.assertEqual(m.intel_vision(asked, 32.0), "none") + section = {"exe": "/h/engine-sycl/strata-vision", "mmproj": "/h/models/mmproj.gguf", "model": "/h/models/m.gguf", "gpu": False, + "max_tokens": 300} + cfg = self.cfg(m, ["--vision"]) + cfg["vision"] = section + c = m.to_sycl(cfg, m.ROOT / "build-sycl-aot" / "strata", 64.0, {}, 32.0, "xe") + self.assertEqual(c["vision"], section) # host paths: the reader runs on the host, not in the container + self.assertIn("--vision", c["args"]) + + def test_pictures_are_opt_in_on_the_arc_until_the_engine_fault_is_fixed(self): + """The first picture on the Arc Pro B70 hung the GPU (xe engine reset, 2026-10-19): off unless asked, --vision yes turns it on.""" + m = self.mod() + self.assertFalse(m.PICTURES_ON_BY_DEFAULT) + src = (ROOT / "sycl" / "setup_intel.py").read_text(encoding="utf-8") + self.assertIn('if "--vision" not in argv and not PICTURES_ON_BY_DEFAULT:', src) + self.assertIn("S.hip_vision = intel_vision", src) + self.assertIn("S.build_vision_cpu(", src) # the CPU reader is compiled by setup's own step + + def test_the_container_shares_dev_shm_with_the_server_for_the_embeddings(self): + sh = (ROOT / "sycl" / "serve" / "strata-sycl.sh").read_text(encoding="utf-8") + self.assertIn("-v /dev/shm:/dev/shm", sh) + self.assertIn("STRATA_SYCL_SHM", sh) + + def test_a_picture_that_cannot_reach_the_container_is_said_once(self): + import importlib.util + spec = importlib.util.spec_from_file_location("server_intel_t", ROOT / "sycl" / "serve" / "server_intel.py") + src = (ROOT / "sycl" / "serve" / "server_intel.py").read_text(encoding="utf-8") + self.assertIn("install_shared_embeddings()", src.split('if __name__ == "__main__":')[1]) + sys.path.insert(0, str(ROOT / "sycl" / "serve")) + try: + m = importlib.util.module_from_spec(spec) + spec.loader.exec_module(m) + except ImportError as e: # no oneAPI / xe telemetry import here: the source check above stands + self.skipTest(str(e)) + finally: + sys.path.pop(0) + out = io.StringIO() + with mock.patch.object(m.S, "combined_embeddings_path", lambda d, n: Path("/tmp/x/req.sve")), contextlib.redirect_stdout(out): + m.install_shared_embeddings() + m.S.combined_embeddings_path(Path("/tmp/x"), 10) + m.S.combined_embeddings_path(Path("/tmp/x"), 10) + self.assertEqual(out.getvalue().count("/dev/shm has no room"), 1) + if __name__ == "__main__": unittest.main() diff --git a/tools/test_setup_unsloth.py b/tools/test_setup_unsloth.py index 0a30687d..81777b09 100644 --- a/tools/test_setup_unsloth.py +++ b/tools/test_setup_unsloth.py @@ -221,7 +221,8 @@ class Main(Base): self.assertEqual(code, 0, out) self.assertNotIn("EXPERIMENTAL", out) base = f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/UD-Q4_K_XL/" - self.assertEqual(self.downloads, [base + n for n in setup.UNSLOTH_SHARDS]) # no image encoder + self.assertEqual(self.downloads[:-1], [base + n for n in setup.UNSLOTH_SHARDS]) # then the image encoder: pictures are on by default + self.assertIn("mmproj", self.downloads[-1]) self.assertEqual([v[0] for v in self.verified], list(setup.UNSLOTH_SHARDS)) self.assertEqual([v[1:] for v in self.verified], list(setup.UNSLOTH_SHARDS.values())) packs = [r for r in self.runs if r[1].endswith("iq_pack.py")] @@ -232,12 +233,12 @@ class Main(Base): args = cfg["args"] self.assertEqual(args[args.index("--resident-budget-gib") + 1], "40") self.assertTrue(args[args.index("--native") + 1].endswith("-00001-of-00004.gguf")) - for flag in ("--ple-gguf", "--mmap-experts", "--resident-experts", "--vision", "--control-vector-scaled", + for flag in ("--ple-gguf", "--mmap-experts", "--resident-experts", "--control-vector-scaled", "--kv-resident"): self.assertNotIn(flag, args) self.assertEqual(args[args.index("--max-context") + 1], "8192") self.assertEqual(cfg["model_name"], "qwen3.8-flash-next-unsloth-ud-q4_k_xl") - self.assertNotIn("vision", cfg) + self.assertFalse(cfg["vision"]["gpu"]) # 11.9 GB: the CPU reader def test_recommended_context_on_12_gb(self): code, out, cfg = self.main([]) @@ -472,7 +473,8 @@ class IQ4XS(Base): self.assertEqual(code, 0, out) self.assertNotIn("is EXPERIMENTAL", out) # (the menu still lists UD-Q4_K_XL) base = f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/UD-IQ4_XS/" - self.assertEqual(self.downloads, [base + n for n in setup.UNSLOTH_IQ4_XS_SHARDS]) + self.assertEqual(self.downloads[:-1], [base + n for n in setup.UNSLOTH_IQ4_XS_SHARDS]) # then the image encoder (pictures on by default) + self.assertIn("mmproj", self.downloads[-1]) self.assertEqual(self.verified, [(n, *v) for n, v in setup.UNSLOTH_IQ4_XS_SHARDS.items()]) packs = [r for r in self.runs if r[1].endswith("iq_pack.py")] self.assertEqual(len(packs), 1, self.runs) @@ -482,14 +484,15 @@ class IQ4XS(Base): args = cfg["args"] self.assertEqual(args[args.index("--resident-budget-gib") + 1], "40") self.assertTrue(args[args.index("--native") + 1].endswith("UD-IQ4_XS-00001-of-00003.gguf")) - for flag in ("--ple-gguf", "--mmap-experts", "--resident-experts", "--vision"): + for flag in ("--ple-gguf", "--mmap-experts", "--resident-experts"): self.assertNotIn(flag, args) + self.assertIn("--vision", args) # pictures are on by default self.assertEqual(cfg["model_name"], "qwen3.8-flash-next-unsloth-ud-iq4_xs") pack = self.t / "data" / "packs" / "unsloth-ud-iq4_xs" # its own pack and tokenizer self.assertEqual(packs[0][packs[0].index("--out") + 1], str(pack)) self.assertEqual(args[args.index("--pack") + 1], str(pack)) self.assertEqual(cfg["tokenizer"], str(pack / "tokenizer")) - self.assertNotIn("vision", cfg) # images: asked, off by default + self.assertFalse(cfg["vision"]["gpu"]) # pictures on by default, the CPU reader under 24 GB with tempfile.TemporaryDirectory() as t: # a start reads the choice back p = Path(t) / "strata-unsloth-ud-iq4_xs.json" p.write_text(json.dumps(cfg)) @@ -824,8 +827,9 @@ class BigFiles(Base): self.assertEqual(code, 0, out) base = f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/Q8_0/" names = [setup.model_file(setup.FAMILIES["unsloth"], Q8, i) for i in range(1, 7)] - self.assertEqual(self.downloads, [base + n for n in names]) - self.assertEqual([v[0] for v in self.verified], names) + self.assertEqual(self.downloads[:-1], [base + n for n in names]) # then the image encoder (pictures on by default) + self.assertIn("mmproj", self.downloads[-1]) + self.assertEqual([v[0] for v in self.verified][:len(names)], names) packs = [r for r in self.runs if r[1].endswith("iq_pack.py")] self.assertIn("--compat-bf16", packs[0]) args = cfg["args"] diff --git a/tools/test_strata_mcp.py b/tools/test_strata_mcp.py index 923c5745..c0e87dfa 100644 --- a/tools/test_strata_mcp.py +++ b/tools/test_strata_mcp.py @@ -308,22 +308,30 @@ class Validation(FakeRoot): self.assertEqual(res["plan"]["images"], "yes") self.assertRejected("strata_install", {"vision": "yes\nrm"}, "control characters") - def test_amd_vision_follows_setups_rules(self): - """#990: --vision cpu is allowed with the AMD backend on Linux (setup.hip_vision); a GPU encoder is not.""" - with mock.patch.object(M, "WIN", False): - self.assertRejected("strata_install", {"backend": "hip", "vision": "yes"}, "no GPU image encoder") - self.assertRejected("strata_install", {"backend": "hip", "vision": "gpu"}, "vision=cpu") - res, err = self.call("strata_install", {"backend": "hip", "vision": "cpu"}) + def test_amd_vision_follows_the_picture_rule(self): + """Owner rule 2026-10-18: pictures are on for AMD too, on Linux and Windows (setup picks the reader: CPU under 24 GB, GPU from 24 GB).""" + for win in (False, True): + with mock.patch.object(M, "WIN", win): + for asked in ("yes", "gpu", "cpu"): + res, err = self.call("strata_install", {"backend": "hip", "vision": asked}) + self.assertFalse(err, res) + self.assertEqual(res["plan"]["images"], asked) + self.assertIn("--vision " + asked, res["plan"]["setup_command"]) + res, err = self.call("strata_install", {"backend": "hip", "vision": "no"}) + self.assertFalse(err, res) + self.assertEqual(res["plan"]["images"], "no") + + def test_pictures_default_on(self): + """Nothing asked: pictures are on where the model can read them (any backend), off for a model that cannot.""" + for backend in (None, "cuda", "hip"): + args = {"backend": backend} if backend else {} + res, err = self.call("strata_install", args) self.assertFalse(err, res) - self.assertEqual(res["plan"]["images"], "cpu") - self.assertIn("--vision cpu", res["plan"]["setup_command"]) - res, err = self.call("strata_install", {"backend": "hip", "vision": "no"}) - self.assertFalse(err, res) - with mock.patch.object(M, "WIN", True): - self.assertRejected("strata_install", {"backend": "hip", "vision": "cpu"}, "Linux") - res, err = self.call("strata_install", {"backend": "hip", "vision": "no"}) # the Windows AMD engine is no longer refused outright - self.assertFalse(err, res) - self.assertIn("--backend hip", res["plan"]["setup_command"]) + self.assertEqual(res["plan"]["images"], "yes") + self.assertIn("--vision yes", res["plan"]["setup_command"]) + res, err = self.call("strata_install", {"vision": "no"}) + self.assertFalse(err, res) + self.assertEqual(res["plan"]["images"], "no") def test_data_dir_paths(self): self.assertRejected("strata_install", {"data_dir": "models"}, "absolute")