mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 08:18:54 +00:00
qwen4: the draft layer (MTP) is ready for the .strata builds on the standalone host: --mtp <MTP.strata> --spec 2
- Q4-CORE's MTP work (#53, #56) makes the draft layer work with the default host embedding, so there is no --embed-host workaround. Measured by the lanes: A6000 Compact 1.35x, R9700 1.59x, RTX 3060 1.08 to 1.12x, Mac about 137 tok/s. - qwen4_family: STRATA_BUILD_FLAG_READY mtp True, STRATA_SPEC_ARGS --spec 2, --mtp and --spec are flags of the standalone host (STRATA_SERVE_FLAGS, no longer ignored), coming_note() names only what is still coming (pictures). - serve: the .strata start turns the config's qwen4_mtp key into --mtp <file> --spec 2 (not when the mode is off, the file is missing, or the table says the engine lacks it); setup, adopt and the catalog already follow mtp_ready: the 0.35 GB MTP.strata is in the default set for a card of 6 GB or more (qwen4_fit.mtp_auto_on) and for unified pools, and the config key is written. - host: QWEN4_STRATA_READY mtp true (qwen4.mjs, qwen4.ts): the .strata panel shows MTP Auto / On / Off. - Metal is unchanged (its own rt chain with --spec 2); the GGUF build is unchanged (--spec 3 --spec-min-p 0.5). - tests: the pinned tables follow, new tests for the key to flags, off, a card under 6 GB and a missing file.
This commit is contained in:
1 parent
4fb9ce94f5
commit
e3fedae5c9
14 files changed
+124
-52
No files matched your search
@@ -50,7 +50,7 @@ export const QWEN4_LOOP_CHOICES = ['off', 'on'];
|
||||
export const QWEN4_LOOP_READY = Object.freeze({ 'strata/cuda': true, 'strata/hip': true, 'strata/metal': true, 'gguf/cuda': true, 'gguf/hip': false, 'gguf/metal': true });
|
||||
/** What the standalone strata-q4-lite engine (the .strata builds) takes today: mirrors terminal/strata_control/qwen4_family.py STRATA_BUILD_FLAG_READY (mtp, vision, loop); the GGUF build (UD-Q4_K_XL, the qwen4exp engine) has them all.
|
||||
* False = "coming with the engine": the app writes no key, no flag, downloads no file for it. tests/qwen4-family.test.mjs parses the Python dict and pins this and src/lib/qwen4.ts to it. */
|
||||
export const QWEN4_STRATA_READY = Object.freeze({ mtp: false, vision: false, loop: true });
|
||||
export const QWEN4_STRATA_READY = Object.freeze({ mtp: true, vision: false, loop: true });
|
||||
/** What a .strata tier takes on a Mac (Metal): converted at install and run on `strata`, so the draft layer and pictures work; Loop is coming. Mirrors qwen4_family.py STRATA_METAL_READY (the host test pins the Python, this and src/lib/qwen4.ts). */
|
||||
export const QWEN4_STRATA_METAL_READY = Object.freeze({ mtp: true, vision: true, loop: true });
|
||||
/** The draft layer / pictures for a build on a backend: the GGUF build yes everywhere; a .strata tier by the standalone host's table (QWEN4_STRATA_READY), or on Metal by QWEN4_STRATA_METAL_READY. */
|
||||
|
||||
@@ -12,7 +12,7 @@ export const qwen4LoopReady = (build?: string | null, backend?: string | null, t
|
||||
return ['compact', 'balanced', 'ultra', 'ud-q4_k_xl'].includes(b) && table[`${b === 'ud-q4_k_xl' ? 'gguf' : 'strata'}/${String(backend || 'cuda').toLowerCase()}`] === true;
|
||||
};
|
||||
/** What the standalone strata-q4-lite engine (the .strata builds) takes today (qwen4_family.py STRATA_BUILD_FLAG_READY; server/qwen4.mjs mirrors it too; the host test pins the three together): false = "coming with the engine". The GGUF build has them all. */
|
||||
export const QWEN4_STRATA_READY: Readonly<Record<string, boolean>> = Object.freeze({ mtp: false, vision: false, loop: true });
|
||||
export const QWEN4_STRATA_READY: Readonly<Record<string, boolean>> = Object.freeze({ mtp: true, vision: false, loop: true });
|
||||
/** What a .strata tier takes on a Mac (Metal): converted at install and run on `strata`, so the draft layer and pictures work; Loop is coming (qwen4_family.py STRATA_METAL_READY; server/qwen4.mjs mirrors it too; the host test pins the three). */
|
||||
export const QWEN4_STRATA_METAL_READY: Readonly<Record<string, boolean>> = Object.freeze({ mtp: true, vision: true, loop: true });
|
||||
const qwen4StrataTable = (backend: string | null | undefined, table: Readonly<Record<string, boolean>>, metalTable: Readonly<Record<string, boolean>>) => String(backend ?? '').toLowerCase() === 'metal' ? metalTable : table;
|
||||
|
||||
@@ -448,7 +448,7 @@ test('Loop (2 steps) is "coming" per model source and backend: one table, the Py
|
||||
assert.equal(qwen4Screen.nativeFieldShown('q4_loop', { isLing: false, isQwen4: true, ownQuant4: true }), true, 'visible, not hidden');
|
||||
});
|
||||
|
||||
test('a .strata build: the engine takes no MTP, pictures or Loop yet: one table in the Python, the server and the screens, nothing written and the options say "coming with the engine"', async () => {
|
||||
test('a .strata build: the engine takes the draft layer and the Loop, not pictures yet: one table in the Python, the server and the screens, pictures say "coming with the engine"', async () => {
|
||||
const family = py('qwen4_family.py');
|
||||
const python = /STRATA_BUILD_FLAG_READY = \{([^}]*)\}/.exec(family)[1];
|
||||
const table = Object.fromEntries([...python.matchAll(/"(\w+)":\s*(True|False)/g)].map(m => [m[1], m[2] === 'True']));
|
||||
@@ -456,11 +456,16 @@ test('a .strata build: the engine takes no MTP, pictures or Loop yet: one table
|
||||
assert.deepEqual({ ...QWEN4_STRATA_READY }, optional, 'server/qwen4.mjs mirrors the Python table');
|
||||
const screen = await bundle('./src/lib/qwen4');
|
||||
assert.deepEqual({ ...screen.QWEN4_STRATA_READY }, optional, 'src/lib/qwen4.ts mirrors it');
|
||||
assert.deepEqual(optional, { mtp: false, vision: false, loop: true }, 'only the Loop today (INT #48): the MTP worker and pictures are not in the engine yet');
|
||||
assert.deepEqual(optional, { mtp: true, vision: false, loop: true }, 'the Loop (INT #48) and the draft layer (Q4-CORE #53/#56, `--mtp <MTP.strata> --spec 2`); pictures are not in the engine yet');
|
||||
assert.equal(QWEN4_STRATA_COMING_NOTE, /STRATA_COMING_NOTE = "([^"]+)"/.exec(family)[1]);
|
||||
for (const ready of [qwen4MtpReady, qwen4VisionReady, screen.qwen4MtpReady, screen.qwen4VisionReady]) {
|
||||
for (const ready of [qwen4MtpReady, screen.qwen4MtpReady]) {
|
||||
for (const b of ['Compact', 'Balanced', 'Ultra']) assert.equal(ready(b), true, b);
|
||||
assert.equal(ready('UD-Q4_K_XL'), true, 'the GGUF build has it');
|
||||
assert.equal(ready('Nope'), false);
|
||||
}
|
||||
for (const ready of [qwen4VisionReady, screen.qwen4VisionReady]) {
|
||||
for (const b of ['Compact', 'Balanced', 'Ultra']) assert.equal(ready(b), false, b);
|
||||
assert.equal(ready('UD-Q4_K_XL'), true, 'the GGUF build has them');
|
||||
assert.equal(ready('UD-Q4_K_XL'), true, 'the GGUF build reads pictures');
|
||||
assert.equal(ready('Nope'), false);
|
||||
}
|
||||
// a .strata tier on a Mac runs on `strata` (converted at install): the draft layer and pictures work, Loop is coming: one more table, pinned to the Python
|
||||
@@ -470,22 +475,23 @@ test('a .strata build: the engine takes no MTP, pictures or Loop yet: one table
|
||||
assert.deepEqual({ ...screen.QWEN4_STRATA_METAL_READY }, metalTable, 'src/lib/qwen4.ts mirrors it');
|
||||
assert.deepEqual(metalTable, { mtp: true, vision: true, loop: true });
|
||||
for (const ready of [qwen4MtpReady, qwen4VisionReady, screen.qwen4MtpReady, screen.qwen4VisionReady]) {
|
||||
const mtp = ready === qwen4MtpReady || ready === screen.qwen4MtpReady; // the draft layer is ready on every backend; pictures only on a Mac for the .strata tiers
|
||||
for (const b of ['Compact', 'Balanced', 'Ultra']) {
|
||||
assert.equal(ready(b, undefined, 'metal'), true, `${b} on a Mac`);
|
||||
assert.equal(ready(b, undefined, 'Metal'), true, 'the backend word is not case sensitive');
|
||||
assert.equal(ready(b, undefined, 'cuda'), false, `${b} on NVIDIA stays coming`);
|
||||
assert.equal(ready(b, undefined, 'hip'), false);
|
||||
assert.equal(ready(b, undefined, undefined), false);
|
||||
assert.equal(ready(b, undefined, 'cuda'), mtp, `${b} on NVIDIA`);
|
||||
assert.equal(ready(b, undefined, 'hip'), mtp);
|
||||
assert.equal(ready(b, undefined, undefined), mtp);
|
||||
}
|
||||
assert.equal(ready('UD-Q4_K_XL', undefined, 'metal'), true);
|
||||
}
|
||||
assert.equal(qwen4MtpReadyFor({ model_name: 'qwen4-35b-a3b-compact', backend: 'metal' }), true);
|
||||
assert.equal(qwen4MtpReadyFor({ model_name: 'qwen4-35b-a3b-compact', backend: 'cuda' }), false);
|
||||
assert.equal(qwen4MtpReadyFor({ model_name: 'qwen4-35b-a3b-compact', backend: 'cuda' }), true);
|
||||
assert.equal(qwen4VisionReadyFor({ args: ['--native', '/m/Compact.gguf', '--vision'], model_name: 'qwen4-35b-a3b-balanced', backend: 'metal' }), true);
|
||||
const all = { mtp: true, vision: true, loop: true };
|
||||
assert.equal(qwen4MtpReady('Compact', all), true);
|
||||
assert.equal(screen.qwen4VisionReady('Ultra', all), true);
|
||||
assert.equal(qwen4MtpReadyFor({ model_name: 'qwen4-35b-a3b-compact' }), false);
|
||||
assert.equal(qwen4MtpReadyFor({ model_name: 'qwen4-35b-a3b-compact' }), true);
|
||||
assert.equal(qwen4MtpReadyFor({ model_name: 'qwen4-35b-a3b-ud-q4_k_xl' }), true);
|
||||
assert.equal(qwen4VisionReadyFor({ args: ['--model', '/m/Qwen4-35B-A3B-Ultra.strata'] }), false);
|
||||
// the strata Loop spelling is `--loop 2 --loop-file PATH`: the server strips it with the other Loop flags
|
||||
|
||||
@@ -205,6 +205,15 @@ def strata_engine_args(cfg: dict, exe: str | None = None, *, announce: bool = Tr
|
||||
out = _without(out, qwen4_family.ALL_LOOP_FLAGS) + qwen4_family.loop_engine_args(loop, build)
|
||||
if announce:
|
||||
print(f"[strata] Qwen4-35B-A3B: {qwen4_family.LOOP_WORDS}", flush=True)
|
||||
if not qwen4_family.mtp_ready(build or qwen4_family.DEFAULT_BUILD, cfg.get("backend")):
|
||||
out = _without(out, ("--mtp", "--spec")) # an engine that does not take the draft layer: the flags never reach it (exit 2)
|
||||
else:
|
||||
mtp = cfg.get(qwen4_family.MTP_CONFIG_KEY) # setup / the launcher keep the sidecar in the config key (not in "args": Control would read --mtp <folder> as Flash-Next's draft layer)
|
||||
if mtp and "--mtp" not in out and str(cfg.get(qwen4_family.MTP_MODE_KEY) or "auto").lower() != "off":
|
||||
if Path(str(mtp)).is_file(): # the engine takes `--mtp <MTP.strata> --spec 2`; no --embed-host workaround (Q4-CORE #56)
|
||||
out += qwen4_family.mtp_engine_args(mtp, cfg.get(qwen4_family.MTP_MODE_KEY) or "auto")
|
||||
elif announce:
|
||||
print(f"[strata] Qwen4-35B-A3B: the draft layer file {mtp} is not there, so the model starts without it", flush=True)
|
||||
return out
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ class StrataFlagsComing(unittest.TestCase):
|
||||
"""A .strata build while the engine takes no --mtp, --vision or --loop: serve never passes them (the engine exits 2 on an unknown flag), with one line each."""
|
||||
|
||||
def test_the_sidecar_key_and_the_vision_flag_are_ignored(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
with tempfile.TemporaryDirectory() as d, mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {"mtp": False}): # (an engine package from before the draft layer: the older behaviour)
|
||||
mtp = Path(d) / F.MTP_FILE
|
||||
mtp.write_bytes(b"m")
|
||||
cfg = dict(CFG, **{F.MTP_CONFIG_KEY: str(mtp), F.MTP_MODE_KEY: "auto"})
|
||||
@@ -247,7 +247,7 @@ class StrataFlagsComing(unittest.TestCase):
|
||||
with with_info({"arch": "x", "images": "1", "mtp": "1"}):
|
||||
args = K.extra_args(cfg, cfg["args"], EXE, announce=False)
|
||||
self.assertEqual(args[args.index("--mtp") + 1], str(mtp))
|
||||
self.assertEqual(args[args.index("--spec") + 1], "4")
|
||||
self.assertEqual(args[args.index("--spec") + 1], "2") # a .strata build: K = 2
|
||||
|
||||
def test_the_serve_probe(self):
|
||||
self.assertTrue(F.strata_serve_ready())
|
||||
@@ -291,19 +291,40 @@ class StrataServe(unittest.TestCase):
|
||||
cfg = {**self.CFG, "args": [*self.CFG["args"], "--mtp", "C:/m/M.strata", "--vision", "C:/m/V.strata", "--loop-adapter", "C:/m/L", "--loop-passes", "2", "--loop-coda", "compact", "--loop-direct-t1", "--spec", "3", "--pool-workers", "4", "--device", "1", "--foo", "x"]}
|
||||
with mock.patch("builtins.print") as pr:
|
||||
args = server.engine_args(cfg, "C:/e/strata-q4-lite.exe", announce=True)
|
||||
self.assertEqual(args, ["--model", "C:/m/Qwen4-35B-A3B-Compact.strata", "--ple-gguf", "C:/m/Qwen4-35B-A3B-PLE-Q4.gguf", "--max-ctx", "32768", "--loop-adapter", "C:/m/L", "--loop-passes", "2",
|
||||
"--loop-coda", "compact", "--device", "1"]) # the Loop (INT #48) goes through; --loop-direct-t1 is the server's own option and stays out
|
||||
self.assertEqual(args, ["--model", "C:/m/Qwen4-35B-A3B-Compact.strata", "--ple-gguf", "C:/m/Qwen4-35B-A3B-PLE-Q4.gguf", "--max-ctx", "32768", "--mtp", "C:/m/M.strata", "--loop-adapter", "C:/m/L", "--loop-passes", "2",
|
||||
"--loop-coda", "compact", "--spec", "3", "--device", "1"]) # the draft layer (Q4-CORE #53) and the Loop (INT #48) go through; --loop-direct-t1 is the server's own option and stays out
|
||||
said = " ".join(str(c) for c in pr.call_args_list)
|
||||
self.assertIn("--foo", said) # an unknown flag is said once
|
||||
self.assertIn("--pool-workers", said)
|
||||
self.assertNotIn("--mtp", said) # a flag the engine accepts and ignores is left out quietly
|
||||
for flag in ("--mtp", "--vision", "--loop-direct-t1", "--spec", "--native", "--ctx"):
|
||||
self.assertNotIn("--vision", said) # a flag the engine accepts and ignores is left out quietly
|
||||
for flag in ("--vision", "--loop-direct-t1", "--native", "--ctx"):
|
||||
self.assertNotIn(flag, args)
|
||||
with mock.patch.dict(F.LOOP_READY, {("strata", "cuda"): False}):
|
||||
off = K.strata_engine_args(cfg, None, announce=False) # Loop "coming" for this build and card: no Loop flag reaches the engine
|
||||
for flag in F.ALL_LOOP_FLAGS:
|
||||
self.assertNotIn(flag, off)
|
||||
|
||||
def test_the_sidecar_key_becomes_mtp_and_spec_two(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
mtp = Path(d) / F.MTP_FILE
|
||||
mtp.write_bytes(b"m")
|
||||
cfg = {**self.CFG, F.MTP_CONFIG_KEY: str(mtp), F.MTP_MODE_KEY: "auto"}
|
||||
args = K.strata_engine_args(cfg, None, announce=False)
|
||||
self.assertEqual(args[args.index("--mtp") + 1], str(mtp))
|
||||
self.assertEqual(args[args.index("--spec") + 1], "2")
|
||||
self.assertEqual(args.count("--mtp"), 1)
|
||||
self.assertNotIn("--embed-host", args) # no workaround: Q4-CORE #56 makes the draft layer work with the default host embedding
|
||||
off = K.strata_engine_args({**cfg, F.MTP_MODE_KEY: "off"}, None, announce=False)
|
||||
self.assertNotIn("--mtp", off)
|
||||
none = K.strata_engine_args({k: v for k, v in cfg.items() if k != F.MTP_CONFIG_KEY}, None, announce=False)
|
||||
self.assertNotIn("--mtp", none)
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {"mtp": False}):
|
||||
old = K.strata_engine_args(cfg, None, announce=False) # an engine package without it: never passed (exit 2)
|
||||
self.assertNotIn("--mtp", old)
|
||||
self.assertNotIn("--spec", old)
|
||||
gone = K.strata_engine_args({**cfg, F.MTP_CONFIG_KEY: str(Path(d) / "nowhere.strata")}, None, announce=False)
|
||||
self.assertNotIn("--mtp", gone) # a missing file: the model starts without it
|
||||
|
||||
def test_the_loop_key_becomes_the_two_flags_once_and_the_server_sends_loop_passes_one_for_thinking_off(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
loop = Path(d) / F.LOOP_FILE
|
||||
|
||||
@@ -190,7 +190,9 @@ class Serve(unittest.TestCase):
|
||||
self.assertEqual(len(h.gens()), 1)
|
||||
argv = h.record_path.with_name(h.record_path.name + ".argv").read_text(encoding="utf-8").split()
|
||||
self.assertEqual(argv[argv.index("--kv") + 1], "int8") # the engine takes --kv (Q4-KV, crash fixed): passed, never dropped; its own default is fp16
|
||||
for flag in ("--mtp", "--vision", "--pool-workers", "--spec"):
|
||||
self.assertEqual(argv[argv.index("--mtp") + 1], "/nowhere/m.strata") # the draft layer is taken by the engine now (Q4-CORE #53): passed as written
|
||||
self.assertEqual(argv[argv.index("--spec") + 1], "3")
|
||||
for flag in ("--vision", "--pool-workers"):
|
||||
self.assertNotIn(flag, argv)
|
||||
|
||||
def test_a_kv_word_the_engine_does_not_take_is_the_default(self):
|
||||
|
||||
+1
-1
@@ -11896,7 +11896,7 @@ def install_qwen4(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted):
|
||||
vision = False
|
||||
if not qwen4_family.mtp_ready(model, backend):
|
||||
mtp_mode = "off"
|
||||
say(" " + qwen4_family.STRATA_COMING_NOTE)
|
||||
say(" " + qwen4_family.coming_note(model, backend))
|
||||
ctx = a.context or qwen4_family.DEFAULT_CONTEXT
|
||||
if not a.context and not a.yes:
|
||||
ctxs = qwen4_family.CONTEXTS
|
||||
|
||||
@@ -562,7 +562,7 @@ def check_qwen4(s: LaunchSettings, *, vram_gb: float | None, ram_gb: float | Non
|
||||
pass
|
||||
else:
|
||||
if not (qwen4_family.mtp_ready(adv["build"], backend) and qwen4_family.vision_ready(adv["build"])):
|
||||
out.append(Notice("warn", qwen4_family.STRATA_COMING_NOTE, ""))
|
||||
out.append(Notice("warn", qwen4_family.coming_note(adv["build"], backend), ""))
|
||||
if qwen4_family.uses_standalone_host(adv["build"], backend) and not qwen4_family.strata_serve_ready():
|
||||
out.append(Notice("warn", qwen4_family.STRATA_SERVE_NOTE, ""))
|
||||
if s.loop == "on":
|
||||
|
||||
@@ -237,32 +237,45 @@ ENGINE_FLAGS_VERIFIED = True # ENGINE_FILE_FLAGS is the table of the GG
|
||||
STRATA_BUILD_FLAGS = {"model": "--model", "ple": "--ple-gguf", "ctx": "--max-ctx", "device": "--device", "mtp": "--mtp", "spec": "--spec", "vision": "--vision", "loop": ENGINE_FILE_FLAGS["loop"], "loop_passes": ENGINE_LOOP_STEPS_FLAG}
|
||||
#: which flags the strata-q4-lite engine takes today (CORE-API.md section 0): flip each to True when CORE-API.md / `strata-q4-lite --version` says it is there. mtp (+ --spec K): the MTP worker, ETA
|
||||
#: 11:30; vision: after text + Loop; loop: Q4-LOOP's strata spelling `--loop 2 --loop-file PATH`; serve: the engine's `--serve` (SHIP worker), without which a strata build cannot be started by Strata.
|
||||
STRATA_BUILD_FLAG_READY = {"model": True, "ple": True, "ctx": True, "device": True, "mtp": False, "vision": False, "loop": True, "serve": True}
|
||||
STRATA_BUILD_FLAG_READY = {"model": True, "ple": True, "ctx": True, "device": True, "mtp": True, "vision": False, "loop": True, "serve": True}
|
||||
#: what a .strata tier takes on a Mac (Metal): converted at install and run on `strata` (qwen4exp), so the draft layer (`--mtp <rt> --spec 2`) and pictures (Vision.strata converted to the mmproj, the Metal
|
||||
#: tower) work today; Loop is coming (LOOP_READY). ONE table, mirrored in app/host/server/qwen4.mjs and src/lib/qwen4.ts (the host test parses this dict and pins the three).
|
||||
STRATA_METAL_READY = {"mtp": True, "vision": True, "loop": True}
|
||||
STRATA_SPEC_ARGS = ["--spec", "4"] # with --mtp PATH on a strata build (K is the engine's to confirm; only written when STRATA_BUILD_FLAG_READY["mtp"])
|
||||
STRATA_SPEC_ARGS = ["--spec", "2"] # with --mtp <MTP.strata> on a strata build: K = 2, what the lanes measured (Q4-CORE #53/#56: A6000 Compact 1.35x, R9700 1.59x, 3060 1.08-1.12x); the engine raises the VRAM reserve to 1000 MiB by itself
|
||||
STRATA_LOOP_ALIASES = ("--loop", "--loop-file") # the engine's own short spelling (`--loop 2 --loop-file F`): accepted by it, never written by us, but stripped like the rest
|
||||
ALL_LOOP_FLAGS = ENGINE_LOOP_FLAGS + STRATA_LOOP_ALIASES # every Loop flag of either spelling: stripped together when Loop is off or not ready
|
||||
#: THE flags of `strata-q4-lite --serve` (SHIP, GATE-Q4-SERVE; any other flag exits 2): {flag: values taken}. Aliases the engine accepts: --native = --model, --max-context = --max-ctx, --gpu = --device.
|
||||
STRATA_SERVE_FLAGS = {"--model": 1, "--native": 1, "--ple-gguf": 1, "--max-ctx": 1, "--max-context": 1, "--device": 1, "--gpu": 1, "--chunk": 1, "--max-tokens": 1, "--eos": 1,
|
||||
"--vram-budget": 1, "--vram-reserve": 1, "--embed-host": 1, "--loop-adapter": 1, "--loop-passes": 1, "--loop": 1, "--loop-file": 1, "--loop-coda": 1, "--kv": 1} # the Loop flags: only with a Loop ready for the build (serve strips them otherwise)
|
||||
"--vram-budget": 1, "--vram-reserve": 1, "--embed-host": 1, "--mtp": 1, "--spec": 1, "--loop-adapter": 1, "--loop-passes": 1, "--loop": 1, "--loop-file": 1, "--loop-coda": 1, "--kv": 1} # the Loop flags: only with a Loop ready for the build (serve strips them otherwise)
|
||||
#: `--kv` is in the table for when the host takes it, but passed ONLY when strata_kv_flag_ready() (KV_READY of the "strata" source); before that serve drops it with the usual one line (exit 2 otherwise)
|
||||
STRATA_SERVE_GATED = ("--kv",)
|
||||
#: flags the engine ACCEPTS AND IGNORES (it prints a stderr note): the launcher's and the GGUF build's spellings of options this engine does not have yet. Serve leaves them out of the start, quietly.
|
||||
STRATA_SERVE_IGNORED = frozenset({"--mtp", "--vision", "--loop-direct-t1", "--spec", "--spec-min-p", "--conversation-cache-mib",
|
||||
STRATA_SERVE_IGNORED = frozenset({"--vision", "--loop-direct-t1", "--spec-min-p", "--conversation-cache-mib",
|
||||
"--ple-io", "--threads", "--batch", "--logits-rows", "--kv-init", "--tail-role-token", "--session-save-reclaim", "--no-mmap", "--ple-ram"})
|
||||
#: the GEN keys the engine takes (a request sends nothing else; hold=, logprobs=, image= and the loop keys are answered ERR): serve/server.py StrataEngine.sampling_keys(q4s=True)
|
||||
STRATA_GEN_KEYS = ("temperature", "top_p", "top_k", "min_p", "seed", "penalty_repeat", "penalty_freq", "penalty_present", "penalty_last_n", "pen_from", "thinking")
|
||||
STRATA_TOP_K_CAP = 64
|
||||
STRATA_COMING_NOTE = "Coming with the engine: the draft layer (MTP) and picture reading are not in the engine for this build yet. They stay off for now."
|
||||
|
||||
|
||||
def coming_note(build=None, backend=None) -> str:
|
||||
"""The Terminal's line for what the engine of this build does not take yet: the draft layer and picture reading (both), or only one of them (the draft layer is ready on every backend now, so on
|
||||
CUDA and HIP only picture reading is left)."""
|
||||
mtp, vis = mtp_ready(build, backend), vision_ready(build, backend)
|
||||
if mtp and not vis:
|
||||
return "Coming with the engine: picture reading is not in the engine for this build yet. It stays off for now."
|
||||
if vis and not mtp:
|
||||
return "Coming with the engine: the draft layer (MTP) is not in the engine for this build yet. It stays off for now."
|
||||
return STRATA_COMING_NOTE
|
||||
|
||||
|
||||
STRATA_SERVE_NOTE = "The engine's server mode is not in this build yet: this build starts when the engine for it is updated."
|
||||
METAL_COMING_NOTE = "Picture reading is off for this build on this Mac: the tool that prepares it is not in this Strata, or it did not finish. Everything else works."
|
||||
|
||||
|
||||
def mtp_ready(build, backend=None) -> bool:
|
||||
"""Does the engine take the MTP sidecar for this build? The GGUF build: yes (its drafter runtime); a .strata tier on a Mac: yes (the Metal drafter, `--mtp <rt> --spec 2`, Q4-METAL); a .strata
|
||||
tier on the standalone host: STRATA_BUILD_FLAG_READY["mtp"] (not yet)."""
|
||||
tier on the standalone host: STRATA_BUILD_FLAG_READY["mtp"] (yes since Q4-CORE's MTP work: `--mtp <MTP.strata> --spec 2`)."""
|
||||
if uses_metal_converter(build, backend):
|
||||
return bool(STRATA_METAL_READY["mtp"])
|
||||
return True if build in GGUF_BUILDS else bool(STRATA_BUILD_FLAG_READY["mtp"]) if build in BUILDS else False
|
||||
|
||||
@@ -222,7 +222,7 @@ class EngineFlags(unittest.TestCase):
|
||||
def test_the_sidecar_flags_follow_the_mode(self):
|
||||
self.assertEqual(F.mtp_engine_args("/m/M.strata", "off"), [])
|
||||
self.assertEqual(F.mtp_engine_args(None, "on"), [])
|
||||
self.assertEqual(F.mtp_engine_args("/m/M.strata", "auto"), ["--mtp", "/m/M.strata", "--spec", "4"]) # a .strata build (the engine takes it: STRATA_READY)
|
||||
self.assertEqual(F.mtp_engine_args("/m/M.strata", "auto"), ["--mtp", "/m/M.strata", "--spec", "2"]) # a .strata build: K = 2 (the lanes' measurements)
|
||||
self.assertEqual(F.mtp_engine_args("/m/rt", "auto", gguf=True), ["--mtp", "/m/rt", "--spec", "3", "--spec-min-p", "0.5"]) # K defaults to 3
|
||||
self.assertEqual(F.mtp_engine_args("/m/rt", "auto", gguf=True, spec_k=4), ["--mtp", "/m/rt", "--spec", "4", "--spec-min-p", "0.5"])
|
||||
|
||||
@@ -233,29 +233,30 @@ class StrataFlagTable(unittest.TestCase):
|
||||
def test_the_default_table_writes_only_the_flags_the_engine_takes_today(self):
|
||||
self.assertEqual(F.STRATA_BUILD_FLAGS["model"], "--model")
|
||||
self.assertEqual(F.STRATA_BUILD_FLAGS["ctx"], "--max-ctx")
|
||||
self.assertEqual({k: v for k, v in F.STRATA_BUILD_FLAG_READY.items() if k in ("mtp", "vision", "loop")}, {"mtp": False, "vision": False, "loop": True}) # loop: Q4-LOOP's engine takes it (INT #45); LOOP_READY decides whether it is offered
|
||||
self.assertEqual({k: v for k, v in F.STRATA_BUILD_FLAG_READY.items() if k in ("mtp", "vision", "loop")}, {"mtp": True, "vision": False, "loop": True}) # mtp: Q4-CORE's MTP work (#53/#56): `--mtp <MTP.strata> --spec 2`; loop: Q4-LOOP's engine takes it (INT #45); LOOP_READY decides whether it is offered
|
||||
args = F.engine_args("/m/Qwen4-35B-A3B-Compact.strata", ple="/m/P.gguf", mtp="/m/M.strata", vision="/m/V.strata", loop="/m/L.safetensors", ctx=8192, device=0)
|
||||
self.assertEqual(args, ["--model", "/m/Qwen4-35B-A3B-Compact.strata", "--ple-gguf", "/m/P.gguf", "--max-ctx", "8192", "--device", "0", "--kv", "int8",
|
||||
"--loop-adapter", "/m/L.safetensors", "--loop-passes", "2"]) # nothing the engine would reject with exit 2; --kv int8 because its own default is fp16; Loop is Q4-LOOP's (the engine picks the coda)
|
||||
for flag in ("--native", "--ctx", "--vision", "--mtp", "--spec"):
|
||||
"--loop-adapter", "/m/L.safetensors", "--loop-passes", "2", "--mtp", "/m/M.strata", "--spec", "2"]) # nothing the engine would reject with exit 2; --kv int8 because its own default is fp16; Loop is Q4-LOOP's (the engine picks the coda); the draft layer K = 2
|
||||
for flag in ("--native", "--ctx", "--vision", "--embed-host"):
|
||||
self.assertNotIn(flag, args)
|
||||
self.assertEqual(F.mtp_engine_args("/m/M.strata", "auto"), []) # a .strata build: no sidecar flag until the engine takes it
|
||||
self.assertEqual(F.mtp_engine_args("/m/M.strata", "auto"), ["--mtp", "/m/M.strata", "--spec", "2"]) # a .strata build: the engine takes the draft layer (Q4-CORE #53/#56)
|
||||
self.assertEqual(F.mtp_engine_args("/m/rt", "auto", gguf=True), ["--mtp", "/m/rt", "--spec", "3", "--spec-min-p", "0.5"]) # K defaults to 3
|
||||
self.assertEqual(F.mtp_engine_args("/m/rt", "auto", gguf=True, spec_k=4), ["--mtp", "/m/rt", "--spec", "4", "--spec-min-p", "0.5"]) # the GGUF build is unchanged
|
||||
|
||||
def test_each_optional_flag_follows_its_own_word(self):
|
||||
for role, flag in (("mtp", "--mtp"), ("vision", "--vision"), ("loop", "--loop-adapter")):
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {role: True, "loop": role == "loop"}):
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {"mtp": role == "mtp", "vision": role == "vision", "loop": role == "loop"}):
|
||||
args = F.engine_args("/m/Q.strata", mtp="/m/M", vision="/m/V", loop="/m/L")
|
||||
self.assertIn(flag, args, role)
|
||||
for other in {"mtp": ("--vision", "--loop-adapter"), "vision": ("--mtp", "--loop-adapter"), "loop": ("--mtp", "--vision")}[role]:
|
||||
self.assertNotIn(other, args, (role, other))
|
||||
|
||||
def test_the_readiness_helpers(self):
|
||||
self.assertEqual([F.mtp_ready(b) for b in ("Compact", "Balanced", "Ultra", "UD-Q4_K_XL", "Nope")], [False, False, False, True, False])
|
||||
self.assertEqual([F.mtp_ready(b) for b in ("Compact", "Balanced", "Ultra", "UD-Q4_K_XL", "Nope")], [True, True, True, True, False])
|
||||
self.assertEqual([F.vision_ready(b) for b in ("Compact", "Ultra", "UD-Q4_K_XL")], [False, False, True])
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {"mtp": True, "vision": True}):
|
||||
self.assertTrue(F.mtp_ready("Compact") and F.vision_ready("Ultra"))
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {"mtp": False, "vision": True}):
|
||||
self.assertTrue(F.vision_ready("Ultra") and not F.mtp_ready("Compact"))
|
||||
self.assertIn("draft layer", F.coming_note("Compact", "cuda"))
|
||||
self.assertTrue(F.strata_serve_ready()) # the engine's --serve is there (SHIP, GATE-Q4-SERVE)
|
||||
self.assertIn("oming with the engine", F.STRATA_COMING_NOTE)
|
||||
|
||||
|
||||
@@ -208,11 +208,12 @@ class Adopt(unittest.TestCase):
|
||||
return adopt.plan(family=FAM, model="Balanced", model_dir=self.folder, data_dir=self.td, src=self.td, context=65536, kv=None, model_name="qwen4-35b-a3b-balanced",
|
||||
family_def={}, log=self.td / "x.log", backend="cuda", pack_name="qwen4-35b-a3b-balanced", **kw)
|
||||
|
||||
def test_adopt_writes_no_sidecar_key_for_a_strata_build(self):
|
||||
def test_adopt_writes_the_sidecar_key_for_a_strata_build(self):
|
||||
(self.folder / F.MTP_FILE).write_bytes(b"m")
|
||||
cfg, problems = self.plan()
|
||||
self.assertEqual(problems, [])
|
||||
self.assertNotIn(F.MTP_CONFIG_KEY, cfg)
|
||||
self.assertEqual(cfg[F.MTP_CONFIG_KEY], str(self.folder / F.MTP_FILE)) # the engine takes the draft layer since Q4-CORE's MTP work: the key, never a flag in "args"
|
||||
self.assertNotIn("--mtp", cfg["args"])
|
||||
self.assertEqual(value(cfg["args"], "--model"), str(self.folder / "Qwen4-35B-A3B-Balanced.strata"))
|
||||
self.assertNotIn("--vision", cfg["args"])
|
||||
|
||||
@@ -593,9 +594,12 @@ class StrataFlagsComing(unittest.TestCase):
|
||||
def test_no_sidecar_key_and_no_vision_flag(self):
|
||||
with_keys = {**self.base, F.MTP_CONFIG_KEY: "C:/m/M.strata", F.MTP_MODE_KEY: "auto", "args": [*self.base["args"], "--vision", "C:/m/V.strata", "--mtp", "C:/m/M.strata"]}
|
||||
cfg = R.derive_config(with_keys, S.LaunchSettings(family=FAM, mtp="on", vision="on"), bool_flags=tune_knobs.BOOL_FLAGS, log="x.log")
|
||||
self.assertEqual(cfg[F.MTP_CONFIG_KEY], "C:/m/M.strata") # the draft layer is ready on the standalone host: the key stays
|
||||
self.assertNotIn("--vision", cfg["args"]) # pictures are not
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, {"mtp": False}):
|
||||
old = R.derive_config(with_keys, S.LaunchSettings(family=FAM, mtp="on", vision="on"), bool_flags=tune_knobs.BOOL_FLAGS, log="x.log")
|
||||
for key in (F.MTP_CONFIG_KEY, F.MTP_MODE_KEY):
|
||||
self.assertNotIn(key, cfg)
|
||||
self.assertNotIn("--vision", cfg["args"])
|
||||
self.assertNotIn(key, old) # an engine without it: no key
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, STRATA_READY):
|
||||
kept = R.derive_config({**with_keys, F.MTP_CONFIG_KEY: "C:/m/M.strata"}, S.LaunchSettings(family=FAM, mtp="on", vision="on"), bool_flags=tune_knobs.BOOL_FLAGS, log="x.log")
|
||||
self.assertEqual(kept[F.MTP_CONFIG_KEY], "C:/m/M.strata")
|
||||
@@ -604,12 +608,15 @@ class StrataFlagsComing(unittest.TestCase):
|
||||
def test_the_notices_say_it_is_coming(self):
|
||||
cards = [{"vendor": "nvidia", "arch": 89, "vram_gb": 24}]
|
||||
out = S.check_qwen4(S.LaunchSettings(family=FAM, model="Compact"), vram_gb=24, ram_gb=64, vendor="nvidia", cards=cards)
|
||||
self.assertTrue(any(n.text == F.STRATA_COMING_NOTE for n in out))
|
||||
note = F.coming_note("Compact", "cuda")
|
||||
self.assertIn("picture reading", note)
|
||||
self.assertNotIn("draft layer", note) # the draft layer is ready: only pictures are coming
|
||||
self.assertTrue(any(n.text == note for n in out))
|
||||
gguf = S.check_qwen4(S.LaunchSettings(family=FAM, model="UD-Q4_K_XL"), vram_gb=24, ram_gb=64, vendor="nvidia", cards=cards)
|
||||
self.assertFalse(any(n.text == F.STRATA_COMING_NOTE for n in gguf)) # the GGUF build is unchanged
|
||||
self.assertFalse(any(n.text in (note, F.STRATA_COMING_NOTE) for n in gguf)) # the GGUF build is unchanged
|
||||
with mock.patch.dict(F.STRATA_BUILD_FLAG_READY, STRATA_READY):
|
||||
ready = S.check_qwen4(S.LaunchSettings(family=FAM, model="Compact"), vram_gb=24, ram_gb=64, vendor="nvidia", cards=cards)
|
||||
self.assertFalse(any(n.text == F.STRATA_COMING_NOTE for n in ready))
|
||||
self.assertFalse(any(n.text in (note, F.STRATA_COMING_NOTE) for n in ready))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -20,10 +20,10 @@ import time
|
||||
|
||||
#: flag -> number of values (the engine's list: SHIP's GATE-Q4-SERVE). Anything else exits 2.
|
||||
KNOWN = {"--serve": 0, "--model": 1, "--native": 1, "--ple-gguf": 1, "--max-ctx": 1, "--max-context": 1, "--device": 1, "--gpu": 1, "--chunk": 1, "--max-tokens": 1, "--eos": 1,
|
||||
"--vram-budget": 1, "--vram-reserve": 1, "--embed-host": 1, "--loop-adapter": 1, "--loop-passes": 1, "--loop": 1, "--loop-file": 1, "--kv": 1, # --kv fp16|int8|fp8|k8v4|q4_0 (Q4-KV, merged into int-0226)
|
||||
"--vram-budget": 1, "--vram-reserve": 1, "--embed-host": 1, "--loop-adapter": 1, "--loop-passes": 1, "--loop": 1, "--loop-file": 1, "--mtp": 1, "--spec": 1, "--kv": 1, # --kv fp16|int8|fp8|k8v4|q4_0 (Q4-KV, merged into int-0226)
|
||||
"--script": 1, "--record": 1, "--delay": 1}
|
||||
#: accepted and ignored by the real engine (a stderr note)
|
||||
IGNORED_FLAGS = {"--mtp": 1, "--vision": 1, "--loop-coda": 1, "--loop-direct-t1": 0, "--spec": 1, "--spec-min-p": 1,
|
||||
IGNORED_FLAGS = {"--vision": 1, "--loop-coda": 1, "--loop-direct-t1": 0, "--spec-min-p": 1,
|
||||
"--conversation-cache-mib": 1, "--ple-io": 1, "--threads": 1, "--batch": 1, "--logits-rows": 1, "--kv-init": 1, "--tail-role-token": 1, "--session-save-reclaim": 0,
|
||||
"--no-mmap": 0, "--ple-ram": 1}
|
||||
GEN_KEYS = {"temperature", "top_p", "top_k", "min_p", "seed", "penalty_repeat", "penalty_freq", "penalty_present", "penalty_last_n", "pen_from", "thinking"}
|
||||
|
||||
@@ -751,21 +751,34 @@ class StrataFlagsComing(unittest.TestCase):
|
||||
rc, w, says, fetched, _ = Install.run_install(Install())
|
||||
cfg = w["cfg"]
|
||||
for flag in ("--native", "--ctx", "--vision", "--mtp", "--spec", "--loop", "--loop-file"):
|
||||
self.assertNotIn(flag, cfg["args"], flag)
|
||||
self.assertNotIn(flag, cfg["args"], flag) # the sidecar is a config key, never a flag in "args"
|
||||
self.assertEqual(cfg["args"][0], "--model")
|
||||
self.assertIn("--max-ctx", cfg["args"])
|
||||
for key in (qwen4_family.MTP_CONFIG_KEY, qwen4_family.MTP_MODE_KEY, qwen4_family.LOOP_CONFIG_KEY):
|
||||
self.assertNotIn(key, cfg)
|
||||
self.assertNotIn(qwen4_family.MTP_FILE, fetched) # nothing is downloaded for what is not used
|
||||
self.assertIn(qwen4_family.MTP_CONFIG_KEY, cfg) # the draft layer is ready on the standalone host (6 GB cards and up): its file is downloaded and the key written
|
||||
self.assertIn(qwen4_family.MTP_FILE, fetched)
|
||||
self.assertNotIn(qwen4_family.LOOP_CONFIG_KEY, cfg)
|
||||
self.assertNotIn(qwen4_family.VISION_FILE, fetched)
|
||||
self.assertTrue(any(qwen4_family.STRATA_COMING_NOTE in s for s in says), says)
|
||||
self.assertTrue(any(qwen4_family.coming_note("Compact", "cuda") in s for s in says), says) # pictures only
|
||||
|
||||
def test_the_draft_layer_follows_the_card_and_the_word(self):
|
||||
"""MTP Auto is on for a card of 6 GB or more (the owner's rule), off below; `--mtp off` always wins; no --embed-host anywhere (Q4-CORE #56)."""
|
||||
_, w, _, fetched, _ = Install.run_install(Install(), vram_gb=8.0)
|
||||
self.assertIn(qwen4_family.MTP_FILE, fetched)
|
||||
self.assertEqual(w["cfg"][qwen4_family.MTP_MODE_KEY], "auto")
|
||||
self.assertNotIn("--embed-host", w["cfg"]["args"])
|
||||
_, w, says, fetched, _ = Install.run_install(Install(), vram_gb=4.0) # under 6 GB: Auto is off
|
||||
self.assertNotIn(qwen4_family.MTP_FILE, fetched)
|
||||
self.assertNotIn(qwen4_family.MTP_CONFIG_KEY, w["cfg"])
|
||||
_, w, _, fetched, _ = Install.run_install(Install(), mtp="off")
|
||||
self.assertNotIn(qwen4_family.MTP_FILE, fetched)
|
||||
self.assertNotIn(qwen4_family.MTP_CONFIG_KEY, w["cfg"])
|
||||
|
||||
def test_the_catalog_and_the_plan_leave_them_out_too(self):
|
||||
s = M.Strata(HERE.parent)
|
||||
with mock.patch.dict(os.environ, {qwen4_family.SHOW_ENV: "1"}):
|
||||
size = s.qwen4_size("qwen4-35b-a3b", "Compact")
|
||||
self.assertFalse(size["vision"]) # no picture option for a .strata build yet
|
||||
names = qwen4_family.files_of("Compact", vision=False, mtp=False, ple="Q4")
|
||||
names = qwen4_family.files_of("Compact", vision=False, mtp=True, ple="Q4") # the draft layer (0.35 GB) is in the default set
|
||||
self.assertEqual(size["download_gb"], round(sum(qwen4_family.size_of(n) for n in names) / 1e9, 1))
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
files = M.expected_files(setup, "qwen4-35b-a3b", "Compact", Path(d), True)
|
||||
|
||||
@@ -72,10 +72,10 @@ class Programs(unittest.TestCase):
|
||||
self.assertFalse(F.uses_metal_converter(F.GGUF_BUILD, "metal"))
|
||||
self.assertFalse(F.uses_standalone_host("Ultra", "metal"))
|
||||
|
||||
def test_the_draft_layer_is_ready_on_a_mac_only(self):
|
||||
def test_the_draft_layer_is_ready_on_every_backend(self):
|
||||
self.assertTrue(F.mtp_ready("Compact", "metal"))
|
||||
self.assertFalse(F.mtp_ready("Compact", "cuda"))
|
||||
self.assertFalse(F.mtp_ready("Compact"))
|
||||
self.assertTrue(F.mtp_ready("Compact", "cuda")) # the standalone host takes `--mtp <MTP.strata> --spec 2` too (Q4-CORE #53/#56)
|
||||
self.assertTrue(F.mtp_ready("Compact"))
|
||||
self.assertTrue(F.mtp_ready(F.GGUF_BUILD, "cuda"))
|
||||
self.assertFalse(F.vision_ready("Compact")) # the standalone host reads no pictures yet
|
||||
self.assertTrue(F.vision_ready("Compact", "metal")) # a Mac tier: Vision.strata converted to the mmproj
|
||||
|
||||
Reference in new issue
Block a user