@simplexai/localmodels-win32-x64 0.1.0-dev.101 → 0.1.0-dev.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +56 -37
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +3 -1
  5. package/modules/localmodels/app.py +35 -7
  6. package/modules/localmodels/catalog.json +306 -1
  7. package/modules/localmodels/cli_parser.py +4 -0
  8. package/modules/localmodels/debug_stub_server.py +280 -7
  9. package/modules/localmodels/download-mirrors.json +76 -0
  10. package/modules/localmodels/engine_adapters/suite_plan.py +4 -2
  11. package/modules/localmodels/engines-speechcpp-v0.11.3.json +84 -0
  12. package/modules/localmodels/library_serve.py +46 -26
  13. package/modules/localmodels/remote_ops_common.py +12 -2
  14. package/modules/localmodels/sidecar_downloads.py +426 -0
  15. package/modules/localmodels/sidecar_http.py +396 -0
  16. package/modules/localmodels/sidecar_state.py +466 -0
  17. package/modules/localmodels/speech_admission.py +13 -0
  18. package/modules/localmodels/speech_jobs.py +81 -370
  19. package/modules/localmodels/speech_server.py +17 -8
  20. package/modules/localmodels/speech_state.py +87 -454
  21. package/modules/localmodels/speech_workers.py +41 -163
  22. package/modules/localmodels/stack.py +18 -0
  23. package/modules/localmodels/stack_capacity.py +37 -1
  24. package/modules/localmodels/stack_cli.py +1 -0
  25. package/modules/localmodels/stack_down.py +19 -14
  26. package/modules/localmodels/stack_hardware.py +18 -16
  27. package/modules/localmodels/stack_plan.py +21 -0
  28. package/modules/localmodels/stack_ports.py +1 -0
  29. package/modules/localmodels/stack_progress.py +15 -0
  30. package/modules/localmodels/stack_run.py +25 -2
  31. package/modules/localmodels/stack_suite.py +54 -12
  32. package/modules/localmodels/stack_up.py +51 -1
  33. package/modules/localmodels/strata_poly_server.py +140 -3
  34. package/modules/localmodels/suite.py +10 -1
  35. package/modules/localmodels/tts-moss.txt +321 -0
  36. package/modules/localmodels/tts_admission.py +396 -0
  37. package/modules/localmodels/tts_backend_speechcpp.py +487 -0
  38. package/modules/localmodels/tts_catalog.py +251 -0
  39. package/modules/localmodels/tts_cli.py +333 -0
  40. package/modules/localmodels/tts_http.py +617 -0
  41. package/modules/localmodels/tts_jobs.py +496 -0
  42. package/modules/localmodels/tts_model.py +591 -0
  43. package/modules/localmodels/tts_moss_presets.json +1 -0
  44. package/modules/localmodels/tts_serve.py +451 -0
  45. package/modules/localmodels/tts_sidecar.py +750 -0
  46. package/modules/localmodels/tts_state.py +395 -0
  47. package/modules/localmodels/tts_worker_kokoro.py +463 -0
  48. package/modules/localmodels/tts_worker_moss.py +748 -0
  49. package/modules/localmodels/tts_workers.py +696 -0
  50. package/modules/{simplex_localmodels-0.1.0.dev101.dist-info → simplex_localmodels-0.1.0.dev103.dist-info}/METADATA +1 -1
  51. package/modules/{simplex_localmodels-0.1.0.dev101.dist-info → simplex_localmodels-0.1.0.dev103.dist-info}/RECORD +53 -34
  52. package/modules/{simplex_localmodels-0.1.0.dev101.dist-info → simplex_localmodels-0.1.0.dev103.dist-info}/licenses/NOTICE +29 -0
  53. package/package.json +1 -1
  54. package/tool.json +1 -1
  55. /package/modules/{simplex_localmodels-0.1.0.dev101.dist-info → simplex_localmodels-0.1.0.dev103.dist-info}/WHEEL +0 -0
  56. /package/modules/{simplex_localmodels-0.1.0.dev101.dist-info → simplex_localmodels-0.1.0.dev103.dist-info}/entry_points.txt +0 -0
  57. /package/modules/{simplex_localmodels-0.1.0.dev101.dist-info → simplex_localmodels-0.1.0.dev103.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -32,6 +32,7 @@ from localmodels.planning.budget import (
32
32
  from localmodels.planning.llm_ram import prompt_cache_bytes, prompt_cache_fit
33
33
  from localmodels.probe import GPU, HostFacts
34
34
  from localmodels.records import Plan
35
+ from localmodels.stack_capacity import start_need
35
36
  from localmodels.stack_plan import (
36
37
  HARNESS_RAM,
37
38
  RAM_FLOOR,
@@ -262,10 +263,12 @@ def _suite_gpu(
262
263
  gpu: int | None = None,
263
264
  *,
264
265
  share_gpu: bool = False,
266
+ free_needed: Callable[[GPU], int] | None = None,
265
267
  ) -> GPU:
266
268
  """The card of the running Strata LLM, else the best idle card (``gpu``: only that one). A
267
269
  running plan without a GPU (WHI-169: a synthetic or CPU plan of the same name) runs on no
268
- suite card."""
270
+ suite card. Shared, a card at least ``need`` large passes with ``free_needed(card)`` free,
271
+ at least what the check before start will ask (``stack_capacity.start_need``)."""
269
272
  placed = running["placement"].get("gpus") if running is not None else None
270
273
  cards_of_running = (
271
274
  [c for c in placed if isinstance(c, dict)] if isinstance(placed, list) else []
@@ -290,21 +293,53 @@ def _suite_gpu(
290
293
  free = gib(mac["free_bytes"])
291
294
  raise StackError(f"{llm['id']} needs {gib(need)} of unified memory, {free} is free")
292
295
  return mac
293
- candidates = sharing_cards(facts, need) if share_gpu else idle_cards(facts, need)
296
+ if share_gpu and free_needed is not None:
297
+ candidates = [
298
+ g
299
+ for g in sharing_cards(facts, 0)
300
+ if g["total_bytes"] >= need and g["free_bytes"] >= free_needed(g)
301
+ ]
302
+ else:
303
+ candidates = sharing_cards(facts, need) if share_gpu else idle_cards(facts, need)
294
304
  cards = [g for g in candidates if gpu is None or g["index"] == gpu]
295
- if not cards:
296
- held_by = holders(facts)
305
+ if cards:
306
+ return cards[0]
307
+ which = "an" if gpu is None else f"GPU {gpu} to be an"
308
+ if share_gpu and free_needed is not None:
297
309
  seen = "; ".join(
298
- f"GPU {g['index']} {gib(g['total_bytes'])}"
299
- + "".join(f", {why}" for why in held_by.get(g["uuid"], ["idle"]))
300
- for g in facts.get("gpus") or []
310
+ f"GPU {g['index']} {gib(g['total_bytes'])}, {gib(g['free_bytes'])} free"
311
+ + (f" of {gib(free_needed(g))} needed" if g["total_bytes"] >= need else "")
312
+ for g in sharing_cards(facts, 0)
301
313
  )
302
- which = "an" if gpu is None else f"GPU {gpu} to be an"
303
314
  raise StackError(
304
- f"{llm['id']} needs {which} NVIDIA GPU with no compute processes and at least "
305
- f"{gib(need)} of memory; this host: {seen or 'no NVIDIA GPU'}"
315
+ f"{llm['id']} needs {which} NVIDIA GPU of at least {gib(need)} with enough free "
316
+ f"VRAM for it; this host: {seen or 'no NVIDIA GPU'}"
306
317
  )
307
- return cards[0]
318
+ held_by = holders(facts)
319
+ seen = "; ".join(
320
+ f"GPU {g['index']} {gib(g['total_bytes'])}"
321
+ + "".join(f", {why}" for why in held_by.get(g["uuid"], ["idle"]))
322
+ for g in facts.get("gpus") or []
323
+ )
324
+ raise StackError(
325
+ f"{llm['id']} needs {which} NVIDIA GPU with no compute processes and at least "
326
+ f"{gib(need)} of memory; this host: {seen or 'no NVIDIA GPU'}"
327
+ )
328
+
329
+
330
+ def _free_to_plan(recipe: suite.SuiteRecipe, card: GPU, options: StackOptions) -> int:
331
+ """The free VRAM a shared ``card`` needs for the recipe: never less than ``stack apply`` asks
332
+ before it starts it (``stack_capacity.start_need`` on its plan's ``vram_bytes`` and floor
333
+ there, with the picture reader this card gets and the decision reserve), and never less
334
+ than the recipe's ``vram_bytes``. A PolyStrata floor is enough to start, not to run at
335
+ speed: on a card another program is using, Windows pages the expert cache in and out
336
+ (MR !781 homewin acceptance, 2026-12-01: 6.5 GiB free decoded about 11 tok/s), so shared
337
+ planning keeps the full-cache size until the engine sizes its cache by the real free VRAM."""
338
+ reader = vision.strata_mode(
339
+ options.get("vision", "off"), card["total_bytes"], bool(recipe.get("vision"))
340
+ )
341
+ vram, floor = suite.gpu_bytes(recipe, reader)
342
+ return max(int(recipe.get("vram_bytes", 0)), start_need(vram, floor, card, options))
308
343
 
309
344
 
310
345
  def strata_parts(
@@ -334,7 +369,14 @@ def strata_parts(
334
369
  unified = metal.supported(facts) and llm_recipe["runtime"] == "strata-poly"
335
370
  need = unified_bytes(llm_recipe) if unified else int(llm_recipe.get("vram_bytes", 0))
336
371
  gpu = _suite_gpu(
337
- facts, llm_recipe, need, running_llm, options.get("gpu"), share_gpu=options["share_gpu"]
372
+ facts,
373
+ llm_recipe,
374
+ need,
375
+ running_llm,
376
+ options.get("gpu"),
377
+ share_gpu=options["share_gpu"],
378
+ # A shared card: at least what stack apply checks before it starts the LLM.
379
+ free_needed=None if unified else (lambda card: _free_to_plan(llm_recipe, card, options)),
338
380
  )
339
381
  # Strata's own free margin, the decision model, and its growth.
340
382
  reserve = STRATA_FREE_MIB + ((vram + DECISION_VRAM_GROWTH) >> 20) if vram else STRATA_FREE_MIB
@@ -28,6 +28,7 @@ from localmodels import (
28
28
  )
29
29
  from localmodels import stack_lifecycle as lifecycle
30
30
  from localmodels.contracts import decode
31
+ from localmodels.plan_envelope import PlanError
31
32
  from localmodels.planning.budget import gpu_conflicts, gpu_users_unknown, unknown_services
32
33
  from localmodels.records import Plan
33
34
  from localmodels.stack_plan import (
@@ -54,7 +55,7 @@ class Part(TypedDict):
54
55
  detail: str
55
56
 
56
57
 
57
- class UpReport(TypedDict):
58
+ class _UpResult(TypedDict):
58
59
  schema: Literal["localmodels.stack-up/v1"]
59
60
  plan_id: str
60
61
  ok: bool
@@ -62,6 +63,42 @@ class UpReport(TypedDict):
62
63
  notes: list[str]
63
64
 
64
65
 
66
+ class UpReport(_UpResult, total=False):
67
+ # A refusal (exit 2): a cause code and a fixed sentence, never the exception's text (it can
68
+ # name paths and plan contents), and for STACK_VRAM_INSUFFICIENT the two byte counts.
69
+ cause_code: str
70
+ message: str
71
+ free_bytes: int
72
+ required_bytes: int
73
+
74
+
75
+ REFUSED = (
76
+ "STACK_UP_REFUSED",
77
+ "stack up refused to start the stack; run the same command without --json to see why",
78
+ )
79
+
80
+
81
+ def refusal(exc: BaseException, plan_id: str) -> UpReport:
82
+ """The ``--json`` result of an ``up`` that raised ``exc`` before it could report: what
83
+ Linger reads instead of a line on stderr alone."""
84
+ code = getattr(exc, "cause_code", None)
85
+ cause = (code, stack_run.CAUSES[code]) if code == "STACK_VRAM_INSUFFICIENT" else REFUSED
86
+ report: UpReport = {
87
+ "schema": SCHEMA,
88
+ "plan_id": stack_run.safe_digest(plan_id) or "",
89
+ "ok": False,
90
+ "parts": [],
91
+ "notes": [],
92
+ "cause_code": cause[0],
93
+ "message": cause[1],
94
+ }
95
+ counts = stack_run.cause_counts(exc)
96
+ if counts:
97
+ report["free_bytes"] = counts["free_bytes"]
98
+ report["required_bytes"] = counts["required_bytes"]
99
+ return report
100
+
101
+
65
102
  def accepted() -> StackPlan | None:
66
103
  """The plan of the last ``stack apply``, if that apply passed."""
67
104
  return stack_run.accepted()
@@ -275,6 +312,18 @@ def print_report(report: UpReport, out: Out = print) -> int:
275
312
 
276
313
 
277
314
  def cli(args: argparse.Namespace) -> int:
315
+ if not args.json:
316
+ return _cli(args)
317
+ plan_id: list[str] = []
318
+ try:
319
+ return _cli(args, plan_id.append)
320
+ except (StackError, PlanError, OSError, ValueError, KeyError) as exc:
321
+ print(json.dumps(refusal(exc, plan_id[-1] if plan_id else ""), indent=1))
322
+ print(f"stack: {exc}", file=sys.stderr)
323
+ return 2
324
+
325
+
326
+ def _cli(args: argparse.Namespace, chosen: Callable[[str], None] = lambda _id: None) -> int:
278
327
  if args.plan is None:
279
328
  plan = stack_run.accepted()
280
329
  if plan is None:
@@ -290,6 +339,7 @@ def cli(args: argparse.Namespace) -> int:
290
339
  f"plan {saved['plan_id'][:12]} has no stack apply record that passed full acceptance; "
291
340
  f"run {command()} stack apply first"
292
341
  )
342
+ chosen(plan["plan_id"])
293
343
  report = up(
294
344
  plan,
295
345
  share_gpu=args.share_gpu,
@@ -12,7 +12,10 @@ the server:
12
12
  2. The serve profile ``stack plan`` wrote names paths under ``~`` when the stack uses its
13
13
  default directory, and PolyStrata takes them literally, so a copy with every such path
14
14
  expanded (``strata-profile.resolved.json``) is what the server reads.
15
- 3. ``serve/server.py --engine strata --config <resolved profile>`` runs inside this process
15
+ 3. Under Windows that copy's ``--vram-reserve-mib`` is read off the card as it is now
16
+ (``for_windows``): the engine sizes its VRAM from CUDA's free memory, which under WDDM does
17
+ not count other programs.
18
+ 4. ``serve/server.py --engine strata --config <resolved profile>`` runs inside this process
16
19
  (``runpy``), so the unit's signals and exit status are the server's while the command line
17
20
  stays the one the deployment records: service discovery tells this tool's own engine from
18
21
  someone else's by matching a GPU process's ancestors against that recorded command.
@@ -28,6 +31,7 @@ import shutil
28
31
  import subprocess
29
32
  import sys
30
33
  from pathlib import Path
34
+ from typing import cast
31
35
 
32
36
 
33
37
  def source_root(engine_dir: Path) -> Path:
@@ -97,12 +101,145 @@ def planning_home(profile: dict[str, object], deploy_dir: Path) -> str:
97
101
  return os.path.expanduser("~")
98
102
 
99
103
 
104
+ RESERVE_FLAG = "--vram-reserve-mib"
105
+ BEFORE_CACHE_KEY = "vram_before_cache_mib"
106
+ WINDOWS = os.name == "nt"
107
+
108
+ # Run in a child Python so no CUDA context outlives it in the server's process; argv: the planned
109
+ # reserve and the VRAM the engine takes before its cache, in MiB. On the engine's card (CUDA
110
+ # device 0 under the unit's CUDA_VISIBLE_DEVICES) it reads NVML's free memory, which counts every
111
+ # process, then allocates as the engine does and prints the free memory CUDA reports to a process
112
+ # holding the second figure, or, when that is 0, holding all the engine may take (the card's free
113
+ # less the planned reserve).
114
+ CARD_PROBE = r"""
115
+ import ctypes, json, os, sys, time
116
+ planned, before = int(sys.argv[1]), int(sys.argv[2])
117
+ nvml = None
118
+ for name in ("nvml.dll", os.path.join(os.environ.get("ProgramFiles", r"C:\Program Files"),
119
+ "NVIDIA Corporation", "NVSMI", "nvml.dll")):
120
+ try:
121
+ nvml = ctypes.WinDLL(name)
122
+ break
123
+ except OSError:
124
+ pass
125
+ cuda = ctypes.WinDLL("nvcuda.dll")
126
+ dev, ctx, uuid = ctypes.c_int(), ctypes.c_void_p(), (ctypes.c_ubyte * 16)()
127
+ assert cuda.cuInit(0) == 0 and cuda.cuDeviceGet(ctypes.byref(dev), 0) == 0
128
+ assert cuda.cuDeviceGetUuid_v2(uuid, dev) == 0
129
+ b = bytes(uuid)
130
+ name = "GPU-%s-%s-%s-%s-%s" % (b[:4].hex(), b[4:6].hex(), b[6:8].hex(), b[8:10].hex(), b[10:].hex())
131
+ class Mem(ctypes.Structure):
132
+ _fields_ = [("total", ctypes.c_ulonglong), ("free", ctypes.c_ulonglong), ("used", ctypes.c_ulonglong)]
133
+ mem, card = Mem(), ctypes.c_void_p()
134
+ assert nvml.nvmlInit_v2() == 0
135
+ assert nvml.nvmlDeviceGetHandleByUUID(name.encode(), ctypes.byref(card)) == 0
136
+ assert nvml.nvmlDeviceGetMemoryInfo(card, ctypes.byref(mem)) == 0
137
+ nvml.nvmlShutdown()
138
+ target = (mem.free >> 20) - planned
139
+ assert cuda.cuDevicePrimaryCtxRetain(ctypes.byref(ctx), dev) == 0
140
+ out, chunks = {"card_free_mib": mem.free >> 20}, []
141
+ def hold(mib):
142
+ held = 256 * len(chunks)
143
+ while held + 256 <= mib:
144
+ ptr = ctypes.c_uint64()
145
+ if cuda.cuMemAlloc_v2(ctypes.byref(ptr), ctypes.c_size_t(256 << 20)) != 0:
146
+ break
147
+ chunks.append(ptr)
148
+ assert cuda.cuMemsetD8_v2(ptr, ctypes.c_ubyte(0), ctypes.c_size_t(256 << 20)) == 0
149
+ held += 256
150
+ assert cuda.cuCtxSynchronize() == 0
151
+ time.sleep(1.0)
152
+ free, total = ctypes.c_size_t(), ctypes.c_size_t()
153
+ assert cuda.cuMemGetInfo_v2(ctypes.byref(free), ctypes.byref(total)) == 0
154
+ return held, free.value >> 20
155
+ try:
156
+ assert cuda.cuCtxSetCurrent(ctx) == 0
157
+ if 0 < before < target:
158
+ out["before_held_mib"], out["before_cuda_free_mib"] = hold(before)
159
+ else:
160
+ out["held_mib"], out["cuda_free_mib"] = hold(target)
161
+ finally:
162
+ for ptr in chunks:
163
+ cuda.cuMemFree_v2(ptr)
164
+ cuda.cuDevicePrimaryCtxRelease(dev)
165
+ print(json.dumps(out))
166
+ """
167
+
168
+
169
+ def windows_reserve_mib(planned: int, before: int) -> int:
170
+ """``--vram-reserve-mib`` for strata-poly under Windows, so that the engine takes what the
171
+ card has free less ``planned``, ``before`` being the VRAM it takes ahead of its cache.
172
+
173
+ The engine fills its cache (or its ``--vram-pool``) to what CUDA reports free less the
174
+ reserve. Under WDDM that figure is the process's budget less its own use, not the card's
175
+ free memory: on homewin's RTX 4060 Ti 16 GB (2026-12-02) a process holding nothing was told
176
+ 15,223 MiB both idle and with another program holding 8,000 MiB (NVML: 14,804 and 6,685).
177
+ With such a program there the budget also shrinks once the process holds about 2.5 GiB, by
178
+ about a MiB for each MiB more, until Windows moves one of them to system memory (decoding
179
+ then fell to about 5 tokens/s). So the reserve is read off that budget: what CUDA reports to
180
+ a process holding ``before`` (what the engine sees when it fills its cache), less the cache
181
+ it may have. Without ``before`` it is what CUDA reports to a process holding all the engine
182
+ may take, which leaves the engine ``before`` over. On a card nothing else uses, the reserve
183
+ stays ``planned`` (homewin: 643 MiB computed, 1,280 kept). ``planned`` also when the card
184
+ cannot be read: the plan's reserve stands."""
185
+ try:
186
+ done = subprocess.run(
187
+ [sys.executable, "-I", "-c", CARD_PROBE, str(planned), str(before)],
188
+ capture_output=True,
189
+ text=True,
190
+ timeout=120,
191
+ check=False,
192
+ )
193
+ views = json.loads(done.stdout.strip().splitlines()[-1])
194
+ target = int(views["card_free_mib"]) - planned
195
+ if "before_cuda_free_mib" in views:
196
+ fill = int(views["before_cuda_free_mib"]) - (target - int(views["before_held_mib"]))
197
+ else:
198
+ fill = int(views["cuda_free_mib"])
199
+ reserve = max(planned, fill)
200
+ except (OSError, subprocess.SubprocessError, ValueError, LookupError, TypeError):
201
+ print(
202
+ "strata_poly_server: could not read the card's free VRAM; keeping the planned "
203
+ f"{RESERVE_FLAG} {planned}",
204
+ file=sys.stderr,
205
+ )
206
+ return planned
207
+ held = views.get("before_held_mib", views.get("held_mib"))
208
+ cuda_free = views.get("before_cuda_free_mib", views.get("cuda_free_mib"))
209
+ print(
210
+ f"strata_poly_server: the card has {views['card_free_mib']} MiB free; CUDA reports "
211
+ f"{cuda_free} MiB free holding {held}; {RESERVE_FLAG} {planned} -> {reserve}",
212
+ file=sys.stderr,
213
+ )
214
+ return reserve
215
+
216
+
217
+ def for_windows(profile: dict[str, object]) -> dict[str, object]:
218
+ """``profile`` with the reserve ``windows_reserve_mib`` gives (when it has a numeric one)."""
219
+ args = profile.get("args")
220
+ if not isinstance(args, list) or RESERVE_FLAG not in args[:-1]:
221
+ return profile
222
+ at = args.index(RESERVE_FLAG) + 1
223
+ try:
224
+ planned = int(str(args[at]))
225
+ except ValueError:
226
+ return profile
227
+ before = profile.get(BEFORE_CACHE_KEY)
228
+ reserve = windows_reserve_mib(planned, before if isinstance(before, int) else 0)
229
+ return {**profile, "args": [*args[:at], str(reserve), *args[at + 1 :]]}
230
+
231
+
100
232
  def resolve(config: Path) -> Path:
101
- """Write the profile with its home-relative paths expanded beside it; returns that file."""
233
+ """Write the profile with its home-relative paths expanded beside it, and under Windows its
234
+ reserve raised by what other programs hold on the card; returns that file."""
102
235
  resolved = config.with_name(config.stem + ".resolved.json")
103
236
  profile = json.loads(config.read_text(encoding="utf-8"))
104
237
  home = planning_home(profile, config.parent.resolve())
105
- resolved.write_text(json.dumps(_expanded(profile, home), indent=1) + "\n", encoding="utf-8")
238
+ profile = cast("dict[str, object]", _expanded(profile, home))
239
+ if WINDOWS:
240
+ profile = for_windows(profile)
241
+ profile.pop(BEFORE_CACHE_KEY, None) # this launcher's, not PolyStrata's
242
+ resolved.write_text(json.dumps(profile, indent=1) + "\n", encoding="utf-8")
106
243
  return resolved
107
244
 
108
245
 
@@ -32,7 +32,7 @@ from localmodels.engines import (
32
32
  from localmodels.plan_envelope import MODELSCOPE_URL, PlanError
33
33
  from localmodels.probe import GPU, HostFacts
34
34
  from localmodels.records import Plan, ReleaseEngine
35
- from localmodels.vision import StrataVision
35
+ from localmodels.vision import StrataVision, strata_gpu_mib
36
36
 
37
37
  GIB = 1 << 30
38
38
  # Engines that keep a MoE model's experts in host RAM beside a GPU cache: Strata, and PolyStrata's
@@ -231,6 +231,15 @@ def unbounded(plan: Plan) -> Plan:
231
231
  return plan
232
232
 
233
233
 
234
+ def gpu_bytes(r: SuiteRecipe, reader: str) -> tuple[int, int]:
235
+ """``(vram_bytes, min_vram_free_bytes)`` of the recipe's plan with picture reader ``reader``:
236
+ a reader on the GPU adds its VRAM to both. The floor is 0 when the recipe sets none; for
237
+ PolyStrata ``vram_bytes`` is the expert cache's ceiling and the floor the least it starts in."""
238
+ added = strata_gpu_mib(r.get("vision") or {}, reader) << 20
239
+ floor = int(r.get("min_vram_free_bytes") or 0)
240
+ return int(r.get("vram_bytes", 0)) + added, (floor + added if floor else 0)
241
+
242
+
234
243
  def bounded_ram(part: Plan) -> int:
235
244
  """What a bounded service may hold before the kernel reclaims from it: MemoryHigh, else
236
245
  MemoryMax, else the recipe's estimate."""