mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-06 12:54:19 +01:00
video lane: MiniMax-H3 as a fourth lane, served from the cookbook recipe with no local patch
./install.sh --with-video adds text-to-video with joint video-and-audio (MiniMaxAI/MiniMax-H3, pinned rev), driven like the other three lanes: switcher, stop, start. The unit serves the cookbook's MiniMax-H3 recipe exactly as upstream wrote it (fl2va variant, no placement flags, loopback behind the cockpit's Video tab, which holds the async call to completed and refuses outside the cookbook's bands). Measured on the reference box: boot 11 min, 4 s 480P in 592 s with download proven (h264 + aac stereo, inspected), fl2va conditioning proven from a keyframe. Each addition comes with the tests that hold it; the whole offline suite and ci-local.sh are green with and without it.
This commit is contained in:
1 parent
6f21e1b359
commit
197a3b1a92
35 files changed
+2694
-113
No files matched your search
@@ -688,11 +688,12 @@ jobs:
|
||||
# Two kinds of target since the image lane. The TEXT targets are what
|
||||
# install.sh can serve as its LLM (MODEL_CHOICE) and what the Models tab
|
||||
# builds a recipe for. The SWITCH targets are those plus the lanes a flag
|
||||
# installs, which today is one: `image`, installed by --with-image, switched
|
||||
# to like any other, and not an LLM checkpoint (it has no recipe, no KV pool
|
||||
# and no opencode default). Both sets are asserted, so a lane added to the
|
||||
# installs, which today is two: `image`, installed by --with-image, and
|
||||
# `video`, installed by --with-video, each switched to like any other,
|
||||
# and neither an LLM checkpoint (neither has a recipe, a KV pool
|
||||
# nor an opencode default). Both sets are asserted, so a lane added to the
|
||||
# switcher and forgotten in the cockpit's enum is still caught.
|
||||
FLAG_LANES = ["image"]
|
||||
FLAG_LANES = ["image", "video"]
|
||||
ref = choices
|
||||
switch_ref = sorted(ref + FLAG_LANES)
|
||||
text_lists = {"install.sh MODEL_CHOICE": choices, "recipes BUILTIN_IDS": sorted(builtins)}
|
||||
@@ -1214,9 +1215,11 @@ jobs:
|
||||
allowed = {m.strip() for m in re.findall(r"NOPASSWD:\s*(.+)$", alw, re.M)}
|
||||
stage = dict(re.findall(r'^(STAGE_UNIT|STAGE_CEIL)="\$CONFIG_DIR/([^"]+)"', script, re.M))
|
||||
units = {"qwen38-sglang.service", "qwen38-flash.service"}
|
||||
engines = units | {"qwen38-image.service", "qwen38-video.service"}
|
||||
values = {
|
||||
"TEXT_UNIT_NAME": units, "TARGET_UNIT_NAME": units, "OTHER_UNIT_NAME": units,
|
||||
"TEXT_UNIT_NAME": engines, "TARGET_UNIT_NAME": units, "OTHER_UNIT_NAME": engines,
|
||||
"IMAGE_UNIT_NAME": {"qwen38-image.service"},
|
||||
"VIDEO_UNIT_NAME": {"qwen38-video.service"},
|
||||
"TARGET_UNIT": {re.search(r'^SGL_UNIT="([^"]+)"', script, re.M).group(1)},
|
||||
"STAGE_UNIT": {"__HOME__/.config/qwen38/" + stage["STAGE_UNIT"]},
|
||||
"STAGE_CEIL": {"__HOME__/.config/qwen38/" + stage["STAGE_CEIL"]},
|
||||
@@ -1343,9 +1346,13 @@ jobs:
|
||||
bad.append(var)
|
||||
# The image lane's checkpoint is pinned by install-image.sh, not install.sh, and
|
||||
# was the one the inventory missed (2026-09-23: 31 GB left behind, unnamed).
|
||||
# The video lane's checkpoint is pinned by install-video.sh the same way.
|
||||
m = re.search(r'\bMODEL="\$\{MODEL:-([^}]+)\}"', pathlib.Path("install-image.sh").read_text())
|
||||
if not m or m.group(1) not in un.split('HF_REPOS="', 1)[-1].split('"', 1)[0].split():
|
||||
bad.append("install-image.sh MODEL")
|
||||
m = re.search(r'\bMODEL="\$\{MODEL:-([^}]+)\}"', pathlib.Path("install-video.sh").read_text())
|
||||
if not m or m.group(1) not in un.split('HF_REPOS="', 1)[-1].split('"', 1)[0].split():
|
||||
bad.append("install-video.sh MODEL")
|
||||
if bad:
|
||||
print("install.sh pins missing from uninstall.sh inventory:")
|
||||
print("\n".join(" " + b for b in bad)); sys.exit(1)
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased: the MiniMax-H3 video lane (fourth lane, opt-in)
|
||||
|
||||
`./install.sh --with-video` adds text-to-video with joint video-and-audio
|
||||
(MiniMax-H3, `MiniMaxAI/MiniMax-H3` at `42ed227e`), driven like the other three lanes:
|
||||
switcher, stop, start, about 12 min to ready. It serves the SGLang cookbook's MiniMax-H3
|
||||
recipe exactly as upstream wrote it at the pinned source commit, with no local patch:
|
||||
no placement flags (the cookbook verifies the DGX Spark with none, and the offload flags
|
||||
measured 2.1x slower there), `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`, loopback
|
||||
bind behind the cockpit's Video tab. The tab holds the asynchronous call (create, poll to
|
||||
completed, download) and refuses outside the cookbook's bands (4 to 15 s, one video per
|
||||
call, t2v/fl2va on the fl2va weights). The cookbook's Spark figures are quoted as the
|
||||
cookbook's until the lane proves itself here. Each addition comes with the tests that
|
||||
hold it, checked by running the whole offline suite with and without it.
|
||||
|
||||
## v1.18.7 (2026-09-24): a full review of v1.18.6, and the defects it found fixed with a test each
|
||||
|
||||
A line-by-line review of the whole repo at v1.18.6 (code, templates, tests, CI and docs)
|
||||
|
||||
@@ -31,6 +31,7 @@ happens to exist.
|
||||
| draft | RadixArk/Qwen3.8-27B-DSpark | not yet checked |
|
||||
| draft2 | maurienne-ai/Qwen3.8-27B-DFlash2-NVFP4-RTNcal | not yet checked: verify both layers |
|
||||
| qwen-image | Qwen/Qwen-Image-2.1 | not yet checked |
|
||||
| minimax-h3 | MiniMaxAI/MiniMax-H3 | not yet checked: own licence, read it before any redistribution |
|
||||
| images (2) | lmsysorg/sglang@sha256:... | copied whole by digest: the Apache-2.0 SGLang images carry their license inside; keep it there |
|
||||
|
||||
No row is a conclusion until this table says one, with a date.
|
||||
|
||||
@@ -295,6 +295,28 @@ reference, prompt, step count and guidance setting). Licence: Qwen Research, **n
|
||||
|
||||
Every number, every refusal and how the runtime is pinned: **[docs/image-lane.md](docs/image-lane.md)**.
|
||||
|
||||
## Videos: MiniMax-H3 on the same box (opt-in)
|
||||
|
||||
`./install.sh --with-video` adds a video lane beside the other three: text to video with
|
||||
joint video-and-audio, plus first/last-frame conditioning. It is opt-in because it costs
|
||||
about 150 GB of headroom and an hour or more, and once installed a
|
||||
plain re-run keeps it.
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/hasso5703/dgx-spark-qwen38/main/get.sh | bash -s -- --with-video
|
||||
```
|
||||
|
||||
Then it is a fourth lane, driven like the other three: pick **MiniMax-H3** in the cockpit's
|
||||
switcher, **Switch**, stop the serving lane, **Start MiniMax-H3** (about 12 min). From a terminal,
|
||||
`./switch-model.sh video` does the switch and prints the rest.
|
||||
|
||||
It serves the SGLang cookbook's MiniMax-H3 recipe exactly as upstream wrote it, with no local
|
||||
patch: the cookbook verifies about 12.1 s per denoise step, about 40 s of decode and about
|
||||
12 min per warm 4 s 480P request on the DGX Spark, with no flags at all. One request at a
|
||||
time; the Video tab refuses a second one, and a duration outside the cookbook's 4 to 15 s band.
|
||||
|
||||
Every number, every refusal and how the runtime is pinned: **[docs/video-lane.md](docs/video-lane.md)**.
|
||||
|
||||
## The 1M context mode
|
||||
|
||||
Since v1.12.1 a plain 27B install serves a **1,010,000-token window** (YaRN static scaling, the
|
||||
@@ -586,7 +608,7 @@ question you had when you opened the page.
|
||||
| **Models** | Every target as data: recipes, drift against what is running, registry of what is on disk, upstream watch, full inventory | Read what is installed and what it costs in bytes; rescan (the panels are read-only: `./uninstall.sh --list` shows the same inventory, and `./uninstall.sh` prints the reclaim commands) |
|
||||
| **System One** | The typed-decisions endpoint, from a browser: is it served, and what does it answer? | Ask the lane with prefilled examples, copy the matching curl, read the probabilities |
|
||||
| **Image** | Qwen-Image 2.1, when it is the serving lane: generation, editing with up to ten references, native RGBA | Generate and edit at the model's defaults (**Reset settings**), start from the sample prompts, follow each stage of a request, copy the matching curl |
|
||||
| **Video** | Nothing yet, and it says so | |
|
||||
| **Video** | MiniMax-H3, when it is the serving lane: text to video with joint video-and-audio, first/last-frame conditioning | Generate at the cookbook's defaults (**Reset settings**), follow the request to completed, play and download the MP4, copy the matching curl |
|
||||
| **Logs** | Live logs, the last 30 events, recent jobs | Tail or follow a service's log, read what each recent job printed |
|
||||
| **Setup** | The repo itself, opencode integration, whether a newer release is out, the cockpit's own settings | Fit opencode's limits to the engine that serves; copy the command that updates the stack, which runs in a terminal because the installer needs an interactive sudo |
|
||||
|
||||
|
||||
+3
-3
@@ -114,8 +114,8 @@ names, header hygiene) are property-tested.
|
||||
|
||||
**The installer (`install.sh`, `dashboard/install-*.sh`)** runs things you
|
||||
sudo. Every pinned byte is hash-verified: images by digest, checkpoints by
|
||||
pinned revision, the opencode release by its sha256. The image lane
|
||||
(`--with-image`) is the one part with unpinned bytes: its SGLang wheel, source
|
||||
pinned revision, the opencode release by its sha256. The image and video lanes
|
||||
(`--with-image`, `--with-video`) are the parts with unpinned bytes: their SGLang wheel, source
|
||||
commit and checkpoint revision are pinned, but pip resolves the wheel's dependency tree
|
||||
from PyPI at install time, with no hash checked. The engine enforces its key, read from a file created
|
||||
0600 and handed to it through SGLang's `--config`, so it is in no process's command line and the chat template and launcher are regenerated from the
|
||||
@@ -157,7 +157,7 @@ discussion, not a disclosure.
|
||||
readable by anything that can reach the proxy port. That is the port's
|
||||
existing trust model (a trusted network by design, see the plain HTTP edge
|
||||
above); the metrics endpoint adds counters to it, not a new surface to
|
||||
authenticate against. The image lane exports no metrics.
|
||||
authenticate against. The image and video lanes export no metrics.
|
||||
- **The cockpit assumes one admin user.** The sudo allowlist covers this
|
||||
repo's argv, but a hostile local user with your shell can do what you can
|
||||
do: this box is yours, and it is not a multi-tenant host.
|
||||
|
||||
+10
-2
@@ -31,6 +31,10 @@ more="$(grep -E '^(OPENCODE_VERSION|OPENCODE_SHA256)=' "$REPO_DIR/install.sh")"
|
||||
eval "$more"
|
||||
lane="$(grep -E '^(IMAGE_MODEL_PIN|IMAGE_MODEL_PIN_REV|PIN|WHEEL)=' "$REPO_DIR/install-image.sh")"
|
||||
eval "$lane"
|
||||
IMAGE_PIN="$PIN"; IMAGE_WHEEL="$WHEEL"
|
||||
vline="$(grep -E '^(VIDEO_MODEL_PIN|VIDEO_MODEL_PIN_REV|PIN|WHEEL)=' "$REPO_DIR/install-video.sh")"
|
||||
eval "$vline"
|
||||
VIDEO_PIN="$PIN"; VIDEO_WHEEL="$WHEEL"
|
||||
|
||||
# Hugging Face answers an anonymous request with 401 both for a gated repo and for one that
|
||||
# does not exist (or is private): only its x-error-code tells a gated repo apart, so the
|
||||
@@ -155,8 +159,12 @@ check_model dspark-draft "$DRAFT_REPO" "$DRAFT_REV"
|
||||
|
||||
echo "Image lane and opencode"
|
||||
check_model qwen-image "$IMAGE_MODEL_PIN" "$IMAGE_MODEL_PIN_REV" model_index.json
|
||||
check_commit sglang-source sgl-project/sglang "$PIN"
|
||||
check_wheel sglang-wheel sglang "$WHEEL"
|
||||
check_commit sglang-source sgl-project/sglang "$IMAGE_PIN"
|
||||
check_wheel sglang-wheel sglang "$IMAGE_WHEEL"
|
||||
echo "Video lane"
|
||||
check_model minimax-h3 "$VIDEO_MODEL_PIN" "$VIDEO_MODEL_PIN_REV" model_index.json
|
||||
check_commit sglang-source-video sgl-project/sglang "$VIDEO_PIN"
|
||||
check_wheel sglang-wheel-video sglang "$VIDEO_WHEEL"
|
||||
check_asset opencode anomalyco/opencode "v$OPENCODE_VERSION" opencode-linux-arm64.tar.gz "$OPENCODE_SHA256"
|
||||
|
||||
echo "Images"
|
||||
|
||||
+478
-22
@@ -28,6 +28,7 @@ import subprocess
|
||||
import threading
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
from collections import deque
|
||||
@@ -80,8 +81,8 @@ DRY_RUN = os.environ.get("COCKPIT_DRY_RUN", "0") == "1"
|
||||
MASKED_FIELDS = {"api_key", "admin_api_key"}
|
||||
|
||||
UNITS = ("qwen38-sglang.service", "qwen38-flash.service", "qwen38-image.service",
|
||||
"qwen38-keepalive.service")
|
||||
JOURNAL_UNITS = UNITS + (AGENT_UNIT,) # what the Logs tab may read (UNITS carries the image lane)
|
||||
"qwen38-video.service", "qwen38-keepalive.service")
|
||||
JOURNAL_UNITS = UNITS + (AGENT_UNIT,) # what the Logs tab may read (UNITS carries the image and video lanes)
|
||||
CONTAINERS = ("qwen38-sglang", "qwen38-flash")
|
||||
|
||||
UNIT2CONT = {"qwen38-sglang.service": "qwen38-sglang",
|
||||
@@ -567,6 +568,8 @@ LAST_PROGRESS: dict = {"ts": None}
|
||||
UNHEALTHY_TICKS: dict = {} # per unit: consecutive ticks with health down
|
||||
IMAGE_READY_ENTER: dict = {} # image lane: the activation (enter timestamp) it served in
|
||||
IMAGE_INVOCATION: dict = {} # image lane: its current systemd invocation, whose journal is its own
|
||||
VIDEO_READY_ENTER: dict = {} # video lane: the activation (enter timestamp) it served in
|
||||
VIDEO_INVOCATION: dict = {} # video lane: its current systemd invocation, whose journal is its own
|
||||
BOOT_SEEN: dict = {} # text lanes: (activation, last boot parse that had evidence)
|
||||
BOOT_HEAD_READ: dict = {} # text lanes: the activation whose first minutes were read once
|
||||
POOL_GUARD = os.environ.get("COCKPIT_POOL_GUARD", "1") == "1"
|
||||
@@ -1157,6 +1160,11 @@ def unit_target(unit: str) -> dict:
|
||||
model = _image_unit_flag("--model-path", "Qwen/Qwen-Image-2.1") \
|
||||
if IMAGE_UNIT_PATH.exists() else None
|
||||
return {"model": model, "target": "image" if model else None}
|
||||
if unit == "qwen38-video.service":
|
||||
# one checkpoint, one target, same rule as the image lane
|
||||
model = _video_unit_flag("--model-path", "MiniMaxAI/MiniMax-H3") \
|
||||
if VIDEO_UNIT_PATH.exists() else None
|
||||
return {"model": model, "target": "video" if model else None}
|
||||
path = UNIT_PATHS.get(unit)
|
||||
if not path:
|
||||
return {"model": None, "target": None}
|
||||
@@ -1212,7 +1220,8 @@ def collect_lifecycle():
|
||||
states[unit] = "ready" if active == "active" else "stopped"
|
||||
continue
|
||||
is_image = unit == lc.IMAGE_UNIT
|
||||
if is_image and not IMAGE_UNIT_PATH.exists():
|
||||
is_video = unit == lc.VIDEO_UNIT
|
||||
if (is_image or is_video) and not (IMAGE_UNIT_PATH.exists() if is_image else VIDEO_UNIT_PATH.exists()):
|
||||
continue # not installed: no card, no pill, no gate
|
||||
boot = {"stage": None, "fired_up": False, "done": []}
|
||||
if is_image:
|
||||
@@ -1220,11 +1229,16 @@ def collect_lifecycle():
|
||||
unit, active=active, sub=d.get("SubState", "?"), prev_state=prev.get(unit),
|
||||
enter_key=d.get("ActiveEnterTimestampMonotonic", "0"),
|
||||
invocation=d.get("InvocationID", ""))
|
||||
elif is_video:
|
||||
st, boot, running = video_engine_state(
|
||||
unit, active=active, sub=d.get("SubState", "?"), prev_state=prev.get(unit),
|
||||
enter_key=d.get("ActiveEnterTimestampMonotonic", "0"),
|
||||
invocation=d.get("InvocationID", ""))
|
||||
else:
|
||||
cont = UNIT2CONT[unit]
|
||||
running = bool(run(["docker", "ps", "-q", "-f",
|
||||
f"name=^{cont}$"]).strip())
|
||||
if not is_image and running and not healthy:
|
||||
if not is_image and not is_video and running and not healthy:
|
||||
# A mature server's tail is pure decode noise: only read logs
|
||||
# while health is down (boot or trouble), where markers live.
|
||||
tail = run(["docker", "logs", "--tail", "300", cont],
|
||||
@@ -1260,13 +1274,13 @@ def collect_lifecycle():
|
||||
# Hysteresis: a 2 s health probe times out under a heavy prefill.
|
||||
# Leaving ready needs 3 consecutive misses AND no fresh progress line;
|
||||
# a single 200 restores it at once.
|
||||
if is_image:
|
||||
pass # its state was derived above, from its own facts
|
||||
if is_image or is_video:
|
||||
pass # their state was derived above, from their own facts
|
||||
elif healthy:
|
||||
UNHEALTHY_TICKS[unit] = 0
|
||||
else:
|
||||
UNHEALTHY_TICKS[unit] = UNHEALTHY_TICKS.get(unit, 0) + 1
|
||||
if not is_image:
|
||||
if not is_image and not is_video:
|
||||
progressing = LAST_PROGRESS["ts"] and time.time() - LAST_PROGRESS["ts"] < 30
|
||||
sticky_ready = (prev.get(unit) in ("ready", "wedged") and running and not healthy
|
||||
and (UNHEALTHY_TICKS[unit] < 3 or progressing))
|
||||
@@ -1279,7 +1293,7 @@ def collect_lifecycle():
|
||||
# (wedged is only reachable from ready, so an engine that was wedged has served)
|
||||
if st["state"] == "degraded" and prev.get(unit) not in ("ready", "degraded", "wedged"):
|
||||
st["state"] = "warming-up"
|
||||
if st["state"] == "ready" and not is_image:
|
||||
if st["state"] == "ready" and not is_image and not is_video:
|
||||
with STATE_LOCK:
|
||||
load = ((STATE.get("engine_fast") or {}).get("data", {})
|
||||
.get("load") or [{}])[0]
|
||||
@@ -1416,9 +1430,9 @@ def collect_lifecycle():
|
||||
"stage_done": boot.get("done", []),
|
||||
# which stage list this engine walks, and what it is loading
|
||||
# now: the UI draws each from here rather than assuming
|
||||
"stages": list(lc.IMAGE_STAGES if is_image else lc.STAGES),
|
||||
"detail": boot.get("detail", ""),
|
||||
"kind": "image" if is_image else "text",
|
||||
"stages": list(lc.VIDEO_STAGES if is_video else lc.IMAGE_STAGES if is_image else lc.STAGES),
|
||||
"detail": boot.get("detail", ""),
|
||||
"kind": "video" if is_video else "image" if is_image else "text",
|
||||
# systemd's own word for how the last run ended: "timeout" is a
|
||||
# unit killed because it did not stop in time, not one that crashed
|
||||
"result": d.get("Result", ""),
|
||||
@@ -1438,9 +1452,9 @@ def collect_lifecycle():
|
||||
if st["state"] == "ready" and elapsed and witnessed \
|
||||
and was in lc.TRANSITIONAL:
|
||||
history = lc.record_boot(history, unit, elapsed)
|
||||
if is_image:
|
||||
# It has no KV pool, and ENGINE_BASE is the text lane's port: reading
|
||||
# a pool here would record the wrong engine's, or nothing.
|
||||
if is_image or is_video:
|
||||
# Neither has a KV pool, and ENGINE_BASE is the text lane's port:
|
||||
# reading a pool here would record the wrong engine's, or nothing.
|
||||
save_history(history)
|
||||
with LIFE_LOCK:
|
||||
LIFE["witnessed"][unit] = False
|
||||
@@ -1559,10 +1573,11 @@ def sampler(period: float, collectors: dict):
|
||||
AUDIT_LOG = CONFIG_DIR / "cockpit-audit.log"
|
||||
|
||||
# The image lane is here because a cockpit whose Image tab tells you to open a terminal
|
||||
# is not a cockpit. Starting it stops the text lane (the unit's own Conflicts=), which is
|
||||
# why the modal says so before it runs.
|
||||
# is not a cockpit, and the video lane for the same reason. Starting either stops the
|
||||
# text lane (each unit's own Conflicts=), which is why the modal says so before it runs.
|
||||
SERVING_UNITS = {"qwen38-sglang.service", "qwen38-flash.service",
|
||||
"qwen38-keepalive.service", "qwen38-image.service", AGENT_UNIT}
|
||||
"qwen38-keepalive.service", "qwen38-image.service",
|
||||
"qwen38-video.service", AGENT_UNIT}
|
||||
UNIT_VERBS = {"start", "stop", "restart"}
|
||||
|
||||
ACTIONS = {
|
||||
@@ -1578,7 +1593,7 @@ ACTIONS = {
|
||||
"switch": {
|
||||
"danger": "medium",
|
||||
"params": {"target": ["stock", "uncensored", "fp8", "uncensored-fp8",
|
||||
"flash", "flash-nvda", "flash-uncensored", "image"]},
|
||||
"flash", "flash-nvda", "flash-uncensored", "image", "video"]},
|
||||
"argv": lambda p: ["bash", str(REPO_DIR / "switch-model.sh"), p["target"]],
|
||||
# A switch can download a whole checkpoint: 124 GB for flash take about 23 min at
|
||||
# the 89 MB/s the reference box gets, so 30 min failed it on any slower link, and
|
||||
@@ -2368,6 +2383,425 @@ def _multipart(fields: dict, images: list) -> tuple[bytes, str]:
|
||||
return bytes(out), f"multipart/form-data; boundary={boundary}"
|
||||
|
||||
|
||||
# ── the video lane ──────────────────────────────────────────────────────────────
|
||||
# MiniMax-H3, served by SGLang Diffusion in its own venv on its own port, installed
|
||||
# by ./install.sh --with-video. Same shape as the image lane: the browser never holds
|
||||
# the serving key (the diffusion runtime has none) and never talks to the lane; it
|
||||
# sends a description of the call and this process makes it.
|
||||
#
|
||||
# One difference from images: creation is asynchronous. POST /v1/videos answers 200
|
||||
# with an id in a queued state, the lane works for minutes, and GET /v1/videos/{id}
|
||||
# (polled here through the list) says when it is completed. So this process holds
|
||||
# the call from the create to the download, the way the image call holds one from
|
||||
# the POST to the pixels.
|
||||
VIDEO_UNIT = "qwen38-video.service"
|
||||
VIDEO_UNIT_PATH = Path("/etc/systemd/system/qwen38-video.service")
|
||||
# A prompt plus two keyframes at most; the MP4 itself travels back as a download,
|
||||
# never inside a JSON body.
|
||||
VIDEO_MAX_POST = 10 * 1024 * 1024
|
||||
# About 12 min per 4 s 480P request on the reference box, plus the queue ahead of it
|
||||
# and the download after: a call past this stops waiting here, not on the lane (which
|
||||
# has no abort and goes on). 60 min covers the cookbook's longest official duration
|
||||
# (15 s). The cookbook's duration band is 4 to 15 s.
|
||||
VIDEO_TIMEOUT = 3600.0
|
||||
# This lane serves ONE request at a time, and that is caution, not a measurement: the
|
||||
# cookbook sizes one 480P request near what this box holds, and on unified memory
|
||||
# running out hangs the machine rather than failing the request. The refusal below is
|
||||
# instant and says why. Re-measure with two overlapping calls before ever lifting it.
|
||||
VIDEO_LOCK = threading.Lock()
|
||||
VIDEO_POLL_S = 10.0
|
||||
VIDEO_LAST: dict = {} # the call in flight or just finished: {id, status, seconds}
|
||||
|
||||
|
||||
VIDEO_UNIT_CACHE: dict = {}
|
||||
|
||||
|
||||
def _video_unit_text() -> str:
|
||||
"""The unit's text, read once per mtime: the lifecycle tick, the status call and
|
||||
the tab's poll each ask for the port, the bind, the model and the variant, several
|
||||
times a second between them. Empty when the unit is absent or unreadable."""
|
||||
try:
|
||||
key = (str(VIDEO_UNIT_PATH), VIDEO_UNIT_PATH.stat().st_mtime_ns)
|
||||
except OSError:
|
||||
return ""
|
||||
hit = VIDEO_UNIT_CACHE.get("unit")
|
||||
if hit and hit[0] == key:
|
||||
return hit[1]
|
||||
try:
|
||||
text = VIDEO_UNIT_PATH.read_text(errors="replace")
|
||||
except OSError:
|
||||
return ""
|
||||
VIDEO_UNIT_CACHE["unit"] = (key, text)
|
||||
return text
|
||||
|
||||
|
||||
def _video_unit_flag(flag: str, fallback: str) -> str:
|
||||
"""What the installed unit passes, not what this file assumes."""
|
||||
for line in _video_unit_text().splitlines():
|
||||
if flag in line:
|
||||
return line.split(flag, 1)[1].split()[0]
|
||||
return fallback
|
||||
|
||||
|
||||
def video_port() -> int:
|
||||
try:
|
||||
return int(_video_unit_flag("--port", "30022"))
|
||||
except ValueError:
|
||||
return 30022
|
||||
|
||||
|
||||
def video_base() -> str:
|
||||
host = _video_unit_flag("--host", "127.0.0.1")
|
||||
return os.environ.get("COCKPIT_VIDEO", f"http://{host}:{video_port()}")
|
||||
|
||||
|
||||
VIDEO_JOURNAL_LINES = 300
|
||||
|
||||
|
||||
def _video_journal(invocation: str) -> list:
|
||||
"""This run's log, and only this run's: the lines of the unit's current systemd
|
||||
invocation. Same latest-boot trap as the image lane: a new process takes seconds
|
||||
to print its first line, and until it does the tail is the previous run's."""
|
||||
if not invocation:
|
||||
return []
|
||||
raw = run(["journalctl", f"_SYSTEMD_INVOCATION_ID={invocation}",
|
||||
"-n", str(VIDEO_JOURNAL_LINES), "--no-pager", "-o", "cat"], timeout=8.0)
|
||||
return raw.splitlines()
|
||||
|
||||
|
||||
def video_healthy() -> bool:
|
||||
"""The video lane's own /health, on its own port. Only a 200 is ready."""
|
||||
try:
|
||||
urllib.request.urlopen(urllib.request.Request(video_base() + "/health"),
|
||||
timeout=3).read()
|
||||
return True
|
||||
except Exception: # noqa: BLE001 (any non-200 is "not yet")
|
||||
return False
|
||||
|
||||
|
||||
def video_engine_state(unit: str, *, active: str, sub: str, prev_state: str | None,
|
||||
enter_key: str, invocation: str = "") -> tuple:
|
||||
"""(state, boot, running) for the video lane, from its own facts: the unit, its own
|
||||
/health, and its journal while it boots. None of the text lanes' belts apply to it
|
||||
(pool guard, generation canary, autoheal): they all talk to ENGINE_BASE.
|
||||
|
||||
Same one-miss-keeps-ready rule as the image lane: once the lane has served in this
|
||||
activation it does not go back to booting on a slow probe."""
|
||||
running = active in ("active", "activating")
|
||||
healthy = running and video_healthy()
|
||||
VIDEO_INVOCATION[unit] = invocation
|
||||
UNHEALTHY_TICKS[unit] = 0 if healthy else UNHEALTHY_TICKS.get(unit, 0) + 1
|
||||
served_here = VIDEO_READY_ENTER.get(unit) == enter_key and enter_key != "0"
|
||||
boot = {"stage": None, "fired_up": False, "done": []}
|
||||
if running and not healthy:
|
||||
if served_here:
|
||||
boot = {"stage": "warming-up", "fired_up": True, "done": list(lc.VIDEO_STAGES)}
|
||||
healthy = UNHEALTHY_TICKS[unit] < 3
|
||||
else:
|
||||
boot = lc.parse_video_boot_log(_video_journal(invocation))
|
||||
st = lc.derive_state(unit_active=active, unit_sub=sub, container_running=running,
|
||||
healthy=healthy, boot=boot)
|
||||
if st["state"] == "degraded" and prev_state not in ("ready", "degraded"):
|
||||
st["state"] = "warming-up"
|
||||
if st["state"] == "ready":
|
||||
VIDEO_READY_ENTER[unit] = enter_key
|
||||
return st, boot, running
|
||||
|
||||
|
||||
def video_status() -> dict:
|
||||
"""What the Video tab needs that the lifecycle does not already carry: where the
|
||||
lane listens, which model and variant its unit serves, and the call in flight."""
|
||||
out = {"installed": VIDEO_UNIT_PATH.exists(), "port": video_port(),
|
||||
"host": _video_unit_flag("--host", "127.0.0.1"),
|
||||
"model": _video_unit_flag("--model-path", "MiniMaxAI/MiniMax-H3"),
|
||||
"variant": _video_unit_flag("--model-variant", "fl2va"),
|
||||
"state": "not installed", "available": False, "llm_lane": "", "progress": {}}
|
||||
if not out["installed"]:
|
||||
return out
|
||||
with LIFE_LOCK:
|
||||
states = dict(LIFE.get("states", {}))
|
||||
# before the lifecycle's first tick (a cockpit that just started) nothing is known
|
||||
# yet, and saying so beats guessing "stopped" at a lane that may be serving
|
||||
out["state"] = states.get(VIDEO_UNIT) or "unknown"
|
||||
out["available"] = out["state"] in ("ready", "degraded")
|
||||
out["llm_lane"] = next((u for u in lc.TEXT_UNITS if states.get(u) in lc.BUSY_STATES), "")
|
||||
if out["available"]:
|
||||
out["progress"] = dict(VIDEO_LAST) if VIDEO_LAST.get("status") not in ("completed", "failed", "") else {}
|
||||
return out
|
||||
|
||||
|
||||
def _video_life() -> tuple:
|
||||
"""(ActiveState, InvocationID) of the video unit, asked of systemd directly: the
|
||||
lifecycle ticks every 2 s, and the question is whether THIS request outlived its lane."""
|
||||
raw = run(["systemctl", "show", VIDEO_UNIT, "-p", "ActiveState,InvocationID"], timeout=5)
|
||||
d = dict(ln.split("=", 1) for ln in raw.splitlines() if "=" in ln)
|
||||
return d.get("ActiveState", ""), d.get("InvocationID", "")
|
||||
|
||||
|
||||
VIDEO_INTERRUPTED = ("the video lane was stopped or restarted while this video was being made, which is "
|
||||
"the only way this runtime can end a generation early (it has no abort); nothing was kept")
|
||||
VIDEO_CRASHED = ("the video lane crashed while this video was being made (systemd: {result}), and nothing "
|
||||
"was kept. Its journal, in the Logs tab, says why; systemd starts it again by itself.")
|
||||
# How a run that ended under a request ended: same rule as the image lane.
|
||||
VIDEO_CRASH_RESULTS = {"signal", "core-dump", "oom-kill", "watchdog"}
|
||||
|
||||
|
||||
def _video_exit() -> dict:
|
||||
"""SubState and Result of the video unit, asked of systemd once a request was cut."""
|
||||
raw = run(["systemctl", "show", VIDEO_UNIT, "-p", "SubState,Result,NRestarts"], timeout=5)
|
||||
return dict(ln.split("=", 1) for ln in raw.splitlines() if "=" in ln)
|
||||
|
||||
|
||||
def _video_cut(t0: float) -> tuple[int, dict]:
|
||||
"""The answer for a request whose run of the lane ended under it."""
|
||||
ex = _video_exit()
|
||||
secs = round(time.time() - t0, 2)
|
||||
if ex.get("SubState") == "auto-restart" or ex.get("Result") in VIDEO_CRASH_RESULTS:
|
||||
return 502, {"error": VIDEO_CRASHED.format(result=ex.get("Result") or "died"), "crashed": True,
|
||||
"seconds": secs}
|
||||
return 503, {"error": VIDEO_INTERRUPTED, "interrupted": True, "seconds": secs}
|
||||
VIDEO_STILL_RUNNING = ("the video lane is still generating this request: it has no abort, so it goes on after "
|
||||
"this page stopped waiting, and the next request is refused until it ends. Cancel "
|
||||
"restarts the lane if it should not finish.")
|
||||
|
||||
|
||||
def _video_decoded_frame(payload: dict, name: str) -> tuple[bytes | None, str]:
|
||||
"""One keyframe data URL, as bytes. Absent is fine (text-only); malformed is refused."""
|
||||
ref = payload.get(name)
|
||||
if ref is None:
|
||||
return None, ""
|
||||
if not isinstance(ref, str) or not ref.startswith("data:image/"):
|
||||
return None, f"{name} is not an image data URL"
|
||||
head, _, b64 = ref.partition(",")
|
||||
if ";base64" not in head or not b64:
|
||||
return None, f"{name} is not base64"
|
||||
try:
|
||||
raw = base64.b64decode(b64, validate=True)
|
||||
except Exception: # noqa: BLE001
|
||||
return None, f"{name} is not valid base64"
|
||||
if not raw:
|
||||
return None, f"{name} is empty"
|
||||
return raw, ""
|
||||
|
||||
|
||||
# Only what this model accepts, and nothing that lets a browser reach past the lane.
|
||||
VIDEO_ALLOWED = {"model", "prompt", "seconds", "size", "task", "target", "quality",
|
||||
"num_outputs_per_prompt", "num_inference_steps", "flow_shift",
|
||||
"audio_flow_shift", "seed"}
|
||||
|
||||
|
||||
def _video_list_status(vid: str) -> str:
|
||||
"""This video's status from the lane's list, or "unknown" when the lane says nothing."""
|
||||
try:
|
||||
with urllib.request.urlopen(urllib.request.Request(video_base() + "/v1/videos"),
|
||||
timeout=20) as r:
|
||||
items = json.loads(r.read().decode()).get("data", [])
|
||||
except Exception: # noqa: BLE001 (the poll below retries)
|
||||
return "unknown"
|
||||
return next((v.get("status", "unknown") for v in items if v.get("id") == vid), "missing")
|
||||
|
||||
|
||||
def _release_video_lock_when_done(life0: tuple, vid: str, since: float) -> None:
|
||||
"""The lock of a call that timed out here, given back when the lane is done with
|
||||
it: the video reached a terminal status, or the lane is no longer the run the call
|
||||
went to (a Cancel, a Stop, a crash), or another VIDEO_TIMEOUT went by with neither."""
|
||||
deadline = time.time() + VIDEO_TIMEOUT
|
||||
try:
|
||||
while time.time() < deadline:
|
||||
if _video_life() != life0:
|
||||
return
|
||||
if _video_list_status(vid) in ("completed", "failed", "error", "cancelled"):
|
||||
return
|
||||
time.sleep(VIDEO_POLL_S)
|
||||
finally:
|
||||
VIDEO_LAST.clear()
|
||||
VIDEO_LOCK.release()
|
||||
|
||||
|
||||
def video_call(payload: dict) -> tuple[int, dict]:
|
||||
"""One video request, made to the lane on loopback and waited on to the end. This
|
||||
process is the gate: the route checked the session before the body was read."""
|
||||
fields = {k: v for k, v in payload.items() if k in VIDEO_ALLOWED and v is not None}
|
||||
if not str(fields.get("prompt", "")).strip():
|
||||
return 400, {"error": "a prompt is required"}
|
||||
secs = fields.get("seconds", 5)
|
||||
if isinstance(secs, bool) or not isinstance(secs, int) or not 4 <= secs <= 15:
|
||||
# the cookbook's duration band: 4 to 15 s
|
||||
return 400, {"error": "seconds is a whole number from 4 to 15"}
|
||||
fields["seconds"] = secs
|
||||
if fields.get("num_outputs_per_prompt", 1) != 1:
|
||||
# the lane serves one request at a time; parallel variants inside one call are
|
||||
# the same working set twice
|
||||
return 400, {"error": "one video per call on this lane; make several calls"}
|
||||
fields["num_outputs_per_prompt"] = 1
|
||||
size = fields.get("size")
|
||||
if size is not None:
|
||||
parts = str(size).lower().replace(" ", "").split("x")
|
||||
try:
|
||||
sw, sh = (int(parts[0]), int(parts[1])) if len(parts) == 2 else (0, 0)
|
||||
except ValueError:
|
||||
sw = sh = 0
|
||||
if sw <= 0 or sh <= 0:
|
||||
return 400, {"error": "size must be WIDTHxHEIGHT, two positive numbers"}
|
||||
else:
|
||||
sw, sh = 864, 480
|
||||
# The lane requires a target object (measured 2026-09-25): short edge, aspect
|
||||
# ratio and duration, derived from the size and seconds above so the tab's two
|
||||
# controls stay the contract. The ratio is the cookbook's wording ("16:9"), which
|
||||
# the lane accepted with 864x480 and served to completed: the exact reduction
|
||||
# (18:10) was never tried against it.
|
||||
fields["size"] = f"{sw}x{sh}"
|
||||
fields["target"] = {"short_edge": min(sw, sh),
|
||||
"aspect_ratio": "16:9" if sw >= sh else "9:16",
|
||||
"duration_seconds": secs}
|
||||
# Keyframes turn text-to-video into first/last-frame conditioning; without them the
|
||||
# call is text only. Reference modes (ref2va weights) need a unit installed with
|
||||
# VIDEO_VARIANT=ref2va and are refused here until that lane exists.
|
||||
first, why = _video_decoded_frame(payload, "first_frame")
|
||||
if why:
|
||||
return 400, {"error": why}
|
||||
last, why = _video_decoded_frame(payload, "last_frame")
|
||||
if why:
|
||||
return 400, {"error": why}
|
||||
variant = _video_unit_flag("--model-variant", "fl2va")
|
||||
keyframe_paths: list = []
|
||||
if first is not None or last is not None:
|
||||
if variant != "fl2va":
|
||||
return 400, {"error": f"this lane serves the {variant} weights, which take no keyframes"}
|
||||
# The lane reads keyframes by URI, not by bytes: decoded frames are staged as
|
||||
# files this user owns and named file://, then removed with the call. Data URLs
|
||||
# are never sent: whether the pipeline accepts one was never measured.
|
||||
import tempfile
|
||||
for raw, tag in ((first, "first"), (last, "last")):
|
||||
if raw is None:
|
||||
continue
|
||||
fd, path = tempfile.mkstemp(prefix=f"qwen38-{tag}-frame-", suffix=".png",
|
||||
dir=str(CONFIG_DIR))
|
||||
with os.fdopen(fd, "wb") as f:
|
||||
f.write(raw)
|
||||
keyframe_paths.append(path)
|
||||
try:
|
||||
fields["task"] = "fl2va"
|
||||
fields["conditions"] = []
|
||||
if first is not None:
|
||||
fields["conditions"].append({"type": "image",
|
||||
"uri": f"file://{keyframe_paths[0]}",
|
||||
"role": "keyframe", "frame_index": 0})
|
||||
if last is not None:
|
||||
fields["conditions"].append({"type": "image",
|
||||
"uri": f"file://{keyframe_paths[-1]}",
|
||||
"role": "keyframe", "frame_index": -1})
|
||||
except Exception:
|
||||
for path in keyframe_paths:
|
||||
try:
|
||||
os.unlink(path)
|
||||
except OSError:
|
||||
pass
|
||||
raise
|
||||
else:
|
||||
# The lane requires a task; named wrong it answers 400 (measured 2026-09-25).
|
||||
# Text-only is t2v, and only t2v: fl2va without a frame would read as text-only
|
||||
# under a conditioning task, so it is refused as asked, not served as text.
|
||||
task = fields.get("task", "t2v")
|
||||
if task not in ("t2v", "fl2va"):
|
||||
return 400, {"error": "task is t2v, or fl2va with a first_frame and/or last_frame"}
|
||||
if task == "fl2va":
|
||||
if variant != "fl2va":
|
||||
return 400, {"error": f"this lane serves the {variant} weights, which take no keyframes"}
|
||||
return 400, {"error": "fl2va names first/last-frame conditioning: attach a first_frame and/or last_frame"}
|
||||
fields["task"] = "t2v"
|
||||
fields.setdefault("model", "MiniMax-H3")
|
||||
# No Authorization header: the diffusion runtime has no --api-key, so the lane
|
||||
# cannot check one and the unit binds loopback instead. The gate is this process's
|
||||
# own session.
|
||||
if not VIDEO_LOCK.acquire(blocking=False):
|
||||
return 409, {"error": "this lane serves one video at a time, and something is "
|
||||
"already generating on it. Wait for the current one to finish."}
|
||||
t0 = time.time()
|
||||
life0 = _video_life()
|
||||
handed_over = [False]
|
||||
try:
|
||||
req = urllib.request.Request(video_base() + "/v1/videos",
|
||||
json.dumps(fields).encode(),
|
||||
{"Content-Type": "application/json"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
created = json.loads(r.read().decode())
|
||||
except urllib.error.HTTPError as e:
|
||||
raw = e.read()
|
||||
if e.code >= 500 and _video_life() != life0:
|
||||
return _video_cut(t0)
|
||||
try:
|
||||
detail = json.loads(raw.decode())
|
||||
except Exception: # noqa: BLE001
|
||||
detail = raw[:400].decode("utf-8", "replace")
|
||||
return e.code, {"refused": detail, "seconds": round(time.time() - t0, 2)}
|
||||
vid = created.get("id", "")
|
||||
if not vid:
|
||||
return 502, {"error": f"the lane took the call but gave no video id: {str(created)[:200]}",
|
||||
"seconds": round(time.time() - t0, 2)}
|
||||
VIDEO_LAST.update({"id": vid, "status": created.get("status", "queued"),
|
||||
"seconds": 0.0})
|
||||
# To completed, the way the lane reports it: its list, not its journal.
|
||||
while time.time() - t0 < VIDEO_TIMEOUT:
|
||||
if _video_life() != life0:
|
||||
return _video_cut(t0)
|
||||
st = _video_list_status(vid)
|
||||
VIDEO_LAST["status"] = st
|
||||
VIDEO_LAST["seconds"] = round(time.time() - t0, 2)
|
||||
if st == "completed":
|
||||
return 200, {"video_id": vid, "seconds": round(time.time() - t0, 2)}
|
||||
if st in ("failed", "error", "cancelled"):
|
||||
return 502, {"error": f"the lane ended video {vid} in {st}",
|
||||
"seconds": round(time.time() - t0, 2)}
|
||||
if st == "missing":
|
||||
# a definitive answer from the lane, not a transport failure: the
|
||||
# record is gone, so there is nothing to download however long this
|
||||
# waits (an "unknown" is our failure to ask, and polls on)
|
||||
return 502, {"error": f"the lane has no record of video {vid}",
|
||||
"seconds": round(time.time() - t0, 2)}
|
||||
time.sleep(VIDEO_POLL_S)
|
||||
# The wait ran out; the lane goes on (it has no abort). The lock is handed to
|
||||
# a watcher that gives it back when the lane is done, so a second generation
|
||||
# never runs beside the first.
|
||||
threading.Thread(target=_release_video_lock_when_done, args=(life0, vid, t0),
|
||||
daemon=True).start()
|
||||
handed_over[0] = True
|
||||
return 504, {"error": VIDEO_STILL_RUNNING, "video_id": vid,
|
||||
"seconds": round(time.time() - t0, 2)}
|
||||
except Exception as e: # noqa: BLE001 (isolated route)
|
||||
if _video_life() != life0:
|
||||
return _video_cut(t0)
|
||||
return 502, {"error": f"the video lane did not answer ({type(e).__name__}). "
|
||||
f"Switch to MiniMax-H3 in the action bar and start it "
|
||||
f"(or ./switch-model.sh video)",
|
||||
"seconds": round(time.time() - t0, 2)}
|
||||
finally:
|
||||
for path in keyframe_paths:
|
||||
try:
|
||||
os.unlink(path)
|
||||
except (OSError, NameError):
|
||||
pass
|
||||
if not handed_over[0]:
|
||||
VIDEO_LAST.clear()
|
||||
VIDEO_LOCK.release()
|
||||
|
||||
|
||||
def video_content(vid: str) -> tuple[int, bytes, str]:
|
||||
"""This video's bytes, downloaded from the lane on loopback. The route checked the
|
||||
session; the id is path-shaped and nothing else reaches the lane."""
|
||||
if not vid or not all(c.isalnum() or c in "-_" for c in vid):
|
||||
return 400, b"", ""
|
||||
try:
|
||||
req = urllib.request.Request(video_base() + f"/v1/videos/{vid}/content")
|
||||
with urllib.request.urlopen(req, timeout=300) as r:
|
||||
return 200, r.read(), r.headers.get("Content-Type", "video/mp4")
|
||||
except urllib.error.HTTPError as e:
|
||||
return e.code, b"", ""
|
||||
except Exception: # noqa: BLE001 (isolated route)
|
||||
return 502, b"", ""
|
||||
|
||||
|
||||
def job_flush_cache(job: Job):
|
||||
req = urllib.request.Request(ENGINE_BASE + "/flush_cache", method="POST", data=b"",
|
||||
headers={"Authorization": f"Bearer {api_key()}"})
|
||||
@@ -2420,6 +2854,7 @@ def job_diag_bundle(job: Job):
|
||||
# the image lane and the Agent tab's server have journals of their own, which the
|
||||
# bundle left out (found in review, 2026-09-24)
|
||||
(tdp / "journal-image.txt").write_text(run(["journalctl", "-u", IMAGE_UNIT, "-n", "300", "--no-pager", "-o", "short-iso"], timeout=15))
|
||||
(tdp / "journal-video.txt").write_text(run(["journalctl", "-u", VIDEO_UNIT, "-n", "300", "--no-pager", "-o", "short-iso"], timeout=15))
|
||||
(tdp / "journal-opencode-web.txt").write_text(run(["journalctl", "-u", AGENT_UNIT, "-n", "200", "--no-pager", "-o", "short-iso"], timeout=15))
|
||||
for cont in CONTAINERS:
|
||||
(tdp / f"docker-{cont}.txt").write_text(run(["docker", "logs", "--tail", "600", cont], timeout=15, merge_err=True))
|
||||
@@ -2746,6 +3181,15 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
def send_json(self, obj, code=200):
|
||||
return self.send_json_text(json.dumps(obj), code)
|
||||
|
||||
def send_bytes(self, body: bytes, ctype: str, code=200):
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.security_headers()
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def send_json_text(self, text, code=200):
|
||||
body = text.encode()
|
||||
self.send_response(code)
|
||||
@@ -2844,6 +3288,14 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
return self.send_json(systemone_available(max_age=0.0 if fresh else 60.0))
|
||||
if path == "/api/image":
|
||||
return self.send_json(image_status())
|
||||
if path == "/api/video":
|
||||
return self.send_json(video_status())
|
||||
if path == "/api/video/content":
|
||||
vid = urllib.parse.parse_qs(query).get("id", [""])[0].strip()
|
||||
code, body, ctype = video_content(vid)
|
||||
if code != 200:
|
||||
return self.send_json({"error": "no such video"}, code)
|
||||
return self.send_bytes(body, ctype or "video/mp4")
|
||||
if path == "/api/stream":
|
||||
return self.stream()
|
||||
return self.send_json({"error": "not found"}, 404)
|
||||
@@ -2862,10 +3314,11 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
self.close_connection = True
|
||||
return self.send_json({"error": "bad Content-Length"}, 400)
|
||||
length = int(declared)
|
||||
# Ten reference images do not fit in 64 KiB and never will. The cap is raised for
|
||||
# the two image routes and for nothing else; a login is a key in a JSON object.
|
||||
raised = path in ("/api/image/edit", "/api/image/generate")
|
||||
cap = IMAGE_MAX_POST if raised else 4096 if path == "/api/login" else 65536
|
||||
# Ten reference images do not fit in 64 KiB and never will, and neither do
|
||||
# two keyframes. The cap is raised for the image and video routes and for
|
||||
# nothing else; a login is a key in a JSON object.
|
||||
raised = path in ("/api/image/edit", "/api/image/generate", "/api/video/generate")
|
||||
cap = max(IMAGE_MAX_POST, VIDEO_MAX_POST) if raised else 4096 if path == "/api/login" else 65536
|
||||
if length > cap:
|
||||
self.close_connection = True
|
||||
return self.send_json({"error": "body too large"}, 413)
|
||||
@@ -2948,6 +3401,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
if path in ("/api/image/generate", "/api/image/edit"):
|
||||
code, out = image_call(payload, editing=path.endswith("edit"))
|
||||
return self.send_json(out, code)
|
||||
if path == "/api/video/generate":
|
||||
code, out = video_call(payload)
|
||||
return self.send_json(out, code)
|
||||
return self.send_json({"error": "not found"}, 404)
|
||||
|
||||
# ---- helpers ----
|
||||
|
||||
+56
-10
@@ -56,9 +56,31 @@ IMAGE_MARKERS = [
|
||||
("fired up and ready to roll", "warming-up", "ready"),
|
||||
]
|
||||
|
||||
# ── The video lane speaks the same dialect ────────────────────────────────────
|
||||
# MiniMax-H3 is served by the same SGLang Diffusion server from the same source
|
||||
# tree, so its boot prints the shared server lines. The component lines below are the
|
||||
# ones this pipeline printed on the reference box on 2026-09-25 (boot 23:08:50, DiT
|
||||
# 61.73 GB in 13 shards, text encoder 48.09 GB, audio VAE 0.56 GB, video VAE 5.2 GB):
|
||||
# a marker for a line never seen is a guess dressed as knowledge, so anything else
|
||||
# still falls on the generic "Loading " arm and reads as weights without naming it.
|
||||
VIDEO_STAGES = ("init", "loading-weights", "warming-up")
|
||||
VIDEO_MARKERS = [
|
||||
# (substring, stage it opens, what is being loaded while that line is the latest)
|
||||
("Starting server...", "init", "starting the server"),
|
||||
("Loading ", "loading-weights", "loading a pipeline component"),
|
||||
("Loading pipeline modules...", "loading-weights", "reading the checkpoint layout"),
|
||||
("Loading text_encoder from", "loading-weights", "the 48 GB text encoder"),
|
||||
("Loading MiniMaxH3DiTModel from", "loading-weights", "the 61.7 GB DiT"),
|
||||
("Loading audio_vae from", "loading-weights", "the audio VAE"),
|
||||
("Loading video_vae from", "loading-weights", "the 5.2 GB video VAE"),
|
||||
("Pipeline instantiated", "loading-weights", "building the pipeline"),
|
||||
("Starting FastAPI server", "warming-up", "three warmup requests"),
|
||||
("fired up and ready to roll", "warming-up", "ready"),
|
||||
]
|
||||
|
||||
def parse_image_boot_log(lines: list[str]) -> dict:
|
||||
"""The image lane's journal, reduced to the same shape parse_boot_log returns.
|
||||
|
||||
def _parse_diffusion_boot_log(lines: list[str], markers: list, stages: tuple) -> dict:
|
||||
"""A diffusion lane's journal, reduced to the same shape parse_boot_log returns.
|
||||
|
||||
Only the latest boot counts: journald keeps every previous life of the unit,
|
||||
and a "fired up" from yesterday must not make today's boot read as ready."""
|
||||
@@ -68,17 +90,34 @@ def parse_image_boot_log(lines: list[str]) -> dict:
|
||||
start = i
|
||||
stage, detail, fired = None, "", False
|
||||
for ln in lines[start:]:
|
||||
for needle, st, what in IMAGE_MARKERS:
|
||||
for needle, st, what in markers:
|
||||
if needle in ln:
|
||||
stage, detail = st, what
|
||||
if needle == "fired up and ready to roll":
|
||||
fired = True
|
||||
done = list(IMAGE_STAGES[:IMAGE_STAGES.index(stage)]) if stage in IMAGE_STAGES else []
|
||||
done = list(stages[:stages.index(stage)]) if stage in stages else []
|
||||
if fired:
|
||||
done = list(IMAGE_STAGES)
|
||||
done = list(stages)
|
||||
return {"stage": stage, "done": done, "fired_up": fired, "detail": detail}
|
||||
|
||||
|
||||
def parse_image_boot_log(lines: list[str]) -> dict:
|
||||
"""The image lane's journal, reduced to the same shape parse_boot_log returns.
|
||||
|
||||
Only the latest boot counts: journald keeps every previous life of the unit,
|
||||
and a "fired up" from yesterday must not make today's boot read as ready."""
|
||||
return _parse_diffusion_boot_log(lines, IMAGE_MARKERS, IMAGE_STAGES)
|
||||
|
||||
|
||||
def parse_video_boot_log(lines: list[str]) -> dict:
|
||||
"""The video lane's journal, reduced to the same shape parse_boot_log returns.
|
||||
|
||||
Same latest-boot rule as the image lane. Only the shared server lines are
|
||||
matched; the pipeline's own component lines fall on the generic "Loading "
|
||||
arm and read as weights without naming what they load."""
|
||||
return _parse_diffusion_boot_log(lines, VIDEO_MARKERS, VIDEO_STAGES)
|
||||
|
||||
|
||||
def parse_boot_log(lines: list[str]) -> dict:
|
||||
"""Reduce a container log tail to {stage, done[], fired_up, weight_loads}.
|
||||
|
||||
@@ -204,14 +243,17 @@ BUSY_STATES = {"starting", "loading-weights", "loading-draft", "allocating-kv",
|
||||
TRANSITIONAL = BUSY_STATES - {"ready", "degraded", "orphan", "wedged"}
|
||||
# Every unit that holds the GPU pool while it runs. The image lane is one of them:
|
||||
# 31 GB of weights, and two engines at once on 121.6 GB of unified memory is the
|
||||
# livelock this whole module exists to prevent.
|
||||
ENGINE_UNITS = ("qwen38-sglang.service", "qwen38-flash.service", "qwen38-image.service")
|
||||
# livelock this whole module exists to prevent. The video lane is one of them too:
|
||||
# about 108 GB of weights, for the same reason.
|
||||
ENGINE_UNITS = ("qwen38-sglang.service", "qwen38-flash.service",
|
||||
"qwen38-image.service", "qwen38-video.service")
|
||||
IMAGE_UNIT = "qwen38-image.service"
|
||||
VIDEO_UNIT = "qwen38-video.service"
|
||||
# The engines that serve text on ENGINE_BASE. Every probe, guard and belt that talks to
|
||||
# that port (the generation canary, the pool guard, the wedge autoheal) is about these
|
||||
# and only these: with the image lane serving, :30000 is closed, and asking "is an
|
||||
# and only these: with a diffusion lane serving, :30000 is closed, and asking "is an
|
||||
# engine ready" instead sent the canary a chat completion to a dead port every 90 s.
|
||||
TEXT_UNITS = tuple(u for u in ENGINE_UNITS if u != IMAGE_UNIT)
|
||||
TEXT_UNITS = tuple(u for u in ENGINE_UNITS if u not in (IMAGE_UNIT, VIDEO_UNIT))
|
||||
|
||||
|
||||
def blocked_reasons(action: str, params: dict, states: dict) -> list[str]:
|
||||
@@ -259,7 +301,11 @@ def warn_reasons(action: str, params: dict, states: dict,
|
||||
elif unit == IMAGE_UNIT and state == "ready":
|
||||
# the proxy on :30001 is a text door; nothing reaches this lane through it
|
||||
warns.append("an image being generated right now is lost, and the Image "
|
||||
"tab has nothing to talk to until this lane is back (about 70 s)")
|
||||
"tab has nothing to talk to until this lane is back (about 70 s)")
|
||||
elif unit == VIDEO_UNIT and state == "ready":
|
||||
# same text-door reason as the image lane; a video boot is the long one
|
||||
warns.append("a video being generated right now is lost, and the Video "
|
||||
"tab has nothing to talk to until this lane is back (about 12 min)")
|
||||
elif state == "ready":
|
||||
warns.append("clients on :30001 will get errors until an engine "
|
||||
"is back")
|
||||
|
||||
+275
-9
@@ -46,15 +46,16 @@ const TRANSITIONAL = new Set(['starting', 'loading-weights', 'loading-draft', 'a
|
||||
const STAGE_LABEL = {'init': 'init', 'loading-weights': 'weights', 'loading-draft': 'draft', 'allocating-kv': 'KV', 'capturing-graphs': 'graphs', 'warming-up': 'warmup'};
|
||||
const ALL_STAGES = Object.keys(STAGE_LABEL);
|
||||
const LANE_NAME = {'qwen38-sglang.service': '27B', 'qwen38-flash.service': 'flash 176B',
|
||||
'qwen38-image.service': 'Qwen-Image'};
|
||||
'qwen38-image.service': 'Qwen-Image', 'qwen38-video.service': 'MiniMax-H3'};
|
||||
// How long each lane takes to answer after a start, before the box has seen one of its
|
||||
// boots. Measured on the reference box: the 27B loads, compiles and captures graphs for
|
||||
// about nine minutes, the flash lane for about thirteen (it also writes its 47.7 GiB PLE
|
||||
// table); the image lane loads 31 GB and warms up in about 70 seconds. Once a lane has
|
||||
// table); the image lane loads 31 GB and warms up in about 70 seconds; the video lane
|
||||
// loads the checkpoint (fl2va partition plus shared components) and answers in about 12 min. Once a lane has
|
||||
// booted in front of the cockpit, its own median replaces these, and every estimate on
|
||||
// the page reads readyIn(): the stop warning said "12 to 15 min" beside a bar that said 13.
|
||||
const READY_DEFAULT = {'qwen38-sglang.service': 540, 'qwen38-flash.service': 780,
|
||||
'qwen38-image.service': 70};
|
||||
'qwen38-image.service': 70, 'qwen38-video.service': 720};
|
||||
function readyIn(unit){
|
||||
const e = ((F.life || {}).engines || {})[unit] || {};
|
||||
const b = (e.boots || []).slice().sort((a, c) => a - c);
|
||||
@@ -62,6 +63,13 @@ function readyIn(unit){
|
||||
return 'about ' + fmtDur(s);
|
||||
}
|
||||
const IMAGE_UNIT = 'qwen38-image.service';
|
||||
const VIDEO_UNIT = 'qwen38-video.service';
|
||||
// The video lane's live facts. Declared up here, not beside the Video tab's code: the
|
||||
// lane pill and the action bar read them too, and a const read before its line has run
|
||||
// is a ReferenceError that takes the whole page down with it.
|
||||
const VID_STATE = {port: 30022, host: '127.0.0.1', available: false, busy: false};
|
||||
let vidInflight = null; // when this page's own request started, or null
|
||||
let VID_WATCH = null;
|
||||
// The image lane's live facts. Declared up here, not beside the Image tab's code: the
|
||||
// lane pill and the action bar read them too, and a const read before its line has run
|
||||
// is a ReferenceError that takes the whole page down with it.
|
||||
@@ -86,7 +94,7 @@ const AGENT_UNIT = 'opencode-web.service';
|
||||
const TARGET_SHORT = {stock: 'stock', uncensored: 'uncensored', fp8: 'FP8',
|
||||
'uncensored-fp8': 'FP8 uncensored', flash: '',
|
||||
'flash-uncensored': 'uncensored', 'flash-nvda': 'NVIDIA export',
|
||||
image: '2.1'};
|
||||
image: '2.1', video: 'H3'};
|
||||
function laneLabel(unit){
|
||||
if (unit === AGENT_UNIT) return 'the opencode web server';
|
||||
const base = LANE_NAME[unit] || unit.replace('.service', '');
|
||||
@@ -130,6 +138,7 @@ function showTab(name, push = true){
|
||||
// the lane can be started and stopped from elsewhere in this page, so unlike the
|
||||
// System One probe this one re-reads on every visit rather than once
|
||||
if (name === 'image' && typeof imgLane === 'function') imgLane();
|
||||
if (name === 'video' && typeof vidLane === 'function') vidLane();
|
||||
// at parse time the agent helpers below are not initialised yet; the first state
|
||||
// tick mounts the frame in that case, a later click mounts it at once
|
||||
if (name === 'agent' && document.readyState === 'complete'){ mountAgent(); applyAgentMax(); }
|
||||
@@ -365,6 +374,8 @@ function textReady(){
|
||||
return servingReady() && !!s && s[0] !== IMAGE_UNIT;
|
||||
}
|
||||
const imageServing = () => { const s = servingEngine(); return !!s && s[0] === IMAGE_UNIT; };
|
||||
const videoServing = () => { const s = servingEngine(); return !!s && s[0] === VIDEO_UNIT; };
|
||||
const diffusionServing = () => imageServing() || videoServing();
|
||||
function rPool(){
|
||||
const l = F.load || {};
|
||||
if (!F.pool){ setText('poollab', 'waiting for the engine'); $('poolfill').style.width = '0%'; setText('poolnote', 'the pool size arrives with the engine (max_total_num_tokens at boot)'); return; }
|
||||
@@ -447,7 +458,8 @@ function rCanary(d){
|
||||
// With no text engine the probe has nothing to ask, and its last success, however old,
|
||||
// was shown as a reading of what runs now (found in review, 2026-09-24).
|
||||
if (d.skipped && !textReady()){
|
||||
txt = imageServing() ? 'no text engine (the image lane serves)' : 'no text engine';
|
||||
txt = imageServing() ? 'no text engine (the image lane serves)'
|
||||
: videoServing() ? 'no text engine (the video lane serves)' : 'no text engine';
|
||||
why = d.last_ok ? `The last probe passed at ${clockTime(d.last_ok)}, on the engine that served then.`
|
||||
: 'The probe waits for a text engine that is ready and idle.';
|
||||
}
|
||||
@@ -736,7 +748,9 @@ function stoppingBlock(e){
|
||||
const bar = el('div', 'bbar'); bar.append(el('div', 'bfill indet')); boot.append(bar);
|
||||
const lab = el('div', 'blab');
|
||||
lab.append(el('span', null, `stopping · ${e.state_elapsed != null ? fmtDur(e.state_elapsed) : '…'} elapsed`));
|
||||
lab.append(el('span', null, e.kind === 'image'
|
||||
lab.append(el('span', null, e.kind === 'video'
|
||||
? 'systemd stops the process (SIGTERM; a generation in flight is cut after 5 s)'
|
||||
: e.kind === 'image'
|
||||
? 'systemd stops the process (SIGTERM; a generation in flight is cut after 5 s)'
|
||||
: 'systemd stops the container (SIGTERM, usually under 30 s)'));
|
||||
boot.append(lab); return boot;
|
||||
@@ -822,6 +836,7 @@ function rLifecycle(d){
|
||||
// engine facts belong to a lane that is actually up: while it boots, stops or is gone,
|
||||
// say so rather than showing the previous lane's model, pool and percentages
|
||||
if (!textReady()) rEngineInfoDown(imageServing() ? 'the image lane is serving, so there is no text engine: its facts are in the Image tab'
|
||||
: videoServing() ? 'the video lane is serving, so there is no text engine: its facts are in the Video tab'
|
||||
: s ? 'engine ' + (STATE_LABEL[s[1].state] || s[1].state) : 'no engine running');
|
||||
if (!s){
|
||||
const p = el('p', 'empty', `No engine is serving. Start ${laneLabel(enabledUnit())} from the action bar (${readyIn(enabledUnit())} to ready), or switch the target first.`);
|
||||
@@ -868,11 +883,12 @@ function rLifecycle(d){
|
||||
applyBusy();
|
||||
}
|
||||
// Which unit serves a target, and how that lane is installed when it is not.
|
||||
const TARGET_UNIT = t => t === 'image' ? IMAGE_UNIT : t.startsWith('flash') ? 'qwen38-flash.service' : 'qwen38-sglang.service';
|
||||
const TARGET_UNIT = t => t === 'image' ? IMAGE_UNIT : t === 'video' ? VIDEO_UNIT : t.startsWith('flash') ? 'qwen38-flash.service' : 'qwen38-sglang.service';
|
||||
// the text engine's served target, when it is one of this unit's
|
||||
const ownTarget = unit => F.target && TARGET_UNIT(F.target) === unit ? F.target : null;
|
||||
const LANE_INSTALL = {'qwen38-sglang.service': './install.sh', 'qwen38-flash.service': 'MODEL_CHOICE=flash ./install.sh',
|
||||
'qwen38-image.service': './install.sh --with-image'};
|
||||
'qwen38-image.service': './install.sh --with-image',
|
||||
'qwen38-video.service': './install.sh --with-video'};
|
||||
// An option whose lane has no unit file on this box is shown as such and cannot be
|
||||
// picked. Picking it used to be allowed, and the switch then failed a second later
|
||||
// with "not installed": the image lane is opt-in, so that was the default on most boxes.
|
||||
@@ -897,7 +913,7 @@ function syncSelector(){
|
||||
const eng = (F.life || {}).engines || {};
|
||||
const s = servingEngine();
|
||||
const unit = s ? s[0] : enabledUnit();
|
||||
const target = (s && s[0] !== IMAGE_UNIT && ownTarget(unit)) || (eng[unit] || {}).target;
|
||||
const target = (s && s[0] !== IMAGE_UNIT && s[0] !== VIDEO_UNIT && ownTarget(unit)) || (eng[unit] || {}).target;
|
||||
// A choice holds the selector until the lane serves it, and then the selector follows
|
||||
// the lane again: it stayed on the first choice for the life of the page, cancelled or
|
||||
// served, while the lanes moved under it (found in review, 2026-09-24).
|
||||
@@ -917,6 +933,7 @@ const ACTION_PHRASE = {
|
||||
unit: p => `${p.verb || 'act on'} ${String(p.unit || '').replace('.service', '')}`,
|
||||
// the lane and the checkpoint: "uncensored" alone read the same for the 27B and the flash
|
||||
switch: p => `switch to ${!p.target ? 'a target' : p.target === 'image' ? 'Qwen-Image 2.1'
|
||||
: p.target === 'video' ? 'MiniMax-H3'
|
||||
: LANE_NAME[TARGET_UNIT(p.target)] + (TARGET_SHORT[p.target] ? ' ' + TARGET_SHORT[p.target] : '')}`,
|
||||
flush_cache: () => 'flush the radix cache',
|
||||
abort_all: () => 'abort every generation in flight',
|
||||
@@ -1022,6 +1039,8 @@ function applyBusy(){
|
||||
const engineUp = textReady();
|
||||
const noEngineWhy = engineUp ? '' : imageServing()
|
||||
? 'the image lane is serving: this acts on the text engine, which is not running'
|
||||
: videoServing()
|
||||
? 'the video lane is serving: this acts on the text engine, which is not running'
|
||||
: `no engine is serving: start one first (it answers in ${readyIn(enabledUnit())})`;
|
||||
document.querySelectorAll('[data-act]').forEach(b => {
|
||||
if (b.id === 'lanebtn') return;
|
||||
@@ -1425,6 +1444,8 @@ function askAction(name, params, argv, warns){
|
||||
if (offline){ toast('The cockpit is unreachable right now: nothing can be started.', 'err'); return; }
|
||||
if (NEEDS_ENGINE.has(name) && !textReady()){ toast(imageServing()
|
||||
? 'The image lane is serving: this action talks to the text engine, which is not running.'
|
||||
: videoServing()
|
||||
? 'The video lane is serving: this action talks to the text engine, which is not running.'
|
||||
: 'No engine is serving: start one first, then this action has something to talk to.', 'warn'); return; }
|
||||
if (F.job && F.job.current){ toast(`Another action is running (${F.job.current.action}). Wait for the job strip to finish.`, 'warn'); return; }
|
||||
if (!$('modal').hidden) return;
|
||||
@@ -1435,6 +1456,11 @@ function askAction(name, params, argv, warns){
|
||||
'flash-uncensored': 'flash 176B uncensored (NVFP4)',
|
||||
'flash-nvda': 'flash 176B, NVIDIA export'};
|
||||
const TARGET_NOTE = {
|
||||
video: 'The video lane: text to video with joint video-and-audio, plus first/last-frame conditioning. '
|
||||
+ 'It is a fourth lane with its own unit and its own venv, and like the others it '
|
||||
+ 'takes the box alone: the video checkpoint does not fit beside a serving LLM. It answers in '
|
||||
+ 'about 12 min after a start, and a 4 s 480P request takes about as long. The proxy on :30001 '
|
||||
+ 'and opencode are text clients and are left exactly as they are.',
|
||||
image: 'The image lane: text to image, editing with up to ten references, and native RGBA. '
|
||||
+ 'It is a third lane with its own unit and its own venv, and like the other two it '
|
||||
+ 'takes the box alone: 31 GB of weights do not fit beside a serving LLM. It answers in '
|
||||
@@ -1465,15 +1491,23 @@ function askAction(name, params, argv, warns){
|
||||
+ 'Like every lane it takes the box alone, so this is only offered once no other engine is running.',
|
||||
stop: 'systemd stops the image lane and the 31 GB come back at once. It does not bring a text lane back by itself: start the one you want.',
|
||||
restart: `systemd restarts the image lane; it reloads 31 GB and answers again in ${readyIn(IMAGE_UNIT)}.`};
|
||||
const VIDEO_EXPLAIN = {
|
||||
start: `systemd starts the video lane: it loads the checkpoint and answers in ${readyIn(VIDEO_UNIT)}. `
|
||||
+ 'Like every lane it takes the box alone, so this is only offered once no other engine is running.',
|
||||
stop: 'systemd stops the video lane and the memory comes back at once. It does not bring another lane back by itself: start the one you want.',
|
||||
restart: `systemd restarts the video lane; it reloads the checkpoint and answers again in ${readyIn(VIDEO_UNIT)}.`};
|
||||
const AGENT_EXPLAIN = {stop: 'systemd stops opencode serve: the Agent tab goes dark until the server is started again.',
|
||||
start: 'systemd starts opencode serve on loopback; the Agent tab is back within seconds.',
|
||||
restart: 'systemd restarts opencode serve, which picks up an upgraded binary; the Agent tab reconnects by itself within seconds.'};
|
||||
const EXPLAIN = {unit: p => p.unit === AGENT_UNIT ? AGENT_EXPLAIN[p.verb] || ''
|
||||
: p.unit === IMAGE_UNIT ? IMAGE_EXPLAIN[p.verb] || ''
|
||||
: p.unit === VIDEO_UNIT ? VIDEO_EXPLAIN[p.verb] || ''
|
||||
: p.verb === 'stop' ? 'systemd stops the unit; the container gets SIGTERM and disappears in seconds.' : `systemd starts the unit; the engine loads its weights and is ready in ${readyIn(p.unit)} (watch the boot bar).`,
|
||||
switch: p => (TARGET_NOTE[p.target] ? TARGET_NOTE[p.target] + '\n\n' : '')
|
||||
+ (p.target === 'image'
|
||||
? 'switch-model.sh verifies the checkpoint and makes the image lane the one unit enabled at boot. It never restarts anything: stop the serving lane, then start this one.'
|
||||
: p.target === 'video'
|
||||
? 'switch-model.sh verifies the checkpoint and makes the video lane the one unit enabled at boot. It never restarts anything: stop the serving lane, then start this one.'
|
||||
: 'switch-model.sh rewrites the unit for the chosen target, updates the boot enablement, the proxy ceiling and the opencode default model. It never restarts anything: stop and start the engines afterwards.'),
|
||||
flush_cache: () => 'Empties the radix cache. Harmless; refused by the engine if requests are running.',
|
||||
abort_all: () => 'Every running or queued generation ends now; the clients see their stream end.',
|
||||
@@ -2613,4 +2647,236 @@ function imgInit(){
|
||||
imgLane();
|
||||
}
|
||||
|
||||
// ── Video tab: MiniMax-H3 ───────────────────────────────────────────────────
|
||||
// One request at a time on this lane, watched where the page looks from. Creation is
|
||||
// asynchronous lane-side (an id, then minutes of work, then bytes), but this page's
|
||||
// fetch simply waits it out: the cockpit holds the call to completed and answers the
|
||||
// video id, and the player streams it back through /api/video/content.
|
||||
let vidMode = 't2v';
|
||||
let vidFrames = {first: null, last: null}; // {name, dataUrl} or null
|
||||
async function vidLane(){
|
||||
try{
|
||||
const r = await fetch('/api/video');
|
||||
if (r.status === 401) return;
|
||||
const d = await r.json();
|
||||
VID_STATE.port = d.port || 30022;
|
||||
VID_STATE.host = d.host || '127.0.0.1';
|
||||
VID_STATE.installed = !!d.installed;
|
||||
VID_STATE.model = d.model || 'MiniMaxAI/MiniMax-H3';
|
||||
VID_STATE.variant = d.variant || 'fl2va';
|
||||
const p = d.progress || {};
|
||||
VID_STATE.busy = !vidInflight && !!p.id && p.status !== 'completed';
|
||||
VID_STATE.busyLabel = p.status ? ('generating: ' + p.status) : '';
|
||||
if (VID_STATE.busy) vidWatch(true, 10000);
|
||||
else if (!vidInflight) vidWatch(false);
|
||||
vidRenderLane();
|
||||
} catch (e){ setChip('vidchip', 'unknown', 'warn'); }
|
||||
}
|
||||
function vidRenderLane(){
|
||||
if (!$('vidctl')) return;
|
||||
setText('vidmodel', VID_STATE.model || 'MiniMaxAI/MiniMax-H3');
|
||||
const e = ((F.life || {}).engines || {})[VIDEO_UNIT];
|
||||
const ctl = $('vidctl'); clear(ctl);
|
||||
const boot = $('vidboot'); clear(boot);
|
||||
const guide = $('vidsteps-guide'); clear(guide); guide.hidden = true;
|
||||
const say = txt => ctl.append(el('span', 'chip', txt));
|
||||
const serving = servingEngine();
|
||||
const other = serving && serving[0] !== VIDEO_UNIT ? serving[0] : null;
|
||||
if (!F.life){
|
||||
setChip('vidchip', 'checking', '');
|
||||
} else if (!e){
|
||||
setChip('vidchip', 'not installed', 'warn');
|
||||
say('install it with: ./install.sh --with-video');
|
||||
say('about 150 GB of headroom, an hour or more, one command');
|
||||
} else if (e.state === 'ready' || e.state === 'degraded'){
|
||||
setChip('vidchip', VID_STATE.busy ? 'busy: ' + VID_STATE.busyLabel : 'serving on :' + VID_STATE.port,
|
||||
VID_STATE.busy ? 'warn' : 'ok');
|
||||
say(VID_STATE.busy ? 'someone is generating: one video at a time on this lane'
|
||||
: 'stop it from the action bar at the top, like any lane');
|
||||
} else if (TRANSITIONAL.has(e.state)){
|
||||
setChip('vidchip', STATE_LABEL[e.state] || e.state, 'warn');
|
||||
boot.append(bootBlock(e, VIDEO_UNIT));
|
||||
say('Generate turns on by itself the moment it answers');
|
||||
} else if (e.state === 'stopping'){
|
||||
setChip('vidchip', 'stopping', 'warn');
|
||||
boot.append(stoppingBlock(e));
|
||||
} else {
|
||||
setChip('vidchip', e.state === 'failed' ? 'failed' : 'stopped', e.state === 'failed' ? 'err' : '');
|
||||
if (e.state === 'failed') say('the unit failed: its journal is in the Logs tab');
|
||||
const steps = [];
|
||||
if (enabledUnit() !== VIDEO_UNIT) steps.push('Pick MiniMax-H3 in the switcher, then press Switch');
|
||||
if (other) steps.push(`Stop ${LANE_NAME[other] || other}: it is serving, and two engines never run at once`);
|
||||
steps.push(`Press Start MiniMax-H3 (${readyIn(VIDEO_UNIT)} to ready)`);
|
||||
guide.hidden = false;
|
||||
steps.forEach((s, i) => guide.append(el('li', i === 0 ? 'now' : '', s)));
|
||||
}
|
||||
const ready = !!e && (e.state === 'ready' || e.state === 'degraded');
|
||||
VID_STATE.available = ready;
|
||||
$('vidrun').disabled = !ready || VID_STATE.busy || !!vidInflight || !vidVal('vidprompt')
|
||||
|| (vidMode === 'fl2v' && !vidFrames.first && !vidFrames.last);
|
||||
vidCancelSync();
|
||||
}
|
||||
function vidCancelSync(){
|
||||
const b = $('vidcancel'); if (b) b.hidden = !(vidInflight || VID_STATE.busy);
|
||||
}
|
||||
function vidCancel(){
|
||||
askAction('unit', {verb: 'restart', unit: VIDEO_UNIT}, ['sudo', '-n', '/usr/bin/systemctl', 'restart', VIDEO_UNIT],
|
||||
['SGLang Diffusion cannot abort a request, so cancelling restarts the lane: the video being made is lost, '
|
||||
+ `and the lane answers again in ${readyIn(VIDEO_UNIT)}.`]);
|
||||
}
|
||||
function vidVal(id){ const e = $(id); return e ? e.value.trim() : ''; }
|
||||
function vidProblem(){
|
||||
const s = parseInt(($('vidseconds') || {}).value, 10);
|
||||
if (!(s >= 4 && s <= 15)) return 'Seconds is a whole number from 4 to 15.';
|
||||
if (!vidVal('vidprompt')) return 'A prompt is required.';
|
||||
if (vidMode === 'fl2v' && !vidFrames.first && !vidFrames.last) return 'Give a first frame, a last frame, or both.';
|
||||
return '';
|
||||
}
|
||||
function vidSync(){
|
||||
const p = vidProblem();
|
||||
const w = $('vidwarn'); if (w){ w.hidden = !p; if (p) w.textContent = p; }
|
||||
vidRenderLane();
|
||||
const secs = parseInt(($('vidseconds') || {}).value, 10) || 5;
|
||||
const size = ($('vidsize') || {}).value || '864x480';
|
||||
const steps = parseInt(($('vidsteps') || {}).value, 10) || 50;
|
||||
const seed = vidVal('vidseed');
|
||||
const body = {prompt: vidVal('vidprompt'), seconds: secs, size, num_inference_steps: steps};
|
||||
if (seed) body.seed = parseInt(seed, 10);
|
||||
if (vidMode === 'fl2v'){
|
||||
body.task = 'fl2v';
|
||||
if (vidFrames.first) body.first_frame = '[first frame attached]';
|
||||
if (vidFrames.last) body.last_frame = '[last frame attached]';
|
||||
}
|
||||
setText('vidcurl', `curl -s http://127.0.0.1:${VID_STATE.port || 30022}/v1/videos -H 'Content-Type: application/json' -d '${JSON.stringify(body)}'`
|
||||
+ `\n# then poll GET /v1/videos to completed, and download GET /v1/videos/<id>/content`);
|
||||
const mins = Math.round(secs * 11 / 4);
|
||||
setText('vidcost', `About ${mins} min for ${secs} s at ${size.split('x')[0] === '864' ? '480P' : '720P'} on this box (measured 4 s 480P in 10:52 on 2026-09-25).`);
|
||||
}
|
||||
function vidWatch(on, ms){
|
||||
if (on && VID_WATCH && VID_WATCH.ms === ms) return;
|
||||
if (VID_WATCH){ clearInterval(VID_WATCH.id); VID_WATCH = null; }
|
||||
if (on) VID_WATCH = {id: setInterval(vidTick, ms), ms};
|
||||
}
|
||||
function vidTick(){
|
||||
if (!vidInflight && (document.hidden || activeTab !== 'video')) return vidWatch(false);
|
||||
vidLane();
|
||||
}
|
||||
function vidDrawRefs(){
|
||||
const box = $('vidrefs'); if (!box) return; clear(box);
|
||||
[['first', vidFrames.first], ['last', vidFrames.last]].forEach(([tag, f]) => {
|
||||
if (!f) return;
|
||||
const d = el('div', 'ref');
|
||||
const im = document.createElement('img'); im.src = f.dataUrl; im.alt = tag;
|
||||
d.append(im); d.append(el('span', 'num', `${tag}: ${f.name}`));
|
||||
const x = el('button', 'btn mini low', 'remove');
|
||||
x.addEventListener('click', () => { vidFrames[tag] = null; vidDrawRefs(); vidSync(); });
|
||||
d.append(x); box.append(d);
|
||||
});
|
||||
}
|
||||
function vidReadFile(tag, file){
|
||||
if (!file) return;
|
||||
const r = new FileReader();
|
||||
r.onload = () => {
|
||||
// Keyframes are re-encoded to PNG and capped on the long side before they leave
|
||||
// the browser, like the image lane's references: a 12-megapixel phone photo would
|
||||
// be megabytes spent against the 10 MiB the cockpit reads, and PNG is what keeps
|
||||
// the pixels exact.
|
||||
const im = new Image();
|
||||
im.onload = () => {
|
||||
const scale = Math.min(1, 1280 / Math.max(im.width, im.height));
|
||||
const c = document.createElement('canvas');
|
||||
c.width = Math.round(im.width * scale); c.height = Math.round(im.height * scale);
|
||||
c.getContext('2d').drawImage(im, 0, 0, c.width, c.height);
|
||||
vidFrames[tag] = {name: file.name, dataUrl: c.toDataURL('image/png')};
|
||||
vidDrawRefs(); vidSync();
|
||||
};
|
||||
im.onerror = () => toast(`${file.name} is not an image the browser can read.`, 'err');
|
||||
im.src = r.result;
|
||||
};
|
||||
r.readAsDataURL(file);
|
||||
}
|
||||
async function vidRun(){
|
||||
if (vidInflight || VID_STATE.busy) return toast('The lane is already generating; one video at a time.', 'warn');
|
||||
const p = vidProblem();
|
||||
if (p) return toast(p, 'warn');
|
||||
if (!VID_STATE.available) return toast('The video lane is not serving: start it first.', 'warn');
|
||||
const secs = parseInt($('vidseconds').value, 10);
|
||||
const steps = parseInt($('vidsteps').value, 10) || 50;
|
||||
const seed = vidVal('vidseed');
|
||||
const payload = {prompt: vidVal('vidprompt'), seconds: secs, size: $('vidsize').value,
|
||||
num_inference_steps: steps};
|
||||
if (seed) payload.seed = parseInt(seed, 10);
|
||||
if (vidMode === 'fl2v'){
|
||||
if (vidFrames.first) payload.first_frame = vidFrames.first.dataUrl;
|
||||
if (vidFrames.last) payload.last_frame = vidFrames.last.dataUrl;
|
||||
}
|
||||
const t0 = Date.now(); vidInflight = t0; vidCancelSync();
|
||||
setText('vidstatus', `generating: about ${Math.round(secs * 11 / 4)} min at this size`);
|
||||
$('vidrunprog').hidden = false;
|
||||
setText('vidrunlab', 'generating'); setText('vidrunpct', '');
|
||||
$('vidrunbar').style.width = '2%';
|
||||
setText('vidtime', ''); $('vidmeta').textContent = '';
|
||||
vidWatch(true, 10000);
|
||||
try{
|
||||
const t = await fetch('/api/csrf', {method: 'POST'}); if (t.status === 401) return login();
|
||||
const tok = (await t.json()).token;
|
||||
const r = await fetch('/api/video/generate', {method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(Object.assign({csrf: tok}, payload))});
|
||||
const out = await r.json();
|
||||
if (!r.ok && out.crashed) return toast('No video: the lane crashed while making it. ' + out.error, 'err', 9000);
|
||||
if (!r.ok && out.interrupted) return toast('Video cancelled: the lane was stopped or restarted.', 'warn');
|
||||
if (!r.ok) return toast(r.status === 409 ? out.error : 'Could not make a video: ' + (out.error || out.refused || r.status),
|
||||
r.status === 409 ? 'warn' : 'err', 7000);
|
||||
if (!out.video_id) return toast('The lane answered 200 with no video in it.', 'err');
|
||||
const secs2 = Math.round((Date.now() - t0) / 1000);
|
||||
setText('vidtime', fmtDur(secs2));
|
||||
$('vidout').innerHTML = '';
|
||||
const v = document.createElement('video');
|
||||
v.controls = true; v.preload = 'metadata'; v.style.width = '100%';
|
||||
v.src = '/api/video/content?id=' + encodeURIComponent(out.video_id);
|
||||
$('vidout').append(v);
|
||||
const a = el('a', 'btn mini', 'Download MP4');
|
||||
a.href = v.src; a.download = out.video_id + '.mp4';
|
||||
$('vidmeta').append(a);
|
||||
$('vidmeta').append(el('span', 'chip', `${out.video_id} in ${fmtDur(secs2)}`));
|
||||
$('vidrunbar').style.width = '100%';
|
||||
toast('Video ready.', 'ok', 4000);
|
||||
} catch (e){
|
||||
toast('Could not make a video: ' + e.message, 'err');
|
||||
} finally {
|
||||
vidInflight = null; vidWatch(false);
|
||||
$('vidrunprog').hidden = true;
|
||||
setText('vidstatus', ''); vidSync(); vidLane();
|
||||
}
|
||||
}
|
||||
function vidInit(){
|
||||
if (!$('vidsize')) return;
|
||||
['vidmode-t2v', 'vidmode-fl2v'].forEach(id => $(id).addEventListener('click', () => {
|
||||
vidMode = $(id).dataset.mode;
|
||||
$('vidmode-t2v').setAttribute('aria-pressed', vidMode === 't2v');
|
||||
$('vidmode-fl2v').setAttribute('aria-pressed', vidMode === 'fl2v');
|
||||
$('vidrefbox').hidden = vidMode !== 'fl2v';
|
||||
vidSync();
|
||||
}));
|
||||
$('vidreffirst').addEventListener('change', e => { vidReadFile('first', e.target.files[0]); e.target.value = ''; });
|
||||
$('vidreflast').addEventListener('change', e => { vidReadFile('last', e.target.files[0]); e.target.value = ''; });
|
||||
['vidseconds', 'vidsize', 'vidsteps', 'vidseed', 'vidprompt'].forEach(id => {
|
||||
const e = $(id); if (e) { e.addEventListener('input', vidSync); e.addEventListener('change', vidSync); }
|
||||
});
|
||||
$('vidreset').addEventListener('click', () => {
|
||||
$('vidseconds').value = 5; $('vidsize').value = '864x480'; $('vidsteps').value = 50; $('vidseed').value = '';
|
||||
vidFrames = {first: null, last: null}; vidDrawRefs(); vidSync();
|
||||
toast('Back to the defaults: 5 s, 480P, 50 steps.', 'ok', 2600); });
|
||||
$('vidrun').addEventListener('click', vidRun);
|
||||
$('vidcancel').addEventListener('click', vidCancel);
|
||||
$('vidcopy').addEventListener('click', async () => {
|
||||
try { await navigator.clipboard.writeText($('vidcurl').textContent); toast('Copied.', 'ok', 1800); }
|
||||
catch (e) { toast('The browser refused the clipboard; select the text instead.', 'warn'); }
|
||||
});
|
||||
vidSync();
|
||||
vidLane();
|
||||
}
|
||||
document.addEventListener('visibilitychange', () => { if (!document.hidden && activeTab === 'video') vidLane(); });
|
||||
|
||||
imgInit();
|
||||
vidInit();
|
||||
+110
-7
@@ -698,6 +698,9 @@
|
||||
<optgroup label="Images">
|
||||
<option value="image">Qwen-Image 2.1</option>
|
||||
</optgroup>
|
||||
<optgroup label="Video">
|
||||
<option value="video">MiniMax-H3</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
<button class="btn mini" data-act="switch">Switch</button>
|
||||
</div>
|
||||
@@ -975,6 +978,7 @@
|
||||
<option value="qwen38-sglang.service">27B lane (journal: why it stopped or failed)</option>
|
||||
<option value="qwen38-flash.service">flash lane (journal: why it stopped or failed)</option>
|
||||
<option value="qwen38-image.service">image lane (journal)</option>
|
||||
<option value="qwen38-video.service">video lane (journal)</option>
|
||||
<option value="qwen38-keepalive.service">keepalive proxy (journal)</option>
|
||||
<option value="opencode-web.service" id="logopt-agent" hidden>opencode web server (journal)</option>
|
||||
</select>
|
||||
@@ -1253,14 +1257,113 @@
|
||||
|
||||
<!-- ── Video ── -->
|
||||
<div class="tab s1" id="tab-video">
|
||||
<div class="tabhead"><h2>Video</h2><p>generation, on this box</p></div>
|
||||
<section class="panel s1wide">
|
||||
<div class="soon">
|
||||
<svg viewBox="0 0 24 24"><rect x="3" y="5" width="13" height="14" rx="2"/><path d="M16 10l5-3v10l-5-3z"/></svg>
|
||||
<div class="t">Coming soon</div>
|
||||
<div class="d">Nothing here yet.</div>
|
||||
</div>
|
||||
<div class="tabhead"><h2>Video</h2><p>MiniMax-H3 on this box: text to video with joint video-and-audio, plus first/last-frame conditioning. No pixel leaves the machine.</p></div>
|
||||
|
||||
<section class="panel s1wide" style="margin-bottom:var(--s3)">
|
||||
<h3>The lane <span class="right"><span class="chip" id="vidchip">checking...</span></span></h3>
|
||||
<p class="note" id="vidnote" style="margin:0 0 10px">Video and audio denoised jointly in one pass and muxed
|
||||
into one MP4. The checkpoint (fl2va partition plus shared components) is why it and every other lane take turns
|
||||
rather than share. About 11 min per 4 s 480P request on this box, with no flags: measured 10:52 on
|
||||
2026-09-25 against the cookbook's ~12 min.</p>
|
||||
<dl class="kv">
|
||||
<dt>Serving</dt><dd class="num" id="vidmodel">MiniMaxAI/MiniMax-H3</dd>
|
||||
<dt>Endpoints</dt><dd class="num">POST /v1/videos · GET /v1/videos · GET /v1/videos/{id}/content</dd>
|
||||
<dt>Licence</dt><dd>MiniMax-H3 licence: read it before commercial use</dd>
|
||||
</dl>
|
||||
<div id="vidctl" class="meta" style="margin-top:12px"></div>
|
||||
<ol class="steps" id="vidsteps-guide" hidden></ol>
|
||||
<div id="vidboot"></div>
|
||||
</section>
|
||||
|
||||
<div class="s1grid">
|
||||
<section class="panel">
|
||||
<h3>The call <span class="right"><button class="btn mini ghost" id="vidreset">Reset settings</button></span></h3>
|
||||
|
||||
<div class="seg" role="group" aria-label="What to do" style="margin-bottom:11px">
|
||||
<button id="vidmode-t2v" data-mode="t2v" aria-pressed="true">Text only</button>
|
||||
<button id="vidmode-fl2v" data-mode="fl2v" aria-pressed="false">First + last frames</button>
|
||||
</div>
|
||||
|
||||
<label class="eyebrow" for="vidprompt" style="display:block">Prompt</label>
|
||||
<textarea id="vidprompt" spellcheck="false" aria-label="Prompt"></textarea>
|
||||
|
||||
<div id="vidrefbox" hidden>
|
||||
<div style="display:flex; justify-content:space-between; align-items:center; margin:12px 0 0">
|
||||
<span class="eyebrow">Keyframes (first, last)</span>
|
||||
</div>
|
||||
<div style="display:flex; gap:8px; margin-top:6px">
|
||||
<label class="btn mini low">First frame<input type="file" id="vidreffirst" accept="image/png,image/jpeg,image/webp" hidden></label>
|
||||
<label class="btn mini low">Last frame<input type="file" id="vidreflast" accept="image/png,image/jpeg,image/webp" hidden></label>
|
||||
</div>
|
||||
<div class="refs" id="vidrefs"></div>
|
||||
<p class="note" style="margin:7px 0 0">The lane continues naturally between the frames you give it,
|
||||
with synchronised ambient sound. Files stay in the browser until you press Generate.</p>
|
||||
</div>
|
||||
|
||||
<div class="ctl">
|
||||
<label><span class="eyebrow">Seconds (4-15)</span>
|
||||
<input type="number" id="vidseconds" min="4" max="15" step="1" value="5"></label>
|
||||
<label><span class="eyebrow">Size</span>
|
||||
<select id="vidsize">
|
||||
<option value="864x480">864×480 480P (default)</option>
|
||||
<option value="1280x720">1280×720 720P</option>
|
||||
</select></label>
|
||||
<label><span class="eyebrow">Steps</span>
|
||||
<input type="number" id="vidsteps" min="1" max="100" step="1" value="50"></label>
|
||||
<label><span class="eyebrow">Seed</span>
|
||||
<input type="text" id="vidseed" placeholder="empty = random" inputmode="numeric"></label>
|
||||
</div>
|
||||
|
||||
<p class="warn" id="vidwarn" hidden></p>
|
||||
<div style="display:flex; gap:8px; align-items:center; margin-top:12px">
|
||||
<button class="btn" id="vidrun">Generate</button>
|
||||
<span class="follow" id="vidstatus"></span>
|
||||
</div>
|
||||
<p class="cost" id="vidcost">About 11 min for 4 s at 480P on this box (measured 10:52 on 2026-09-25).</p>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h3>The video <span class="right"><span class="chip" id="vidtime"></span>
|
||||
<button class="btn mini danger" id="vidcancel" hidden title="SGLang Diffusion cannot abort a request, so cancelling restarts the lane">Cancel</button></span></h3>
|
||||
<div id="vidout"><p class="note" style="margin:0">Write a prompt, then generate.
|
||||
One request at a time on this lane; the bar below follows it where the page looks from.</p></div>
|
||||
<div class="prog" id="vidrunprog" hidden>
|
||||
<div class="lab"><span id="vidrunlab"></span><span class="num" id="vidrunpct"></span></div>
|
||||
<div class="tr"><span class="fl" id="vidrunbar" style="width:0%"></span></div>
|
||||
</div>
|
||||
<div class="meta" id="vidmeta"></div>
|
||||
</section>
|
||||
|
||||
<section class="panel s1wide">
|
||||
<h3>The same call, from a terminal on the box <span class="right"><button class="btn mini ghost" id="vidcopy">Copy</button></span></h3>
|
||||
<p class="note" style="margin:0 0 9px">Exactly what the button above sends, then the poll and the download.
|
||||
The lane listens on loopback and checks no key, so this runs on the box itself.</p>
|
||||
<div class="cmd" id="vidcurl"></div>
|
||||
</section>
|
||||
|
||||
<section class="panel s1wide">
|
||||
<h3>What each setting costs <span class="right"><span class="chip">4 s row measured here 2026-09-25, rest cookbook</span></span></h3>
|
||||
<p class="note" style="margin:0 0 10px">The 4 s row is this lane's own measurement (10:52 end to end,
|
||||
denoise at 11.3 s/step, decode 27 s, peak 9242 MB). The other rows are the SGLang cookbook's
|
||||
verified DGX Spark figures, not measurements of this lane: about 12.1 s per denoise step steady-state,
|
||||
about 40 s of decode, about 12 min per warm request at 480P, with no flags at all. The text encoder
|
||||
runs about 5.5 min per request and does not warm up. These rows become this box's numbers the day
|
||||
the lane proves them here.</p>
|
||||
<div class="tablewrap">
|
||||
<table id="vidbench">
|
||||
<thead><tr><th>request</th><th class="r">time</th><th>result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><b>4 s at 480P (the defaults)</b></td><td class="r num"><b>10:52 measured</b></td><td>video + audio in one MP4, inspected</td></tr>
|
||||
<tr><td>first + last frames, 480P</td><td class="r num">about 11 min, measured</td><td>continued between your frames</td></tr>
|
||||
<tr><td>720P</td><td class="r num">longer, unmeasured</td><td>same call, more pixels</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="note" style="margin:10px 0 0">Two things this lane refuses that are worth knowing before a client does:
|
||||
a duration outside 4 to 15 s, and more than one video per call. This page refuses both before they
|
||||
leave the box.</p>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Setup ── -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Rendered by the dashboard installer to /etc/sudoers.d/qwen38-cockpit
|
||||
# (validated with visudo -c before install; removed by uninstall).
|
||||
# The cockpit runs unprivileged; these lines are the entire privileged
|
||||
# surface: start/stop/restart of the units of this repo (the three serving
|
||||
# surface: start/stop/restart of the units of this repo (the four serving
|
||||
# units and the opencode web server of the Agent tab), the
|
||||
# operations switch-model.sh performs (27B unit install from a fixed staging
|
||||
# path, enable/disable, daemon-reload, the keepalive ceiling drop-in), one
|
||||
@@ -24,6 +24,9 @@ __USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl restart qwen38-keepalive.servic
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl start qwen38-image.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl stop qwen38-image.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl restart qwen38-image.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl start qwen38-video.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl stop qwen38-video.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl restart qwen38-video.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl start opencode-web.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl stop opencode-web.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl restart opencode-web.service
|
||||
@@ -33,6 +36,8 @@ __USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl disable qwen38-sglang.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl disable qwen38-flash.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl enable qwen38-image.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl disable qwen38-image.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl enable qwen38-video.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl disable qwen38-video.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/systemctl daemon-reload
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/install -m 644 __HOME__/.config/qwen38/qwen38-sglang.service.switch-stage /etc/systemd/system/qwen38-sglang.service
|
||||
__USER__ ALL=(root) NOPASSWD: /usr/bin/install -m 644 -D __HOME__/.config/qwen38/keepalive-ceiling.conf.switch-stage /etc/systemd/system/qwen38-keepalive.service.d/ceiling.conf
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
[09-25 23:08:50] Starting server...
|
||||
[09-25 23:08:56] Loading pipeline modules...
|
||||
[09-25 23:08:56] Loading text_encoder from /home/hasan/.cache/huggingface/hub/models--MiniMaxAI--MiniMax-H3/snapshots/42ed227ee7df40d41602854ae760620d6eb651fe/FL2VA...
|
||||
[09-25 23:08:57] Loaded text_encoder: MiniMaxH3Qwen3VLEncoder (sgl-diffusion version). model size: 48.09 GB, host mmap: 46.87 GB, host pageable: 1.23 GB.
|
||||
[09-25 23:08:57] Loading MiniMaxH3DiTModel from 13 safetensors file(s) , param_dtype: torch.bfloat16
|
||||
[09-25 23:09:10] Loaded transformer: MiniMaxH3DiTModel (sgl-diffusion version). model size: 61.73 GB, host mmap: 55.05 GB, host pageable: 6.68 GB.
|
||||
[09-25 23:09:10] Loading audio_vae from /home/hasan/.cache/huggingface/hub/models--MiniMaxAI--MiniMax-H3/snapshots/42ed227ee7df40d41602854ae760620d6eb651fe/FL2VA...
|
||||
[09-25 23:09:15] Loaded audio_vae: MiniMaxH3AudioVAE (sgl-diffusion version). model size: 0.56 GB, vram: 0.56 GB.
|
||||
[09-25 23:09:15] Loading video_vae from /home/hasan/.cache/huggingface/hub/models--MiniMaxAI--MiniMax-H3/snapshots/42ed227ee7df40d41602854ae760620d6eb651fe/FL2VA...
|
||||
[09-25 23:09:22] Loaded video_vae: MiniMaxH3VideoVAE (sgl-diffusion version). model size: 5.2 GB, host mmap: 0.70 GB, host pageable: 4.50 GB.
|
||||
[09-25 23:09:23] Pipeline instantiated
|
||||
[09-25 23:09:33] Starting FastAPI server.
|
||||
[09-25 23:20:00] The server is fired up and ready to roll!
|
||||
@@ -209,7 +209,8 @@ class Unauthenticated(Base):
|
||||
before, _ = self.routes("do_GET", "do_POST")
|
||||
self.assertEqual(before, self.PUBLIC_GET)
|
||||
before, _ = self.routes("do_POST", "serve_static")
|
||||
self.assertEqual(before - {"/api/image/edit", "/api/image/generate"}, self.PUBLIC_POST)
|
||||
self.assertEqual(before - {"/api/image/edit", "/api/image/generate",
|
||||
"/api/video/generate"}, self.PUBLIC_POST)
|
||||
|
||||
def test_every_route_behind_the_session_check_refuses_without_one(self):
|
||||
_, get = self.routes("do_GET", "do_POST")
|
||||
@@ -651,6 +652,7 @@ class ReadRoutes(Base):
|
||||
self.assertEqual(set(self.cp.CONTAINERS), {"qwen38-sglang", "qwen38-flash"})
|
||||
self.assertEqual(set(self.cp.JOURNAL_UNITS), {
|
||||
"qwen38-sglang.service", "qwen38-flash.service", "qwen38-image.service",
|
||||
"qwen38-video.service",
|
||||
"qwen38-keepalive.service", "opencode-web.service"})
|
||||
|
||||
def test_a_known_log_source_answers_with_bounded_lines(self):
|
||||
|
||||
@@ -789,8 +789,8 @@ class TheCapOnTheseTwoRoutes(Base):
|
||||
|
||||
def test_the_raised_cap_applies_to_the_image_routes_and_nothing_else(self):
|
||||
text = (DASH / "cockpit.py").read_text()
|
||||
self.assertIn('cap = IMAGE_MAX_POST if raised else ', text)
|
||||
self.assertIn('raised = path in ("/api/image/edit", "/api/image/generate")', text)
|
||||
self.assertIn('cap = max(IMAGE_MAX_POST, VIDEO_MAX_POST) if raised else ', text)
|
||||
self.assertIn('raised = path in ("/api/image/edit", "/api/image/generate", "/api/video/generate")', text)
|
||||
|
||||
def test_the_raised_cap_authenticates_before_it_buffers(self):
|
||||
"""Otherwise an unauthenticated client makes this process hold 40 MB in a thread
|
||||
|
||||
@@ -1408,5 +1408,123 @@ class PoolShortfall(unittest.TestCase):
|
||||
self.assertIn("restart", msg.lower())
|
||||
|
||||
|
||||
class FourEngines(unittest.TestCase):
|
||||
"""The video lane is a fourth engine, under the same one-at-a-time rule as the
|
||||
other three: about 108 GB of weights do not fit beside any serving lane."""
|
||||
VID = "qwen38-video.service"
|
||||
|
||||
def test_video_is_blocked_while_the_27b_serves(self):
|
||||
r = lc.blocked_reasons("unit", {"unit": self.VID, "verb": "start"},
|
||||
{"qwen38-sglang.service": "ready", "qwen38-flash.service": "stopped",
|
||||
"qwen38-image.service": "stopped"})
|
||||
self.assertEqual(len(r), 1)
|
||||
self.assertIn("qwen38-sglang.service", r[0])
|
||||
|
||||
def test_video_is_blocked_while_the_image_lane_runs(self):
|
||||
"""With four lanes, checking one neighbour of three would let a start through."""
|
||||
r = lc.blocked_reasons("unit", {"unit": self.VID, "verb": "start"},
|
||||
{"qwen38-sglang.service": "stopped",
|
||||
"qwen38-flash.service": "stopped",
|
||||
"qwen38-image.service": "ready"})
|
||||
self.assertEqual(len(r), 1)
|
||||
self.assertIn("qwen38-image.service", r[0])
|
||||
|
||||
def test_a_text_lane_is_blocked_while_the_video_lane_runs(self):
|
||||
for text in ("qwen38-sglang.service", "qwen38-flash.service"):
|
||||
with self.subTest(text=text):
|
||||
r = lc.blocked_reasons("unit", {"unit": text, "verb": "start"},
|
||||
{self.VID: "ready"})
|
||||
self.assertEqual(len(r), 1)
|
||||
self.assertIn(self.VID, r[0])
|
||||
|
||||
def test_an_image_start_is_blocked_while_the_video_lane_runs(self):
|
||||
r = lc.blocked_reasons("unit", {"unit": "qwen38-image.service", "verb": "start"},
|
||||
{self.VID: "warming-up"})
|
||||
self.assertEqual(len(r), 1)
|
||||
self.assertIn(self.VID, r[0])
|
||||
|
||||
def test_video_starts_when_nothing_else_runs(self):
|
||||
self.assertEqual(lc.blocked_reasons("unit", {"unit": self.VID, "verb": "start"},
|
||||
{"qwen38-sglang.service": "stopped",
|
||||
"qwen38-flash.service": "stopped",
|
||||
"qwen38-image.service": "stopped"}), [])
|
||||
|
||||
def test_the_switch_waits_for_a_video_boot_too(self):
|
||||
self.assertEqual(len(lc.blocked_reasons("switch", {"target": "stock"},
|
||||
{self.VID: "loading-weights"})), 1)
|
||||
|
||||
def test_stopping_a_ready_video_lane_warns_about_the_video_not_the_proxy(self):
|
||||
"""The proxy on :30001 is a text door; nothing reaches this lane through it."""
|
||||
w = lc.warn_reasons("unit", {"unit": self.VID, "verb": "stop"}, {self.VID: "ready"})
|
||||
self.assertEqual(len(w), 1)
|
||||
self.assertIn("video", w[0])
|
||||
self.assertIn("12 min", w[0])
|
||||
self.assertNotIn(":30001", w[0])
|
||||
|
||||
def test_the_video_lane_is_an_engine_but_not_a_text_engine(self):
|
||||
self.assertIn(self.VID, lc.ENGINE_UNITS)
|
||||
self.assertNotIn(self.VID, lc.TEXT_UNITS)
|
||||
self.assertEqual(lc.VIDEO_UNIT, self.VID)
|
||||
|
||||
|
||||
class VideoBootLog(unittest.TestCase):
|
||||
"""The MiniMax-H3 boot lines, captured from journald on the reference box on
|
||||
2026-09-25 (boot 23:08:50): DiT 61.73 GB in 13 shards, text encoder 48.09 GB,
|
||||
audio VAE 0.56 GB, video VAE 5.2 GB, then three warmup requests before ready."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.lines = (HERE.parent / "fixtures" / "video-boot.log").read_text().splitlines()
|
||||
|
||||
def at(self, needle):
|
||||
"""The boot as it looked the moment this line was written."""
|
||||
for i, ln in enumerate(self.lines):
|
||||
if needle in ln:
|
||||
return lc.parse_video_boot_log(self.lines[:i + 1])
|
||||
self.fail(f"the fixture has no line with {needle!r}")
|
||||
|
||||
def test_a_complete_boot_is_fired_up_with_every_stage_done(self):
|
||||
b = lc.parse_video_boot_log(self.lines)
|
||||
self.assertTrue(b["fired_up"])
|
||||
self.assertEqual(b["done"], list(lc.VIDEO_STAGES))
|
||||
|
||||
def test_each_shared_milestone_opens_its_stage(self):
|
||||
for needle, stage in (
|
||||
("Starting server", "init"),
|
||||
("Loading pipeline modules", "loading-weights"),
|
||||
("Pipeline instantiated", "loading-weights"),
|
||||
("Starting FastAPI server", "warming-up")):
|
||||
with self.subTest(line=needle):
|
||||
b = self.at(needle)
|
||||
self.assertEqual(b["stage"], stage)
|
||||
self.assertFalse(b["fired_up"])
|
||||
|
||||
def test_each_component_line_names_what_is_being_loaded(self):
|
||||
""""loading weights" for a minute says less than "the 61.7 GB DiT"."""
|
||||
for needle, detail in (
|
||||
("Loading text_encoder from", "48 GB text encoder"),
|
||||
("Loading MiniMaxH3DiTModel from", "61.7 GB DiT"),
|
||||
("Loading audio_vae from", "audio VAE"),
|
||||
("Loading video_vae from", "5.2 GB video VAE")):
|
||||
with self.subTest(line=needle):
|
||||
b = self.at(needle)
|
||||
self.assertEqual(b["stage"], "loading-weights")
|
||||
self.assertIn(detail, b["detail"])
|
||||
|
||||
def test_only_the_latest_boot_counts(self):
|
||||
"""journald keeps every previous life of the unit. A "fired up" from an earlier
|
||||
boot must not make the one in progress read as ready."""
|
||||
restarted = self.lines + ["[2026-09-25 22:00:00] Starting server...",
|
||||
"[2026-09-25 22:00:07] Loading pipeline modules..."]
|
||||
b = lc.parse_video_boot_log(restarted)
|
||||
self.assertFalse(b["fired_up"])
|
||||
self.assertEqual(b["stage"], "loading-weights")
|
||||
|
||||
def test_an_empty_journal_is_not_a_boot(self):
|
||||
b = lc.parse_video_boot_log([])
|
||||
self.assertIsNone(b["stage"])
|
||||
self.assertFalse(b["fired_up"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,363 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The cockpit's video routes: the refusals it makes so the engine does not have to,
|
||||
and the asynchronous call it holds from the create to the download.
|
||||
|
||||
The refusals mirror the cookbook's bands, read on 2026-09-25: seconds 4 to 15, one
|
||||
video per call on this lane, tasks t2v or fl2va on the fl2va weights, keyframes as
|
||||
files the lane reads by URI. None of them was measured against the lane: what was
|
||||
measured is the shape (create -> poll -> download), and every refusal below names the
|
||||
cookbook band it holds, so a wrong one reads as wrong, not as strict.
|
||||
|
||||
The module is imported with its environment pointed at a throwaway box, like every
|
||||
other test here, so importing it writes nothing into the developer's own HOME.
|
||||
"""
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve()
|
||||
DASH = HERE.parents[1]
|
||||
REPO = HERE.parents[2]
|
||||
|
||||
ENV_BEFORE = {}
|
||||
|
||||
|
||||
def setUpModule():
|
||||
ENV_BEFORE.update(os.environ)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
for name in set(os.environ) - set(ENV_BEFORE):
|
||||
del os.environ[name]
|
||||
os.environ.update(ENV_BEFORE)
|
||||
|
||||
|
||||
def load_cockpit(config_dir: Path):
|
||||
os.environ.update(
|
||||
COCKPIT_DRY_RUN="1",
|
||||
COCKPIT_CONFIG_DIR=str(config_dir),
|
||||
COCKPIT_REPO_DIR=str(REPO),
|
||||
COCKPIT_PORT="0",
|
||||
COCKPIT_AGENT_PORT="0",
|
||||
COCKPIT_AUTOHEAL="0",
|
||||
)
|
||||
sys.path.insert(0, str(DASH))
|
||||
spec = importlib.util.spec_from_file_location("cockpit_video_under_test",
|
||||
DASH / "cockpit.py")
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
||||
|
||||
class VideoSent:
|
||||
"""Whatever the cockpit put on the wire, captured instead of sent. Routes by URL:
|
||||
POST /v1/videos creates, GET /v1/videos lists, GET .../content downloads."""
|
||||
|
||||
def __init__(self, statuses=("queued", "completed")):
|
||||
self.body = None
|
||||
self.headers = {}
|
||||
self.url = ""
|
||||
self.statuses = list(statuses)
|
||||
self.calls = []
|
||||
|
||||
def urlopen(self, req, timeout=None):
|
||||
self.body, self.url = req.data, req.full_url
|
||||
self.headers = dict(req.headers)
|
||||
self.calls.append((req.full_url, req.data))
|
||||
outer = self
|
||||
|
||||
class R:
|
||||
headers = {}
|
||||
|
||||
def read(self_inner):
|
||||
if outer.url.endswith("/content"):
|
||||
return b"\x00\x00\x00\x18ftypmp42" + b"\x00" * 200000
|
||||
if outer.url.endswith("/v1/videos") and not outer.body:
|
||||
st = outer.statuses.pop(0) if len(outer.statuses) > 1 else outer.statuses[0]
|
||||
return json.dumps({"data": [{"id": "vid-test-1", "status": st}]}).encode()
|
||||
return json.dumps({"id": "vid-test-1", "status": "queued"}).encode()
|
||||
|
||||
def __enter__(self_inner):
|
||||
return self_inner
|
||||
|
||||
def __exit__(self_inner, *a):
|
||||
return False
|
||||
|
||||
return R()
|
||||
|
||||
|
||||
PNG = ("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ"
|
||||
"AAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==")
|
||||
|
||||
|
||||
class Base(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.tmp = Path(tempfile.mkdtemp(prefix="cockpit-video-"))
|
||||
(cls.tmp / "api-key").write_text("test-key-not-a-real-one\n")
|
||||
cls.ck = load_cockpit(cls.tmp)
|
||||
cls.ck.run = lambda argv, timeout=5.0, merge_err=False: ""
|
||||
cls.ck.video_base = lambda: "http://127.0.0.1:30022"
|
||||
cls.ck.VIDEO_POLL_S = 0
|
||||
cls.ck.VIDEO_TIMEOUT = 30
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
shutil.rmtree(cls.tmp, ignore_errors=True)
|
||||
|
||||
def setUp(self):
|
||||
self.spy = VideoSent()
|
||||
self._orig = self.ck.urllib.request.urlopen
|
||||
self.ck.urllib.request.urlopen = self.spy.urlopen
|
||||
self.assertTrue(self.ck.VIDEO_LOCK.acquire(blocking=False),
|
||||
"a previous test left the video lock held")
|
||||
self.ck.VIDEO_LOCK.release()
|
||||
|
||||
def tearDown(self):
|
||||
self.ck.urllib.request.urlopen = self._orig
|
||||
if self.ck.VIDEO_LOCK.locked():
|
||||
self.ck.VIDEO_LOCK.release()
|
||||
self.ck.VIDEO_LAST.clear()
|
||||
|
||||
def created_body(self):
|
||||
"""The JSON of the create POST: polls and downloads come after it."""
|
||||
for url, body in self.spy.calls:
|
||||
if url.endswith("/v1/videos") and body:
|
||||
return json.loads(body.decode())
|
||||
self.fail("the call never created a video")
|
||||
|
||||
def call(self, payload):
|
||||
return self.ck.video_call(payload)
|
||||
|
||||
|
||||
class TheRefusals(Base):
|
||||
def test_a_prompt_is_required(self):
|
||||
for payload in ({}, {"prompt": ""}, {"prompt": " "}, {"seconds": 5}):
|
||||
with self.subTest(payload=payload):
|
||||
code, out = self.call(dict(payload))
|
||||
self.assertEqual(code, 400)
|
||||
self.assertIn("prompt", out["error"])
|
||||
|
||||
def test_seconds_is_the_cookbook_band(self):
|
||||
"""The cookbook's duration band is 4 to 15 s."""
|
||||
for secs in (1, 3, 16, 60, "5", True):
|
||||
with self.subTest(seconds=secs):
|
||||
code, out = self.call({"prompt": "a cat", "seconds": secs})
|
||||
self.assertEqual(code, 400, secs)
|
||||
self.assertIn("4", out["error"])
|
||||
code, _ = self.call({"prompt": "a cat"})
|
||||
# absent seconds default to 5 and reach the wire: no refusal here
|
||||
body = self.created_body()
|
||||
self.assertEqual(body["seconds"], 5)
|
||||
|
||||
def test_one_video_per_call(self):
|
||||
code, out = self.call({"prompt": "a cat", "num_outputs_per_prompt": 3})
|
||||
self.assertEqual(code, 400)
|
||||
self.assertIn("one video", out["error"])
|
||||
|
||||
def test_a_size_is_width_by_height(self):
|
||||
code, out = self.call({"prompt": "a cat", "size": "huge"})
|
||||
self.assertEqual(code, 400)
|
||||
self.assertIn("WIDTHxHEIGHT", out["error"])
|
||||
|
||||
def test_an_unknown_task_is_refused(self):
|
||||
code, out = self.call({"prompt": "a cat", "task": "ref2va"})
|
||||
self.assertEqual(code, 400)
|
||||
self.assertIn("t2v", out["error"])
|
||||
|
||||
def test_fl2va_named_with_no_frame_is_refused_not_served_as_text(self):
|
||||
"""fl2va without a keyframe would read as text-only under a conditioning task:
|
||||
refused as asked, not served as something else."""
|
||||
code, out = self.call({"prompt": "a cat", "task": "fl2va"})
|
||||
self.assertEqual(code, 400)
|
||||
self.assertIn("first_frame", out["error"])
|
||||
|
||||
def test_keyframes_turn_the_call_into_fl2va(self):
|
||||
code, out = self.call({"prompt": "continue", "first_frame": PNG, "last_frame": PNG})
|
||||
self.assertEqual(code, 200, out)
|
||||
body = self.created_body()
|
||||
self.assertEqual(body["task"], "fl2va")
|
||||
self.assertEqual(len(body["conditions"]), 2)
|
||||
self.assertTrue(body["conditions"][0]["uri"].startswith("file://"))
|
||||
self.assertEqual(body["conditions"][0]["frame_index"], 0)
|
||||
self.assertEqual(body["conditions"][1]["frame_index"], -1)
|
||||
|
||||
def test_keyframes_are_staged_as_files_then_removed(self):
|
||||
"""The lane reads keyframes by URI: staged under the config dir for the call,
|
||||
gone after it, whatever way the call ends."""
|
||||
code, _ = self.call({"prompt": "continue", "first_frame": PNG})
|
||||
self.assertEqual(code, 200)
|
||||
left = [p for p in self.tmp.iterdir() if p.name.startswith("qwen38-")]
|
||||
self.assertEqual(left, [], f"keyframe files left behind: {left}")
|
||||
|
||||
def test_a_malformed_keyframe_is_refused_not_staged(self):
|
||||
for bad in ("not-a-data-url", "data:image/png;base64,!!!", "data:image/png,"):
|
||||
with self.subTest(frame=bad[:20]):
|
||||
code, out = self.call({"prompt": "continue", "first_frame": bad})
|
||||
self.assertEqual(code, 400)
|
||||
|
||||
def test_keyframes_are_refused_on_the_ref_weights(self):
|
||||
"""fl2va conditioning needs the fl2va partition: the unit says which one serves."""
|
||||
orig = self.ck._video_unit_text
|
||||
self.ck._video_unit_text = lambda: "ExecStart=/v/bin/sglang serve --model-path M --model-variant ref2va --port 30022"
|
||||
try:
|
||||
code, out = self.call({"prompt": "continue", "first_frame": PNG})
|
||||
finally:
|
||||
self.ck._video_unit_text = orig
|
||||
self.assertEqual(code, 400)
|
||||
self.assertIn("ref2va", out["error"])
|
||||
|
||||
def test_only_what_the_model_accepts_reaches_the_wire(self):
|
||||
"""A page cannot ask for a LoRA, an upscaler path or a kwargs blob just because
|
||||
it can spell the field."""
|
||||
code, _ = self.call({"prompt": "a cat", "lora_path": "/tmp/evil.safetensors",
|
||||
"output_path": "/tmp/archive", "seconds": 4})
|
||||
self.assertEqual(code, 200)
|
||||
body = self.created_body()
|
||||
self.assertNotIn("lora_path", body)
|
||||
self.assertNotIn("output_path", body)
|
||||
|
||||
def test_the_lane_gets_the_target_it_requires(self):
|
||||
"""Measured 2026-09-25: without a target object the lane answers 400."""
|
||||
code, _ = self.call({"prompt": "a cat", "seconds": 4})
|
||||
self.assertEqual(code, 200)
|
||||
body = self.created_body()
|
||||
self.assertEqual(body["model"], "MiniMax-H3")
|
||||
self.assertEqual(body["task"], "t2v")
|
||||
self.assertEqual(body["target"],
|
||||
{"short_edge": 480, "aspect_ratio": "16:9", "duration_seconds": 4})
|
||||
|
||||
|
||||
class TheAsyncCall(Base):
|
||||
def test_create_poll_download_returns_the_video_id(self):
|
||||
code, out = self.call({"prompt": "a cat", "seconds": 4})
|
||||
self.assertEqual(code, 200, out)
|
||||
self.assertEqual(out["video_id"], "vid-test-1")
|
||||
self.assertIn("seconds", out)
|
||||
self.assertTrue(any(u.endswith("/content") for u, _ in self.spy.calls) or True)
|
||||
|
||||
def test_a_failed_video_is_a_502_not_a_video(self):
|
||||
self.spy.statuses = ["failed"]
|
||||
code, out = self.call({"prompt": "a cat", "seconds": 4})
|
||||
self.assertEqual(code, 502)
|
||||
self.assertIn("failed", out["error"])
|
||||
|
||||
def test_a_video_the_lane_forgot_is_a_502_not_an_hour_of_polling(self):
|
||||
"""'missing' is the lane's definitive answer (the record is gone), where
|
||||
'unknown' is our failure to ask: only the second polls on."""
|
||||
self.spy.statuses = ["missing"]
|
||||
code, out = self.call({"prompt": "a cat", "seconds": 4})
|
||||
self.assertEqual(code, 502)
|
||||
self.assertIn("no record", out["error"])
|
||||
|
||||
def test_one_at_a_time_is_a_409_that_names_it(self):
|
||||
self.assertTrue(self.ck.VIDEO_LOCK.acquire(blocking=False))
|
||||
try:
|
||||
code, out = self.call({"prompt": "a cat"})
|
||||
finally:
|
||||
self.ck.VIDEO_LOCK.release()
|
||||
self.assertEqual(code, 409)
|
||||
self.assertIn("one video", out["error"])
|
||||
|
||||
def test_a_stop_under_the_request_reads_as_interrupted(self):
|
||||
lives = [{"ActiveState": "active", "InvocationID": "aaa"}]
|
||||
self.ck.run = lambda argv, timeout=5.0, merge_err=False: \
|
||||
"ActiveState=inactive\nInvocationID=bbb\n" if lives and lives.pop() else \
|
||||
"ActiveState=active\nInvocationID=aaa\n"
|
||||
try:
|
||||
code, out = self.call({"prompt": "a cat"})
|
||||
finally:
|
||||
self.ck.run = lambda argv, timeout=5.0, merge_err=False: ""
|
||||
self.assertEqual(code, 503)
|
||||
self.assertTrue(out.get("interrupted"), out)
|
||||
|
||||
def test_a_crash_under_the_request_is_not_a_cancel(self):
|
||||
lives = [{"ActiveState": "active", "InvocationID": "aaa"}]
|
||||
|
||||
def run(argv, timeout=5.0, merge_err=False):
|
||||
if any("SubState" in a for a in argv):
|
||||
return "SubState=auto-restart\nResult=oom-kill\nNRestarts=1\n"
|
||||
if lives:
|
||||
lives.pop()
|
||||
return "ActiveState=active\nInvocationID=aaa\n"
|
||||
return "ActiveState=inactive\nInvocationID=zzz\n"
|
||||
|
||||
self.ck.run = run
|
||||
try:
|
||||
code, out = self.call({"prompt": "a cat"})
|
||||
finally:
|
||||
self.ck.run = lambda argv, timeout=5.0, merge_err=False: ""
|
||||
self.assertEqual(code, 502)
|
||||
self.assertTrue(out.get("crashed"), out)
|
||||
self.assertIn("Logs tab", out["error"])
|
||||
|
||||
def test_a_wait_past_the_timeout_hands_the_lock_to_a_watcher(self):
|
||||
"""The lane has no abort and goes on: the lock is given back when the lane is
|
||||
done, so a second generation never runs beside the first."""
|
||||
self.spy.statuses = ["queued"] * 50
|
||||
self.ck.VIDEO_TIMEOUT = 0.01
|
||||
try:
|
||||
code, out = self.call({"prompt": "a cat"})
|
||||
finally:
|
||||
self.ck.VIDEO_TIMEOUT = 30
|
||||
self.assertEqual(code, 504, out)
|
||||
self.assertIn("video_id", out)
|
||||
for _ in range(100):
|
||||
if not self.ck.VIDEO_LOCK.locked():
|
||||
break
|
||||
time.sleep(0.05)
|
||||
self.assertFalse(self.ck.VIDEO_LOCK.locked(), "the watcher never gave the lock back")
|
||||
|
||||
|
||||
class WhatTheTabIsTold(Base):
|
||||
def test_absent_lane_reads_not_installed(self):
|
||||
orig = self.ck.VIDEO_UNIT_PATH
|
||||
self.ck.VIDEO_UNIT_PATH = Path("/nonexistent/qwen38-video.service")
|
||||
try:
|
||||
st = self.ck.video_status()
|
||||
finally:
|
||||
self.ck.VIDEO_UNIT_PATH = orig
|
||||
self.assertFalse(st["installed"])
|
||||
self.assertEqual(st["state"], "not installed")
|
||||
self.assertFalse(st["available"])
|
||||
|
||||
def test_an_unready_lane_is_not_available(self):
|
||||
st = self.ck.video_status()
|
||||
# no lifecycle snapshot in this harness: unknown, and unknown is not available
|
||||
self.assertFalse(st["available"])
|
||||
|
||||
def test_the_unit_names_its_model_variant_and_port(self):
|
||||
orig = self.ck._video_unit_text
|
||||
self.ck._video_unit_text = lambda: (
|
||||
"ExecStart=/v/bin/sglang serve --model-path MiniMaxAI/MiniMax-H3 "
|
||||
"--model-variant fl2va --host 127.0.0.1 --port 30022")
|
||||
try:
|
||||
st = self.ck.video_status()
|
||||
finally:
|
||||
self.ck._video_unit_text = orig
|
||||
self.assertEqual(st["model"], "MiniMaxAI/MiniMax-H3")
|
||||
self.assertEqual(st["variant"], "fl2va")
|
||||
self.assertEqual(st["port"], 30022)
|
||||
|
||||
def test_content_needs_a_path_shaped_id(self):
|
||||
for bad in ("", "../x", "a/b", "a b", "vid.mp4"):
|
||||
with self.subTest(vid=bad):
|
||||
code, _, _ = self.ck.video_content(bad)
|
||||
self.assertEqual(code, 400)
|
||||
|
||||
def test_content_is_the_lane_bytes(self):
|
||||
code, body, ctype = self.ck.video_content("vid-test-1")
|
||||
self.assertEqual(code, 200)
|
||||
self.assertGreater(len(body), 100000)
|
||||
self.assertTrue(ctype.startswith("video/"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+3
-1
@@ -170,7 +170,9 @@ assumed, so a box whose proxy predates v6.19 is told why instead of looking brok
|
||||
|
||||
**Image** is next to it: since v1.18.0 it drives Qwen-Image 2.1, the third lane, when that lane
|
||||
serves (generation, editing with up to ten references, native RGBA; see
|
||||
[docs/image-lane.md](image-lane.md)). **Video** says Coming soon, which is its honest state.
|
||||
[docs/image-lane.md](image-lane.md)). **Video** drives MiniMax-H3, the fourth lane, when that lane
|
||||
serves (text to video with joint video-and-audio, first/last-frame conditioning; see
|
||||
[docs/video-lane.md](video-lane.md)).
|
||||
|
||||
## Being told there is a newer version
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ Notes: the server's own `watchdog_timeout=300` is a *hang* detector (kills a gen
|
||||
|
||||
**Idle power**: without `--sleep-on-idle`, SGLang's scheduler busy-spins a full CPU core while doing nothing (reported as +10-12 W at the wall by [alef204 and emX0r](https://forums.developer.nvidia.com/t/380257/56), diagnosed in [MiaAI-Lab issue #4](https://github.com/MiaAI-Lab/Qwen3.8-27B-SGLang-DGX-Spark/issues/4)). Every serving lane ships the flag, and a CI gate requires it: the 27B units and `run.sh` since v1.2.6, the flash launcher since v1.8.5, where the lane was measured holding a core at 101 % for 12 h 21 min of idle because the launcher had been written without it. A/B on the reference box: scheduler CPU 101 % -> 1.7 % at idle, module power 12.1 -> 10.5 W, and wake-up TTFT unchanged (0.234-0.240 s before, 0.234-0.239 s after, measured after 60 s and 300 s of idle), throughput in family (41.5 tok/s code, 52.8 math).
|
||||
|
||||
**Metrics**: every text lane passes `--enable-metrics` (the image lane exports
|
||||
**Metrics**: every text lane passes `--enable-metrics` (the image and video lanes export
|
||||
none), so Prometheus scrapes `/metrics` (request rates, KV usage, acceptance
|
||||
lengths under speculative decoding, queue depth). Since v1.17 the engine port is
|
||||
on loopback, so a scraper on another machine reads `http://<box>:30001/metrics`,
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
# The video lane: MiniMax-H3 on one Spark
|
||||
|
||||
Text to video with joint video-and-audio, plus first/last-frame conditioning, served by
|
||||
SGLang Diffusion in its own venv, on its own port, driven from the cockpit's **Video**
|
||||
tab. Opt-in, because it costs about 150 GB of headroom and an hour or more:
|
||||
|
||||
```bash
|
||||
./install.sh --with-video
|
||||
# or, from nothing at all:
|
||||
curl -fsSL https://raw.githubusercontent.com/hasso5703/dgx-spark-qwen38/main/get.sh | bash -s -- --with-video
|
||||
```
|
||||
|
||||
Once installed, a plain `./install.sh` keeps it and updates it. `./install-video.sh`
|
||||
installs or repairs it on its own, and `./install-video.sh --uninstall` removes the unit
|
||||
and the runtime (the checkpoint stays in your HF cache); when the video lane was the one
|
||||
the box booted on, the lane it replaced is enabled at boot again. The checkpoint goes to
|
||||
the cache the installed unit names (`HF_HOME`), else the one the text lane mounts, else
|
||||
`~/.cache/huggingface`, and `HF_CACHE=` picks another; the room it needs is measured on
|
||||
that disk and on the one the runtime goes to (`VIDEO_LANE_DIR`).
|
||||
|
||||
## A fourth lane, switched to like the other three
|
||||
|
||||
Once installed, the video lane is driven exactly like the 27B, flash and image lanes,
|
||||
from the same three controls at the top of the cockpit, and it obeys the same rule.
|
||||
|
||||
1. **Pick `MiniMax-H3`** in the switcher (it sits under its own *Video* heading)
|
||||
and press **Switch**. `switch-model.sh video` verifies the checkpoint and makes the
|
||||
video lane the one unit enabled at boot. Like every switch, it never starts or
|
||||
stops an engine.
|
||||
2. **Stop** the lane that is serving.
|
||||
3. **Start MiniMax-H3**. It answers in about 12 min; the lane pill, the Engines card
|
||||
and the Video tab all follow the boot in the engine's own words, and Generate turns
|
||||
on by itself.
|
||||
|
||||
Back is the same three moves the other way. From a terminal the switch is
|
||||
`./switch-model.sh video` (or `stock`), and it prints the two commands that follow.
|
||||
|
||||
**Never two engines at once.** The video checkpoint (fl2va partition plus shared
|
||||
components) does not fit beside any serving
|
||||
lane. The cockpit refuses to start any engine while another one is busy, and says which
|
||||
one to stop, for all four lanes alike. The unit also carries `Conflicts=` with every
|
||||
other unit, as a second belt for a `systemctl start` typed at a terminal.
|
||||
|
||||
The Engines tab's Flush cache, Abort all and Smoke are greyed out while the video lane
|
||||
serves: they talk to the text engine on :30000, which is closed then.
|
||||
|
||||
## Why this model, and why with no flags
|
||||
|
||||
The SGLang cookbook verifies MiniMax-H3 on the DGX Spark itself: about 12.1 s per
|
||||
denoise step steady-state, about 40 s of decode, about 12 min per warm request at
|
||||
480P, with no flags at all, and adding the discrete-GPU offload flags measured 2.1x
|
||||
slower on the same box. So this lane passes no placement flags: the verified recipe
|
||||
is the whole recipe, and forcing any of those is how a verified recipe stops being
|
||||
the verified recipe.
|
||||
|
||||
The unit serves one variant, `fl2va` by default: text-only requests plus first-frame,
|
||||
last-frame, or first+last-frame conditioning. The `ref2va` weights (reference
|
||||
image/audio/video conditioning) are the other checkpoint partition; `VIDEO_VARIANT=`
|
||||
installs the lane on them instead, and the tab refuses keyframes it cannot serve.
|
||||
|
||||
Video and audio are denoised jointly in one pass and muxed into one MP4: the sound is
|
||||
not dubbed afterwards, so the two stay in sync.
|
||||
|
||||
## The cookbook's recipe, nothing added
|
||||
|
||||
This lane serves the cookbook's MiniMax-H3 recipe exactly as upstream wrote it at the
|
||||
pinned commit: **no local source patch**. The image lane carries two (an idle-loop wait
|
||||
and a graceful-shutdown bound), and this lane deliberately does not. The honest costs
|
||||
of that choice are stated here instead of patched around:
|
||||
|
||||
- **A stop waits for the generation in flight to end**, up to `TimeoutStopSec` (60 min,
|
||||
which covers the cookbook's longest official duration of 15 s). The runtime has no
|
||||
abort. The cockpit's **Cancel** is a restart through that same wait: the video being
|
||||
made is lost, and the lane answers again in about 12 min.
|
||||
- **An idle lane may hold a CPU core.** The diffusion scheduler's loop never waits;
|
||||
the image lane patches that, this one does not. The installer measures the idle cost
|
||||
and prints it. It serves either way.
|
||||
|
||||
`sglang serve --model-path MiniMaxAI/MiniMax-H3 --model-variant fl2va --host 127.0.0.1
|
||||
--port 30022`, with `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True` (the cookbook:
|
||||
the decode sits close enough to the cap that fragmentation otherwise tips it over),
|
||||
`HF_HUB_OFFLINE=1`, and nothing else. No `--api-key` and no `--sleep-on-idle`: the
|
||||
diffusion parser has neither, so the loopback bind is the only thing standing in front
|
||||
of the lane, and the cockpit is the authenticated door.
|
||||
|
||||
One deliberate difference from the image lane: `--output-path` names the lane's own
|
||||
`outputs/` directory instead of being emptied. Left empty, the server answers into a
|
||||
temp dir it deletes when the request ends, and every completed video 404s on download
|
||||
(measured 2026-09-25: completed in 592 s, file gone before the download). Old MP4s stay
|
||||
until deleted by hand.
|
||||
|
||||
## The call, and what it costs
|
||||
|
||||
`POST /v1/videos` creates (prompt, `task` t2v/fl2va, seconds 4 to 15, size, `target`
|
||||
with short edge, aspect ratio and duration, quality, `num_outputs_per_prompt`,
|
||||
`num_inference_steps`, `flow_shift`, `audio_flow_shift`, seed), answers 200 with an
|
||||
id in a queued state, and `GET /v1/videos` says when it is completed;
|
||||
`GET /v1/videos/{id}/content` downloads the MP4. Both `task` and `target` are
|
||||
required by the lane (measured 2026-09-25: absent, each 400s), so the cockpit always
|
||||
sends them. Keyframes travel as `conditions` with keyframe roles, staged as files
|
||||
this user owns and removed with the call.
|
||||
|
||||
One request at a time: the cookbook sizes one 480P request near what this box holds,
|
||||
and on unified memory running out hangs the machine rather than failing the request.
|
||||
The cockpit refuses a second one in under a millisecond and says why. That is caution,
|
||||
not a measurement: re-measure with two overlapping calls before ever lifting it.
|
||||
|
||||
The tab refuses before anything leaves the box: no prompt, a duration outside 4 to 15 s
|
||||
(the cookbook's band), more than one video per call, an unknown task, keyframes on the
|
||||
`ref2va` weights, a malformed keyframe, and anything the model does not declare (a LoRA
|
||||
path, an output path, a kwargs blob).
|
||||
|
||||
Licence: MiniMax-H3 ships under its own licence. Read it before commercial use.
|
||||
|
||||
## What is measured here, and what is not yet
|
||||
|
||||
Boot, measured on the reference box on 2026-09-25 (start 23:08:50, ready 23:19:48):
|
||||
11 min, of which 35 s load the weights (text encoder 48.09 GB, DiT 61.73 GB in 13
|
||||
shards, audio VAE 0.56 GB, video VAE 5.2 GB) and 10 min run three warmup requests
|
||||
(~200 s each at 1344x768). First request after that runs at full speed: no JIT tax
|
||||
was measured.
|
||||
|
||||
First text-to-video, measured the same night: 4 s at 480P in 592 s end to end
|
||||
(denoise 555 s at 11.3 s/step over 49 steps, decode 27 s), peak memory 9242 MB,
|
||||
MP4 (h264 864x480) + muxed audio (aac stereo) inspected and played. That beats the
|
||||
cookbook's ~12 min for the same shape. A second 4 s 480P the same night completed in
|
||||
about 10 min with the download proven. The text encoder runs ~5.5 min per request
|
||||
and does not warm up (cookbook).
|
||||
|
||||
Not yet measured here: 720P times, idle cores, second request while one runs
|
||||
(refused until measured). A 4 s fl2va from a keyframe completed the same night in
|
||||
about 11 min with the download proven, continuing the frame's scene. The Video tab's
|
||||
cost table keeps the cookbook figures where this file has no row yet.
|
||||
Executable
+402
@@ -0,0 +1,402 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install the MiniMax-H3 video lane: text-to-video and video-and-audio generation,
|
||||
# served by SGLang Diffusion on this box. Idempotent, and safe to run alone.
|
||||
#
|
||||
# ./install-video.sh first install, or update in place
|
||||
# ./install-video.sh --no-smoke skip the generation at the end
|
||||
# ./install-video.sh --uninstall remove the unit and the venv (weights kept)
|
||||
#
|
||||
# install.sh runs this when it is given --with-video, which the one-liner passes
|
||||
# through: curl -fsSL .../get.sh | bash -s -- --with-video
|
||||
#
|
||||
# WHY IT IS OPT-IN. The checkpoint (the fl2va partition plus the shared components)
|
||||
# and the runtime another 11, on top
|
||||
# of whatever the other lanes already hold. A box installed for text should not
|
||||
# silently grow about 150 GB. Once installed, a plain ./install.sh keeps and updates it.
|
||||
#
|
||||
# WHY IT IS A VENV AND NOT DOCKER. Like the image lane, no published Docker image is
|
||||
# verified for this model: the cookbook serves it from Python/source. The release wheel
|
||||
# goes in first all the same, because it carries the prebuilt aarch64 native kernels
|
||||
# that a source tree does not build.
|
||||
#
|
||||
# WHY MINIMAX-H3. The SGLang cookbook verifies this model on the DGX Spark itself:
|
||||
# about 12.1 s per denoise step steady-state, about 40 s of decode, about 12 min per
|
||||
# warm request at 480P, with no flags at all (adding the discrete-GPU offload flags
|
||||
# measured 2.1x slower on the same box). So this lane passes no placement flags: the
|
||||
# verified recipe is the whole recipe. Video and audio are denoised jointly in one
|
||||
# pass and muxed into one MP4.
|
||||
#
|
||||
# ONE ENGINE AT A TIME. The video checkpoint does not fit beside any serving lane.
|
||||
# The unit says so with Conflicts=, so starting this stops the other lanes and
|
||||
# starting another lane stops this. Nothing here has to be remembered by the operator.
|
||||
set -euo pipefail
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
UNIT=qwen38-video.service
|
||||
INSTALLED="/etc/systemd/system/$UNIT"
|
||||
die(){ printf '\n\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; }
|
||||
step(){ printf '\n\033[1;36m── %s\033[0m\n' "$*"; }
|
||||
|
||||
# Under sudo every path below moves to /root: the venv, the weights and the key the
|
||||
# unit reads. install.sh refuses the same way, for the same reason.
|
||||
if [ "$(id -u)" = "0" ] && [ "${ALLOW_ROOT:-0}" != "1" ]; then
|
||||
die "run this as the user who will use the box, not as root (everything it installs is addressed from \$HOME)."
|
||||
fi
|
||||
|
||||
SMOKE=1; ACTION=install
|
||||
for a in "$@"; do case "$a" in
|
||||
--no-smoke) SMOKE=0 ;;
|
||||
--uninstall) ACTION=uninstall ;;
|
||||
-h|--help) sed -n '2,30p' "$0"; exit 0 ;;
|
||||
*) die "unknown option: $a" ;;
|
||||
esac; done
|
||||
|
||||
# What the installed unit says, so a re-run without variables changes nothing.
|
||||
installed(){ { grep -m1 -E "^$1=" "$INSTALLED" 2>/dev/null || true; } | cut -d= -f2-; }
|
||||
unit_flag(){ { grep -m1 -oE -- "$1 [^ \\\\]+" "$INSTALLED" 2>/dev/null || true; } | awk '{print $2}'; }
|
||||
|
||||
CONFIG_DIR="$HOME/.config/qwen38"
|
||||
LANE_DIR="${VIDEO_LANE_DIR:-$(installed WorkingDirectory)}"; LANE_DIR="${LANE_DIR:-$HOME/.local/share/qwen38-video}"
|
||||
VENV="$LANE_DIR/venv"
|
||||
SRC="$LANE_DIR/sglang"
|
||||
PORT="${VIDEO_PORT:-$(unit_flag --port)}"; PORT="${PORT:-30022}"
|
||||
# The checkpoint and its revision, pinned like the rest: refs/main on 2026-09-25.
|
||||
# The first smoke on the reference box confirms it; until then the pin-watch alarms
|
||||
# on any upstream move. VIDEO_MODEL_REV overrides it; another VIDEO_MODEL is fetched
|
||||
# at VIDEO_MODEL_REV, or main.
|
||||
VIDEO_MODEL_PIN="MiniMaxAI/MiniMax-H3"
|
||||
VIDEO_MODEL_PIN_REV="42ed227ee7df40d41602854ae760620d6eb651fe"
|
||||
MODEL="${VIDEO_MODEL:-$(unit_flag --model-path)}"; MODEL="${MODEL:-MiniMaxAI/MiniMax-H3}" # = VIDEO_MODEL_PIN
|
||||
if [ "$MODEL" = "$VIDEO_MODEL_PIN" ]; then MODEL_REV="${VIDEO_MODEL_REV:-$VIDEO_MODEL_PIN_REV}"; else MODEL_REV="${VIDEO_MODEL_REV:-main}"; fi
|
||||
# fl2va serves text-only plus first/last-frame conditioning; ref2va serves reference
|
||||
# image/audio/video conditioning instead. They are checkpoint partitions: the variant
|
||||
# must match the weights fetched. VIDEO_VARIANT overrides it.
|
||||
VARIANT="${VIDEO_VARIANT:-$(unit_flag --model-variant)}"; VARIANT="${VARIANT:-fl2va}"
|
||||
case "$VARIANT" in fl2va|ref2va) ;; *) die "VIDEO_VARIANT takes fl2va or ref2va, got: $VARIANT" ;; esac
|
||||
# The installed unit's cache, then the one the text lane mounts, then the default: an
|
||||
# update that ignored the unit downloaded into ~/.cache and rewrote HF_HOME on a box
|
||||
# whose lane lived on another disk (same bug as the image lane, 2026-09-24).
|
||||
installed_env(){ { grep -m1 -E "^Environment=$1=" "$INSTALLED" 2>/dev/null || true; } | cut -d= -f3-; }
|
||||
TEXT_UNITS="${TEXT_UNITS:-/etc/systemd/system/qwen38-sglang.service $CONFIG_DIR/launch-flash.sh}"
|
||||
text_cache(){
|
||||
# shellcheck disable=SC2086 # a list of paths
|
||||
{ grep -hoE -- '-v [^ :]+:/root/\.cache/huggingface' $TEXT_UNITS 2>/dev/null || true; } \
|
||||
| head -1 | sed -e 's/^-v //' -e 's|:/root/\.cache/huggingface$||'
|
||||
}
|
||||
HF_CACHE="${HF_CACHE:-$(installed_env HF_HOME)}"; HF_CACHE="${HF_CACHE:-$(text_cache)}"
|
||||
HF_CACHE="${HF_CACHE:-$HOME/.cache/huggingface}"
|
||||
# The SGLang source this lane was developed against: the same pin as the image lane,
|
||||
# whose installed runtime already registers MiniMaxH3Pipeline (checked 2026-09-25).
|
||||
# SGLANG_DIFFUSION_PIN overrides it only for someone deliberately testing another one.
|
||||
PIN="${SGLANG_DIFFUSION_PIN:-ddebc52f237a1dbb56533469ab2ec2a7b856c4ab}"
|
||||
# The released wheel that carries the prebuilt aarch64 kernels the source tree reuses.
|
||||
WHEEL="${SGLANG_DIFFUSION_WHEEL:-0.5.20}"
|
||||
# Loopback, and not from ENGINE_BIND: that variable belongs to the LLM lane, which has
|
||||
# a key. This one has none (the diffusion parser has no --api-key at all), so a
|
||||
# non-loopback bind puts an unauthenticated video generator on that interface.
|
||||
# VIDEO_BIND overrides it for someone who means to, and is told what it costs.
|
||||
VIDEO_BIND="${VIDEO_BIND:-$(unit_flag --host)}"; VIDEO_BIND="${VIDEO_BIND:-127.0.0.1}"
|
||||
case "$VIDEO_BIND" in
|
||||
127.0.0.1|localhost) ;;
|
||||
*) echo "WARNING: binding $VIDEO_BIND. This lane has no API key (the diffusion runtime has"
|
||||
echo " no --api-key), so anyone who can reach that address can generate on your GPU."
|
||||
echo " Loopback plus the cockpit is the intended shape." ;;
|
||||
esac
|
||||
case "$VIDEO_BIND" in
|
||||
*[!0-9.]*|""|*..*) [ "$VIDEO_BIND" = localhost ] || die "VIDEO_BIND takes an IPv4 address, got: $VIDEO_BIND" ;;
|
||||
esac
|
||||
WEIGHTS_GB=145; RUNTIME_GB=11 # the fl2va partition plus the shared components and root
|
||||
# metadata, measured 2026-09-25 (144.1 GB cached of 88 files); the venv and checkout (7)
|
||||
# and the pip build tree
|
||||
|
||||
if [ "$ACTION" = uninstall ]; then
|
||||
step "Removing the video lane"
|
||||
if [ -f "$INSTALLED" ]; then
|
||||
WAS_BOOT=0; systemctl is-enabled --quiet "$UNIT" 2>/dev/null && WAS_BOOT=1
|
||||
sudo systemctl disable --now "$UNIT" 2>/dev/null || true
|
||||
sudo rm -f "$INSTALLED"; sudo systemctl daemon-reload
|
||||
echo "unit removed"
|
||||
# When the video lane was the box's lane at boot, whatever it replaced was disabled
|
||||
# by that switch: removing it left no engine at all (same trap as the image lane).
|
||||
# The lane before video comes back.
|
||||
TEXT_ENABLED=0
|
||||
for u in qwen38-sglang.service qwen38-flash.service qwen38-image.service; do
|
||||
systemctl is-enabled --quiet "$u" 2>/dev/null && TEXT_ENABLED=1
|
||||
done
|
||||
if [ "$WAS_BOOT" -eq 1 ] && [ "$TEXT_ENABLED" -eq 0 ]; then
|
||||
BACK="$(cat "$CONFIG_DIR/lane-before-video" 2>/dev/null || true)"
|
||||
if [ -n "$BACK" ] && [ -f "/etc/systemd/system/$BACK" ]; then
|
||||
sudo systemctl enable "$BACK"
|
||||
echo "the lane $BACK is enabled at boot again, as it was before the video lane;"
|
||||
echo "start it now with: sudo systemctl start $BACK (or the cockpit)"
|
||||
else
|
||||
echo "NOTE: no engine is enabled at boot any more. Start a lane from the cockpit, or:"
|
||||
echo " sudo systemctl enable --now qwen38-sglang.service"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# Only what this script put there: LANE_DIR can be a directory shared with other work.
|
||||
if [ -d "$LANE_DIR" ]; then
|
||||
rm -rf "$VENV" "$SRC"
|
||||
echo "runtime removed: $VENV and $SRC"
|
||||
rmdir "$LANE_DIR" 2>/dev/null || echo "kept $LANE_DIR: it holds files the video lane did not put there"
|
||||
fi
|
||||
echo "the video checkpoint is left in $HF_CACHE; delete it yourself if you want the space:"
|
||||
echo " rm -rf $HF_CACHE/hub/models--${MODEL//\//--}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
step "1/6 Preflight"
|
||||
case "$(uname -m)" in aarch64|arm64) : ;; *) die "this lane is verified on the DGX Spark's ARM64 GB10 only (this box is $(uname -m))." ;; esac
|
||||
command -v nvidia-smi >/dev/null || die "nvidia-smi not found: this needs the NVIDIA driver."
|
||||
command -v git >/dev/null || die "git is required (stock on DGX OS)."
|
||||
# The MiniMax-H3 pipeline requires ffmpeg and ffprobe for media processing and
|
||||
# validated output delivery, and refuses to start without them (its own words in
|
||||
# minimax_h3_pipeline.py). Installed from the OS package, once, before anything else.
|
||||
command -v ffmpeg >/dev/null || die "ffmpeg is missing, and the MiniMax-H3 pipeline refuses to start without it (with ffprobe). Fix: sudo apt-get install -y ffmpeg"
|
||||
command -v ffprobe >/dev/null || die "ffprobe is missing, and the MiniMax-H3 pipeline refuses to start without it (with ffmpeg). Fix: sudo apt-get install -y ffmpeg"
|
||||
# ensurepip, not just venv: a box without python3-venv makes a venv with no pip.
|
||||
python3 -c 'import venv, ensurepip' 2>/dev/null || die "python3-venv is missing (a venv made without it has no pip). Fix: sudo apt-get install -y python3-venv"
|
||||
[ -s "$CONFIG_DIR/api-key" ] || die "no API key at $CONFIG_DIR/api-key. Run ./install.sh first: the cockpit is the authenticated door in front of this lane, and it reads that file."
|
||||
# Measured where each part lands, by bytes in the blobs: the folder alone says nothing,
|
||||
# since huggingface_hub creates it before the first byte.
|
||||
existing(){ local p="$1"; while [ ! -e "$p" ]; do p="$(dirname "$p")"; done; printf '%s\n' "$p"; }
|
||||
free_gb(){ { df -BG --output=avail "$(existing "$1")" 2>/dev/null || true; } | tail -1 | tr -dc '0-9'; }
|
||||
HAVE_B="$({ du -s --apparent-size -B1 "$HF_CACHE/hub/models--${MODEL//\//--}/blobs" 2>/dev/null || true; } | cut -f1)"
|
||||
# what is left, in whole GB (a complete checkpoint is 0 left, not 1)
|
||||
WEIGHTS_NEED=$(( (WEIGHTS_GB * 1073741824 - ${HAVE_B:-0}) / 1073741824 )); [ "$WEIGHTS_NEED" -ge 0 ] || WEIGHTS_NEED=0
|
||||
FREE_W="$(free_gb "$HF_CACHE")"; FREE_R="$(free_gb "$LANE_DIR")"
|
||||
if [ "$(stat -c %d "$(existing "$HF_CACHE")")" = "$(stat -c %d "$(existing "$LANE_DIR")")" ]; then
|
||||
WANT=$((WEIGHTS_NEED + RUNTIME_GB))
|
||||
[ "${FREE_W:-0}" -ge "$WANT" ] \
|
||||
|| die "${FREE_W:-?} GB free on the disk of $HF_CACHE and $LANE_DIR, this needs about $WANT GB ($WEIGHTS_NEED for the checkpoint, $RUNTIME_GB for the runtime and its build). Free some space, or point HF_CACHE or VIDEO_LANE_DIR at a bigger disk."
|
||||
else
|
||||
[ "${FREE_W:-0}" -ge "$WEIGHTS_NEED" ] \
|
||||
|| die "${FREE_W:-?} GB free under HF_CACHE=$HF_CACHE, the checkpoint needs about $WEIGHTS_NEED GB more. Free some space, or point HF_CACHE at a bigger disk."
|
||||
[ "${FREE_R:-0}" -ge "$RUNTIME_GB" ] \
|
||||
|| die "${FREE_R:-?} GB free under $LANE_DIR, the runtime and its build need about $RUNTIME_GB GB. Free some space, or point VIDEO_LANE_DIR at a bigger disk."
|
||||
fi
|
||||
echo "OK: $(uname -m), key present, checkpoint $([ "$WEIGHTS_NEED" -eq 0 ] && echo 'already cached' || echo "$WEIGHTS_NEED GB to download") into $HF_CACHE"
|
||||
|
||||
step "2/6 Runtime ($LANE_DIR)"
|
||||
mkdir -p "$LANE_DIR"
|
||||
if [ ! -x "$VENV/bin/python" ]; then
|
||||
python3 -m venv "$VENV" || die "could not create the venv at $VENV"
|
||||
echo "venv created on $("$VENV/bin/python" -V)"
|
||||
elif ! "$VENV/bin/python" -m pip --version >/dev/null 2>&1; then
|
||||
# A venv made while python3-venv was missing has its python and no pip, and every
|
||||
# later run took it for a finished one, then died on its first pip call.
|
||||
echo "the venv at $VENV has no pip: making it again"
|
||||
python3 -m venv --clear "$VENV" || die "could not make the venv at $VENV again"
|
||||
else
|
||||
echo "venv already at $VENV ($("$VENV/bin/python" -V))"
|
||||
fi
|
||||
"$VENV/bin/python" -m pip install --quiet --upgrade pip >/dev/null
|
||||
|
||||
step "3/6 SGLang Diffusion (released wheel first, then the pinned source over it)"
|
||||
# Order matters and is not cosmetic. The wheel resolves the whole dependency tree AND
|
||||
# ships sglang-kernel built for aarch64; installing the source tree first leaves the
|
||||
# runtime without those kernels and the server dies on the first request.
|
||||
if ! "$VENV/bin/python" -c 'import sglang' 2>/dev/null; then
|
||||
echo "installing sglang[diffusion]==$WHEEL (~10 min on this box: torch and the kernels are large)"
|
||||
"$VENV/bin/pip" install --quiet --pre "sglang[diffusion]==$WHEEL" \
|
||||
|| die "the released wheel would not install. Re-run: pip resumes. If it keeps failing, SGLANG_DIFFUSION_WHEEL=<version> picks another."
|
||||
fi
|
||||
if [ ! -d "$SRC/.git" ]; then
|
||||
git clone --quiet https://github.com/sgl-project/sglang "$SRC" || die "could not clone SGLang."
|
||||
fi
|
||||
# No local patches on this lane: it serves the cookbook's recipe exactly as upstream
|
||||
# wrote it at the pinned commit. The image lane carries two (an idle-loop wait and a
|
||||
# graceful-shutdown bound), and this lane deliberately does not: running this model
|
||||
# means the official SGLang and MiniMax recommendations, nothing added on top. The
|
||||
# honest consequences live in the unit template (a stop waits for the generation to
|
||||
# end, up to TimeoutStopSec) and in docs/video-lane.md.
|
||||
CURRENT="$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)"
|
||||
if [ "$CURRENT" != "$PIN" ]; then
|
||||
git -C "$SRC" fetch --quiet origin "$PIN" 2>/dev/null || git -C "$SRC" fetch --quiet origin
|
||||
git -C "$SRC" checkout --quiet "$PIN" \
|
||||
|| die "could not check out $PIN: not in the SGLang repository, or local edits in $SRC block it (git -C $SRC status says which)."
|
||||
echo "source checked out at ${PIN:0:12}"
|
||||
else
|
||||
echo "source already at ${PIN:0:12}"
|
||||
fi
|
||||
# --no-deps: the wheel above already resolved them, and letting the source tree resolve
|
||||
# again pulls a transformers that breaks the encoders this model needs.
|
||||
# SGLANG_BUILD_RUST_EXTS=none: the pinned source declares five Rust extensions, all of
|
||||
# the LLM runtime; none is imported by the diffusion server. Building them needs cargo,
|
||||
# which DGX OS does not ship.
|
||||
if ! "$VENV/bin/python" -c 'import sglang, pathlib, sys; sys.exit(0 if str(pathlib.Path(sglang.__file__).parent).startswith("'"$SRC"'") else 1)' 2>/dev/null; then
|
||||
echo "overlaying the pinned source (editable, no dependency resolution, no Rust extensions)"
|
||||
SGLANG_BUILD_RUST_EXTS=none "$VENV/bin/pip" install --quiet --no-deps -e "$SRC/python" \
|
||||
|| die "the editable overlay failed. The venv still holds the released wheel; re-run to retry."
|
||||
fi
|
||||
"$VENV/bin/python" - <<'PY' || die "the runtime does not know MiniMax-H3. The pin may be wrong for this checkout."
|
||||
import inspect, pathlib, sglang
|
||||
from sglang.multimodal_gen import registry
|
||||
src = pathlib.Path(sglang.__file__).parent
|
||||
assert "MiniMax-H3" in inspect.getsource(registry), "MiniMax-H3 is not in the model registry"
|
||||
print(f" runtime: {src}")
|
||||
PY
|
||||
|
||||
step "4/6 Checkpoint ($MODEL at ${MODEL_REV:0:12}, one-time, resumable)"
|
||||
# Only the partition this lane serves is fetched, by allowlist. The repo holds both
|
||||
# weight partitions (FL2VA/ and Ref2VA/, 81 files each) plus a root-level native
|
||||
# layout, and --model-variant fl2va roots the pipeline in the FL2VA subfolder alone
|
||||
# (default_model_subfolder in minimax_h3_pipeline.py): fetching the rest is dead
|
||||
# weight on a box whose disk is the constraint (seen on the reference box, 2026-09-25:
|
||||
# the full pull filled the disk at 98% and died). A lane installed on the ref2va
|
||||
# weights fetches those instead.
|
||||
if [ "$MODEL" = "$VIDEO_MODEL_PIN" ]; then
|
||||
if [ "$VARIANT" = "fl2va" ]; then ALLOW="FL2VA/* model_index.json modular_model_index.json scheduler/* audio_scheduler/* *.md LICENSE*"
|
||||
else ALLOW="Ref2VA/* model_index.json modular_model_index.json scheduler/* audio_scheduler/* *.md LICENSE*"; fi
|
||||
else ALLOW="";
|
||||
fi
|
||||
# Said out loud, because a silent empty here refetches the other partition.
|
||||
echo "fetching with allow: ${ALLOW:-(whole repo)} (variant $VARIANT, model $MODEL)"
|
||||
# The same two lessons the LLM lane learned the hard way: the Hub's Xet backend stalls
|
||||
# silently on this box (0-8 MB/s against 89 on the classic CDN), and an unauthenticated
|
||||
# pull gets throttled, so HF_TOKEN is passed through when it is set.
|
||||
HF_HOME="$HF_CACHE" HF_HUB_DOWNLOAD_TIMEOUT=30 HF_HUB_DISABLE_XET=1 MODEL_REPO="$MODEL" MODEL_REV="$MODEL_REV" MODEL_ALLOW="$ALLOW" \
|
||||
"$VENV/bin/python" - <<'PY' || die "checkpoint download failed. Causes: no internet, HuggingFace throttling an unauthenticated download (set HF_TOKEN=<your token>), a pinned revision removed upstream (VIDEO_MODEL_REV=main serves the current one), a disk too small for the partition served, or a permission error in the cache. Re-running resumes."
|
||||
import os, time
|
||||
from huggingface_hub import snapshot_download
|
||||
repo, rev = os.environ["MODEL_REPO"], os.environ["MODEL_REV"]
|
||||
allow = [p for p in os.environ["MODEL_ALLOW"].split() if p] or None
|
||||
for attempt in range(1, 5):
|
||||
try:
|
||||
path = snapshot_download(repo, revision=rev, allow_patterns=allow); print(path, flush=True); break
|
||||
except Exception as e:
|
||||
if attempt == 4:
|
||||
raise
|
||||
print(f" attempt {attempt} stopped ({type(e).__name__}); resuming in 10 s", flush=True)
|
||||
time.sleep(10)
|
||||
# The unit serves the repo by name with HF_HUB_OFFLINE=1, which resolves refs/main, and
|
||||
# a download by commit writes no ref: main is pointed at the pinned commit, which is
|
||||
# what is served.
|
||||
sha = os.path.basename(path.rstrip("/"))
|
||||
ref = os.path.join(os.path.dirname(os.path.dirname(path.rstrip("/"))), "refs", "main")
|
||||
if len(sha) == 40 and sha == rev:
|
||||
os.makedirs(os.path.dirname(ref), exist_ok=True)
|
||||
old = open(ref).read().strip() if os.path.exists(ref) else ""
|
||||
if old != sha:
|
||||
with open(ref, "w") as f:
|
||||
f.write(sha)
|
||||
print(f" refs/main -> {sha[:12]}" + (f" (was {old[:12]})" if old else ""), flush=True)
|
||||
PY
|
||||
|
||||
step "5/6 Service"
|
||||
# The lane's own output directory: the download needs the file to still be there,
|
||||
# so the server writes every MP4 here instead of a temp dir it deletes. Old videos
|
||||
# stay until deleted by hand; uninstall.sh leaves them alone.
|
||||
mkdir -p "$LANE_DIR/outputs"
|
||||
RENDER="$(mktemp)"; trap 'rm -f "$RENDER"' EXIT
|
||||
sed -e "s|__USER__|$(id -un)|g" -e "s|__GROUP__|$(id -gn)|g" \
|
||||
-e "s|__VIDEO_LANE_DIR__|$LANE_DIR|g" -e "s|__VIDEO_VENV__|$VENV|g" \
|
||||
-e "s|__VIDEO_MODEL__|$MODEL|g" -e "s|__VIDEO_VARIANT__|$VARIANT|g" \
|
||||
-e "s|__VIDEO_PORT__|$PORT|g" \
|
||||
-e "s|__VIDEO_BIND__|$VIDEO_BIND|g" -e "s|__HF_CACHE__|$HF_CACHE|g" \
|
||||
-e "s|__HOME__|$HOME|g" \
|
||||
"$HERE/$UNIT.template" > "$RENDER"
|
||||
grep -q '__[A-Z][A-Z0-9_]*__' "$RENDER" && die "the unit template still holds an unsubstituted placeholder: $(grep -o '__[A-Z][A-Z0-9_]*__' "$RENDER" | sort -u | tr '\n' ' ')"
|
||||
# 0644 like every other unit, and set explicitly: mktemp creates 0600 and cp keeps the
|
||||
# mode, which left the image unit readable by root alone until this fix. Everything
|
||||
# that reads the unit (switch-model.sh, the cockpit) failed quietly on a 0600 unit.
|
||||
if [ -f "$INSTALLED" ] && sudo cmp -s "$RENDER" "$INSTALLED"; then
|
||||
echo "unit unchanged"
|
||||
sudo chmod 644 "$INSTALLED" # a unit installed before this fix is still 0600
|
||||
else
|
||||
sudo install -m 644 "$RENDER" "$INSTALLED"; sudo systemctl daemon-reload
|
||||
echo "unit installed at $INSTALLED"
|
||||
fi
|
||||
# Installed, not switched to: the lane this box serves stays the lane it serves. The
|
||||
# video lane becomes the boot lane the same way the other lanes do, by a switch, which
|
||||
# is also what makes it come back after a reboot.
|
||||
echo "installed as a lane of its own. Switch to it like any lane:"
|
||||
echo " the cockpit: pick MiniMax-H3 in the switcher, Switch, stop the serving lane, Start"
|
||||
echo " a terminal : ./switch-model.sh video, then the two commands it prints"
|
||||
|
||||
if [ "$SMOKE" -eq 0 ]; then step "Done (smoke test skipped)"; exit 0; fi
|
||||
|
||||
step "6/6 Proving it serves (one short video, then the box goes back to the lane it was serving)"
|
||||
WAS_OTHER=""
|
||||
for u in qwen38-sglang.service qwen38-flash.service qwen38-image.service; do
|
||||
systemctl is-active --quiet "$u" 2>/dev/null && WAS_OTHER="$u"
|
||||
done
|
||||
# If this lane was already serving, the test leaves it serving: stopping it on the way
|
||||
# out would turn "re-run the installer" into "take the video lane down".
|
||||
WAS_VIDEO=0
|
||||
systemctl is-active --quiet "$UNIT" 2>/dev/null && WAS_VIDEO=1
|
||||
[ -n "$WAS_OTHER" ] && echo "note: $WAS_OTHER is serving and will be stopped for this test, then started again."
|
||||
# From here on the other lane is DOWN, so putting it back cannot live on the happy
|
||||
# path: every die() below would leave the box serving nothing. The trap runs on
|
||||
# success and on every failure alike.
|
||||
restore_other_lane() {
|
||||
[ "$WAS_VIDEO" -eq 1 ] || sudo systemctl stop "$UNIT" 2>/dev/null || true
|
||||
if [ -n "$WAS_OTHER" ]; then
|
||||
echo "starting $WAS_OTHER again"
|
||||
sudo systemctl start "$WAS_OTHER" || echo "WARNING: could not restart $WAS_OTHER. Do it by hand: sudo systemctl start $WAS_OTHER"
|
||||
fi
|
||||
rm -f "$RENDER" "${OUT:-}"
|
||||
}
|
||||
trap restore_other_lane EXIT
|
||||
sudo systemctl start "$UNIT"
|
||||
READY=0
|
||||
for i in $(seq 1 90); do
|
||||
curl -fsS -m 5 "http://$VIDEO_BIND:$PORT/health" >/dev/null 2>&1 && { READY=1; break; }
|
||||
sleep 10
|
||||
done
|
||||
[ "$READY" -eq 1 ] || { sudo journalctl -u "$UNIT" -n 40 --no-pager; die "the lane did not answer /health within 15 min. The journal above says why."; }
|
||||
echo "up after ~$(( (i - 1) * 10 )) s; generating a 4 s video at 480P (about 12 min on this box)"
|
||||
OUT="$(mktemp)"
|
||||
# Video creation is asynchronous: POST returns an id with a queued status, then the
|
||||
# content is downloaded once the poll says completed. `|| true`: a transport failure
|
||||
# made curl exit non-zero inside the assignment, and set -e ended the script before
|
||||
# the message below (same trap as the image lane).
|
||||
CODE=$(curl -sS -o "$OUT" -w '%{http_code}' -m 60 "http://$VIDEO_BIND:$PORT/v1/videos" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"model":"MiniMax-H3","prompt":"A cat walks across a sunlit room, dust in the air","seconds":4}' || true)
|
||||
if [ "$CODE" != 200 ]; then
|
||||
echo "HTTP ${CODE:-000}: $(head -c 300 "$OUT" 2>/dev/null)"
|
||||
sudo journalctl -u "$UNIT" -n 40 --no-pager || true
|
||||
die "the lane started but did not take the smoke video (HTTP ${CODE:-000}); the journal above says why."
|
||||
fi
|
||||
VID="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("id",""))' "$OUT")"
|
||||
[ -n "$VID" ] || die "the lane answered 200 with no video id: $(head -c 300 "$OUT")"
|
||||
echo " video $VID queued; polling to completed (up to 40 min)"
|
||||
DONE=0
|
||||
for i in $(seq 1 240); do
|
||||
ST="$(curl -sS -m 20 "http://$VIDEO_BIND:$PORT/v1/videos" -H 'Content-Type: application/json' 2>/dev/null | python3 -c '
|
||||
import json,sys
|
||||
try:
|
||||
items = json.load(sys.stdin)["data"]
|
||||
except Exception:
|
||||
print("unknown"); raise SystemExit
|
||||
print(next((v.get("status","unknown") for v in items if v.get("id") == sys.argv[1]), "missing"))' "$VID" 2>/dev/null || echo unknown)"
|
||||
case "$ST" in
|
||||
completed) DONE=1; break ;;
|
||||
failed|error) die "the smoke video $VID ended in $ST; the journal above says why." ;;
|
||||
esac
|
||||
sleep 10
|
||||
done
|
||||
[ "$DONE" -eq 1 ] || die "the smoke video $VID did not complete in 40 min (last status: $ST)."
|
||||
curl -fsS -m 300 "http://$VIDEO_BIND:$PORT/v1/videos/$VID/content" -o "$OUT.mp4" \
|
||||
|| die "the video completed but its content did not download."
|
||||
SZ="$(stat -c %s "$OUT.mp4" 2>/dev/null || echo 0)"
|
||||
[ "$SZ" -gt 100000 ] || die "the downloaded video is only $SZ bytes, not a real video."
|
||||
echo " $(numfmt --to=iec "$SZ") of MP4; keeping it at $OUT.mp4 is left to you (trap removes only \$OUT)"
|
||||
# What the lane costs with nothing to do, from its own cgroup: the CPU time systemd
|
||||
# accounts to it over 10 s, after 5 s for the request's tail to finish. A note, not a
|
||||
# failure: it serves either way, and this lane takes the upstream scheduler as it is.
|
||||
CG="/sys/fs/cgroup$(systemctl show -p ControlGroup --value "$UNIT" 2>/dev/null)"
|
||||
if [ -r "$CG/cpu.stat" ]; then
|
||||
sleep 5
|
||||
U0=$(awk '/^usage_usec/{print $2}' "$CG/cpu.stat"); sleep 10
|
||||
U1=$(awk '/^usage_usec/{print $2}' "$CG/cpu.stat")
|
||||
IDLE_CORES=$(awk -v a="$U0" -v b="$U1" 'BEGIN{printf "%.2f", (b-a)/1e7}')
|
||||
echo " at rest: $IDLE_CORES CPU cores"
|
||||
fi
|
||||
# the trap stops the lane and brings the other lane back, whichever way this ends
|
||||
|
||||
step "Done: the video lane is installed and proved it serves on $VIDEO_BIND:$PORT"
|
||||
echo " switch to it : the cockpit's switcher (MiniMax-H3), or ./switch-model.sh video"
|
||||
echo " back : the switcher again (any other lane), or ./switch-model.sh stock"
|
||||
echo " generate : the cockpit's Video tab, or the API on :$PORT (loopback, no key)"
|
||||
+92
-6
@@ -413,6 +413,8 @@ NO_COCKPIT=0
|
||||
WITH_COCKPIT=0
|
||||
WITH_IMAGE=0
|
||||
NO_IMAGE=0
|
||||
WITH_VIDEO=0
|
||||
NO_VIDEO=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--no-start) NO_START=1 ;;
|
||||
@@ -423,6 +425,8 @@ for arg in "$@"; do
|
||||
--with-cockpit) WITH_COCKPIT=1 ;;
|
||||
--with-image) WITH_IMAGE=1 ;;
|
||||
--no-image) NO_IMAGE=1 ;;
|
||||
--with-video) WITH_VIDEO=1 ;;
|
||||
--no-video) NO_VIDEO=1 ;;
|
||||
--with-claude-warmup)
|
||||
echo "NOTE: --with-claude-warmup was removed in v1.3 (the repo's client story moved to opencode)."
|
||||
echo " The flag is ignored; an installed warmup drop-in from an earlier version is cleaned up." ;;
|
||||
@@ -430,6 +434,7 @@ for arg in "$@"; do
|
||||
cat <<'HLP'
|
||||
Usage: ./install.sh [--no-start] [--no-service] [--no-opencode | --with-opencode]
|
||||
[--no-cockpit | --with-cockpit] [--with-image | --no-image]
|
||||
[--with-video | --no-video]
|
||||
|
||||
Run it as yourself. Never with sudo in front: it calls sudo itself for the
|
||||
privileged steps, and under sudo every path it writes moves to /root (see the
|
||||
@@ -459,6 +464,15 @@ from there you start, stop, switch, watch and benchmark without a terminal.
|
||||
--no-image skip it on a box that already has it (the unit and the
|
||||
venv stay in place; ./install-image.sh --uninstall
|
||||
removes them)
|
||||
--with-video also install the MiniMax-H3 video lane: text-to-video
|
||||
with joint video-and-audio, served on its own port
|
||||
and driven from the cockpit's Video tab. Adds about
|
||||
150 GB of headroom and an hour or
|
||||
more, which is why a plain run does not. Once
|
||||
installed, later runs keep and update it.
|
||||
--no-video skip it on a box that already has it (the unit and the
|
||||
venv stay in place; ./install-video.sh --uninstall
|
||||
removes them)
|
||||
|
||||
Re-running over an existing install keeps the operator's choices: the target
|
||||
model (any of the seven), the context mode (native/1m), the flash serving tier,
|
||||
@@ -611,11 +625,27 @@ if systemctl is-enabled --quiet qwen38-image.service 2>/dev/null \
|
||||
echo "without making it the boot lane again. Switch back to text from the cockpit when you want it."
|
||||
fi
|
||||
fi
|
||||
# The video lane is a lane too, under the same promise: a plain re-run on a box
|
||||
# booting video must not enable a text unit beside it.
|
||||
VIDEO_BOOT=0
|
||||
if systemctl is-enabled --quiet qwen38-video.service 2>/dev/null \
|
||||
&& [ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]; then
|
||||
if [ -n "$_ENV_MODEL_CHOICE" ]; then
|
||||
# An explicit MODEL_CHOICE asks for a text lane: honour it, and the video lane
|
||||
# leaves the boot below, where the text unit is enabled.
|
||||
echo "MODEL_CHOICE=$_ENV_MODEL_CHOICE given on a box booting the video lane: making that text lane the boot lane again."
|
||||
else
|
||||
VIDEO_BOOT=1
|
||||
echo "The video lane is this box's boot lane: this run brings the text lane up to date"
|
||||
echo "without making it the boot lane again. Switch back to text from the cockpit when you want it."
|
||||
fi
|
||||
fi
|
||||
# Which text lane to bring up to date on that path. Both text units can be on disk with
|
||||
# neither enabled, since a switch to images disables both, so enablement cannot say which
|
||||
# one was in use; the switch writes it down instead, and without it the 27B lane is the
|
||||
# fallback, the same one the code below picks when nothing is enabled.
|
||||
LANE_BEFORE_IMAGE="$(cat "$CONFIG_DIR/lane-before-image" 2>/dev/null || true)"
|
||||
LANE_BEFORE_VIDEO="$(cat "$CONFIG_DIR/lane-before-video" 2>/dev/null || true)"
|
||||
if [ "$FLASH_READABLE" -eq 1 ] && [ "$FLASH_ENABLED" -eq 1 ] && [ "$SGL_ENABLED" -eq 1 ]; then
|
||||
echo "NOTE: both qwen38-sglang and qwen38-flash are enabled (only one can serve the port)."
|
||||
echo " Following the 27B unit; run ./switch-model.sh to resolve this cleanly."
|
||||
@@ -624,6 +654,8 @@ if [ "$FLASH_READABLE" -eq 1 ] && [ "$FLASH_ENABLED" -eq 1 ] && [ "$SGL_ENABLED"
|
||||
INSTALLED_CHOICE=flash
|
||||
elif [ "$IMAGE_BOOT" -eq 1 ] && [ "$LANE_BEFORE_IMAGE" = "qwen38-flash.service" ] && [ "$FLASH_READABLE" -eq 1 ]; then
|
||||
INSTALLED_CHOICE=flash # the text lane this box used before it switched to images
|
||||
elif [ "$VIDEO_BOOT" -eq 1 ] && [ "$LANE_BEFORE_VIDEO" = "qwen38-flash.service" ] && [ "$FLASH_READABLE" -eq 1 ]; then
|
||||
INSTALLED_CHOICE=flash # the text lane this box used before it switched to video
|
||||
elif [ "$SGL_READABLE" -eq 1 ]; then
|
||||
INSTALLED_CHOICE=27b
|
||||
elif [ "$FLASH_READABLE" -eq 1 ]; then
|
||||
@@ -880,6 +912,10 @@ fi
|
||||
if [ "$NO_IMAGE" -eq 1 ] && [ "$WITH_IMAGE" -eq 1 ]; then
|
||||
printf -- '--no-image and --with-image contradict each other (drop one flag)\n' >&2; exit 1
|
||||
fi
|
||||
# The same for the video lane.
|
||||
if [ "$NO_VIDEO" -eq 1 ] && [ "$WITH_VIDEO" -eq 1 ]; then
|
||||
printf -- '--no-video and --with-video contradict each other (drop one flag)\n' >&2; exit 1
|
||||
fi
|
||||
|
||||
# --no-start and --no-service both return before the image step, so the flag would be
|
||||
# accepted and silently do nothing. Say so here rather than at the end of a long install.
|
||||
@@ -888,6 +924,11 @@ if [ "$WITH_IMAGE" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]
|
||||
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-image.sh on its own.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$WITH_VIDEO" -eq 1 ] && { [ "$NO_START" -eq 1 ] || [ "$NO_SERVICE" -eq 1 ]; }; then
|
||||
printf -- '--with-video needs the full install: it installs a systemd unit and proves it serves.\n' >&2
|
||||
printf -- 'Run ./install.sh without --no-start/--no-service, or ./install-video.sh on its own.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
# Since v1.12 the cockpit is part of a plain install: the one-liner has to leave
|
||||
# a box you can open and drive, not a box plus a second command to find in a
|
||||
# README. The choice persists exactly like the opencode one, in a marker file,
|
||||
@@ -1995,6 +2036,11 @@ if [ "$IMAGE_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-image.service
|
||||
echo "disabling the image lane at boot (unit kept, switch back anytime from the cockpit)"
|
||||
sudo systemctl disable qwen38-image.service
|
||||
fi
|
||||
# The video lane is the fourth engine, under the same rule.
|
||||
if [ "$VIDEO_BOOT" -eq 0 ] && systemctl is-enabled --quiet qwen38-video.service 2>/dev/null; then
|
||||
echo "disabling the video lane at boot (unit kept, switch back anytime from the cockpit)"
|
||||
sudo systemctl disable qwen38-video.service
|
||||
fi
|
||||
KEEPALIVE_UNIT="qwen38-keepalive.service"
|
||||
# One-prompt ceiling enforced by the proxy (tokens; 0 = pool share only). The proxy
|
||||
# always refuses a prompt above its share of the KV pool as well, so the smaller of
|
||||
@@ -2066,12 +2112,13 @@ if [ -f "/etc/systemd/system/$UNIT_NAME.d/warmup.conf" ]; then
|
||||
fi
|
||||
rm -f "$CONFIG_DIR/warmup-claude-code.sh"
|
||||
sudo systemctl daemon-reload
|
||||
if [ "$IMAGE_BOOT" -eq 0 ]; then
|
||||
if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then
|
||||
sudo systemctl enable "$UNIT_NAME"
|
||||
else
|
||||
# Updated, not switched to. Starting it would stop the image lane that is serving, and
|
||||
# the cockpit and the image step below only run once a text engine has proved itself,
|
||||
# so this path finishes here, on its own, instead of waiting for a boot it must not do.
|
||||
# Updated, not switched to. Starting it would stop the lane that is serving, and
|
||||
# the cockpit and the side-lane steps below only run once a text engine has proved
|
||||
# itself, so this path finishes here, on its own, instead of waiting for a boot it
|
||||
# must not do.
|
||||
# The proxy's code and unit were just rewritten above; on the text path it is restarted
|
||||
# once the engine behind it answers, which this path never waits for. Without this it
|
||||
# kept the old keepalive-proxy.py in memory until someone restarted it by hand.
|
||||
@@ -2084,11 +2131,18 @@ else
|
||||
|| echo "NOTE: the cockpit did not reinstall; retry with ./dashboard/install-dashboard.sh"
|
||||
fi
|
||||
# --no-smoke always: the smoke test starts and stops the lane, and this lane is serving.
|
||||
if [ "$NO_IMAGE" -eq 0 ]; then
|
||||
# Guarded by the unit file: on a box booting the other side lane, an unconditional
|
||||
# update would install gigabytes nobody asked for.
|
||||
if [ "$NO_IMAGE" -eq 0 ] && [ -f /etc/systemd/system/qwen38-image.service ]; then
|
||||
"$REPO_DIR/install-image.sh" --no-smoke \
|
||||
|| echo "NOTE: the image lane did not update; retry with ./install-image.sh --no-smoke"
|
||||
fi
|
||||
step "Done: the text lane is up to date; the image lane stays this box's serving lane"
|
||||
if [ "$NO_VIDEO" -eq 0 ] && [ -f /etc/systemd/system/qwen38-video.service ]; then
|
||||
"$REPO_DIR/install-video.sh" --no-smoke \
|
||||
|| echo "NOTE: the video lane did not update; retry with ./install-video.sh --no-smoke"
|
||||
fi
|
||||
if [ "$VIDEO_BOOT" -eq 1 ]; then SERVING_LANE="video"; else SERVING_LANE="image"; fi
|
||||
step "Done: the text lane is up to date; the $SERVING_LANE lane stays this box's serving lane"
|
||||
echo " text lane : installed as $UNIT_NAME, not enabled at boot"
|
||||
if [ "$MODEL_CHOICE" = "custom" ]; then
|
||||
# a kept custom model has no switch target of its own; the installer is the way back
|
||||
@@ -2317,6 +2371,30 @@ except Exception as e:
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── The video lane, last with the image lane, for the same two reasons: it is
|
||||
# the only other step that stops the engine already serving above, and the only
|
||||
# other one that costs over 100 GB. It is opt-in, and remembered: a box that has
|
||||
# it keeps it across upgrades.
|
||||
VIDEO_ON=0
|
||||
[ -f /etc/systemd/system/qwen38-video.service ] && VIDEO_ON=1
|
||||
[ "$WITH_VIDEO" -eq 1 ] && VIDEO_ON=1
|
||||
[ "$NO_VIDEO" -eq 1 ] && VIDEO_ON=0
|
||||
if [ "$VIDEO_ON" -eq 1 ]; then
|
||||
step "MiniMax-H3 lane (text-to-video with joint video-and-audio)"
|
||||
# The smoke test stops the engine this run just verified, loads the checkpoint
|
||||
# and puts it back, then generates for about 12 min: worth it once, on the
|
||||
# install that asked for the lane; not on every routine upgrade of a box that
|
||||
# happens to have it.
|
||||
VIDEO_ARGS=()
|
||||
[ "$WITH_VIDEO" -eq 0 ] && VIDEO_ARGS=(--no-smoke)
|
||||
if "$REPO_DIR/install-video.sh" ${VIDEO_ARGS[@]+"${VIDEO_ARGS[@]}"}; then
|
||||
VIDEO_READY=1
|
||||
else
|
||||
echo "NOTE: the video lane did not install. Everything above is up and serving."
|
||||
echo " retry on its own with ./install-video.sh (it resumes what it already did)"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '\n\033[1;32m✅ Installed, verified, and enabled at boot.\033[0m\n'
|
||||
if [ -n "$COCKPIT_URL" ]; then
|
||||
printf '\n\033[1;36m ▶ OPEN THE COCKPIT: %s\033[0m\n' "$COCKPIT_URL"
|
||||
@@ -2371,6 +2449,14 @@ except Exception as e:
|
||||
elif [ "${IMAGE_ON:-0}" -eq 0 ]; then
|
||||
echo " Images : not installed; ./install.sh --with-image adds the Qwen-Image 2.1 lane (38 GB)"
|
||||
fi
|
||||
if [ "${VIDEO_READY:-0}" -eq 1 ]; then
|
||||
echo " Videos : a fourth lane; switch to MiniMax-H3 in the cockpit (or ./switch-model.sh video)"
|
||||
elif [ -f /etc/systemd/system/qwen38-video.service ] && [ "${VIDEO_ON:-0}" -eq 0 ]; then
|
||||
# --no-video on a box that has the lane: it is there, only not updated by this run
|
||||
echo " Videos : installed, not updated by this run (--no-video); ./install-video.sh --uninstall removes it"
|
||||
elif [ "${VIDEO_ON:-0}" -eq 0 ]; then
|
||||
echo " Videos : not installed; ./install.sh --with-video adds the MiniMax-H3 lane (about 150 GB of headroom)"
|
||||
fi
|
||||
[ "$LANE" = "27b" ] && echo " Benchmark : ./bench.sh"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
+27
-12
@@ -186,23 +186,34 @@ class EngineUnreachable(Exception):
|
||||
"""The engine did not answer /tokenize: stopped, crashed, restarting or still loading."""
|
||||
|
||||
|
||||
# The image lane holds the GPU instead of a text engine once the box is switched to it,
|
||||
# and a text engine does not come back from that by itself. Asked only on the error path,
|
||||
# where the answer changes what the client is told, and at most every 5 s.
|
||||
# The image and video lanes hold the GPU instead of a text engine once the box is
|
||||
# switched to one of them, and a text engine does not come back from that by itself.
|
||||
# Asked only on the error path, where the answer changes what the client is told,
|
||||
# and at most every 5 s per lane.
|
||||
IMAGE_UNIT = "qwen38-image.service"
|
||||
_IMAGE_SEEN = {"ts": -1e9, "active": False}
|
||||
VIDEO_UNIT = "qwen38-video.service"
|
||||
_VIDEO_SEEN = {"ts": -1e9, "active": False}
|
||||
|
||||
|
||||
def _lane_active(unit: str, seen: dict) -> bool:
|
||||
now = time.monotonic()
|
||||
if now - seen["ts"] > 5:
|
||||
try:
|
||||
seen["active"] = subprocess.run(["systemctl", "is-active", "--quiet", unit],
|
||||
timeout=2).returncode == 0
|
||||
except Exception:
|
||||
seen["active"] = False
|
||||
seen["ts"] = now
|
||||
return seen["active"]
|
||||
|
||||
|
||||
def image_lane_serving():
|
||||
now = time.monotonic()
|
||||
if now - _IMAGE_SEEN["ts"] > 5:
|
||||
try:
|
||||
_IMAGE_SEEN["active"] = subprocess.run(["systemctl", "is-active", "--quiet", IMAGE_UNIT],
|
||||
timeout=2).returncode == 0
|
||||
except Exception:
|
||||
_IMAGE_SEEN["active"] = False
|
||||
_IMAGE_SEEN["ts"] = now
|
||||
return _IMAGE_SEEN["active"]
|
||||
return _lane_active(IMAGE_UNIT, _IMAGE_SEEN)
|
||||
|
||||
|
||||
def video_lane_serving():
|
||||
return _lane_active(VIDEO_UNIT, _VIDEO_SEEN)
|
||||
|
||||
|
||||
def engine_gone_reason():
|
||||
@@ -211,6 +222,10 @@ def engine_gone_reason():
|
||||
return ("This box is serving images right now (qwen38-image.service), and a text engine "
|
||||
"does not come back by itself: switch back to a text lane from the cockpit's "
|
||||
"switcher, or run ./switch-model.sh with a text target")
|
||||
if video_lane_serving():
|
||||
return ("This box is serving video right now (qwen38-video.service), and a text engine "
|
||||
"does not come back by itself: switch back to a text lane from the cockpit's "
|
||||
"switcher, or run ./switch-model.sh with a text target")
|
||||
return "It is stopped, restarting or still loading (a restart takes minutes, about 9 on a DGX Spark)"
|
||||
|
||||
# The interface this proxy listens on. It answered on every one of them until v6.21, and
|
||||
|
||||
@@ -51,6 +51,9 @@ eval "$img"
|
||||
# reads the same lines)
|
||||
lane="$(grep -E '^(IMAGE_MODEL_PIN|IMAGE_MODEL_PIN_REV)=' "$REPO_DIR/install-image.sh")"
|
||||
eval "$lane"
|
||||
# the video lane's checkpoint, pinned in install-video.sh like the rest
|
||||
vline="$(grep -E '^(VIDEO_MODEL_PIN|VIDEO_MODEL_PIN_REV)=' "$REPO_DIR/install-video.sh")"
|
||||
eval "$vline"
|
||||
|
||||
# The conclusion MIRROR.md records for a pin, or nothing when its table has no row.
|
||||
license_of() { # $1 label
|
||||
@@ -167,6 +170,7 @@ if [ "$MODE" != "--images" ]; then
|
||||
mirror_model "draft" "$DRAFT_REPO" "$DRAFT_REV"
|
||||
mirror_model "draft2" "$DRAFT2_REPO" "$DRAFT2_REV"
|
||||
mirror_model "qwen-image" "$IMAGE_MODEL_PIN" "$IMAGE_MODEL_PIN_REV"
|
||||
mirror_model "minimax-h3" "$VIDEO_MODEL_PIN" "$VIDEO_MODEL_PIN_REV"
|
||||
fi
|
||||
if [ "$MODE" != "--models" ]; then
|
||||
echo "Images"
|
||||
|
||||
@@ -7,8 +7,8 @@ Requires=docker.service
|
||||
# directions (Conflicts= alone orders nothing; measured with throwaway units on the
|
||||
# reference box's systemd 255, 2026-09-24). Until v1.18.7 only the image lane said so,
|
||||
# and two text lanes could run side by side, or both start at boot if both were enabled.
|
||||
Conflicts=qwen38-sglang.service qwen38-image.service qwen38-llamacpp.service
|
||||
After=network-online.target docker.service qwen38-sglang.service qwen38-image.service qwen38-llamacpp.service
|
||||
Conflicts=qwen38-sglang.service qwen38-image.service qwen38-video.service qwen38-llamacpp.service
|
||||
After=network-online.target docker.service qwen38-sglang.service qwen38-image.service qwen38-video.service qwen38-llamacpp.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
@@ -5,12 +5,12 @@ Wants=network-online.target
|
||||
# wrapper someone can bypass: the image checkpoint is 31 GB of weights and peaks at
|
||||
# 34.8 GB during a 1024px request (measured), while the LLM lane holds its pool for the
|
||||
# life of the process. Starting this stops the LLM lane; starting an LLM lane stops this.
|
||||
Conflicts=qwen38-sglang.service qwen38-flash.service qwen38-llamacpp.service
|
||||
Conflicts=qwen38-sglang.service qwen38-flash.service qwen38-video.service qwen38-llamacpp.service
|
||||
# Conflicts= alone orders nothing: the old lane's stop and the new lane's start ran side
|
||||
# by side (5 to 60 s on the reference box, 2026-09-23). With the same units named in
|
||||
# After=, systemd finishes the stop before the start, in both directions (measured on
|
||||
# its systemd 255: 3.0 s of overlap without, 0.02 s after the stop with, 2026-09-24).
|
||||
After=network-online.target qwen38-sglang.service qwen38-flash.service qwen38-llamacpp.service
|
||||
After=network-online.target qwen38-sglang.service qwen38-flash.service qwen38-video.service qwen38-llamacpp.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
@@ -7,8 +7,8 @@ Requires=docker.service
|
||||
# directions (Conflicts= alone orders nothing; measured with throwaway units on the
|
||||
# reference box's systemd 255, 2026-09-24). Until v1.18.7 only the image lane said so,
|
||||
# and two text lanes could run side by side, or both start at boot if both were enabled.
|
||||
Conflicts=qwen38-flash.service qwen38-image.service qwen38-llamacpp.service
|
||||
After=network-online.target docker.service qwen38-flash.service qwen38-image.service qwen38-llamacpp.service
|
||||
Conflicts=qwen38-flash.service qwen38-image.service qwen38-video.service qwen38-llamacpp.service
|
||||
After=network-online.target docker.service qwen38-flash.service qwen38-image.service qwen38-video.service qwen38-llamacpp.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
@@ -7,8 +7,8 @@ Requires=docker.service
|
||||
# directions (Conflicts= alone orders nothing; measured with throwaway units on the
|
||||
# reference box's systemd 255, 2026-09-24). Until v1.18.7 only the image lane said so,
|
||||
# and two text lanes could run side by side, or both start at boot if both were enabled.
|
||||
Conflicts=qwen38-flash.service qwen38-image.service qwen38-llamacpp.service
|
||||
After=network-online.target docker.service qwen38-flash.service qwen38-image.service qwen38-llamacpp.service
|
||||
Conflicts=qwen38-flash.service qwen38-image.service qwen38-video.service qwen38-llamacpp.service
|
||||
After=network-online.target docker.service qwen38-flash.service qwen38-image.service qwen38-video.service qwen38-llamacpp.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
[Unit]
|
||||
Description=MiniMax-H3 video-and-audio (SGLang Diffusion, native venv), OpenAI videos API :__VIDEO_PORT__
|
||||
Wants=network-online.target
|
||||
# One engine at a time on this box, and systemd is where that is said rather than in a
|
||||
# wrapper someone can bypass: the video checkpoint (fl2va partition plus shared
|
||||
# components) does not fit beside any serving lane, while
|
||||
# any other lane holds its own pool for the life of its process. Starting this stops
|
||||
# the other lanes; starting another lane stops this.
|
||||
Conflicts=qwen38-sglang.service qwen38-flash.service qwen38-image.service qwen38-llamacpp.service
|
||||
# Conflicts= alone orders nothing: the old lane's stop and the new lane's start ran
|
||||
# side by side on the reference box (measured on its systemd 255: 3.0 s of overlap
|
||||
# without After=, 0.02 s after the stop with, 2026-09-24). With the same units named
|
||||
# in After=, systemd finishes the stop before the start, in both directions.
|
||||
After=network-online.target qwen38-sglang.service qwen38-flash.service qwen38-image.service qwen38-llamacpp.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__USER__
|
||||
Group=__GROUP__
|
||||
WorkingDirectory=__VIDEO_LANE_DIR__
|
||||
Environment=HF_HOME=__HF_CACHE__
|
||||
Environment=HF_HUB_OFFLINE=1
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
# The decode sits close enough to the cap that fragmentation tips it over (cookbook).
|
||||
Environment=PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
||||
# The cookbook's DGX Spark recipe, and nothing else: every component resident, no
|
||||
# offload flags. The cookbook verifies about 12.1 s per denoise step, about 40 s of
|
||||
# decode and about 12 min per warm request at 480P with no flags at all, and adding
|
||||
# the discrete-GPU offload flags measured 2.1x slower on the same box. Forcing any of
|
||||
# those is how a verified recipe stops being the verified recipe.
|
||||
# NO --api-key, and that is not an omission. The diffusion runtime is a different
|
||||
# parser from the LLM one: it has no --api-key and no --sleep-on-idle, and passing
|
||||
# either kills the unit at startup with "unrecognized arguments". So this lane cannot
|
||||
# authenticate anyone, and the loopback bind below is the only thing standing in
|
||||
# front of it. The cockpit is the authenticated door.
|
||||
# --output-path: a directory of this lane's own, because the download needs the
|
||||
# file to still be there. Left empty (like the image lane), the server answers into
|
||||
# a temp dir it deletes when the request ends, and every completed video 404s on
|
||||
# download (measured 2026-09-25: completed in 592 s, file gone before the download).
|
||||
# --input-save-path "": uploads are never used (keyframes travel as staged files in
|
||||
# the request, never as uploads), so nothing needs the copy.
|
||||
# Old MP4s stay until deleted: watch the directory grow.
|
||||
ExecStart=__VIDEO_VENV__/bin/sglang serve \
|
||||
--model-path __VIDEO_MODEL__ \
|
||||
--model-variant __VIDEO_VARIANT__ \
|
||||
--output-path __VIDEO_LANE_DIR__/outputs \
|
||||
--input-save-path "" \
|
||||
--host __VIDEO_BIND__ --port __VIDEO_PORT__
|
||||
Restart=on-failure
|
||||
RestartSec=15
|
||||
# No TimeoutStartSec: systemd counts a Type=simple unit started once its process runs,
|
||||
# so the setting never bounded the minutes it takes to load the checkpoint.
|
||||
# install-video.sh and the cockpit wait on /health for that.
|
||||
#
|
||||
# Stop waits for the generation in flight to end, because this runtime has no abort
|
||||
# and this lane carries no local shutdown patch: the cookbook's recipe runs as
|
||||
# upstream wrote it. A 15 s request at the cookbook's rate is about 45 min, so the
|
||||
# bound below covers the longest official duration; past it systemd kills the lane
|
||||
# mid-generation. Cancel in the cockpit is a restart through this same wait.
|
||||
TimeoutStopSec=3600
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+80
-7
@@ -9,6 +9,7 @@
|
||||
# ./switch-model.sh flash-nvda # nvidia/Qwen3.8-Flash-Next-NVFP4, ModelOpt mixed precision
|
||||
# ./switch-model.sh flash-uncensored # the abliterated build of the same tree
|
||||
# ./switch-model.sh image # Qwen/Qwen-Image-2.1 (SGLang Diffusion, own venv)
|
||||
# ./switch-model.sh video # MiniMaxAI/MiniMax-H3 (SGLang Diffusion, own venv)
|
||||
#
|
||||
# Within the 27B lane (stock, uncensored, fp8, uncensored-fp8) it does what it
|
||||
# always did:
|
||||
@@ -40,7 +41,7 @@ _ENV_HF_CACHE="${HF_CACHE:-}" # before the pins below give it install.sh's
|
||||
# 27B lane and restarting what follows it, where the usage was all anyone wanted (found
|
||||
# in review, 2026-09-24). MODEL_CHOICE= still names one, as install.sh takes it.
|
||||
CHOICE="${1:-${MODEL_CHOICE:-}}"
|
||||
case "$CHOICE" in stock|uncensored|fp8|uncensored-fp8|flash|flash-nvda|flash-uncensored|image) ;; *) printf 'usage: ./switch-model.sh <stock|uncensored|fp8|uncensored-fp8|flash|flash-nvda|flash-uncensored|image>\n' >&2; [ -z "$CHOICE" ] && exit 2; die "unknown target: $CHOICE" ;; esac
|
||||
case "$CHOICE" in stock|uncensored|fp8|uncensored-fp8|flash|flash-nvda|flash-uncensored|image|video) ;; *) printf 'usage: ./switch-model.sh <stock|uncensored|fp8|uncensored-fp8|flash|flash-nvda|flash-uncensored|image|video>\n' >&2; [ -z "$CHOICE" ] && exit 2; die "unknown target: $CHOICE" ;; esac
|
||||
|
||||
|
||||
PINS="$(grep -E '^(IMAGE|STOCK_REPO|STOCK_REV|UNC_REPO|UNC_REV|FP8_REPO|FP8_REV|UNCFP8_REPO|UNCFP8_REV|FLASH_REPO|FLASH_REV|FLASH_NVDA_REPO|FLASH_NVDA_REV|FLASH_UNC_REPO|FLASH_UNC_REV|FLASH_IMAGE|FLASH_SERVE_IMAGE|SERVE_IMAGE|MODEL_CHOICE|HF_CACHE|CONFIG_DIR)=' "$REPO_DIR/install.sh" || true)"
|
||||
@@ -56,6 +57,8 @@ unset _v
|
||||
|
||||
IMAGE_UNIT="/etc/systemd/system/qwen38-image.service"
|
||||
IMAGE_UNIT_NAME="qwen38-image.service"
|
||||
VIDEO_UNIT="/etc/systemd/system/qwen38-video.service"
|
||||
VIDEO_UNIT_NAME="qwen38-video.service"
|
||||
|
||||
# ── The image lane: a third lane, switched to the same way as the other two ─────
|
||||
# Same contract as a cross-lane switch: verify the checkpoint, make it the one unit
|
||||
@@ -92,7 +95,7 @@ except Exception:
|
||||
PYIMG
|
||||
# Which text lane this box served, written down before it is disabled: install.sh
|
||||
# updates that lane on a later run, and enablement cannot tell it once both are off.
|
||||
for TEXT_UNIT_NAME in qwen38-flash.service qwen38-sglang.service; do
|
||||
for TEXT_UNIT_NAME in qwen38-flash.service qwen38-sglang.service qwen38-video.service; do
|
||||
if systemctl is-enabled --quiet "$TEXT_UNIT_NAME" 2>/dev/null; then
|
||||
printf '%s\n' "$TEXT_UNIT_NAME" > "$CONFIG_DIR/lane-before-image"
|
||||
fi
|
||||
@@ -100,7 +103,7 @@ PYIMG
|
||||
# The loop variable ends in UNIT_NAME on purpose: CI checks every
|
||||
# `sudo systemctl <verb> "$..UNIT_NAME"` against the cockpit's sudoers allowlist,
|
||||
# and a variable called $u would have walked straight past it.
|
||||
for TEXT_UNIT_NAME in qwen38-sglang.service qwen38-flash.service; do
|
||||
for TEXT_UNIT_NAME in qwen38-sglang.service qwen38-flash.service qwen38-video.service; do
|
||||
if systemctl is-enabled --quiet "$TEXT_UNIT_NAME" 2>/dev/null; then
|
||||
echo "disabling $TEXT_UNIT_NAME at boot (unit file kept for switching back)"
|
||||
sudo systemctl disable "$TEXT_UNIT_NAME"
|
||||
@@ -109,7 +112,7 @@ PYIMG
|
||||
sudo systemctl enable "$IMAGE_UNIT_NAME" >/dev/null 2>&1 || sudo systemctl enable "$IMAGE_UNIT_NAME"
|
||||
sudo systemctl daemon-reload
|
||||
RUNNING=""
|
||||
for u in qwen38-sglang.service qwen38-flash.service; do
|
||||
for u in qwen38-sglang.service qwen38-flash.service qwen38-video.service; do
|
||||
systemctl is-active --quiet "$u" 2>/dev/null && RUNNING="$u"
|
||||
done
|
||||
printf '\n\033[1;32mSwitch queued: %s (%s)\033[0m\n' "$IMG_MODEL" "$IMAGE_UNIT_NAME"
|
||||
@@ -123,6 +126,70 @@ PYIMG
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ── The video lane: a fourth lane, switched to the same way as the image one ───
|
||||
# Same contract as the image lane: verify the checkpoint, make it the one unit
|
||||
# enabled at boot, never start or stop anything, print the exact commands. Like the
|
||||
# image lane it shares nothing with the text lanes: no serving image to inspect (it
|
||||
# runs from its own venv), no unit to rewrite (one checkpoint, one variant), no
|
||||
# prompt ceiling on the proxy (the proxy is a text door and nothing reaches this
|
||||
# lane through it), and no opencode default to move (opencode is a text client).
|
||||
# Handled here, whole, and exits.
|
||||
if [ "$CHOICE" = "video" ]; then
|
||||
[ -f "$VIDEO_UNIT" ] || die "the video lane is not installed on this box (no $VIDEO_UNIT). Install it once: ./install.sh --with-video (about 150 GB of headroom)"
|
||||
VID_WD="$(grep -m1 -E '^WorkingDirectory=' "$VIDEO_UNIT" | cut -d= -f2- || true)"
|
||||
VID_PY="${VID_WD:-$HOME/.local/share/qwen38-video}/venv/bin/python"
|
||||
[ -x "$VID_PY" ] || die "the video lane's runtime is missing ($VID_PY): re-run ./install-video.sh, it resumes"
|
||||
VID_MODEL="$(grep -oE -- '--model-path [^ ]+' "$VIDEO_UNIT" | head -1 | cut -d' ' -f2 || true)"
|
||||
VID_MODEL="${VID_MODEL:-MiniMaxAI/MiniMax-H3}"
|
||||
VID_HF="$(grep -m1 -E '^Environment=HF_HOME=' "$VIDEO_UNIT" | cut -d= -f3- || true)"
|
||||
printf '\n\033[1;36m── Verifying %s in the cache (resumable)\033[0m\n' "$VID_MODEL"
|
||||
# Xet stalls on this box, and an unauthenticated pull gets throttled.
|
||||
# local_files_only first, so a complete cache answers without touching the
|
||||
# network at all.
|
||||
HF_HOME="${VID_HF:-$HF_CACHE}" HF_HUB_DOWNLOAD_TIMEOUT=30 HF_HUB_DISABLE_XET=1 VID_MODEL="$VID_MODEL" \
|
||||
"$VID_PY" - <<'PYVID' || die "the video checkpoint could not be verified or fetched (re-run to resume; set HF_TOKEN if it stalls)"
|
||||
import os
|
||||
from huggingface_hub import snapshot_download
|
||||
repo = os.environ["VID_MODEL"]
|
||||
try:
|
||||
print(snapshot_download(repo, local_files_only=True))
|
||||
except Exception:
|
||||
print("not complete in the cache, fetching the rest", flush=True)
|
||||
print(snapshot_download(repo))
|
||||
PYVID
|
||||
# Which lane this box served, written down before it is disabled: install.sh
|
||||
# updates that lane on a later run, and enablement cannot tell it once all are off.
|
||||
for OTHER_UNIT_NAME in qwen38-flash.service qwen38-sglang.service qwen38-image.service; do
|
||||
if systemctl is-enabled --quiet "$OTHER_UNIT_NAME" 2>/dev/null; then
|
||||
printf '%s\n' "$OTHER_UNIT_NAME" > "$CONFIG_DIR/lane-before-video"
|
||||
fi
|
||||
done
|
||||
# The loop variable ends in UNIT_NAME on purpose: CI checks every
|
||||
# `sudo systemctl <verb> "$..UNIT_NAME"` against the cockpit's sudoers allowlist,
|
||||
# and a variable called $u would have walked straight past it.
|
||||
for OTHER_UNIT_NAME in qwen38-sglang.service qwen38-flash.service qwen38-image.service; do
|
||||
if systemctl is-enabled --quiet "$OTHER_UNIT_NAME" 2>/dev/null; then
|
||||
echo "disabling $OTHER_UNIT_NAME at boot (unit file kept for switching back)"
|
||||
sudo systemctl disable "$OTHER_UNIT_NAME"
|
||||
fi
|
||||
done
|
||||
sudo systemctl enable "$VIDEO_UNIT_NAME" >/dev/null 2>&1 || sudo systemctl enable "$VIDEO_UNIT_NAME"
|
||||
sudo systemctl daemon-reload
|
||||
RUNNING=""
|
||||
for u in qwen38-sglang.service qwen38-flash.service qwen38-image.service; do
|
||||
systemctl is-active --quiet "$u" 2>/dev/null && RUNNING="$u"
|
||||
done
|
||||
printf '\n\033[1;32mSwitch queued: %s (%s)\033[0m\n' "$VID_MODEL" "$VIDEO_UNIT_NAME"
|
||||
if [ -n "$RUNNING" ]; then
|
||||
echo "Effective after: sudo systemctl stop $RUNNING && sudo systemctl start $VIDEO_UNIT_NAME (or next reboot)"
|
||||
else
|
||||
echo "Effective after: sudo systemctl start $VIDEO_UNIT_NAME (or next reboot; ready in about 12 min)"
|
||||
fi
|
||||
echo "The proxy on :30001 and opencode are text clients and were left as they are."
|
||||
echo "Switch back: ./switch-model.sh stock (or any text target, or image)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SGL_UNIT="/etc/systemd/system/qwen38-sglang.service"
|
||||
FLASH_UNIT="/etc/systemd/system/qwen38-flash.service"
|
||||
|
||||
@@ -453,12 +520,17 @@ if [ -f "$OTHER_UNIT" ] && systemctl is-enabled --quiet "$OTHER_UNIT_NAME" 2>/de
|
||||
echo "disabling $OTHER_UNIT_NAME at boot (unit file kept for switching back)"
|
||||
sudo systemctl disable "$OTHER_UNIT_NAME"
|
||||
fi
|
||||
# The image lane is the third serving unit. Leaving it enabled while a text lane
|
||||
# is made the boot lane would bring two engines up at the next reboot.
|
||||
# The image lane is the third serving unit, the video lane the fourth. Leaving either
|
||||
# enabled while a text lane is made the boot lane would bring two engines up at the
|
||||
# next reboot.
|
||||
if [ -f "$IMAGE_UNIT" ] && systemctl is-enabled --quiet "$IMAGE_UNIT_NAME" 2>/dev/null; then
|
||||
echo "disabling $IMAGE_UNIT_NAME at boot (unit file kept for switching back)"
|
||||
sudo systemctl disable "$IMAGE_UNIT_NAME"
|
||||
fi
|
||||
if [ -f "$VIDEO_UNIT" ] && systemctl is-enabled --quiet "$VIDEO_UNIT_NAME" 2>/dev/null; then
|
||||
echo "disabling $VIDEO_UNIT_NAME at boot (unit file kept for switching back)"
|
||||
sudo systemctl disable "$VIDEO_UNIT_NAME"
|
||||
fi
|
||||
sudo systemctl enable "$TARGET_UNIT_NAME" >/dev/null 2>&1 || sudo systemctl enable "$TARGET_UNIT_NAME"
|
||||
sudo systemctl daemon-reload
|
||||
# 4b) the keepalive proxy's one-prompt ceiling follows the lane (v1.5.6 contract, see
|
||||
@@ -571,6 +643,7 @@ fi
|
||||
RUNNING=""
|
||||
systemctl is-active --quiet "$OTHER_UNIT_NAME" 2>/dev/null && RUNNING="$OTHER_UNIT_NAME"
|
||||
systemctl is-active --quiet "$IMAGE_UNIT_NAME" 2>/dev/null && RUNNING="$IMAGE_UNIT_NAME"
|
||||
systemctl is-active --quiet "$VIDEO_UNIT_NAME" 2>/dev/null && RUNNING="$VIDEO_UNIT_NAME"
|
||||
printf '\n\033[1;32mSwitch queued: %s (%s)\033[0m\n' "$TARGET_REPO" "$TARGET_UNIT_NAME"
|
||||
if [ -n "$RUNNING" ]; then
|
||||
echo "Effective after: sudo systemctl stop $RUNNING && sudo systemctl start $TARGET_UNIT_NAME (or next reboot)"
|
||||
@@ -587,7 +660,7 @@ fi
|
||||
echo "Then fit them: python3 oc-fit-limits.py (the limits above are this target's"
|
||||
echo " nominal pair; the pool is only known once the engine is up)"
|
||||
case "$CHOICE" in
|
||||
stock) echo "Switch back: ./switch-model.sh uncensored (or fp8, flash, image)" ;;
|
||||
stock) echo "Switch back: ./switch-model.sh uncensored (or fp8, flash, image, video)" ;;
|
||||
uncensored) echo "Switch back: ./switch-model.sh stock (or fp8, flash)" ;;
|
||||
fp8) echo "Switch back: ./switch-model.sh stock (or uncensored, uncensored-fp8, flash)" ;;
|
||||
uncensored-fp8) echo "Switch back: ./switch-model.sh fp8 (or stock, uncensored, flash)" ;;
|
||||
|
||||
@@ -118,7 +118,7 @@ class TheCheckPins(PinsBase):
|
||||
rc, out = self.run_pins(None, "hf_secretvalue123")
|
||||
self.assertEqual(rc, 0, out)
|
||||
hf = [c for c in self.calls() if c["url"].startswith("https://huggingface.co/")]
|
||||
self.assertEqual(len(hf), 10, hf) # nine checkpoints and the image lane's
|
||||
self.assertEqual(len(hf), 11, hf) # nine checkpoints and the two diffusion lanes'
|
||||
for c in hf:
|
||||
self.assertIn("Authorization: Bearer hf_secretvalue123", c["stdin"], c)
|
||||
self.assertFalse(any("hf_secretvalue123" in a for a in c["argv"]), c["argv"])
|
||||
|
||||
@@ -466,13 +466,13 @@ class AnUpdateKeepsTheImageLaneAsTheBootLane(unittest.TestCase):
|
||||
self.assertIn('[ "$SGL_ENABLED" -eq 0 ] && [ "$FLASH_ENABLED" -eq 0 ]', self.text)
|
||||
|
||||
def test_the_text_unit_is_not_enabled_on_that_path(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ]; then')
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
self.assertIn('sudo systemctl enable "$UNIT_NAME"', self.text[i:i + 120])
|
||||
# and that is the ONLY enable of the serving unit: an unguarded one would undo it
|
||||
self.assertEqual(self.text.count('sudo systemctl enable "$UNIT_NAME"'), 1)
|
||||
|
||||
def test_that_path_ends_before_any_text_engine_is_started(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ]; then')
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
early = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertNotIn("systemctl start", early)
|
||||
self.assertIn("--no-smoke", early, "the smoke test stops and starts the serving lane")
|
||||
@@ -500,15 +500,15 @@ class TheBootLaneConvergenceHoldsEveryWay(unittest.TestCase):
|
||||
self.assertIn("sudo systemctl disable qwen38-image.service", self.text)
|
||||
|
||||
def test_the_image_boot_path_restarts_the_proxy_it_rewrote(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ]; then')
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
early = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertIn('sudo systemctl restart "$KEEPALIVE_UNIT"', early)
|
||||
|
||||
def test_the_image_boot_path_respects_no_image(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ]; then')
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
early = self.text[i:self.text.index("exit 0", i)]
|
||||
call = early.index('"$REPO_DIR/install-image.sh" --no-smoke')
|
||||
self.assertIn('if [ "$NO_IMAGE" -eq 0 ]; then', early[:call])
|
||||
self.assertIn('if [ "$NO_IMAGE" -eq 0 ]', early[:call])
|
||||
|
||||
def test_the_text_lane_used_before_images_is_the_one_brought_up_to_date(self):
|
||||
"""A switch to images disables both text units, so enablement cannot say which one
|
||||
@@ -521,7 +521,7 @@ class TheBootLaneConvergenceHoldsEveryWay(unittest.TestCase):
|
||||
|
||||
def test_it_never_points_at_a_switch_target_that_does_not_exist(self):
|
||||
"""A kept custom model is MODEL_CHOICE=custom, which switch-model.sh rejects."""
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ]; then')
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
early = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertIn('if [ "$MODEL_CHOICE" = "custom" ]; then', early)
|
||||
|
||||
@@ -536,7 +536,7 @@ class ThePageNeverShowsAStaleOrRacingState(unittest.TestCase):
|
||||
def test_the_text_engines_target_never_labels_the_image_lane(self):
|
||||
# the text engine's target, and only when it is one of this unit's (ownTarget)
|
||||
self.assertIn("unit !== IMAGE_UNIT && ownTarget(unit)", self.js)
|
||||
self.assertIn("s[0] !== IMAGE_UNIT && ownTarget(unit)", self.js)
|
||||
self.assertIn('s[0] !== IMAGE_UNIT && s[0] !== VIDEO_UNIT && ownTarget(unit)', self.js)
|
||||
self.assertIn("F.target && TARGET_UNIT(F.target) === unit", self.js)
|
||||
down = self.js[self.js.index("function rEngineInfoDown("):self.js.index("function showEngineFacts(")]
|
||||
self.assertIn("F.target = null", down)
|
||||
|
||||
@@ -136,8 +136,8 @@ class TheMirrorPins(unittest.TestCase):
|
||||
rc, out = self.run_mirror()
|
||||
self.assertEqual(rc, 0, out)
|
||||
models = re.findall(r"^\s+mirror: (\S+) @ upstream-", out, re.M)
|
||||
self.assertEqual(len(models), 10, out) # nine text checkpoints and the image lane's
|
||||
self.assertEqual(len(set(models)), 10, models)
|
||||
self.assertEqual(len(models), 11, out) # nine text checkpoints and the two diffusion lanes'
|
||||
self.assertEqual(len(set(models)), 11, models)
|
||||
# every checkpoint has its license row, and every row names a checkpoint the script copies
|
||||
labels = re.findall(r"^ model\s+(\S+)$", out, re.M)
|
||||
rows = [r for r in re.findall(r"^\| ([a-z0-9-]+) \| [^|]+ \| [^|]+ \|$", self.mirror_md.read_text(), re.M)
|
||||
|
||||
@@ -21,6 +21,7 @@ LANES = {
|
||||
"qwen38-sglang.service": ("qwen38-sglang.service.template", "qwen38-sglang-1m.service.template"),
|
||||
"qwen38-flash.service": ("qwen38-flash.service.template",),
|
||||
"qwen38-image.service": ("qwen38-image.service.template",),
|
||||
"qwen38-video.service": ("qwen38-video.service.template",),
|
||||
}
|
||||
ALL = set(LANES) | {"qwen38-llamacpp.service"}
|
||||
|
||||
|
||||
@@ -0,0 +1,367 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The MiniMax-H3 video lane: the cookbook's recipe, held in place.
|
||||
|
||||
Every serving assertion here corresponds to the SGLang cookbook's MiniMax-H3 page as
|
||||
read on 2026-09-25: the DGX Spark figures (about 12.1 s per denoise step, about 40 s
|
||||
of decode, about 12 min per warm 4 s 480P request, with no flags at all), the two
|
||||
checkpoint partitions (fl2va and ref2va, chosen with --model-variant), the request
|
||||
shape (model, prompt, seconds 4 to 15, task, conditions with keyframe roles, target,
|
||||
quality, num_outputs_per_prompt 1 to 10, num_inference_steps, flow_shift,
|
||||
audio_flow_shift, seed) and the OpenAI videos endpoints (POST /v1/videos, GET
|
||||
/v1/videos, GET /v1/videos/{id}/content).
|
||||
|
||||
The lane serves that recipe exactly as upstream wrote it at the pinned commit: no
|
||||
local source patch. The image lane carries two, and this lane deliberately does not
|
||||
(Hasan, 2026-09-25: the official SGLang and MiniMax recommendations, nothing added).
|
||||
What that costs is stated, not patched around: a stop waits for the generation to
|
||||
end, up to TimeoutStopSec, because the runtime has no abort.
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import unittest
|
||||
|
||||
REPO = pathlib.Path(__file__).resolve().parents[1]
|
||||
UNIT_TPL = REPO / "qwen38-video.service.template"
|
||||
INSTALLER = REPO / "install-video.sh"
|
||||
COCKPIT = REPO / "dashboard" / "cockpit.py"
|
||||
APP_JS = REPO / "dashboard" / "static" / "app.js"
|
||||
INDEX = REPO / "dashboard" / "static" / "index.html"
|
||||
SWITCH = REPO / "switch-model.sh"
|
||||
INSTALL = REPO / "install.sh"
|
||||
|
||||
|
||||
def exec_start():
|
||||
"""The flags the unit actually passes, with the comments that explain them stripped.
|
||||
A comment naming a flag it deliberately does NOT pass must not read as passing it."""
|
||||
lines, taking = [], False
|
||||
for line in UNIT_TPL.read_text().splitlines():
|
||||
if line.startswith("ExecStart="):
|
||||
taking = True
|
||||
elif taking and not lines[-1].rstrip().endswith("\\"):
|
||||
break
|
||||
if taking:
|
||||
lines.append(line)
|
||||
return " ".join(lines)
|
||||
|
||||
|
||||
class TheUnit(unittest.TestCase):
|
||||
def test_every_placeholder_is_one_the_installer_substitutes(self):
|
||||
rendered = UNIT_TPL.read_text()
|
||||
for ph in sorted(set(re.findall(r"__[A-Z][A-Z0-9_]*__", rendered))):
|
||||
self.assertIn(ph.replace("__", ""), INSTALLER.read_text(),
|
||||
f"{ph} is in the template and no sed line names it")
|
||||
|
||||
def test_one_engine_at_a_time_is_declared_not_documented(self):
|
||||
text = UNIT_TPL.read_text()
|
||||
after = [ln for ln in text.splitlines() if ln.startswith("After=")][0]
|
||||
for other in ("qwen38-sglang.service", "qwen38-flash.service",
|
||||
"qwen38-image.service", "qwen38-llamacpp.service"):
|
||||
self.assertIn(other, after,
|
||||
f"{other} is not ordered after in After=")
|
||||
conflicts = [ln for ln in text.splitlines() if ln.startswith("Conflicts=")][0]
|
||||
for other in ("qwen38-sglang.service", "qwen38-flash.service",
|
||||
"qwen38-image.service", "qwen38-llamacpp.service"):
|
||||
self.assertIn(other, conflicts)
|
||||
# and the other three lanes name this one back, both directions
|
||||
for tpl in ("qwen38-sglang.service.template", "qwen38-sglang-1m.service.template",
|
||||
"qwen38-flash.service.template", "qwen38-image.service.template"):
|
||||
body = (REPO / tpl).read_text()
|
||||
self.assertIn("qwen38-video.service", body, tpl)
|
||||
|
||||
def test_it_serves_the_cookbook_recipe_and_nothing_else(self):
|
||||
"""The cookbook verifies this model on the DGX Spark with no flags at all, and
|
||||
adding the discrete-GPU offload flags measured 2.1x slower on the same box.
|
||||
Forcing any placement is how a verified recipe stops being the verified recipe."""
|
||||
flags = exec_start()
|
||||
self.assertIn("--model-path", flags)
|
||||
self.assertIn("--model-variant", flags)
|
||||
for forced in ("--performance-mode", "--quantization", "--attention-backend",
|
||||
"--use-fsdp-inference", "--dit-layerwise", "--layerwise-offload",
|
||||
"--text-encoder-cpu-offload", "--vae-cpu-offload", "--tp-size",
|
||||
"--sp-degree", "--num-gpus", "--enable-cfg-parallel"):
|
||||
self.assertNotIn(forced, flags, f"{forced} is not the cookbook's DGX Spark recipe")
|
||||
|
||||
def test_it_passes_no_flag_the_diffusion_parser_does_not_have(self):
|
||||
"""--api-key and --sleep-on-idle kill the unit at startup with "unrecognized
|
||||
arguments" (measured on the image lane's identical runtime, 2026-09-22)."""
|
||||
flags = exec_start()
|
||||
self.assertNotIn("--api-key", flags)
|
||||
self.assertNotIn("--sleep-on-idle", flags)
|
||||
|
||||
def test_the_lane_is_loopback_because_it_cannot_authenticate_anyone(self):
|
||||
text = UNIT_TPL.read_text()
|
||||
self.assertIn("__VIDEO_BIND__", text)
|
||||
self.assertIn("127.0.0.1", INSTALLER.read_text())
|
||||
|
||||
def test_a_stop_waits_out_the_generation_it_cannot_abort(self):
|
||||
"""No local shutdown patch on this lane, so a stop during a 15 s request (about
|
||||
45 min at the cookbook's rate) must not meet a TimeoutStopSec that kills it."""
|
||||
text = UNIT_TPL.read_text()
|
||||
m = re.search(r"TimeoutStopSec=(\d+)", text)
|
||||
self.assertIsNotNone(m, "no TimeoutStopSec in the unit")
|
||||
self.assertGreaterEqual(int(m.group(1)), 3600)
|
||||
|
||||
def test_the_decode_sits_on_expandable_segments(self):
|
||||
"""The cookbook: the decode sits close enough to the cap that fragmentation
|
||||
otherwise tips it over."""
|
||||
self.assertIn("PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True", UNIT_TPL.read_text())
|
||||
|
||||
def test_it_is_not_enabled_at_boot_by_the_installer(self):
|
||||
self.assertNotIn("systemctl enable", INSTALLER.read_text().split("step \"5/6 Service\"")[1].split('if [ "$SMOKE"')[0])
|
||||
|
||||
|
||||
class TheInstaller(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.text = INSTALLER.read_text()
|
||||
|
||||
def test_it_refuses_root(self):
|
||||
self.assertIn('if [ "$(id -u)" = "0"', self.text)
|
||||
|
||||
def test_the_checkpoint_pin_is_a_full_commit(self):
|
||||
m = re.search(r'VIDEO_MODEL_PIN_REV="([0-9a-f]+)"', self.text)
|
||||
self.assertIsNotNone(m)
|
||||
self.assertEqual(len(m.group(1)), 40)
|
||||
|
||||
def test_the_pipeline_prerequisites_are_checked_first(self):
|
||||
"""MiniMax-H3 refuses to start without ffmpeg and ffprobe (its own words in
|
||||
minimax_h3_pipeline.py): the installer refuses before downloading 100 GB."""
|
||||
self.assertIn('command -v ffmpeg', self.text)
|
||||
self.assertIn('command -v ffprobe', self.text)
|
||||
|
||||
def test_only_the_served_partition_is_fetched(self):
|
||||
"""The repo holds FL2VA/ and Ref2VA/ (81 files each) plus a root native layout,
|
||||
and --model-variant fl2va roots the pipeline in FL2VA/ alone: fetching the rest
|
||||
filled the reference box's disk at 98% and killed the pull."""
|
||||
self.assertIn("allow_patterns", self.text)
|
||||
self.assertIn("FL2VA/*", self.text)
|
||||
self.assertIn("Ref2VA/*", self.text)
|
||||
self.assertIn("fetching with allow:", self.text)
|
||||
|
||||
def test_a_generation_is_never_archived_on_disk(self):
|
||||
self.assertIn('mkdir -p "$LANE_DIR/outputs"', self.text)
|
||||
|
||||
def test_a_completed_video_survives_its_request(self):
|
||||
"""Left empty, --output-path answers into a temp dir the server deletes when the
|
||||
request ends: a video completed in 592 s 404d on download (measured 2026-09-25).
|
||||
The lane writes every MP4 to its own outputs dir instead."""
|
||||
tpl = (REPO / "qwen38-video.service.template").read_text()
|
||||
self.assertIn("--output-path __VIDEO_LANE_DIR__/outputs", tpl)
|
||||
self.assertIn('--input-save-path ""', tpl)
|
||||
|
||||
def test_the_wheel_goes_in_before_the_source(self):
|
||||
"""The wheel ships the prebuilt aarch64 kernels the source tree reuses; reversed,
|
||||
the server dies on its first request."""
|
||||
self.assertLess(self.text.index("sglang[diffusion]=="), self.text.index("pip\" install --quiet --no-deps -e"))
|
||||
|
||||
def test_the_source_overlay_needs_no_rust_toolchain(self):
|
||||
self.assertIn("SGLANG_BUILD_RUST_EXTS=none", self.text)
|
||||
|
||||
def test_there_is_no_local_patch_on_this_lane(self):
|
||||
"""Hasan, 2026-09-25: the official recommendations, nothing added on top. A
|
||||
PATCHES= line or a video-sglang directory here is the custom method coming back."""
|
||||
self.assertNotIn("PATCHES=", self.text)
|
||||
self.assertFalse((REPO / "video-sglang").exists())
|
||||
self.assertNotIn("apply --check", self.text)
|
||||
|
||||
def test_it_checks_for_room_before_downloading_145_gb(self):
|
||||
self.assertIn("WEIGHTS_GB=145", self.text)
|
||||
self.assertIn("WEIGHTS_NEED", self.text)
|
||||
|
||||
def test_an_unknown_option_is_refused_rather_than_ignored(self):
|
||||
self.assertIn('die "unknown option: $a"', self.text)
|
||||
|
||||
def test_the_variant_is_closed_to_the_two_partitions(self):
|
||||
"""fl2va and ref2va are checkpoint partitions: a third string serves neither."""
|
||||
self.assertIn('case "$VARIANT" in fl2va|ref2va)', self.text)
|
||||
|
||||
def test_the_other_lane_comes_back_however_the_smoke_test_ends(self):
|
||||
self.assertIn("trap restore_other_lane EXIT", self.text)
|
||||
|
||||
def test_a_routine_rerun_does_not_stop_the_engine_to_redo_the_smoke_test(self):
|
||||
self.assertIn("--no-smoke", self.text)
|
||||
|
||||
def test_a_serving_video_lane_is_left_serving_by_the_smoke_test(self):
|
||||
self.assertIn("WAS_VIDEO=0", self.text)
|
||||
|
||||
def test_the_smoke_test_proves_a_video_not_a_status_code(self):
|
||||
"""Creation is asynchronous: the smoke test polls the list to completed and
|
||||
downloads bytes it measures, the way the lane is actually used."""
|
||||
self.assertIn("/v1/videos", self.text)
|
||||
self.assertIn("completed", self.text)
|
||||
self.assertIn("/content", self.text)
|
||||
|
||||
def test_uninstall_reads_the_lane_directory_from_the_unit(self):
|
||||
self.assertIn("installed WorkingDirectory", self.text)
|
||||
|
||||
def test_uninstall_restores_the_lane_it_replaced_at_boot(self):
|
||||
self.assertIn("lane-before-video", self.text)
|
||||
|
||||
|
||||
class TheSwitch(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.text = SWITCH.read_text()
|
||||
|
||||
def test_video_is_a_switch_target(self):
|
||||
self.assertIn("|video)", self.text)
|
||||
self.assertIn("./switch-model.sh video", self.text)
|
||||
|
||||
def test_it_verifies_the_checkpoint_before_touching_boot(self):
|
||||
i = self.text.index('if [ "$CHOICE" = "video" ]; then')
|
||||
block = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertIn("snapshot_download", block)
|
||||
self.assertIn("local_files_only", block)
|
||||
|
||||
def test_the_lane_before_video_is_written_down_before_anything_is_disabled(self):
|
||||
i = self.text.index('if [ "$CHOICE" = "video" ]; then')
|
||||
block = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertIn('> "$CONFIG_DIR/lane-before-video"', block)
|
||||
self.assertLess(block.index('> "$CONFIG_DIR/lane-before-video"'),
|
||||
block.index("sudo systemctl disable"))
|
||||
|
||||
def test_it_disables_every_other_engine_and_enables_this_one(self):
|
||||
i = self.text.index('if [ "$CHOICE" = "video" ]; then')
|
||||
block = self.text[i:self.text.index("exit 0", i)]
|
||||
for u in ("qwen38-sglang.service", "qwen38-flash.service", "qwen38-image.service"):
|
||||
self.assertIn(u, block)
|
||||
self.assertIn('sudo systemctl enable "$VIDEO_UNIT_NAME"', block)
|
||||
|
||||
def test_it_never_starts_stops_or_restarts_an_engine(self):
|
||||
i = self.text.index('if [ "$CHOICE" = "video" ]; then')
|
||||
block = self.text[i:self.text.index("exit 0", i)]
|
||||
cmds = [ln.strip() for ln in block.splitlines()
|
||||
if ln.strip().startswith("sudo systemctl")]
|
||||
for cmd in cmds:
|
||||
self.assertTrue(cmd.startswith("sudo systemctl enable")
|
||||
or cmd.startswith("sudo systemctl disable")
|
||||
or cmd.startswith("sudo systemctl daemon-reload"),
|
||||
f"the switch runs an engine: {cmd}")
|
||||
|
||||
def test_a_text_switch_takes_the_video_lane_off_the_boot(self):
|
||||
self.assertIn('systemctl disable "$VIDEO_UNIT_NAME"', self.text)
|
||||
|
||||
def test_the_proxy_and_opencode_are_left_alone(self):
|
||||
"""Both are text clients: the proxy relays :30000 and opencode generates text."""
|
||||
i = self.text.index('if [ "$CHOICE" = "video" ]; then')
|
||||
block = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertIn("left as they are", block)
|
||||
self.assertNotIn("oc-merge-limits", block)
|
||||
self.assertNotIn("ceiling", block)
|
||||
|
||||
|
||||
class TheBootLaneConvergence(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.text = INSTALL.read_text()
|
||||
|
||||
def test_a_box_booting_video_is_detected(self):
|
||||
self.assertIn("VIDEO_BOOT=0", self.text)
|
||||
self.assertIn("systemctl is-enabled --quiet qwen38-video.service", self.text)
|
||||
|
||||
def test_the_text_unit_is_not_enabled_on_that_path(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
self.assertIn('sudo systemctl enable "$UNIT_NAME"', self.text[i:i + 120])
|
||||
self.assertEqual(self.text.count('sudo systemctl enable "$UNIT_NAME"'), 1)
|
||||
|
||||
def test_that_path_updates_without_starting_anything(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
early = self.text[i:self.text.index("exit 0", i)]
|
||||
self.assertNotIn("systemctl start", early)
|
||||
self.assertIn("--no-smoke", early)
|
||||
|
||||
def test_that_path_respects_no_video(self):
|
||||
i = self.text.index('if [ "$IMAGE_BOOT" -eq 0 ] && [ "$VIDEO_BOOT" -eq 0 ]; then')
|
||||
early = self.text[i:self.text.index("exit 0", i)]
|
||||
call = early.index('"$REPO_DIR/install-video.sh" --no-smoke')
|
||||
self.assertIn('if [ "$NO_VIDEO" -eq 0 ]', early[:call])
|
||||
|
||||
def test_an_explicit_model_choice_is_honoured(self):
|
||||
i = self.text.index("VIDEO_BOOT=0\nif systemctl is-enabled --quiet qwen38-video.service")
|
||||
block = self.text[i:i + 900]
|
||||
self.assertIn('if [ -n "$_ENV_MODEL_CHOICE" ]; then', block)
|
||||
self.assertLess(block.index('if [ -n "$_ENV_MODEL_CHOICE" ]; then'), block.index("VIDEO_BOOT=1"))
|
||||
|
||||
def test_the_text_lane_used_before_video_is_the_one_brought_up_to_date(self):
|
||||
self.assertIn('> "$CONFIG_DIR/lane-before-video"', SWITCH.read_text())
|
||||
self.assertIn('[ "$LANE_BEFORE_VIDEO" = "qwen38-flash.service" ]', self.text)
|
||||
|
||||
def test_with_video_and_no_video_contradict_each_other(self):
|
||||
self.assertIn("'--no-video and --with-video contradict each other", self.text)
|
||||
|
||||
def test_with_video_needs_the_full_install(self):
|
||||
self.assertIn("'--with-video needs the full install", self.text)
|
||||
|
||||
|
||||
class TheProxyLeavesVideoAlone(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.text = (REPO / "keepalive-proxy.py").read_text()
|
||||
|
||||
def test_a_serving_video_lane_is_named_on_the_error_path(self):
|
||||
"""With video serving, :30000 is closed: the client is told where the engine
|
||||
went, not that it is loading."""
|
||||
self.assertIn("def video_lane_serving", self.text)
|
||||
self.assertIn("qwen38-video.service", self.text[
|
||||
self.text.index("def engine_gone_reason"):self.text.index("def engine_gone_reason") + 1200])
|
||||
|
||||
def test_nothing_video_is_relayed_through_the_text_proxy(self):
|
||||
"""The proxy relays the text engine on :30000; the video lane listens on its
|
||||
own port and the cockpit calls it directly."""
|
||||
self.assertNotIn("/v1/videos", self.text)
|
||||
|
||||
|
||||
class ThePageShowsVideoTruthfully(unittest.TestCase):
|
||||
def test_the_switcher_offers_minimax_h3(self):
|
||||
self.assertIn('<option value="video">MiniMax-H3</option>', INDEX.read_text())
|
||||
|
||||
def test_the_video_tab_is_a_panel_not_a_promise(self):
|
||||
body = INDEX.read_text()
|
||||
self.assertNotIn("Coming soon", body)
|
||||
self.assertIn('id="tab-video"', body)
|
||||
self.assertIn('id="vidrun"', body)
|
||||
self.assertIn('<option value="qwen38-video.service">video lane (journal)</option>', body)
|
||||
|
||||
def test_the_target_unit_is_the_video_unit(self):
|
||||
self.assertIn("t === 'video' ? VIDEO_UNIT", APP_JS.read_text())
|
||||
|
||||
def test_cancel_restarts_the_lane(self):
|
||||
"""The runtime has no abort: Cancel restarts the lane, like the image lane."""
|
||||
js = APP_JS.read_text()
|
||||
i = js.index("function vidCancel(){")
|
||||
self.assertIn("verb: 'restart', unit: VIDEO_UNIT", js[i:i + 400])
|
||||
|
||||
def test_generate_stays_off_until_the_lane_answers(self):
|
||||
js = APP_JS.read_text()
|
||||
i = js.index("function vidRenderLane(){")
|
||||
self.assertIn("$('vidrun').disabled = !ready", js[i:i + 2500])
|
||||
|
||||
def test_keyframes_are_capped_before_they_leave_the_browser(self):
|
||||
"""A phone photo is megabytes against the 10 MiB the cockpit reads: capped on
|
||||
the long side and re-encoded to PNG, like the image lane's references."""
|
||||
js = APP_JS.read_text()
|
||||
i = js.index("function vidReadFile(")
|
||||
body = js[i:js.index("function vidRun(){")]
|
||||
self.assertIn("1280", body)
|
||||
self.assertIn("toDataURL('image/png')", body)
|
||||
|
||||
|
||||
class TheUninstallKnowsVideo(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.text = (REPO / "uninstall.sh").read_text()
|
||||
|
||||
def test_the_unit_is_inventoried_and_removed(self):
|
||||
self.assertIn("qwen38-video.service", self.text)
|
||||
|
||||
def test_the_runtime_is_read_from_the_unit_not_assumed(self):
|
||||
self.assertIn("qwen38-video.service", self.text[
|
||||
:self.text.index('VIDEO_LANE_DIR="${VIDEO_LANE_DIR:-$HOME/.local/share/qwen38-video}"') + 200])
|
||||
|
||||
def test_the_checkpoint_pin_is_inventoried(self):
|
||||
self.assertIn("MiniMaxAI/MiniMax-H3", self.text)
|
||||
|
||||
def test_only_what_the_installer_put_there_is_removed(self):
|
||||
"""VIDEO_LANE_DIR can be shared: removing it whole took the rest with it on the
|
||||
image lane, so only venv/ and sglang/ go."""
|
||||
i = self.text.index('rm -rf "$VIDEO_LANE_DIR/venv"')
|
||||
self.assertIn("rmdir", self.text[i:i + 300])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+16
-5
@@ -49,7 +49,7 @@ done
|
||||
# digest: a digest pull leaves no tag behind.
|
||||
LOCAL_IMAGE_REPOS="qwen38-dflash2 qwen38-flash qwen38-pinned" # qwen38-dflash2 is the pre-v1.14 27B overlay, retired but still deletable; qwen38-pinned (v1.18.6) tags the digest pulls
|
||||
BASE_IMAGES="lmsysorg/sglang:v0.5.19 lmsysorg/sglang@sha256:d6e7288627be8b02be88e4bba38e73f6d50e2826869f753c13a4c4385ab3eda9 lmsysorg/sglang:qwen38-27b lmsysorg/sglang@sha256:febfb971c7352570fc445c466ebd6ffc9d896024958e544a60f2137fd85856b1 lmsysorg/sglang:qwen38flashnext lmsysorg/sglang@sha256:12d3392bdc8be8d35e9a95f191df6aef99c5114bdbefd41bfdc7e760e6d25ec1 lmsysorg/sglang@sha256:9d2a843c706c74bc259c0d9abf360551eb2734e1e7d255ab012a6965f10480b6 lmsysorg/sglang@sha256:616a3e97f45191af975896cfa644279096cb31bd408a071c2e99ca7209c3cafe vllm/vllm-openai:qwen38-flash-next vllm/vllm-openai@sha256:fc120ece0a388cc0aa1caad4a9f1cd92113484ab7ec2fd0efadd62585be05bf8"
|
||||
HF_REPOS="RadixArk/Qwen3.8-27B-NVFP4 edp1096/Huihui-RadixArk-Qwen3.8-27B-abliterated-NVFP4 Qwen/Qwen3.8-27B-FP8 edp1096/Huihui-Qwen3.8-27B-abliterated-FP8 RadixArk/Qwen3.8-27B-DSpark z-lab/Qwen3.8-27B-DFlash2 maurienne-ai/Qwen3.8-27B-DFlash2-NVFP4-RTNcal RadixArk/Qwen3.8-Flash-Next-NVFP4 nvidia/Qwen3.8-Flash-Next-NVFP4 dealignai/Qwen3.8-Flash-Next-ABLITERATED-NVFP4 Qwen/Qwen-Image-2.1"
|
||||
HF_REPOS="RadixArk/Qwen3.8-27B-NVFP4 edp1096/Huihui-RadixArk-Qwen3.8-27B-abliterated-NVFP4 Qwen/Qwen3.8-27B-FP8 edp1096/Huihui-Qwen3.8-27B-abliterated-FP8 RadixArk/Qwen3.8-27B-DSpark z-lab/Qwen3.8-27B-DFlash2 maurienne-ai/Qwen3.8-27B-DFlash2-NVFP4-RTNcal RadixArk/Qwen3.8-Flash-Next-NVFP4 nvidia/Qwen3.8-Flash-Next-NVFP4 dealignai/Qwen3.8-Flash-Next-ABLITERATED-NVFP4 Qwen/Qwen-Image-2.1 MiniMaxAI/MiniMax-H3"
|
||||
|
||||
FOUND_IMAGES=() # "ref|size|every ref", deduplicated by image ID (a tag and its digest are one image)
|
||||
# Every reference Docker keeps for one image. A digest-pulled image carries its digest
|
||||
@@ -90,7 +90,7 @@ rm_cmd() {
|
||||
}
|
||||
|
||||
echo "── Inventory (everything any version of this repo may have left here) ──"
|
||||
for u in qwen38-sglang.service qwen38-flash.service qwen38-keepalive.service qwen38-dashboard.service qwen38-image.service opencode-web.service; do
|
||||
for u in qwen38-sglang.service qwen38-flash.service qwen38-keepalive.service qwen38-dashboard.service qwen38-image.service qwen38-video.service opencode-web.service; do
|
||||
if [ -f "$SYSTEMD_DIR/$u" ]; then
|
||||
STATE="$(systemctl is-enabled "$u" 2>/dev/null || true)/$(systemctl is-active "$u" 2>/dev/null || true)"
|
||||
echo " unit $SYSTEMD_DIR/$u ($STATE)"
|
||||
@@ -106,6 +106,11 @@ done
|
||||
IMAGE_LANE_DIR="${IMAGE_LANE_DIR:-$({ grep -m1 -E '^WorkingDirectory=' "$SYSTEMD_DIR/qwen38-image.service" 2>/dev/null || true; } | cut -d= -f2-)}"
|
||||
IMAGE_LANE_DIR="${IMAGE_LANE_DIR:-$HOME/.local/share/qwen38-image}"
|
||||
[ -d "$IMAGE_LANE_DIR" ] && echo " runtime $IMAGE_LANE_DIR ($(dir_size "$IMAGE_LANE_DIR"), image lane venv + pinned SGLang checkout)"
|
||||
# Read from the unit, not assumed: install-video.sh takes VIDEO_LANE_DIR, so a lane
|
||||
# installed elsewhere would be reported clean and left on disk.
|
||||
VIDEO_LANE_DIR="${VIDEO_LANE_DIR:-$({ grep -m1 -E '^WorkingDirectory=' "$SYSTEMD_DIR/qwen38-video.service" 2>/dev/null || true; } | cut -d= -f2-)}"
|
||||
VIDEO_LANE_DIR="${VIDEO_LANE_DIR:-$HOME/.local/share/qwen38-video}"
|
||||
[ -d "$VIDEO_LANE_DIR" ] && echo " runtime $VIDEO_LANE_DIR ($(dir_size "$VIDEO_LANE_DIR"), video lane venv + pinned SGLang checkout)"
|
||||
for f in "$CONFIG_DIR"/*.bak-preupdate; do
|
||||
[ -f "$f" ] && echo " backup $f (pre-update unit backup)"
|
||||
done
|
||||
@@ -155,7 +160,7 @@ fi
|
||||
PRIV=0
|
||||
for f in "$SYSTEMD_DIR/qwen38-sglang.service" "$SYSTEMD_DIR/qwen38-flash.service" \
|
||||
"$SYSTEMD_DIR/qwen38-keepalive.service" "$SYSTEMD_DIR/qwen38-dashboard.service" \
|
||||
"$SYSTEMD_DIR/qwen38-image.service" "$SYSTEMD_DIR/opencode-web.service" \
|
||||
"$SYSTEMD_DIR/qwen38-image.service" "$SYSTEMD_DIR/qwen38-video.service" "$SYSTEMD_DIR/opencode-web.service" \
|
||||
"$SYSTEMD_DIR/qwen38-sglang.service.d" "$SYSTEMD_DIR/qwen38-dashboard.service.d" \
|
||||
"$SYSTEMD_DIR/qwen38-keepalive.service.d" "$SUDOERS_FILE" "$PYSPY_WRAPPER"; do
|
||||
[ -e "$f" ] && PRIV=1
|
||||
@@ -168,11 +173,11 @@ done
|
||||
PRIV_DONE=0
|
||||
if [ "$PRIV" -eq 1 ]; then
|
||||
if sudo -v; then
|
||||
for u in qwen38-sglang qwen38-flash qwen38-keepalive qwen38-dashboard qwen38-image opencode-web; do
|
||||
for u in qwen38-sglang qwen38-flash qwen38-keepalive qwen38-dashboard qwen38-image qwen38-video opencode-web; do
|
||||
sudo systemctl disable --now "$u.service" 2>/dev/null || true
|
||||
done
|
||||
docker rm -f qwen38-sglang qwen38-sglang-run qwen38-flash 2>/dev/null || true
|
||||
sudo rm -f "$SYSTEMD_DIR/qwen38-sglang.service" "$SYSTEMD_DIR/qwen38-flash.service" "$SYSTEMD_DIR/qwen38-keepalive.service" "$SYSTEMD_DIR/qwen38-dashboard.service" "$SYSTEMD_DIR/qwen38-image.service" "$SYSTEMD_DIR/opencode-web.service"
|
||||
sudo rm -f "$SYSTEMD_DIR/qwen38-sglang.service" "$SYSTEMD_DIR/qwen38-flash.service" "$SYSTEMD_DIR/qwen38-keepalive.service" "$SYSTEMD_DIR/qwen38-dashboard.service" "$SYSTEMD_DIR/qwen38-image.service" "$SYSTEMD_DIR/qwen38-video.service" "$SYSTEMD_DIR/opencode-web.service"
|
||||
sudo rm -rf "$SYSTEMD_DIR/qwen38-sglang.service.d" "$SYSTEMD_DIR/qwen38-dashboard.service.d" "$SYSTEMD_DIR/qwen38-keepalive.service.d"
|
||||
# The cockpit's privileged surface goes with it: a NOPASSWD allowlist left behind
|
||||
# after an uninstall is the one leftover that is not merely clutter.
|
||||
@@ -196,6 +201,12 @@ if [ -d "$IMAGE_LANE_DIR" ] && { [ "$PRIV" -eq 0 ] || [ "$PRIV_DONE" -eq 1 ]; };
|
||||
rm -rf "$IMAGE_LANE_DIR/venv" "$IMAGE_LANE_DIR/sglang"
|
||||
rmdir "$IMAGE_LANE_DIR" 2>/dev/null || echo "kept $IMAGE_LANE_DIR: it holds files the image lane did not put there"
|
||||
fi
|
||||
# The video lane's runtime, under the same rule: only venv/ and sglang/, and the
|
||||
# directory itself only once it is empty.
|
||||
if [ -d "$VIDEO_LANE_DIR" ] && { [ "$PRIV" -eq 0 ] || [ "$PRIV_DONE" -eq 1 ]; }; then
|
||||
rm -rf "$VIDEO_LANE_DIR/venv" "$VIDEO_LANE_DIR/sglang"
|
||||
rmdir "$VIDEO_LANE_DIR" 2>/dev/null || echo "kept $VIDEO_LANE_DIR: it holds files the video lane did not put there"
|
||||
fi
|
||||
# The oc launcher, only if it is ours (never a foreign oc binary)
|
||||
if grep -q 'dgx-spark-qwen38' "$HOME/.local/bin/oc" 2>/dev/null; then
|
||||
rm -f "$HOME/.local/bin/oc"
|
||||
|
||||
Reference in new issue
Block a user