Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
DeepSeek-V4.1-Flash: 512K and 1M contexts in setup and the Terminal, as Project Maya v1.1.28 did (#442 by @needmorevram, MIT)
Niko122133780a495532
diff --git a/docs/DEEPSEEK41.md b/docs/DEEPSEEK41.mdindex ed49b5473..86a98e63f 100644--- a/docs/DEEPSEEK41.md+++ b/docs/DEEPSEEK41.md@@ -78,6 +78,13 @@ Setup needs `strata-dsv41` next to the engine (or `STRATA_DSV41_EXE`) and says s`cmake -DSTRATA_BUILD_DSV41=ON`. The default context is 8192 tokens, the size it was checked at; `--context` asks for more.Loading takes a few minutes (the config sets `"engine_ready_s": 3600`).+**Context up to 1M.** The model reads 1,048,576 positions natively, so `--context` takes 8K to 1M (`--context 512k`, `--context 1m`; the Terminal's context step+lists 8K, 32K, 64K, 128K, 256K, 512K and 1M, and the app lists them up to the limit its pack states in `ds4.txt`, `max_position_embeddings`). A size past what the+pack reads is refused before anything is downloaded. Nothing past 256K has been tested by us: the owner's decision is to offer 512K and 1M and let users try them+(Project Maya v1.1.28 did the same, #442 by @needmorevram, MIT). The cost is real. The context's cache lives in graphics memory, so every position takes memory from+the expert cache and fewer experts stay on the card; and a very long prompt is read slowly, because the indexer's work grows with the square of its length. Start+with 256K or less, and expect the first reply of a 512K or 1M prompt to take many minutes.+## Through the APIThe server speaks to the engine as it does for the other models, so `/v1/chat/completions`, `/v1/messages`, streaming, stop anddiff --git a/setup.py b/setup.pyindex 4c88035b5..55f8941f2 100644--- a/setup.py+++ b/setup.py@@ -68,6 +68,7 @@ from strata_control import tlstls.install() # #3722: HTTPS checks the server against the operating system's certificates (what Chrome and curl.exe do)from strata_control import atomicfrom strata_control import draft_layer+from strata_control import dsv41_contextfrom strata_control.discovery import in_trashfrom strata_control import user_args@@ -8133,6 +8134,10 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,tag = fam["tag"] + modelcards = dsv41_cards(gpu, all_cards, bool(a.gpu is not None or a.gpus))ctx = a.context or DSV41_CONTEXT+ if dsv41_context.problem(ctx): # 8K to 1M: the model reads 1,048,576 positions (Project Maya #442); a size it cannot address stops here, before any download+ fail(dsv41_context.problem(ctx), "--context takes 8192 up to 1048576 (8K, 32K, 64K, 128K, 256K, 512K, 1M); the default is 8192")+ if dsv41_context.note(ctx):+ warn(f"context {dsv41_context.label(ctx)}: {dsv41_context.note(ctx)}")folder = dsv41_folder(a, fam, tag, model)shards = [dsv41_pick(folder, n) for n in md["shards"]]shared_dir = dsv41_shared_dir(a, fam)@@ -8274,6 +8279,8 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,ok("test question answered sensibly")else:ok(f"pack: {pack}")+ if dsv41_context.problem(ctx, dsv41_context.read_limit(pack)): # the pack's own limit (ds4.txt) is the last word; no file, no limit+ fail(dsv41_context.problem(ctx, dsv41_context.read_limit(pack)), f"choose a smaller --context (the pack in {pack} says what it reads)")step(7, "writing the start script")# --dspark auto, never off: "off" still LOADS the drafter, and its 7 GB of experts take the graphics memory (found 2026-10-23);diff --git a/strata_cli/launch/app.py b/strata_cli/launch/app.pyindex f7ed0825d..8c52bd3c4 100644--- a/strata_cli/launch/app.py+++ b/strata_cli/launch/app.py@@ -72,7 +72,8 @@ class Ctx:s = self.settingsout = [n.line() for n in S.check_access(s)]out += [n.line() for n in S.check_parallel(s, vram_gb=self.computer.main_vram_gb or None)]- out += [n.line() for n in S.check_context(s)]+ deepseek = bool(s.family and self.catalog.strata.multi_family(s.family))+ out += [n.line() for n in S.check_context(s, deepseek=deepseek, pack_limit=self.catalog.pack_limit(s.family, s.model) if deepseek else None)]r = next((x for x in self.rows if (x.family, x.model) == (s.family, s.model)), None)if r is not None and r.verdict != "fits":out.append(f"{r.title}: {r.words}.")diff --git a/strata_cli/launch/catalog.py b/strata_cli/launch/catalog.pyindex 9f8e9359c..a7d61fccd 100644--- a/strata_cli/launch/catalog.py+++ b/strata_cli/launch/catalog.py@@ -316,6 +316,26 @@ class Catalog:def contexts(self) -> list[int]:return [int(c) for c in self.tables()[2]]+ def contexts_for(self, family: str | None, model: str | None = None) -> list[int]:+ """The context sizes to offer for this model: DeepSeek-V4.1-Flash goes up to 1M (its installed pack's own limit when it has one), the+ others keep the shared list."""+ if family and self.strata.multi_family(family):+ from strata_control import dsv41_context+ return dsv41_context.choices(self.pack_limit(family, model))+ return self.contexts()++ def pack_limit(self, family: str | None, model: str | None) -> int | None:+ """The installed DeepSeek pack's own context limit (ds4.txt), None when it is not installed or the file does not say."""+ if not (family and model and self.strata.multi_family(family)):+ return None+ try:+ from strata_control import dsv41_context+ from strata_cli.launch.runner import read_config+ path = self.installed_config(self.tag_of(family, model))+ return dsv41_context.limit_of_config(read_config(path)) if path else None+ except Exception: # noqa: BLE001 - no file, no limit: the choices stay as they are+ return None+def recommendation(self, hw: dict | None = None) -> dict:return self.strata.recommend(hw or self.hardware())diff --git a/strata_cli/launch/cmd.py b/strata_cli/launch/cmd.pyindex 99b49a2d8..48cd78ed5 100644--- a/strata_cli/launch/cmd.py+++ b/strata_cli/launch/cmd.py@@ -91,7 +91,7 @@ def add_parsers(sp: argparse._SubParsersAction) -> list[argparse.ArgumentParser]g.add_argument("--move-data", action="store_true",help="with --data-dir: move the models you already have into the new folder. Without it nothing is moved: your models stay ""where they are and stay usable, and the new folder gets the new downloads")- g.add_argument("--context", type=_context, metavar="SIZE", help="how much text it remembers at once: 32k, 64k, 128k, 256k or a number of tokens")+ g.add_argument("--context", type=_context, metavar="SIZE", help="how much text it remembers at once: 32k, 64k, 128k, 256k or a number of tokens (DeepSeek-V4.1-Flash: up to 512k and 1m)")g.add_argument("--kv", type=_choice("a memory format", S.KV_MODES), metavar="FORMAT", help="conversation memory format: int8 (default), q4_0 (half the memory), k8v4, fp16")g.add_argument("--vision", type=_choice("a picture setting", S.VISION_MODES), metavar="off|on|gpu|cpu",help="let the model read pictures. Default: on when the model can read pictures and the engine has the picture reader. "@@ -350,7 +350,8 @@ def apply_defaults(s: S.LaunchSettings, catalog) -> tuple[S.LaunchSettings, listelif s.speed:notices.append(S.Notice("warn", "--speed and --full-quality are for DeepSeek; this model uses all its experts, so they are not used.", ""))s.speed = None- notices += S.check_context(s, max_fit_tokens=None)+ deepseek = bool(catalog.strata.multi_family(s.family))+ notices += S.check_context(s, max_fit_tokens=None, deepseek=deepseek, pack_limit=catalog.pack_limit(s.family, s.model) if deepseek else None)if s.access != "local" and not s.api_key and not s.no_key:from strata_cli.launch import accesskept = access.kept_key(s.name or f"{s.model or 'model'} {S.context_label(s.context)}")diff --git a/strata_cli/launch/screens.py b/strata_cli/launch/screens.pyindex 78a524f5e..772b55182 100644--- a/strata_cli/launch/screens.py+++ b/strata_cli/launch/screens.py@@ -24,6 +24,7 @@ from strata_cli.launch import access as accfrom strata_cli.launch import params as Pfrom strata_cli.launch import settings as Sfrom strata_cli.launch import store+from strata_control import dsv41_contextfrom strata_cli.launch.widgets import (ACCENT, BAD, DARK, FG, LIGHT, MUTE, WARN, Cell, Item, Menu, bar)STEPS = (("model", "Model"), ("cards", "Cards"), ("folder", "Folder"), ("context", "Context"), ("pictures", "Pictures"),@@ -898,20 +899,25 @@ class ContextScreen(Base):s, cat = self.ctx.settings, self.ctx.catalogitems = []sel = 0- for i, c in enumerate(cat.contexts()):+ deepseek = bool(s.family and cat.strata.multi_family(s.family)) # DeepSeek-V4.1-Flash: 8K to 1M, not Qwen's list or its rope scaling+ sizes = cat.contexts_for(s.family, s.model)+ for i, c in enumerate(sizes):kvgb = cat.kv_gb(c, self.kv())note, style = "", ""if c == self.rec:note = "recommended"+ elif deepseek:+ if dsv41_context.note(c):+ note, style = "not tested yet: takes memory from the model", WARNelif c > max(self.rec * 2, 131072) and c <= 262144:note, style = "tight on this computer", WARNelif c > 262144:note, style = "experimental: rope scaling", WARN- items.append(Item([S.context_label(c), S.words_for(c), f"+{kvgb:.1f} GB", Cell(note, style)], key=c))+ items.append(Item([S.context_label(c), S.words_for(c), "" if deepseek else f"+{kvgb:.1f} GB", Cell(note, style)], key=c))if c == s.context:sel = i- if s.context and s.context not in cat.contexts():- items.append(Item([S.context_label(s.context), S.words_for(s.context), f"+{cat.kv_gb(s.context, self.kv()):.1f} GB",+ if s.context and s.context not in sizes:+ items.append(Item([S.context_label(s.context), S.words_for(s.context), "" if deepseek else f"+{cat.kv_gb(s.context, self.kv()):.1f} GB",Cell("your own size", "")], key=s.context))sel = len(items) - 1items.append(Item(["Custom…"], key="custom"))@@ -932,8 +938,13 @@ class ContextScreen(Base):cur = self.menu().current if self.menu() else Noneout = Text("More context lets agents read bigger projects. It uses more memory and the first reply of a long chat is slower. ""The memory shown is only the extra for the conversation itself.", style=MUTE)+ s = self.ctx.settings+ deepseek = bool(s.family and self.ctx.catalog.strata.multi_family(s.family))if cur is not None and isinstance(cur.key, int) and cur.key > 262144:- out.append("\nThis is past what the model was trained on; setup adds rope scaling and answers may get less reliable.", style=WARN)+ if deepseek:+ out.append("\n" + dsv41_context.NOTE, style=WARN)+ else:+ out.append("\nThis is past what the model was trained on; setup adds rope scaling and answers may get less reliable.", style=WARN)return outdef action_memory(self) -> None:@@ -956,6 +967,12 @@ class ContextScreen(Base):except ValueError as e:self.say(str(e), True)return+ s = self.ctx.settings+ if s.family and self.ctx.catalog.strata.multi_family(s.family): # DeepSeek: a size the pack cannot read is the one refusal+ why = dsv41_context.problem(n, self.ctx.catalog.pack_limit(s.family, s.model))+ if why:+ self.say(why, True)+ returnself.ctx.settings.context = nself.close_field("custom")self.build()diff --git a/strata_cli/launch/settings.py b/strata_cli/launch/settings.pyindex 0345ce1b8..f2f7ef944 100644--- a/strata_cli/launch/settings.py+++ b/strata_cli/launch/settings.py@@ -78,6 +78,8 @@ def parse_context(text: Any) -> int:def context_label(tokens: int | None) -> str:if not tokens:return "default"+ if tokens >= 1048576 and tokens % 1048576 == 0: # DeepSeek-V4.1-Flash reads 1,048,576 positions: "1M"+ return f"{tokens // 1048576}M"if tokens % 1024 == 0:return f"{tokens // 1024}K"if tokens >= 1000:@@ -226,8 +228,17 @@ def check_parallel(s: LaunchSettings, *, vram_gb: float | None, fitted: int | Noreturn out-def check_context(s: LaunchSettings, *, max_fit_tokens: int | None = None) -> list[Notice]:+def check_context(s: LaunchSettings, *, max_fit_tokens: int | None = None, deepseek: bool = False, pack_limit: int | None = None) -> list[Notice]:out: list[Notice] = []+ if deepseek: # DeepSeek-V4.1-Flash: 8K to 1M, its own words (strata_control/dsv41_context.py), no rope scaling of ours+ from strata_control import dsv41_context+ if s.context is not None:+ why = dsv41_context.problem(int(s.context), pack_limit)+ if why:+ out.append(Notice("error", why, "Choose a smaller context."))+ elif dsv41_context.note(s.context):+ out.append(Notice("warn", f"{context_label(s.context)}: {dsv41_context.note(s.context)}", ""))+ return outif s.context is not None and s.context > 262144:out.append(Notice("warn", f"{context_label(s.context)} is more than the model was trained on (256K).","Setup adds rope scaling for it (experimental); answers may get less reliable."))diff --git a/strata_control/dsv41_context.py b/strata_control/dsv41_context.pynew file mode 100644index 000000000..b1d2a0ca3--- /dev/null+++ b/strata_control/dsv41_context.py@@ -0,0 +1,82 @@+"""DeepSeek-V4.1-Flash's context sizes: 8K up to 1M (the model reads 1,048,576 positions natively).++Project Maya v1.1.28 (#442, @needmorevram, MIT) offered 512K and 1M in its setup and dashboard; this is the same rule in Strata.++- The choices are 8K, 32K, 64K, 128K, 256K, 512K and 1M, limited to the pack's own limit when it is known (``max_position_embeddings`` in the pack's+ ds4.txt, written by tools/dsv41/pack_gguf.py from the GGUF's context_length). Without a pack file the Terminal and setup still offer up to 1M (the+ model's own length); the app offers up to 256K until the pack says more.+- Past 256K nothing was tested by us: the owner's decision is to offer it and let users try it. The words for that are NOTE.+- A size past the pack's limit (or past 1,048,576 when no pack says) cannot run: that is an error, the only one.+- The engine takes whatever ``--max-context`` it is given (src/dsv41/ds4_model.cu allocates for it, no clamp); the rope settings come from the pack.++apps/host/server/dsv41-context.mjs says the same for the app; tests/terminal/test_dsv41_context.py compares the two.+"""+from __future__ import annotations++import re+from pathlib import Path+from typing import Any, Iterable, Mapping++CHOICES: tuple[int, ...] = (8192, 32768, 65536, 131072, 262144, 524288, 1048576)+TESTED = 262144 # the largest size that is not flagged as untested+NATIVE = 1048576 # the model's own length: the most any pack can say+NOTE = ("Not tested yet. A context this long takes graphics memory from the model and reads long prompts slowly.")++_LIMIT = re.compile(r"^max_position_embeddings\s+(\d+)\s*$", re.MULTILINE)+++def read_limit(pack: str | Path | None) -> int | None:+ """The pack's own limit from its ds4.txt; None when there is no pack, no file or no such line (the caller then behaves as before)."""+ if not pack:+ return None+ try:+ text = (Path(pack) / "ds4.txt").read_text(encoding="utf-8", errors="replace")+ except OSError:+ return None+ m = _LIMIT.search(text)+ if not m:+ return None+ value = int(m.group(1))+ return value if value >= 1024 else None+++def limit_of_config(cfg: Mapping[str, Any] | None) -> int | None:+ """The limit of the pack a DeepSeek run config names (``--pack DIR``)."""+ args = [str(a) for a in (cfg or {}).get("args") or []]+ if "--pack" in args and args.index("--pack") + 1 < len(args):+ return read_limit(args[args.index("--pack") + 1])+ return None+++def choices(limit: int | None = None, *, unknown_cap: int = NATIVE) -> list[int]:+ """The sizes to offer: up to the pack's limit when known, else up to ``unknown_cap`` (the Terminal and setup: the model's 1M; the app: TESTED)."""+ cap = limit if limit else unknown_cap+ return [c for c in CHOICES if c <= cap]+++def problem(context: int, limit: int | None = None) -> str:+ """"" when the size can run; otherwise one plain sentence (the only refusal: a size the model cannot address)."""+ cap = limit or NATIVE+ if context < 1024:+ return f"A context of {context} tokens is too small to be useful; the smallest size offered is 8K."+ if context > cap:+ what = "this model's pack reads" if limit else "DeepSeek-V4.1-Flash reads"+ return f"{label(context)} is more than {what} ({label(cap)}). Choose {label(cap)} or less."+ return ""+++def note(context: int | None) -> str:+ """The plain words past 256K, "" otherwise."""+ return NOTE if context and context > TESTED else ""+++def label(tokens: int) -> str:+ if tokens % NATIVE == 0:+ return f"{tokens // NATIVE}M"+ if tokens % 1024 == 0:+ return f"{tokens // 1024}K"+ return f"{tokens:,} tokens"+++def labels(sizes: Iterable[int]) -> list[str]:+ return [label(c) for c in sizes]diff --git a/tests/terminal/test_dsv41_context.py b/tests/terminal/test_dsv41_context.pynew file mode 100644index 000000000..2f35e8735--- /dev/null+++ b/tests/terminal/test_dsv41_context.py@@ -0,0 +1,151 @@+"""DeepSeek-V4.1-Flash's context sizes, 8K up to 1M (Project Maya #442 by @needmorevram): the choices, the pack's own limit, the refusal of a size the+model cannot address, the words past 256K, and that setup, the Terminal and the app say the same. Nothing is downloaded or started."""+from __future__ import annotations++import json+import shutil+import subprocess+import tempfile+import unittest+from pathlib import Path+from unittest import mock++from strata_cli.launch import settings as S+from strata_cli.launch.catalog import Catalog+from strata_control import dsv41_context as C+from tests.terminal.launch_support import HW_12, Home, catalog, run_cli++ROOT = Path(__file__).resolve().parents[2]+R9700 = {"name": "AMD Radeon AI PRO R9700", "vram_gb": 32.0, "usable": True, "vendor": "amd"}+HW_4X32 = {**HW_12, "ram_gb": 251.0, "disk_free_gb": 900.0, "engine_vendor": "amd", "gpus": [{**R9700, "index": i} for i in range(4)]}+++def pack_with(limit_line: str | None) -> Path:+ d = Path(tempfile.mkdtemp(prefix="strata-ds4-pack-"))+ (d / "ds4.txt").write_text("vocab_size 129280\n" + (limit_line + "\n" if limit_line else "") + "num_hidden_layers 43\n", encoding="utf-8")+ return d+++class Choices(unittest.TestCase):+ def test_the_sizes_go_up_to_one_million_and_are_labelled_512K_and_1M(self):+ self.assertEqual(C.CHOICES, (8192, 32768, 65536, 131072, 262144, 524288, 1048576))+ self.assertEqual(C.labels(C.CHOICES), ["8K", "32K", "64K", "128K", "256K", "512K", "1M"])+ self.assertEqual([S.context_label(c) for c in C.CHOICES], ["8K", "32K", "64K", "128K", "256K", "512K", "1M"])+ self.assertEqual(S.context_label(2097152), "2M")+ self.assertEqual(S.parse_context("1m"), 1048576)+ self.assertEqual(S.parse_context("512k"), 524288)+ self.assertEqual(S.context_label(S.parse_context("1M")), "1M")++ def test_one_million_is_accepted_and_two_million_refused(self):+ self.assertEqual(C.problem(524288), "")+ self.assertEqual(C.problem(1048576), "")+ self.assertIn("2M is more than DeepSeek-V4.1-Flash reads (1M)", C.problem(2097152))+ self.assertNotEqual(C.problem(1048577), "", "one position more than the model reads")+ self.assertNotEqual(C.problem(512), "", "too small to be useful")++ def test_the_pack_limit_is_read_from_ds4_txt_and_is_the_last_word(self):+ full = pack_with("max_position_embeddings 1048576")+ small = pack_with("max_position_embeddings 262144")+ none = pack_with(None)+ for d in (full, small, none):+ self.addCleanup(shutil.rmtree, d, True)+ self.assertEqual(C.read_limit(full), 1048576)+ self.assertEqual(C.read_limit(small), 262144)+ self.assertIsNone(C.read_limit(none), "a pack without the line behaves as before")+ self.assertIsNone(C.read_limit(full / "nowhere"))+ self.assertIsNone(C.read_limit(None))+ self.assertEqual(C.choices(C.read_limit(full)), list(C.CHOICES))+ self.assertEqual(C.choices(C.read_limit(small)), [8192, 32768, 65536, 131072, 262144])+ self.assertEqual(C.choices(None), list(C.CHOICES), "setup and the Terminal know the model: up to 1M without a pack")+ self.assertEqual(C.choices(None, unknown_cap=C.TESTED), [8192, 32768, 65536, 131072, 262144], "the app: up to 256K without a pack")+ self.assertEqual(C.problem(524288, C.read_limit(small)).split(" is ")[0], "512K")+ self.assertEqual(C.problem(262144, C.read_limit(small)), "")+ cfg = {"args": ["--pack", str(small), "--max-context", "8192"]}+ self.assertEqual(C.limit_of_config(cfg), 262144)+ self.assertIsNone(C.limit_of_config({"args": ["--native", "m.gguf"]}))++ def test_past_256K_the_note_says_it_is_untested_and_what_it_costs(self):+ self.assertEqual(C.note(262144), "")+ self.assertEqual(C.note(8192), "")+ for size in (524288, 1048576):+ self.assertEqual(C.note(size), "Not tested yet. A context this long takes graphics memory from the model and reads long prompts slowly.")+++class Terminal(unittest.TestCase):+ def setUp(self):+ self.home = Home().__enter__()+ self.addCleanup(self.home.__exit__, None, None, None)+ p = mock.patch.object(Catalog, "hardware", lambda s, fresh=False: dict(HW_4X32))+ p.start()+ self.addCleanup(p.stop)++ def plan(self, *args, ok=True):+ code, out, err = run_cli(["launch", "--plan", "--output", "json", *args])+ if ok:+ self.assertEqual(code, 0, err + out)+ return code, out, err++ def test_the_context_step_offers_8K_to_1M_for_deepseek_and_keeps_the_others(self):+ cat = catalog(HW_4X32)+ self.assertEqual(cat.contexts_for("deepseek41", "UD-Q8_K_XL"), list(C.CHOICES))+ self.assertEqual(cat.contexts_for("qwen", "IQ3_S"), cat.contexts(), "Qwen's choices stay as they are")+ self.assertNotIn(1048576, cat.contexts_for("qwen", "IQ3_S"))++ def test_the_flag_takes_512k_and_1m(self):+ for text, tokens in (("512k", 524288), ("1m", 1048576), ("524288", 524288), ("1048576", 1048576)):+ code, out, err = self.plan("--model", "ud-q8_k_xl", "--context", text, "--no-tui")+ plan = json.loads(out)["plan"]+ self.assertEqual(plan["settings"]["context"], tokens, text)+ self.assertTrue(any("Not tested yet" in n["text"] for n in plan["notices"]) if "notices" in plan else "Not tested yet" in out, text)++ def test_two_million_is_refused_with_a_plain_sentence(self):+ code, out, err = self.plan("--model", "ud-q8_k_xl", "--context", "2m", "--no-tui", ok=False)+ self.assertNotEqual(code, 0)+ self.assertIn("2M is more than DeepSeek-V4.1-Flash reads (1M)", out + err)++ def test_256k_has_no_untested_note_and_qwen_keeps_its_rope_scaling_words(self):+ code, out, err = self.plan("--model", "ud-q8_k_xl", "--context", "256k", "--no-tui")+ self.assertNotIn("Not tested yet", out + err)+ notes = S.check_context(S.LaunchSettings(context=524288))+ self.assertIn("rope scaling", notes[0].next)+ deep = S.check_context(S.LaunchSettings(context=524288), deepseek=True)+ self.assertEqual([n.level for n in deep], ["warn"])+ self.assertIn("Not tested yet", deep[0].text)+ self.assertEqual(S.check_context(S.LaunchSettings(context=262144), deepseek=True), [])+ self.assertEqual([n.level for n in S.check_context(S.LaunchSettings(context=2097152), deepseek=True)], ["error"])+ self.assertEqual([n.level for n in S.check_context(S.LaunchSettings(context=524288), deepseek=True, pack_limit=262144)], ["error"])+++class SetupAndApp(unittest.TestCase):+ def test_setup_stops_before_any_download_and_checks_the_pack_again(self):+ source = (ROOT / "setup.py").read_text(encoding="utf-8")+ early = source.index("ctx = a.context or DSV41_CONTEXT")+ self.assertIn("dsv41_context.problem(ctx)", source[early:early + 400])+ self.assertLess(early, source.index("folder = dsv41_folder(a, fam, tag, model)", early) + 1)+ self.assertIn("dsv41_context.read_limit(pack)", source)++ def test_the_install_tool_refuses_a_size_the_model_cannot_read(self):+ source = (ROOT / "tools" / "strata_mcp.py").read_text(encoding="utf-8")+ self.assertIn("dsv41_context.problem(int(context))", source)++ def test_the_engine_does_not_clamp_max_context(self):+ main = (ROOT / "src" / "dsv41" / "ds4_main.cpp").read_text(encoding="utf-8", errors="replace")+ self.assertIn('o.max_context = std::atoll(val("--max-context").c_str());', main)+ self.assertNotRegex(main, r"max_context\s*=\s*std::(min|clamp)")+ model = (ROOT / "src" / "dsv41" / "ds4_model.cu").read_text(encoding="utf-8", errors="replace")+ self.assertNotRegex(model, r"max_context\s*=\s*std::(min|clamp)")++ @unittest.skipUnless(shutil.which("node"), "node is not installed")+ def test_the_app_says_the_same(self):+ script = ("import {CONTEXT_CHOICES,TESTED_CONTEXT,NATIVE_CONTEXT,UNTESTED_NOTE} from './apps/host/src/lib/deepseek-context.ts';"+ "console.log(JSON.stringify({CONTEXT_CHOICES,TESTED_CONTEXT,NATIVE_CONTEXT,UNTESTED_NOTE}))")+ out = subprocess.run(["node", "--input-type=module", "-e", script], cwd=ROOT, capture_output=True, text=True, timeout=60)+ if out.returncode != 0:+ self.skipTest("this node cannot load TypeScript: " + out.stderr[-200:])+ app = json.loads(out.stdout)+ self.assertEqual(app["CONTEXT_CHOICES"], list(C.CHOICES))+ self.assertEqual((app["TESTED_CONTEXT"], app["NATIVE_CONTEXT"], app["UNTESTED_NOTE"]), (C.TESTED, C.NATIVE, C.NOTE))+++if __name__ == "__main__":+ unittest.main()diff --git a/tools/strata_mcp.py b/tools/strata_mcp.pyindex a047bc910..5a5eb2fef 100644--- a/tools/strata_mcp.py+++ b/tools/strata_mcp.py@@ -2193,6 +2193,10 @@ class Tools:context = context or (s.mac().recommend_context(hw.get("ram_gb") or 0) if s.mac() else 32768)if context is None and md.get("multi_file"):context = getattr(s.setup_module(), "DSV41_CONTEXT", 8192) # the context the engine was checked at+ if md.get("multi_file"): # DeepSeek-V4.1-Flash reads up to 1,048,576 positions (Project Maya #442): a size past that cannot run+ from strata_control import dsv41_context+ if dsv41_context.problem(int(context)):+ raise ToolError(dsv41_context.problem(int(context)))if context is None:usable = s.engine_gpus(hw)vram = max((g["vram_gb"] for g in usable), default=12)