Merge f-022-flow: Docker and re-run fixes from the end-to-end flow walk
This commit is contained in:
commit
4e1e6bad4e
11 files changed
+257
-16
No files matched your search
+73
-4
@@ -69,6 +69,57 @@ for legacy in HOST LOW_RAM REINSTALL RESIDENT_BUDGET_GIB KV_STREAMING LAYER_SPLI
|
||||
[ -n "$v" ] && warn "$legacy is from the older image and is ignored here. See docs/DOCKER.md (\"From the older image\")."
|
||||
done
|
||||
|
||||
# ---- a volume from the older (0.1.x) image: its models, packs and draft layer are in /data/models, /data/packs and /data/mtp.
|
||||
# This image keeps them in /data/Strata-data. Move them over (a rename inside one volume: instant, no copy, no download).
|
||||
# A folder that is its own mount (a bind mount of yours) is never touched.
|
||||
legacy_moved=""
|
||||
for d in models packs mtp; do
|
||||
[ -d "/data/$d" ] || continue
|
||||
grep -q " /data/$d " /proc/self/mountinfo 2>/dev/null && continue
|
||||
[ -n "$(ls -A "/data/$d" 2>/dev/null)" ] || continue
|
||||
mkdir -p "/data/Strata-data/$d" 2>/dev/null || continue
|
||||
for item in "/data/$d"/* "/data/$d"/.[!.]*; do
|
||||
[ -e "$item" ] || continue
|
||||
name=${item##*/}
|
||||
[ -e "/data/Strata-data/$d/$name" ] && continue
|
||||
if mv "$item" "/data/Strata-data/$d/$name" 2>/dev/null; then legacy_moved="$legacy_moved $d/$name"
|
||||
else warn "Could not move $item into /data/Strata-data/$d (the model is downloaded again unless you set MODEL_PATH=/data/$d/...)."; fi
|
||||
done
|
||||
rmdir "/data/$d" 2>/dev/null || true
|
||||
done
|
||||
[ -n "$legacy_moved" ] && say "Found model files from the older image in the volume and moved them into /data/Strata-data (no copy, nothing is downloaded again):$legacy_moved"
|
||||
|
||||
# ---- run settings made by an image for another card or another engine version name that image's engine folder
|
||||
# (/opt/strata/components/engine/<package>/...): in this image that folder is not there, so the server would stop at the start. Drop
|
||||
# them; the next step writes them again from the model files, which are kept.
|
||||
for c in /data/install/strata-*.json; do
|
||||
[ -f "$c" ] || continue
|
||||
gone=$("$PYBIN" -c '
|
||||
import json, os, sys
|
||||
def walk(v):
|
||||
if isinstance(v, str):
|
||||
yield v
|
||||
elif isinstance(v, dict):
|
||||
for x in v.values():
|
||||
yield from walk(x)
|
||||
elif isinstance(v, list):
|
||||
for x in v:
|
||||
yield from walk(x)
|
||||
try:
|
||||
cfg = json.load(open(sys.argv[1], encoding="utf-8-sig"))
|
||||
except (OSError, ValueError):
|
||||
sys.exit(0)
|
||||
for s in walk(cfg):
|
||||
if s.startswith("/opt/strata/components/") and not os.path.exists(s):
|
||||
print(s)
|
||||
break
|
||||
' "$c" 2>/dev/null)
|
||||
if [ -n "$gone" ]; then
|
||||
say "The saved run settings $(basename "$c") name $gone, which this image does not have (made by an image for another card or engine version): making them again. The model files are kept."
|
||||
rm -f "$c"
|
||||
fi
|
||||
done
|
||||
|
||||
# ---- is there an engine for this card?
|
||||
phase checking
|
||||
engine_json=$("$STRATA" components engine --output json 2>/dev/null || true)
|
||||
@@ -86,10 +137,13 @@ MSG
|
||||
fi
|
||||
|
||||
# the card is found through sysfs even when no device file was passed in: say so now instead of failing when the engine starts
|
||||
# (before the model is prepared; /dev/dxg is the GPU of Docker Desktop on WSL2)
|
||||
backend=$(printf '%s' "$engine_json" | sed -n 's/.*"backend": *"\([a-z0-9]*\)".*/\1/p' | head -1)
|
||||
dev="${STRATA_DEV_DIR:-/dev}"
|
||||
case "$backend" in
|
||||
hip) [ -e /dev/kfd ] || { echo "[X] This is an AMD card, but /dev/kfd is not in the container. Add: --device /dev/kfd --device /dev/dri --group-add video --group-add <render group number> (docs/DOCKER.md)" >&2; exit 3; } ;;
|
||||
sycl) ls /dev/dri/renderD* >/dev/null 2>&1 || { echo "[X] This is an Intel card, but /dev/dri is not in the container. Add: --device /dev/dri --group-add <render group number> (docs/DOCKER.md)" >&2; exit 3; } ;;
|
||||
cuda) ls "$dev"/nvidia[0-9]* >/dev/null 2>&1 || [ -e "$dev/dxg" ] || { echo "[X] This computer has an NVIDIA card, but the container cannot use it, so nothing would run (and the model would be prepared for nothing). Start the container with: --gpus all (needs the NVIDIA Container Toolkit on the host; docs/DOCKER.md, Troubleshooting)." >&2; exit 3; } ;;
|
||||
hip) [ -e "$dev/kfd" ] || { echo "[X] This is an AMD card, but /dev/kfd is not in the container. Add: --device /dev/kfd --device /dev/dri --group-add video --group-add <render group number> (docs/DOCKER.md)" >&2; exit 3; } ;;
|
||||
sycl) ls "$dev"/dri/renderD* >/dev/null 2>&1 || { echo "[X] This is an Intel card, but /dev/dri is not in the container. Add: --device /dev/dri --group-add <render group number> (docs/DOCKER.md)" >&2; exit 3; } ;;
|
||||
esac
|
||||
|
||||
# ---- the API key
|
||||
@@ -107,6 +161,18 @@ preset_exists=""
|
||||
if "$STRATA" launch --list-presets --output json 2>/dev/null | grep -q "\"name\": *\"$PRESET\""; then preset_exists=1; fi
|
||||
|
||||
model_path="${MODEL_PATH:-${GGUF_DIR:-}}"
|
||||
if [ -n "$model_path" ]; then
|
||||
# a folder that is not mounted (or a typo) must not end as "missing /xxx.gguf" after a minute of setup, and must never turn into a download
|
||||
if [ ! -e "$model_path" ]; then
|
||||
die "MODEL_PATH=$model_path is not in the container, so no model file can be found there. Mount your folder at that place, for example: -v /srv/gguf/IQ3_XXS:$model_path:ro (docs/DOCKER.md, \"Files you already have\"). Nothing was downloaded." 2
|
||||
elif [ -d "$model_path" ] && ! ls "$model_path"/*.gguf >/dev/null 2>&1; then
|
||||
sub=$(find "$model_path" -maxdepth 2 -name '*.gguf' 2>/dev/null | head -1)
|
||||
if [ -n "$sub" ]; then
|
||||
die "MODEL_PATH=$model_path has no .gguf files directly in it, but there are some in ${sub%/*}. Set MODEL_PATH=${sub%/*} (the folder that holds the shards of one model). Nothing was downloaded." 2
|
||||
fi
|
||||
die "MODEL_PATH=$model_path holds no .gguf files. Mount the folder with the model's shards (the -0000N-of-0000M.gguf files). Nothing was downloaded." 2
|
||||
fi
|
||||
fi
|
||||
[ -n "${MODEL:-}" ] && { set -- "$@" --model "$MODEL"; have=1; }
|
||||
[ -n "${FAMILY:-}" ] && { set -- "$@" --family "$FAMILY"; have=1; }
|
||||
[ -n "$model_path" ] && { set -- "$@" --model-path "$model_path"; have=1; }
|
||||
@@ -184,7 +250,10 @@ trap on_term TERM INT
|
||||
RESET_INT='import os, signal, sys; signal.signal(signal.SIGINT, signal.SIG_DFL); os.execv(sys.argv[1], sys.argv[1:])'
|
||||
|
||||
phase preparing
|
||||
say "Starting Strata: ${MODEL:-recommended model}${model_path:+ from $model_path} (preset '$PRESET')."
|
||||
if [ -n "${MODEL:-}" ]; then what="$MODEL${model_path:+ from $model_path}"
|
||||
elif [ -n "$model_path" ]; then what="the model files in $model_path"
|
||||
else what="the recommended model"; fi
|
||||
say "Starting Strata: $what (preset '$PRESET')."
|
||||
if [ -n "$key" ]; then
|
||||
STRATA_LAUNCH_KEY="$key" "$PYBIN" -c "$RESET_INT" "$STRATA" "$@" &
|
||||
else
|
||||
@@ -197,7 +266,7 @@ launch_pid=""
|
||||
[ -n "$stopping" ] && exit 0
|
||||
if [ "$rc" -ne 0 ]; then
|
||||
phase failed
|
||||
die "strata launch stopped with code $rc (the lines above say why). The container ends; a restart continues where it stopped (downloads resume)." "$rc"
|
||||
die "strata launch stopped with code $rc (the lines above say why). The container ends. Fix that and start it again: finished steps are not repeated, and an interrupted download continues where it stopped." "$rc"
|
||||
fi
|
||||
|
||||
# keep the key where `docker exec ... strata monitor` and the health check can read it (private file on the volume)
|
||||
|
||||
+17
-3
@@ -41,7 +41,8 @@ tag if you want updates only when you decide. The examples below use these image
|
||||
|
||||
Each command runs Strata in the background, keeps your files in the volume `strata-data`, and listens only on this computer
|
||||
(`127.0.0.1:8080`). Replace `MODEL` and the key. The first start downloads the model (tens of GB): watch it with
|
||||
`docker logs -f strata`.
|
||||
`docker logs -f strata`. Already have the model's GGUF files? Add `-e MODEL_PATH=/models -v /your/folder:/models:ro` and nothing is
|
||||
downloaded for the model itself ([Files you already have](#files-you-already-have)).
|
||||
|
||||
**NVIDIA**
|
||||
|
||||
@@ -142,6 +143,17 @@ container's user). Nothing large is written anywhere else in the container.
|
||||
Mount the folder with the model's GGUF files read-only and name it: `-v /srv/gguf/IQ3_XXS:/models:ro -e MODEL_PATH=/models
|
||||
-e MODEL=IQ3_XXS`. Nothing is downloaded for the model itself; the prepared pack is made in the volume.
|
||||
|
||||
- The folder holds the shards of one model directly (`...-00001-of-00002.gguf`, `...-00002-of-00002.gguf`), not a folder of folders.
|
||||
If you mount a parent folder, the container says which sub-folder to name in `MODEL_PATH`.
|
||||
- The folder has to be mounted: a `MODEL_PATH` that is not in the container, or a folder with no `.gguf` files, stops the start at
|
||||
once with a message, and nothing is downloaded.
|
||||
- Read-only (`:ro`) is fine. The pack (about 40 GB for IQ3_XXS) and the draft layer (about 6 GB, fetched once) are written to the
|
||||
volume, so it needs that room. With pictures on (the default) the picture reader (0.9 GB) is fetched too; `VISION=off` skips it.
|
||||
- Links to the files work when the links' targets are mounted too, and `MODEL` is set (without `MODEL`, Strata identifies the files itself
|
||||
and does not follow links).
|
||||
- Without `MODEL_PATH`, files you put into the volume by hand (`/data/Strata-data/models/<model folder>/`) are found as well, if they have the
|
||||
published names.
|
||||
|
||||
## The API key
|
||||
|
||||
The server listens on every address **inside** the container (that is what lets the published port work), and Strata does not
|
||||
@@ -260,8 +272,10 @@ package and start through `strata launch`. Mapping:
|
||||
| `HOST` | not needed: the server listens on every address inside the container; choose where it is reachable with `-p` |
|
||||
| `LOW_RAM`, `RESIDENT_BUDGET_GIB`, `KV_STREAMING`, `LAYER_SPLIT`, `CONFIG`, `REINSTALL` | ignored with a warning; use `STRATA_SET` for engine settings and `strata launch --help` for the rest |
|
||||
|
||||
The old volume layout (`/data/config`, `/data/models`) is not read; the model files are found again if you point `MODEL_PATH` at
|
||||
the old model folder. The container name, the volume and the port can stay as they were.
|
||||
A volume from the older image is picked up: the first start moves `/data/models`, `/data/packs` and `/data/mtp` into
|
||||
`/data/Strata-data` (a rename inside the volume: nothing is copied or downloaded again, and the prepared pack is kept). The old
|
||||
`/data/config` is not read; the run settings are made again from the files. A folder you mounted yourself at one of those places
|
||||
is left alone: point `MODEL_PATH` at it. The container name, the volume and the port can stay as they were.
|
||||
|
||||
## Build it yourself
|
||||
|
||||
|
||||
@@ -7663,6 +7663,26 @@ def default_model_name(cfg: dict) -> str:
|
||||
return cfg.get("model_name") or FAMILY_MODEL_NAMES.get(cfg.get("arch") or "qwen4exp", "qwen3.8-flash-next")
|
||||
|
||||
|
||||
def with_current_reader(cfg: dict, package: Path) -> dict:
|
||||
"""The picture reader (vision "exe", "cpu_exe") is written into the run config as an absolute path inside the engine package's folder,
|
||||
and that folder is named after the engine version: after an engine update, or in a container made for another card, the path is gone
|
||||
and the server would stop with "server_exited". Use the same file of the package that is installed now (the reader ships in the package)."""
|
||||
vision = cfg.get("vision")
|
||||
if not isinstance(vision, dict):
|
||||
return cfg
|
||||
fixed = dict(vision)
|
||||
for key in ("exe", "cpu_exe"):
|
||||
old = fixed.get(key)
|
||||
if isinstance(old, str) and old and not engine_component.is_reference(old) and os.path.isabs(old) and not os.path.exists(old):
|
||||
new = package / old.replace("\\", "/").rsplit("/", 1)[-1]
|
||||
if new.is_file():
|
||||
print(f"[strata] the picture reader {old} is not there any more; using {new} from the engine package in use", flush=True)
|
||||
fixed[key] = str(new)
|
||||
if fixed == vision:
|
||||
return cfg
|
||||
return {**cfg, "vision": fixed}
|
||||
|
||||
|
||||
def with_component_engine(cfg: dict) -> dict:
|
||||
"""A run config that names "component:strata-engine" gets the engine package for this PC: the path in `exe`, and
|
||||
the package's own folder first on the library path (the GPU runtime libraries ship beside the binary)."""
|
||||
@@ -7671,6 +7691,7 @@ def with_component_engine(cfg: dict) -> dict:
|
||||
cfg = dict(cfg)
|
||||
cfg["exe"] = _component_exe(cfg["exe"], cfg)
|
||||
cfg["lib_dirs"] = [*engine_component.package_lib_dirs(Path(cfg["exe"]).parent), *(cfg.get("lib_dirs") or [])]
|
||||
cfg = with_current_reader(cfg, Path(cfg["exe"]).parent)
|
||||
if cfg.get("backend") == "hip": # AMD: the package's own hipBLASLt tuning table for this card, when its hipBLASLt version matches
|
||||
cfg = hipblaslt_tuning.apply(cfg, Path(cfg["exe"]).parent, say=lambda line: print(line, flush=True))
|
||||
return cfg
|
||||
|
||||
@@ -510,7 +510,7 @@ def run_launch(a: argparse.Namespace) -> int:
|
||||
sm = store.summary(i)
|
||||
_say(f"{i.name:<28} {sm['model']:<14} {S.context_label(i.context):<6} "
|
||||
f"{(str(i.parallel) + ' request' + ('s' if i.parallel != 1 else '')) if i.parallel else 'fit to card':<14} "
|
||||
f"{('tuned ' + (i.tuned_at or '')) if i.tuned_preset else 'not tuned':<16} {i.last_used or ''}")
|
||||
f"{('tuned ' + (i.tuned_at or '')) if i.is_tuned else 'not tuned':<16} {i.last_used or ''}")
|
||||
return 0
|
||||
if a.delete_preset:
|
||||
store.delete(a.delete_preset)
|
||||
|
||||
@@ -818,6 +818,9 @@ class Runner:
|
||||
return
|
||||
except presets.PresetError:
|
||||
pass
|
||||
elif s.tuned_at: # measured before: the standard settings were already the fastest, nothing was saved
|
||||
self.emit("tune", f"Already tuned on {s.tuned_at}: this computer runs best with the standard settings. Nothing to do.", 100)
|
||||
return
|
||||
mode = "thorough" if s.tune == "thorough" else "quick"
|
||||
status_file = launch_dir() / f"{self.name}.tune.json"
|
||||
try:
|
||||
|
||||
@@ -241,9 +241,9 @@ class StartScreen(Base):
|
||||
for p in self.presets:
|
||||
sm = store.summary(p)
|
||||
req = (f"{p.parallel} request" + ("s" if p.parallel != 1 else "")) if p.parallel else "fit to card"
|
||||
tuned = f"tuned {p.tuned_at[5:]}" if p.tuned_preset and p.tuned_at else "not tuned"
|
||||
tuned = f"tuned {p.tuned_at[5:]}" if p.is_tuned and p.tuned_at else "not tuned"
|
||||
used = f"last used {p.last_used[5:10]}" if p.last_used else "not used yet"
|
||||
items.append(Item([p.name or "?", str(sm["model"]), S.context_label(p.context), req, Cell(tuned, MUTE if not p.tuned_preset else ""),
|
||||
items.append(Item([p.name or "?", str(sm["model"]), S.context_label(p.context), req, Cell(tuned, MUTE if not p.is_tuned else ""),
|
||||
Cell(used, MUTE)], key=("preset", p.name)))
|
||||
items.append(Item([Cell("Set up from the beginning", "")], key=("new", None)))
|
||||
items.append(Item([Cell("Use model files I already have", "")], key=("own", None)))
|
||||
@@ -921,11 +921,11 @@ class TuningScreen(Base):
|
||||
|
||||
def on_mount(self) -> None:
|
||||
s = self.ctx.settings
|
||||
first = self.ctx.fresh_setup and not s.tuned_preset
|
||||
first = self.ctx.fresh_setup and not s.is_tuned
|
||||
items = [Item(["Quick", "about 20 minutes", "checks the most likely gains" + ("; suggested the first time" if first else "")], key="quick"),
|
||||
Item(["Thorough", "up to 2 hours", "tries more settings, measures each one several times"], key="thorough"),
|
||||
Item(["Skip", "", "use the default settings (already good on most computers)"], key="skip")]
|
||||
if not self.ctx.tune_chosen and s.tune == "skip" and not s.tuned_preset and self.ctx.fresh_setup:
|
||||
if not self.ctx.tune_chosen and s.tune == "skip" and not s.is_tuned and self.ctx.fresh_setup:
|
||||
s.tune = "quick"
|
||||
self.query_one(Menu).set_items(items, {"quick": 0, "thorough": 1, "skip": 2}.get(s.tune, 0))
|
||||
self.paint()
|
||||
|
||||
@@ -100,6 +100,12 @@ class LaunchSettings:
|
||||
last_used: str | None = None
|
||||
created: str | None = None
|
||||
|
||||
@property
|
||||
def is_tuned(self) -> bool:
|
||||
"""Tuning was done for this preset: it saved faster settings (tuned_preset), or it measured that the standard settings are already the
|
||||
fastest (only tuned_at is set). Either way the next start must not tune again."""
|
||||
return bool(self.tuned_preset or self.tuned_at)
|
||||
|
||||
def to_dict(self, *, with_key: bool = True) -> dict[str, Any]:
|
||||
d = {"schema": SCHEMA, **asdict(self)}
|
||||
if not with_key:
|
||||
|
||||
@@ -139,5 +139,5 @@ def touch_used(name: str) -> None:
|
||||
def summary(s: LaunchSettings) -> dict[str, Any]:
|
||||
"""The columns of the start screen."""
|
||||
return {"name": s.name, "model": s.model or ("own files" if s.model_path else "-"),
|
||||
"context": s.context, "parallel": s.parallel, "tuned": bool(s.tuned_preset), "tuned_at": s.tuned_at,
|
||||
"context": s.context, "parallel": s.parallel, "tuned": s.is_tuned, "tuned_at": s.tuned_at,
|
||||
"last_used": s.last_used, "access": s.access}
|
||||
@@ -202,6 +202,23 @@ class ComponentStart(unittest.TestCase):
|
||||
server.with_component_engine({"exe": "component:strata-engine", "backend": "cuda"})
|
||||
self.assertEqual(caught.exception.code, 5)
|
||||
|
||||
def test_a_picture_reader_path_from_an_older_engine_folder_follows_the_installed_package(self):
|
||||
"""After an engine update the folder name changes; the run config's absolute vision exe must not stop the server."""
|
||||
from serve import server
|
||||
folder = install_fake_engine(self.components)
|
||||
reader = folder / "strata-vision"
|
||||
reader.write_text("x", encoding="utf-8")
|
||||
gone = str(self.components / "engine" / "0.0.1-old" / "strata-vision")
|
||||
cfg = server.with_component_engine({"exe": "component:strata-engine", "backend": "cuda",
|
||||
"vision": {"exe": gone, "cpu_exe": gone, "mmproj": "/m.gguf"}})
|
||||
self.assertEqual(cfg["vision"]["exe"], str(reader))
|
||||
self.assertEqual(cfg["vision"]["cpu_exe"], str(reader))
|
||||
self.assertEqual(cfg["vision"]["mmproj"], "/m.gguf")
|
||||
ok = {"exe": "component:strata-engine", "backend": "cuda", "vision": {"exe": str(reader)}}
|
||||
self.assertEqual(server.with_component_engine(ok)["vision"], {"exe": str(reader)})
|
||||
none = server.with_component_engine({"exe": "component:strata-engine", "backend": "cuda", "vision": {"exe": gone.replace("strata-vision", "other")}})
|
||||
self.assertTrue(none["vision"]["exe"].endswith("other")) # no such file in the package: left as it is
|
||||
|
||||
def test_the_build_json_lib_dirs_follow_the_package_folder(self):
|
||||
"""The Windows HIP package keeps the ROCm DLLs in rocm/bin (BUILD.json lib_dirs): strata.exe does not load without them on PATH."""
|
||||
from serve import server
|
||||
|
||||
@@ -611,6 +611,20 @@ class AdoptRules(unittest.TestCase):
|
||||
r.check_pictures(path)
|
||||
self.assertEqual(seen, [])
|
||||
|
||||
def test_tuning_that_found_the_standard_settings_fastest_is_not_run_again(self):
|
||||
# "already fastest" saves no tuning preset, only tuned_at: the next start (a container restart with TUNE=quick) must not measure for 20 minutes again
|
||||
with Home():
|
||||
seen = []
|
||||
s = S.LaunchSettings(family="qwen", model="IQ3_XXS", context=32768, tune="quick", tuned_at="2026-10-20")
|
||||
self.assertTrue(s.is_tuned)
|
||||
r = Runner(s, catalog=catalog(HW_12), emit=seen.append)
|
||||
with mock.patch.object(r, "_spawn", side_effect=AssertionError("tuned again")):
|
||||
r.tune()
|
||||
self.assertTrue(any("Already tuned on 2026-10-20" in e.text for e in seen))
|
||||
self.assertFalse(S.LaunchSettings(tune="quick").is_tuned)
|
||||
store.save(s, "Fastest")
|
||||
self.assertTrue(store.summary(store.load("Fastest"))["tuned"])
|
||||
|
||||
def test_runner_adopts_when_setup_cannot_handle_the_card(self):
|
||||
with Home() as h:
|
||||
d, m = self.files(h.base)
|
||||
|
||||
@@ -23,7 +23,7 @@ STUB = r"""#!/bin/sh
|
||||
# records every call; answers the few read-only queries the entrypoint makes
|
||||
echo "$*" >> "$STUB_LOG"
|
||||
case "$1 $2" in
|
||||
"components engine") if [ "${STUB_ENGINE:-ok}" = ok ]; then echo '{"usable": true}'; else echo '{"usable": false}'; echo "no engine for this card" >&2; fi; exit 0 ;;
|
||||
"components engine") if [ "${STUB_ENGINE:-ok}" = ok ]; then echo "{\"usable\": true, \"backend\": \"${STUB_BACKEND:-}\"}"; else echo '{"usable": false}'; echo "no engine for this card" >&2; fi; exit 0 ;;
|
||||
esac
|
||||
case "$*" in
|
||||
*"--list-presets --output json"*) if [ -n "${STUB_PRESET:-}" ]; then echo '{"presets": [{"name": "docker"}]}'; fi; exit 0 ;;
|
||||
@@ -79,11 +79,13 @@ class Entrypoint(unittest.TestCase):
|
||||
return next(line for line in log.splitlines() if line.startswith("launch --no-tui"))
|
||||
|
||||
def test_settings_become_flags_and_sigterm_stops_cleanly(self):
|
||||
(self.tmp / "models").mkdir()
|
||||
(self.tmp / "models" / "m-00001-of-00002.gguf").write_text("x")
|
||||
p = self.start(MODEL="IQ3_XXS", CONTEXT="64k", PARALLEL="2", VISION="yes", TUNE="quick", GPUS="0,1", PORT="8123", PRESET="office",
|
||||
API_KEY="a-long-enough-key-123456", MODEL_PATH="/models", STRATA_SET="prefill=65536 STRATA_PIN_BY_NEED=1")
|
||||
API_KEY="a-long-enough-key-123456", MODEL_PATH=str(self.tmp / "models"), STRATA_SET="prefill=65536 STRATA_PIN_BY_NEED=1")
|
||||
log = self.wait_for("--show-key")
|
||||
line = self.launch_line(log)
|
||||
for want in ("--access lan", "--port 8123", "--model IQ3_XXS", "--model-path /models", "--context 64k", "--parallel 2",
|
||||
for want in ("--access lan", "--port 8123", "--model IQ3_XXS", "--model-path " + str(self.tmp / "models"), "--context 64k", "--parallel 2",
|
||||
"--vision on", "--gpu 0,1", "--tune quick", "--set prefill=65536", "--set STRATA_PIN_BY_NEED=1",
|
||||
"--save-preset office", "--api-key-env STRATA_LAUNCH_KEY"):
|
||||
self.assertIn(want, line)
|
||||
@@ -166,6 +168,101 @@ class Entrypoint(unittest.TestCase):
|
||||
self.stop(p)
|
||||
self.assertTrue((install / "strata-q2_0.json").exists())
|
||||
|
||||
def test_a_volume_of_the_older_image_is_moved_not_downloaded_again(self):
|
||||
data = self.tmp / "data"
|
||||
(data / "models" / "Qwen3.8-Flash-Next-IQ3_XXS").mkdir(parents=True)
|
||||
shard = data / "models" / "Qwen3.8-Flash-Next-IQ3_XXS" / "a-00001-of-00002.gguf"
|
||||
shard.write_text("weights")
|
||||
(data / "models" / "Qwen3.8-Flash-Next-IQ3_XXS" / "a-00001-of-00002.gguf.done").write_text("x")
|
||||
(data / "packs" / "qwen3.8-flash-next-iq3_xxs").mkdir(parents=True)
|
||||
(data / "packs" / "qwen3.8-flash-next-iq3_xxs" / "experts.bin").write_text("pack")
|
||||
(data / "mtp" / "rt").mkdir(parents=True)
|
||||
(data / "mtp" / "rt" / "experts.bin").write_text("mtp")
|
||||
ino = shard.stat().st_ino
|
||||
p = self.start(MODEL="IQ3_XXS")
|
||||
self.wait_for("--show-key")
|
||||
code, out, err = self.stop(p)
|
||||
new = data / "Strata-data"
|
||||
moved = new / "models" / "Qwen3.8-Flash-Next-IQ3_XXS" / "a-00001-of-00002.gguf"
|
||||
self.assertEqual(moved.read_text(), "weights")
|
||||
self.assertEqual(moved.stat().st_ino, ino) # renamed, not copied
|
||||
self.assertTrue((moved.parent / "a-00001-of-00002.gguf.done").exists())
|
||||
self.assertTrue((new / "packs" / "qwen3.8-flash-next-iq3_xxs" / "experts.bin").exists())
|
||||
self.assertTrue((new / "mtp" / "rt" / "experts.bin").exists())
|
||||
self.assertFalse((data / "models").exists())
|
||||
self.assertIn("moved them into", out)
|
||||
|
||||
def test_a_file_already_in_the_new_place_is_never_overwritten(self):
|
||||
data = self.tmp / "data"
|
||||
(data / "models" / "t").mkdir(parents=True)
|
||||
(data / "models" / "t" / "f.gguf").write_text("old")
|
||||
(data / "Strata-data" / "models" / "t").mkdir(parents=True)
|
||||
(data / "Strata-data" / "models" / "t" / "f.gguf").write_text("new")
|
||||
p = self.start(MODEL="IQ3_XXS")
|
||||
self.wait_for("--show-key")
|
||||
self.stop(p)
|
||||
self.assertEqual((data / "Strata-data" / "models" / "t" / "f.gguf").read_text(), "new") # never overwritten
|
||||
self.assertEqual((data / "models" / "t" / "f.gguf").read_text(), "old")
|
||||
|
||||
def test_run_settings_that_name_another_images_engine_folder_are_made_again(self):
|
||||
install = self.tmp / "data" / "install"
|
||||
install.mkdir(parents=True)
|
||||
here = self.tmp / "opt" / "components" / "engine" / "0.1.46-cuda12"
|
||||
here.mkdir(parents=True)
|
||||
(here / "strata-vision").write_text("x")
|
||||
gone = self.tmp / "opt" / "components" / "engine" / "0.1.46-cuda13"
|
||||
(install / "strata-a.json").write_text('{"exe": "component:strata-engine", "vision": {"exe": "%s/strata-vision"}}' % gone)
|
||||
(install / "strata-b.json").write_text('{"exe": "component:strata-engine", "vision": {"exe": "%s/strata-vision"}}' % here)
|
||||
(install / "strata-c.json").write_text('{"exe": "component:strata-engine", "args": []}')
|
||||
(install / "strata-bad.json").write_text("not json")
|
||||
p = self.start(MODEL="IQ3_XXS")
|
||||
self.wait_for("--show-key")
|
||||
code, out, err = self.stop(p)
|
||||
self.assertFalse((install / "strata-a.json").exists())
|
||||
self.assertTrue((install / "strata-b.json").exists())
|
||||
self.assertTrue((install / "strata-c.json").exists())
|
||||
self.assertTrue((install / "strata-bad.json").exists())
|
||||
self.assertIn("strata-a.json", out)
|
||||
self.assertIn("does not have", out)
|
||||
|
||||
def test_nvidia_card_without_gpu_access_ends_before_any_work(self):
|
||||
dev = self.tmp / "dev"
|
||||
dev.mkdir()
|
||||
r = subprocess.run([SH, str(self.script)], env=self.env(STUB_BACKEND="cuda", STRATA_DEV_DIR=str(dev), MODEL="Q2_0"),
|
||||
capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(r.returncode, 3)
|
||||
self.assertIn("--gpus all", r.stderr)
|
||||
self.assertNotIn("launch --no-tui", self.log.read_text())
|
||||
(dev / "nvidia0").write_text("") # with the device files the start goes on
|
||||
p = self.start(STUB_BACKEND="cuda", STRATA_DEV_DIR=str(dev), MODEL="Q2_0")
|
||||
self.wait_for("launch --no-tui")
|
||||
self.stop(p)
|
||||
|
||||
def test_model_path_that_is_not_there_or_empty_ends_the_start_in_plain_words(self):
|
||||
missing = self.tmp / "nothing-mounted"
|
||||
r = subprocess.run([SH, str(self.script)], env=self.env(MODEL="IQ3_XXS", MODEL_PATH=str(missing)), capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(r.returncode, 2)
|
||||
self.assertIn("is not in the container", r.stderr)
|
||||
self.assertIn("-v /srv/gguf/IQ3_XXS:", r.stderr)
|
||||
empty = self.tmp / "empty"
|
||||
(empty / "IQ3_XXS").mkdir(parents=True)
|
||||
r = subprocess.run([SH, str(self.script)], env=self.env(MODEL="IQ3_XXS", MODEL_PATH=str(empty)), capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(r.returncode, 2)
|
||||
self.assertIn("holds no .gguf files", r.stderr)
|
||||
(empty / "IQ3_XXS" / "a-00001-of-00002.gguf").write_text("x")
|
||||
r = subprocess.run([SH, str(self.script)], env=self.env(MODEL="IQ3_XXS", MODEL_PATH=str(empty)), capture_output=True, text=True, timeout=30)
|
||||
self.assertEqual(r.returncode, 2)
|
||||
self.assertIn("Set MODEL_PATH=" + str(empty / "IQ3_XXS"), r.stderr)
|
||||
self.assertNotIn("launch --no-tui", self.log.read_text() if self.log.exists() else "")
|
||||
|
||||
def test_own_files_without_a_model_name_do_not_say_recommended_model(self):
|
||||
(self.tmp / "g").mkdir()
|
||||
(self.tmp / "g" / "m-00001-of-00001.gguf").write_text("x")
|
||||
p = self.start(MODEL_PATH=str(self.tmp / "g"))
|
||||
self.wait_for("--show-key")
|
||||
code, out, err = self.stop(p)
|
||||
self.assertIn("Starting Strata: the model files in " + str(self.tmp / "g"), out)
|
||||
|
||||
def test_other_commands_run_instead_of_the_server(self):
|
||||
r = subprocess.run([SH, str(self.script), "strata", "launch", "--plan", "--model", "q2_0"], env=self.env(), capture_output=True,
|
||||
text=True, timeout=30)
|
||||
|
||||
Reference in new issue
Block a user