@simplexai/localmodels-linux-arm64 0.1.0-dev.103 → 0.1.0-dev.105

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 (172) hide show
  1. package/LICENSE +201 -0
  2. package/{modules/simplex_localmodels-0.1.0.dev103.dist-info/licenses/NOTICE → NOTICE} +42 -13
  3. package/README.md +10 -0
  4. package/bootstrap.identity +1 -1
  5. package/bootstrap.sha256 +159 -158
  6. package/modules/localmodels/__init__.py +1 -1
  7. package/modules/localmodels/__main__.py +204 -86
  8. package/modules/localmodels/apple_sensors.py +23 -0
  9. package/modules/localmodels/approval.py +25 -2
  10. package/modules/localmodels/catalog.json +584 -158
  11. package/modules/localmodels/catalog.py +18 -3
  12. package/modules/localmodels/catalog_recipes.py +64 -6
  13. package/modules/localmodels/cli_help.py +10 -0
  14. package/modules/localmodels/cli_parser.py +313 -230
  15. package/modules/localmodels/component.py +21 -3
  16. package/modules/localmodels/console.py +1 -1
  17. package/modules/localmodels/context_policy.py +6 -5
  18. package/modules/localmodels/custom_probe.py +4 -2
  19. package/modules/localmodels/debug_cli.py +0 -12
  20. package/modules/localmodels/debug_mode.py +0 -6
  21. package/modules/localmodels/decode_calibration.json +3 -4
  22. package/modules/localmodels/decode_calibration.py +5 -2
  23. package/modules/localmodels/deploy.py +11 -1
  24. package/modules/localmodels/deployment_lifecycle.py +1 -1
  25. package/modules/localmodels/download-mirrors.json +1 -1
  26. package/modules/localmodels/engine_adapters/base.py +11 -1
  27. package/modules/localmodels/engine_adapters/strata_poly.py +65 -3
  28. package/modules/localmodels/engine_adapters/suite_plan.py +61 -24
  29. package/modules/localmodels/engines-b11583.json +6 -26
  30. package/modules/localmodels/engines-b12588-mix-c0c3de8.json +3 -15
  31. package/modules/localmodels/engines-b12757-mix-ef2df21.json +3 -15
  32. package/modules/localmodels/engines-prism-b12178-03ec600.json +3 -15
  33. package/modules/localmodels/engines-speechcpp-v0.11.3.json +4 -20
  34. package/modules/localmodels/engines-strata-0.1.47.json +1 -5
  35. package/modules/localmodels/engines-strata-0.1.49.2.json +1 -5
  36. package/modules/localmodels/engines-strata-0.1.59.1.json +1 -5
  37. package/modules/localmodels/engines-strata-poly-0.2.20-poly.1.json +6 -30
  38. package/modules/localmodels/engines-strata-poly-0.2.20-poly.9.json +129 -0
  39. package/modules/localmodels/engines-whisper-b5454.json +6 -30
  40. package/modules/localmodels/engines.json +13 -61
  41. package/modules/localmodels/estimator.py +10 -5
  42. package/modules/localmodels/gpu_specs.py +1 -1
  43. package/modules/localmodels/host_sensors.py +25 -2
  44. package/modules/localmodels/hosts.py +38 -21
  45. package/modules/localmodels/kokoro-tts-0.6.1.txt +1 -1
  46. package/modules/localmodels/library_cli.py +34 -16
  47. package/modules/localmodels/library_custom.py +9 -1
  48. package/modules/localmodels/library_direct.py +41 -1
  49. package/modules/localmodels/library_elastic.py +135 -6
  50. package/modules/localmodels/library_jobs.py +23 -4
  51. package/modules/localmodels/library_kept.py +9 -1
  52. package/modules/localmodels/library_model.py +174 -2
  53. package/modules/localmodels/library_order.py +175 -69
  54. package/modules/localmodels/library_poly.py +150 -21
  55. package/modules/localmodels/library_presentation.py +485 -0
  56. package/modules/localmodels/library_pricing.py +15 -4
  57. package/modules/localmodels/library_serve.py +342 -70
  58. package/modules/localmodels/library_smoke.py +63 -5
  59. package/modules/localmodels/library_state.py +48 -10
  60. package/modules/localmodels/library_status.py +37 -17
  61. package/modules/localmodels/llm_rank.py +22 -11
  62. package/modules/localmodels/metal.py +1 -2
  63. package/modules/localmodels/plan_envelope.py +40 -13
  64. package/modules/localmodels/planning/budget.py +14 -12
  65. package/modules/localmodels/planning/memory_pools.py +7 -1
  66. package/modules/localmodels/privacy_acceptance.py +6 -5
  67. package/modules/localmodels/probe.py +34 -7
  68. package/modules/localmodels/py.typed +0 -0
  69. package/modules/localmodels/quant_formats.py +10 -3
  70. package/modules/localmodels/recommend_cli.py +1 -1
  71. package/modules/localmodels/records.py +19 -2
  72. package/modules/localmodels/remote_ops_launchd.py +8 -1
  73. package/modules/localmodels/remote_ops_verify.py +91 -24
  74. package/modules/localmodels/runtime_index.py +303 -0
  75. package/modules/localmodels/runtime_process.py +1 -1
  76. package/modules/localmodels/service_deployment.py +2 -4
  77. package/modules/localmodels/service_probe.py +59 -13
  78. package/modules/localmodels/setup_inspection.py +94 -73
  79. package/modules/localmodels/setup_text.py +7 -56
  80. package/modules/localmodels/sidecar_downloads.py +34 -0
  81. package/modules/localmodels/sidecar_http.py +61 -5
  82. package/modules/localmodels/sidecar_state.py +52 -2
  83. package/modules/localmodels/speech_admission.py +20 -4
  84. package/modules/localmodels/speech_catalog.py +23 -0
  85. package/modules/localmodels/speech_cli.py +30 -16
  86. package/modules/localmodels/speech_jobs.py +42 -17
  87. package/modules/localmodels/speech_serve.py +9 -2
  88. package/modules/localmodels/speech_server.py +185 -81
  89. package/modules/localmodels/speech_state.py +4 -1
  90. package/modules/localmodels/speech_workers.py +11 -0
  91. package/modules/localmodels/stack.py +1 -1
  92. package/modules/localmodels/stack_args.py +276 -145
  93. package/modules/localmodels/stack_auto.py +91 -6
  94. package/modules/localmodels/stack_aux_gpu.py +1 -1
  95. package/modules/localmodels/stack_cleanup.py +21 -18
  96. package/modules/localmodels/stack_cli.py +120 -115
  97. package/modules/localmodels/stack_compose.py +16 -5
  98. package/modules/localmodels/stack_debug.py +15 -6
  99. package/modules/localmodels/stack_decision.py +4 -4
  100. package/modules/localmodels/stack_doctor.py +2 -2
  101. package/modules/localmodels/stack_down.py +2 -0
  102. package/modules/localmodels/stack_events.py +1 -1
  103. package/modules/localmodels/stack_gpu_memory.py +1 -1
  104. package/modules/localmodels/stack_hardware.py +17 -15
  105. package/modules/localmodels/stack_mcp.py +1 -2
  106. package/modules/localmodels/stack_mlx.py +8 -1
  107. package/modules/localmodels/stack_picks.py +20 -21
  108. package/modules/localmodels/stack_plan.py +12 -11
  109. package/modules/localmodels/stack_ports.py +31 -4
  110. package/modules/localmodels/stack_review.py +28 -7
  111. package/modules/localmodels/stack_rollback.py +1 -1
  112. package/modules/localmodels/stack_run.py +1 -1
  113. package/modules/localmodels/stack_suite.py +72 -21
  114. package/modules/localmodels/stack_up.py +2 -0
  115. package/modules/localmodels/stack_view.py +180 -35
  116. package/modules/localmodels/stack_view_agent.py +1 -1
  117. package/modules/localmodels/stack_view_demo.py +2 -0
  118. package/modules/localmodels/stack_view_gpu.py +36 -2
  119. package/modules/localmodels/stack_view_schema.py +26 -3
  120. package/modules/localmodels/stack_view_serve.py +0 -2
  121. package/modules/localmodels/stack_view_slots.py +3 -1
  122. package/modules/localmodels/stack_view_telemetry.py +90 -4
  123. package/modules/localmodels/stack_view_tick.py +246 -40
  124. package/modules/localmodels/stack_view_words.py +9 -2
  125. package/modules/localmodels/stack_warm.py +2 -2
  126. package/modules/localmodels/stack_whatif.py +524 -41
  127. package/modules/localmodels/stack_whatif_html.py +900 -0
  128. package/modules/localmodels/startlux-decide-83fe6c7d.txt +2 -2
  129. package/modules/localmodels/{strata-poly-serve-0.2.20-poly.7.txt → strata-poly-serve-0.2.20-poly.9.txt} +1 -1
  130. package/modules/localmodels/strata_poly_server.py +114 -3
  131. package/modules/localmodels/suite.py +265 -6
  132. package/modules/localmodels/telemetry_math.py +458 -18
  133. package/modules/localmodels/transport.py +8 -1
  134. package/modules/localmodels/tts_admission.py +2 -17
  135. package/modules/localmodels/tts_catalog.py +29 -1
  136. package/modules/localmodels/tts_cli.py +45 -22
  137. package/modules/localmodels/tts_http.py +10 -4
  138. package/modules/localmodels/tts_jobs.py +49 -19
  139. package/modules/localmodels/tts_serve.py +9 -2
  140. package/modules/localmodels/tts_server.py +1 -1
  141. package/modules/localmodels/tts_sidecar.py +69 -28
  142. package/modules/localmodels/tts_state.py +7 -2
  143. package/modules/localmodels/vision.py +5 -3
  144. package/modules/localmodels/web/view/ASSET-SOURCES.md +4 -7
  145. package/modules/localmodels/web/view/view.css +0 -1
  146. package/modules/localmodels/web/view/view.js +2 -5
  147. package/modules/localmodels/web/whatif/app.js +730 -0
  148. package/modules/localmodels/web/whatif/page.html +1172 -0
  149. package/modules/localmodels/web/whatif/sim.js +297 -0
  150. package/modules/localmodels/win_probe.py +89 -16
  151. package/modules/localmodels/windows_job.py +179 -11
  152. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/METADATA +14 -0
  153. package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +151 -145
  154. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/LICENSE +201 -0
  155. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/NOTICE +126 -0
  156. package/package.json +11 -2
  157. package/tool.json +1 -1
  158. package/modules/localmodels/engines-strata-poly-0.2.20-poly.7.json +0 -94
  159. package/modules/localmodels/fixtures/stack-research-demo-plan.json +0 -1059
  160. package/modules/localmodels/stack_research.py +0 -716
  161. package/modules/localmodels/stack_research_demo.py +0 -125
  162. package/modules/localmodels/stack_research_plan.py +0 -146
  163. package/modules/localmodels/web/index.html +0 -2605
  164. package/modules/localmodels/web/sizecalc/app.js +0 -1306
  165. package/modules/localmodels/web/sizecalc/calc.js +0 -269
  166. package/modules/localmodels/web/sizecalc/page.html +0 -520
  167. package/modules/localmodels/web/view/logo-claude.svg +0 -3
  168. package/modules/localmodels/web/view/logo-codex.png +0 -0
  169. package/modules/simplex_localmodels-0.1.0.dev103.dist-info/METADATA +0 -9
  170. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
  171. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
  172. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -64,8 +64,8 @@ def add_arguments(plan: argparse._ActionsContainer) -> None:
64
64
  type=_aux,
65
65
  default="none",
66
66
  metavar="auto|none|TASK[,TASK]",
67
- help="optional embedding, reranker and STT: none (the default since roadmap decision "
68
- "26: only the LLM is installed), auto fits all three into the RAM left, a comma list "
67
+ help="optional embedding, reranker and STT: none (default: only the LLM is installed), "
68
+ "auto fits all three into the RAM left, a comma list "
69
69
  "such as embedding,reranker plans only those",
70
70
  )
71
71
  plan.add_argument(
@@ -168,15 +168,14 @@ def poly_reserve_mib(recipe: suite.SuiteRecipe, gpu: GPU, beside_mib: int) -> in
168
168
 
169
169
 
170
170
  def auto_strata_wanted(facts: HostFacts, options: StackOptions) -> bool:
171
- """Whether ``--llm auto`` also weighs Strata recipes: on Linux and Windows (a Mac runs a
172
- strata-poly recipe that ``--llm`` names, and none is validated there; on Windows only
173
- recipes whose engine has a Windows build, see auto_strata_candidates), and not for ``--prefer concurrent``, because a Strata recipe whose
174
- experts stay in RAM gains nothing from a second request (GY1), nor under ``--context``: a
175
- Strata recipe fixes its own window."""
171
+ """Whether ``--llm auto`` also weighs Strata/PolyStrata recipes: on Linux and Windows (a Mac
172
+ runs a strata-poly recipe only when ``--llm`` names it; on Windows only recipes whose engine
173
+ has a Windows build, see auto_strata_candidates), and never under ``--context`` (Strata
174
+ recipes fix their own window). Under ``--prefer concurrent``, ``stack_auto`` further filters
175
+ candidates to full-VRAM-resident ``strata-poly`` recipes with ``parallel >= 2``."""
176
176
  return (
177
177
  options["llm"] == "auto"
178
178
  and facts["platform"] in ("linux", "win32")
179
- and options.get("prefer") != "concurrent"
180
179
  and not options.get("context")
181
180
  )
182
181
 
@@ -203,7 +202,11 @@ def auto_strata_candidates(
203
202
  if llama_score is None:
204
203
  return at_least
205
204
  return llm_rank.strata_recipe_bar(
206
- llama_score, opts, prefer_over_llama=bool(r.get("prefer_over_llama"))
205
+ llama_score,
206
+ opts,
207
+ prefer_over_llama=bool(r.get("prefer_over_llama")),
208
+ allow_poly_fastest=r.get("runtime") == "strata-poly"
209
+ and r.get("decode_fraction") is not None,
207
210
  )
208
211
 
209
212
  found = [
@@ -219,8 +222,7 @@ def auto_strata_candidates(
219
222
  found,
220
223
  key=lambda r: (
221
224
  -r["quality"]["score"],
222
- -int(bool(r.get("prefer_over_llama"))),
223
- -r.get("vram_bytes", 0),
225
+ -suite.strata_smart_tie(r),
224
226
  ),
225
227
  )
226
228
 
@@ -241,15 +243,53 @@ def strata_recipe(facts: HostFacts, requested: str) -> tuple[suite.SuiteRecipe |
241
243
  METAL_BESIDE_BYTES = 12 << 30
242
244
 
243
245
 
244
- def unified_bytes(recipe: suite.SuiteRecipe) -> int:
245
- """What a strata-poly LLM holds on a Mac, where every expert stays in unified memory: its
246
- files and METAL_BESIDE_BYTES (PS219, M5 Ultra, prompts up to 58K tokens: the engine held 1.4
247
- to 4.4 GiB beside them; --conversation-cache-mib auto parks up to 8 GiB more)."""
248
- return sum(f["size_bytes"] for f in recipe["files"] if not f.get("vision")) + METAL_BESIDE_BYTES
246
+ def unified_bytes(
247
+ recipe: suite.SuiteRecipe,
248
+ *,
249
+ window: int | None = None,
250
+ slots: int | None = None,
251
+ kv_fmt: str | None = None,
252
+ vision_reader: str = "off",
253
+ ) -> int:
254
+ """What a strata-poly LLM holds on a Mac, where every expert stays in unified memory.
255
+
256
+ Recipes carrying explicit KV geometry (e.g. Inkling 2 Mini ``poly.9``) use compositional sizing
257
+ (weights + KV + resident Metal vision + Metal overhead); legacy recipes without KV geometry
258
+ fall back to ``weights + METAL_BESIDE_BYTES`` (PS219, M5 Ultra)."""
259
+ total, _ = suite.poly_unified_footprint(
260
+ recipe,
261
+ window=window,
262
+ slots=slots,
263
+ kv_fmt=kv_fmt,
264
+ vision_reader=vision_reader,
265
+ allow_catalog_fallback=False,
266
+ fallback_beside_bytes=METAL_BESIDE_BYTES,
267
+ )
268
+ return total
249
269
 
250
270
 
251
271
  def _on_unified_memory(llm: Plan, recipe: suite.SuiteRecipe) -> Plan:
252
272
  """The plan on a Mac: priced whole and once (``launch.unified_bytes``), no cgroup ceiling."""
273
+ if suite.poly_kv_geometry(recipe, allow_catalog_fallback=False) is not None:
274
+ launch = llm["launch"]
275
+ window = int(str(launch.get("window") or 0)) or None
276
+ slots = int(str(launch.get("slots") or 0)) or None
277
+ reader = str(launch.get("vision") or "off")
278
+ kv_fmt = suite.plan_kv_format(llm, recipe)
279
+ total, wired = suite.poly_unified_footprint(
280
+ recipe,
281
+ window=window,
282
+ slots=slots,
283
+ kv_fmt=kv_fmt,
284
+ vision_reader=reader,
285
+ allow_catalog_fallback=False,
286
+ fallback_beside_bytes=METAL_BESIDE_BYTES,
287
+ )
288
+ parking = int(str(launch.get("conversation_cache_mib") or 0)) << 20
289
+ llm["launch"]["unified_bytes"] = total + parking
290
+ llm["launch"]["vram_bytes"] = wired
291
+ llm["launch"].pop("min_vram_free_bytes", None)
292
+ return suite.unbounded(llm)
253
293
  added = int(str(llm["launch"]["memory_estimate_bytes"])) - recipe["memory_estimate_bytes"]
254
294
  llm["launch"]["unified_bytes"] = unified_bytes(recipe) + added
255
295
  return suite.unbounded(llm)
@@ -266,7 +306,7 @@ def _suite_gpu(
266
306
  free_needed: Callable[[GPU], int] | None = None,
267
307
  ) -> GPU:
268
308
  """The card of the running Strata LLM, else the best idle card (``gpu``: only that one). A
269
- running plan without a GPU (WHI-169: a synthetic or CPU plan of the same name) runs on no
309
+ running plan without a GPU (a synthetic or CPU plan of the same name) runs on no
270
310
  suite card. Shared, a card at least ``need`` large passes with ``free_needed(card)`` free,
271
311
  at least what the check before start will ask (``stack_capacity.start_need``)."""
272
312
  placed = running["placement"].get("gpus") if running is not None else None
@@ -333,7 +373,7 @@ def _free_to_plan(recipe: suite.SuiteRecipe, card: GPU, options: StackOptions) -
333
373
  there, with the picture reader this card gets and the decision reserve), and never less
334
374
  than the recipe's ``vram_bytes``. A PolyStrata floor is enough to start, not to run at
335
375
  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
376
+ (reference 8 GB WDDM measurement: 6.5 GiB free decoded about 11 tok/s), so shared
337
377
  planning keeps the full-cache size until the engine sizes its cache by the real free VRAM."""
338
378
  reader = vision.strata_mode(
339
379
  options.get("vision", "off"), card["total_bytes"], bool(recipe.get("vision"))
@@ -367,7 +407,17 @@ def strata_parts(
367
407
  raise StackError(f"{exc}; cannot share a card with {llm_recipe['id']}") from None
368
408
  vram = pick.tier["vram_bytes"] if pick else 0
369
409
  unified = metal.supported(facts) and llm_recipe["runtime"] == "strata-poly"
370
- need = unified_bytes(llm_recipe) if unified else int(llm_recipe.get("vram_bytes", 0))
410
+ spec = llm_recipe.get("vision") or {}
411
+ need = (
412
+ unified_bytes(
413
+ llm_recipe,
414
+ vision_reader=vision.strata_mode(
415
+ options.get("vision", "off"), 0, bool(spec), unified=True
416
+ ),
417
+ )
418
+ if unified
419
+ else int(llm_recipe.get("vram_bytes", 0))
420
+ )
371
421
  gpu = _suite_gpu(
372
422
  facts,
373
423
  llm_recipe,
@@ -380,8 +430,9 @@ def strata_parts(
380
430
  )
381
431
  # Strata's own free margin, the decision model, and its growth.
382
432
  reserve = STRATA_FREE_MIB + ((vram + DECISION_VRAM_GROWTH) >> 20) if vram else STRATA_FREE_MIB
383
- spec = llm_recipe.get("vision") or {}
384
- reader = vision.strata_mode(options.get("vision", "off"), gpu["total_bytes"], bool(spec))
433
+ reader = vision.strata_mode(
434
+ options.get("vision", "off"), gpu["total_bytes"], bool(spec), unified=unified
435
+ )
385
436
  if llm_recipe["runtime"] == "strata-poly":
386
437
  cache = "auto"
387
438
  reserve = poly_reserve_mib(
@@ -23,6 +23,7 @@ from localmodels import (
23
23
  deploy,
24
24
  deployment_lifecycle,
25
25
  hosts,
26
+ runtime_index,
26
27
  stack_hardware,
27
28
  stack_run,
28
29
  )
@@ -278,6 +279,7 @@ def _up(
278
279
  r["action"] != "failed" and deployment_lifecycle.healthy(r["state"], r["health"])
279
280
  for r in report.values()
280
281
  )
282
+ runtime_index.refresh()
281
283
  return {
282
284
  "schema": SCHEMA,
283
285
  "plan_id": plan["plan_id"],
@@ -26,6 +26,7 @@ from localmodels import (
26
26
  deployment_lifecycle,
27
27
  host_sensors,
28
28
  hosts,
29
+ library_state,
29
30
  metal,
30
31
  stack_lifecycle,
31
32
  stack_run,
@@ -104,6 +105,60 @@ def _rate(tokens: float, seconds: float) -> float | None:
104
105
  return tokens / seconds if seconds > 0 and tokens > 0 else None
105
106
 
106
107
 
108
+ def is_llm_task(task: str) -> bool:
109
+ """True for primary/fast stack LLMs and standalone loaded ``library`` model components."""
110
+ return task in ("llm", "llm_fast") or task.startswith("library:")
111
+
112
+
113
+ def discover_library_parts(
114
+ plan: StackPlan | None,
115
+ ) -> tuple[list[tuple[str, Plan]], dict[str, str]]:
116
+ """Discover standalone loaded ``library`` models under ``$LOCALMODELS_STATE/library/models``.
117
+
118
+ Deduplicates cleanly by deployment name and loopback port against ``stack_run.latest()`` so an
119
+ engine already represented in ``plan`` is never polled or rendered twice.
120
+ """
121
+ seen_names: set[str] = set()
122
+ seen_ports: set[int] = set()
123
+ has_primary_llm = plan is not None
124
+ if plan is not None:
125
+ for _, part in parts_of(plan):
126
+ if name := str(part.get("name") or ""):
127
+ seen_names.add(name)
128
+ port = _int(part["service"].get("port"))
129
+ if port > 0:
130
+ seen_ports.add(port)
131
+ found: list[tuple[str, Plan]] = []
132
+ lib_ids: dict[str, str] = {}
133
+ for rec in sorted(library_state.records(), key=lambda r: str(r.get("id") or "")):
134
+ if rec.get("state") != "loaded":
135
+ continue
136
+ lib_part = rec.get("plan")
137
+ if not isinstance(lib_part, dict):
138
+ continue
139
+ svc = lib_part.get("service")
140
+ if not isinstance(svc, dict):
141
+ continue
142
+ name = str(lib_part.get("name") or "")
143
+ port = _int(svc.get("port"))
144
+ if (name and name in seen_names) or (port > 0 and port in seen_ports):
145
+ continue
146
+ if name:
147
+ seen_names.add(name)
148
+ if port > 0:
149
+ seen_ports.add(port)
150
+ model_id = str(rec.get("id") or name)
151
+ if not has_primary_llm:
152
+ task = "llm"
153
+ has_primary_llm = True
154
+ else:
155
+ task = f"library:{model_id}"
156
+ found.append((task, lib_part))
157
+ if name:
158
+ lib_ids[name] = model_id
159
+ return found, lib_ids
160
+
161
+
107
162
  def _endpoint(part: Plan) -> str:
108
163
  base = part["endpoint"].get("base_url", "")
109
164
  return base.split("?", 1)[0].split("#", 1)[0]
@@ -177,7 +232,7 @@ def _perf(
177
232
  dec_rate = counters.get("predicted_tokens_seconds")
178
233
  perf["prefill_tok_s"] = _figure(pre_rate, "live", say("fig.prefill.live"))
179
234
  perf["decode_tok_s"] = _figure(dec_rate, "live", say("fig.decode.live"))
180
- if task in ("llm", "llm_fast"):
235
+ if is_llm_task(task):
181
236
  perf["decode_bound"] = _decode_estimate(hw, part)
182
237
  if perf["decode_tok_s"]["value"] is None:
183
238
  perf["decode_tok_s"] = _figure(None, "none", say("fig.decode.none"))
@@ -217,17 +272,29 @@ def _device(part: Plan, gpu: int | None) -> str:
217
272
  def _component(task: str, part: Plan, reading: Reading, ram: int) -> Component:
218
273
  launch = part["launch"]
219
274
  gpu = _gpu_of(part)
220
- parts = sum(llm_parts(part).values()) if task in ("llm", "llm_fast") else 0
221
- vram = (parts or _int(launch.get("vram_bytes"))) if gpu is not None else 0
222
- if gpu is None and task in ("llm", "llm_fast"):
223
- ram = ram or parts # an LLM off the GPU holds its weights and KV in host memory
275
+ llm_like = is_llm_task(task)
276
+ parts = sum(llm_parts(part).values()) if llm_like else 0
277
+ fallback_mem = _int(launch.get("vram_bytes")) or _int(launch.get("memory_estimate_bytes"))
278
+ vram = (parts or fallback_mem) if gpu is not None else 0
279
+ if gpu is None and llm_like:
280
+ ram = ram or parts or _int(launch.get("memory_estimate_bytes"))
224
281
  state, health = _state(reading["liveness"].get(part["name"]))
225
282
  kv = launch.get("kv_types")
226
283
  plan = reading["plan"]
227
284
  title = str(part["model"].get("display_name") or part["model"]["id"]).split("\uff08")[0]
228
- return {
285
+ role = (
286
+ say("role.llm")
287
+ if task.startswith("library:")
288
+ else (say(f"role.{task}") if task in TASKS else task)
289
+ )
290
+ explain = (
291
+ say("explain.llm")
292
+ if task.startswith("library:")
293
+ else (say(f"explain.{task}") if task in TASKS else "")
294
+ )
295
+ comp: Component = {
229
296
  "id": task,
230
- "role": say(f"role.{task}") if task in TASKS else task,
297
+ "role": role,
231
298
  "title": title.split(" (")[0] if task == "decision" else title,
232
299
  "model": part["model"]["model_id"],
233
300
  "quant": part["model"]["quant"],
@@ -248,9 +315,13 @@ def _component(task: str, part: Plan, reading: Reading, ram: int) -> Component:
248
315
  reading["counters"].get(part["name"]),
249
316
  reading["events"],
250
317
  ),
251
- "explain": say(f"explain.{task}") if task in TASKS else "",
318
+ "explain": explain,
252
319
  "live_slots": reading["slots"].get(part["name"]),
253
320
  }
321
+ lib_ids = reading.get("library_ids") or {}
322
+ if lib_id := lib_ids.get(part["name"]):
323
+ comp["library_id"] = lib_id
324
+ return comp
254
325
 
255
326
 
256
327
  def parts_of(plan: StackPlan) -> list[tuple[str, Plan]]:
@@ -278,13 +349,21 @@ def _segment(
278
349
  }
279
350
 
280
351
 
281
- def _shares(comp: Component, plan: StackPlan | None) -> list[Segment]:
282
- if comp["id"] == "llm" and plan is not None and (parts := llm_parts(plan["llm"])):
283
- return [
284
- _segment(k, say(f"part.{k}"), v, "estimate", "llm", say(f"note.{k}"))
285
- for k, v in parts.items()
286
- if v
287
- ]
352
+ def _shares(
353
+ comp: Component, plan: StackPlan | None, part_by_id: dict[str, Plan] | None = None
354
+ ) -> list[Segment]:
355
+ part = (
356
+ plan["llm"]
357
+ if comp["id"] == "llm" and plan is not None
358
+ else (part_by_id.get(comp["id"]) if part_by_id else None)
359
+ )
360
+ if (comp["id"] == "llm" or comp["id"].startswith("library:")) and part is not None:
361
+ if parts := llm_parts(part):
362
+ return [
363
+ _segment(k, say(f"part.{k}"), v, "estimate", comp["id"], say(f"note.{k}"))
364
+ for k, v in parts.items()
365
+ if v
366
+ ]
288
367
  size = comp["vram_bytes"] if comp["gpu"] is not None else comp["ram_bytes"]
289
368
  return [_segment(comp["id"], comp["role"], size, "estimate", comp["id"], comp["explain"])]
290
369
 
@@ -318,7 +397,13 @@ def _rest(
318
397
 
319
398
 
320
399
  def _gpu_view(
321
- card: dict[str, object], comps: list[Component], plan: StackPlan | None, basis: str
400
+ card: dict[str, object],
401
+ comps: list[Component],
402
+ plan: StackPlan | None,
403
+ basis: str,
404
+ *,
405
+ part_by_id: dict[str, Plan] | None = None,
406
+ gpu_load_row: GpuLoad | None = None,
322
407
  ) -> Gpu:
323
408
  index = _int(card.get("index"))
324
409
  total, used = _int(card.get("total_bytes")), _int(card.get("used_bytes"))
@@ -327,14 +412,14 @@ def _gpu_view(
327
412
  for comp in comps:
328
413
  if comp["gpu"] != index:
329
414
  continue
330
- for share in _shares(comp, plan):
415
+ for share in _shares(comp, plan, part_by_id):
331
416
  segments.append(share)
332
417
  ours += share["bytes"]
333
418
  running += share["bytes"] if comp["state"] == "serving" else 0
334
419
  holders = card.get("held_by")
335
420
  bandwidth = card.get("bandwidth_gb_s")
336
421
  reserve = AGENT_VRAM_RESERVE_BYTES if ours else 0
337
- return {
422
+ gpu_doc: Gpu = {
338
423
  "index": index,
339
424
  "name": str(card.get("name", "")),
340
425
  "total_bytes": total,
@@ -347,9 +432,20 @@ def _gpu_view(
347
432
  ],
348
433
  "segments": [*segments, *_rest(total, used, ours, running, reserve, basis)],
349
434
  }
435
+ spill = gpu_load_row.get("wddm_shared_spill_bytes") if gpu_load_row is not None else None
436
+ if isinstance(spill, int) and not isinstance(spill, bool) and spill >= 0:
437
+ gpu_doc["wddm_shared_spill_bytes"] = spill
438
+ return gpu_doc
350
439
 
351
440
 
352
- def _ram_view(hw: Hardware, comps: list[Component], plan: StackPlan | None, basis: str) -> Memory:
441
+ def _ram_view(
442
+ hw: Hardware,
443
+ comps: list[Component],
444
+ plan: StackPlan | None,
445
+ basis: str,
446
+ *,
447
+ part_by_id: dict[str, Plan] | None = None,
448
+ ) -> Memory:
353
449
  total, available = hw["ram_total_bytes"], hw["ram_available_bytes"]
354
450
  raw = plan["budget"].get("ram_parts") if plan else None
355
451
  parts = {k: _int(v) for k, v in raw.items()} if isinstance(raw, dict) else {}
@@ -358,9 +454,13 @@ def _ram_view(hw: Hardware, comps: list[Component], plan: StackPlan | None, basi
358
454
  order = [*TASKS, "harness"]
359
455
  segments: list[Segment] = []
360
456
  for comp in comps:
361
- if comp["id"] == "llm" and comp["gpu"] is None and comp["ram_bytes"]:
362
- segments += _shares(comp, plan)
363
- parts.pop("llm", None)
457
+ if (
458
+ (comp["id"] == "llm" or comp["id"].startswith("library:"))
459
+ and comp["gpu"] is None
460
+ and comp["ram_bytes"]
461
+ ):
462
+ segments += _shares(comp, plan, part_by_id)
463
+ parts.pop(comp["id"], None)
364
464
  for key, size in sorted(
365
465
  parts.items(), key=lambda kv: order.index(kv[0]) if kv[0] in order else 99
366
466
  ):
@@ -452,10 +552,12 @@ def render(reading: Reading) -> StackView:
452
552
  hw, plan, source = reading["hw"], reading["plan"], reading["source"]
453
553
  raw = plan["budget"].get("ram_parts") if plan else None
454
554
  ram_parts = raw if isinstance(raw, dict) else {}
455
- comps = [
456
- _component(task, part, reading, _int(ram_parts.get(task)))
457
- for task, part in (parts_of(plan) if plan else [])
555
+ all_parts = [
556
+ *(parts_of(plan) if plan else []),
557
+ *(reading.get("library_parts") or []),
458
558
  ]
559
+ part_by_id = dict(all_parts)
560
+ comps = [_component(task, part, reading, _int(ram_parts.get(task))) for task, part in all_parts]
459
561
  if source == "demo": # synthetic counters and gateway log: nothing in it is live
460
562
  for comp in comps:
461
563
  perf = cast(dict[str, object], comp["perf"])
@@ -463,11 +565,23 @@ def render(reading: Reading) -> StackView:
463
565
  if isinstance(figure, dict) and figure.get("basis") == "live":
464
566
  figure["basis"], figure["note"] = "demo", say("fig.demo")
465
567
  basis = "demo" if source == "demo" else "measured"
466
- gpus = [_gpu_view(cast(dict[str, object], c), comps, plan, basis) for c in hw["cards"]]
568
+ gpu_load_by_idx = {g["index"]: g for g in reading["gpu_load"]}
569
+ gpus = [
570
+ _gpu_view(
571
+ cast(dict[str, object], c),
572
+ comps,
573
+ plan,
574
+ basis,
575
+ part_by_id=part_by_id,
576
+ gpu_load_row=gpu_load_by_idx.get(_int(c.get("index"))),
577
+ )
578
+ for c in hw["cards"]
579
+ ]
467
580
  sensors = reading.get("sensors") or stack_view_telemetry.default_sensors(source)
468
581
  telemetry = stack_view_telemetry.summary(reading, comps, gpus, sensors)
469
582
  gateway: Gateway | None = None
470
- notes = [] if plan else [say("notes.empty")]
583
+ has_work = plan is not None or bool(all_parts)
584
+ notes = [] if has_work else [say("notes.empty")]
471
585
  if source == "demo":
472
586
  notes.insert(0, say("notes.demo"))
473
587
  notes += stack_view_events.alerts(comps)
@@ -475,7 +589,7 @@ def render(reading: Reading) -> StackView:
475
589
  "schema": SCHEMA,
476
590
  "schema_version": SCHEMA_VERSION,
477
591
  "generated_at": reading["generated_at"],
478
- "source": source if plan or source == "demo" else "empty",
592
+ "source": source if has_work or source == "demo" else "empty",
479
593
  "lang": "en",
480
594
  "plan_id": plan["plan_id"] if plan else None,
481
595
  "host": _host(hw),
@@ -483,12 +597,12 @@ def render(reading: Reading) -> StackView:
483
597
  "clients": _clients(plan, reading["owned"]),
484
598
  "components": comps,
485
599
  "gpus": gpus,
486
- "ram": _ram_view(hw, comps, plan, basis),
600
+ "ram": _ram_view(hw, comps, plan, basis, part_by_id=part_by_id),
487
601
  "what_if": _what_if(plan, gpus, hw) if plan else None,
488
602
  "events": reading["events"], # every call the figures counted, so the page agrees
489
603
  "measured": measured_rows(comps, reading["measured"]),
490
604
  "notes": notes,
491
- "next_steps": [] if plan or source == "demo" else next_steps(),
605
+ "next_steps": [] if has_work or source == "demo" else next_steps(),
492
606
  "apply": running.rows(reading["apply"], plan) if plan else None,
493
607
  "gpu_load": reading["gpu_load"],
494
608
  "sensors": sensors,
@@ -500,6 +614,9 @@ def render(reading: Reading) -> StackView:
500
614
  "prefix_hit_pct": telemetry["prefix_hit_pct"],
501
615
  "requests_deferred": telemetry["requests_deferred"],
502
616
  "kv_cache_usage_ratio": telemetry["kv_cache_usage_ratio"],
617
+ "spec_decode_acceptance_pct": telemetry["spec_decode_acceptance_pct"],
618
+ "expert_cache_hit_pct": telemetry["expert_cache_hit_pct"],
619
+ "pcie_share_pct": telemetry["pcie_share_pct"],
503
620
  "in_flight": telemetry["in_flight"],
504
621
  "client_lanes": telemetry["client_lanes"],
505
622
  }
@@ -521,8 +638,10 @@ def reading(
521
638
  slots: dict[str, list[Slot]] | None = None,
522
639
  sensors: HostSensors | None = None,
523
640
  waterfall: list[WaterfallEntry] | None = None,
641
+ library_parts: list[tuple[str, Plan]] | None = None,
642
+ library_ids: dict[str, str] | None = None,
524
643
  ) -> Reading:
525
- return {
644
+ doc: Reading = {
526
645
  "hw": hw,
527
646
  "plan": plan,
528
647
  "liveness": liveness or {},
@@ -538,6 +657,11 @@ def reading(
538
657
  "sensors": sensors,
539
658
  "waterfall": waterfall or [],
540
659
  }
660
+ if library_parts:
661
+ doc["library_parts"] = library_parts
662
+ if library_ids:
663
+ doc["library_ids"] = library_ids
664
+ return doc
541
665
 
542
666
 
543
667
  def build(hw: Hardware, plan: StackPlan | None, **found: Any) -> StackView:
@@ -559,9 +683,10 @@ def read_hardware() -> Hardware:
559
683
 
560
684
 
561
685
  def read_live(hw: Hardware | None = None) -> Reading:
562
- """This computer now: the latest applied plan, each of its services' state and counters,
563
- and the gateway's recent calls."""
686
+ """This computer now: the latest applied plan plus standalone loaded ``library`` models,
687
+ each service's live state, counters, and slots."""
564
688
  _, plan = stack_run.latest()
689
+ lib_parts, lib_ids = discover_library_parts(plan)
565
690
  hw = hw or read_hardware()
566
691
  liveness: dict[str, tuple[str, str]] = {}
567
692
  counters: dict[str, Counters] = {}
@@ -576,12 +701,30 @@ def read_live(hw: Hardware | None = None) -> Reading:
576
701
  live[task] = part # measured below: what it holds beside what the plan priced
577
702
  if found := read_metrics(part):
578
703
  counters[part["name"]] = found
579
- if task in ("llm", "llm_fast") and (ctx := stack_view_slots.read(part)) is not None:
704
+ if is_llm_task(task) and (ctx := stack_view_slots.read(part)) is not None:
580
705
  slots[part["name"]] = ctx
706
+ for task, part in lib_parts:
707
+ name = part["name"]
708
+ state_pair = stack_lifecycle.liveness(part)
709
+ found = None
710
+ if deployment_lifecycle.healthy(*state_pair):
711
+ liveness[name] = state_pair
712
+ found = read_metrics(part)
713
+ else:
714
+ # Standalone library servers may answer authenticated loopback /metrics even when a
715
+ # host service-manager receipt (e.g. systemd unit) is unavailable or managed externally.
716
+ found = read_metrics(part)
717
+ liveness[name] = ("active", "ok") if found is not None else state_pair
718
+ if deployment_lifecycle.healthy(*liveness[name]):
719
+ live[task] = part
720
+ if found is not None:
721
+ counters[name] = found
722
+ if is_llm_task(task) and (ctx := stack_view_slots.read(part)) is not None:
723
+ slots[name] = ctx
581
724
  events: list[Event] = []
582
725
  wf: list[WaterfallEntry] = []
583
726
  held = measure(live, any(_gpu_of(p) is not None for p in live.values()))
584
- sensors, _ = host_sensors.collect(liveness=liveness)
727
+ sensors, _ = host_sensors.collect(liveness=liveness or None)
585
728
  return reading(
586
729
  hw,
587
730
  plan,
@@ -595,6 +738,8 @@ def read_live(hw: Hardware | None = None) -> Reading:
595
738
  slots=slots,
596
739
  sensors=sensors,
597
740
  waterfall=wf,
741
+ library_parts=lib_parts,
742
+ library_ids=lib_ids,
598
743
  )
599
744
 
600
745
 
@@ -308,7 +308,7 @@ def add_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]) ->
308
308
  cli_help.document(
309
309
  agent,
310
310
  "Optional add-on for a view hub: reads this stack like `stack view` and sends the same "
311
- "document. Changes nothing in the stack, Bifrost, Magpie or the clients.",
311
+ "document. Changes nothing in the stack or its clients.",
312
312
  examples=[
313
313
  ("%(prog)s install --hub http://hub:18491 --token TOKEN", ""),
314
314
  ("%(prog)s status", "exit 0 when running and the last report was accepted"),
@@ -233,6 +233,7 @@ def slots(seconds: float) -> list[Slot]:
233
233
  return [
234
234
  {
235
235
  "id": 0,
236
+ "id_task": int(seconds // TURN_S) + 1,
236
237
  "n_ctx": 131072,
237
238
  "busy": busy,
238
239
  "phase": slot0_phase,
@@ -248,6 +249,7 @@ def slots(seconds: float) -> list[Slot]:
248
249
  },
249
250
  {
250
251
  "id": 1,
252
+ "id_task": 0,
251
253
  "n_ctx": 131072,
252
254
  "busy": False,
253
255
  "phase": "idle",
@@ -12,12 +12,15 @@ from __future__ import annotations
12
12
  import shutil
13
13
  import subprocess
14
14
  import sys
15
+ import time
15
16
  from typing import TypedDict
16
17
 
17
18
  from localmodels import nvml_ctypes
18
19
 
19
20
  COLUMNS = "index,utilization.gpu,power.draw,power.limit,temperature.gpu,utilization.memory"
20
21
  TIMEOUT_S = 2.0
22
+ _WDDM_CACHE_TTL_S = 5.0
23
+ _WDDM_CACHE: tuple[float, int | None] | None = None
21
24
 
22
25
 
23
26
  class _GpuLoadOptional(TypedDict, total=False):
@@ -25,6 +28,7 @@ class _GpuLoadOptional(TypedDict, total=False):
25
28
  vram_total_bytes: int | None
26
29
  vram_used_bytes: int | None
27
30
  vram_free_bytes: int | None
31
+ wddm_shared_spill_bytes: int | None
28
32
  source: str # nvml | nvidia-smi | apple_sensors | demo
29
33
 
30
34
 
@@ -134,14 +138,44 @@ def _read_apple() -> list[GpuLoad]:
134
138
  ]
135
139
 
136
140
 
141
+ def reset_wddm_cache() -> None:
142
+ """Clear the Windows WDDM shared-spill TTL cache (for tests)."""
143
+ global _WDDM_CACHE
144
+ _WDDM_CACHE = None
145
+
146
+
147
+ def _read_wddm_shared_spill_bytes() -> int | None:
148
+ global _WDDM_CACHE
149
+ if sys.platform != "win32":
150
+ return None
151
+ now = time.monotonic()
152
+ if _WDDM_CACHE is not None and (now - _WDDM_CACHE[0]) < _WDDM_CACHE_TTL_S:
153
+ return _WDDM_CACHE[1]
154
+ from localmodels import win_probe
155
+
156
+ spill = win_probe.wddm_shared_spill_bytes()
157
+ _WDDM_CACHE = (now, spill)
158
+ return spill
159
+
160
+
161
+ def _attach_wddm_spill(rows: list[GpuLoad]) -> list[GpuLoad]:
162
+ if not rows or sys.platform != "win32":
163
+ return rows
164
+ spill = _read_wddm_shared_spill_bytes()
165
+ if spill is not None:
166
+ for row in rows:
167
+ row["wddm_shared_spill_bytes"] = spill
168
+ return rows
169
+
170
+
137
171
  def read() -> list[GpuLoad]:
138
172
  """Read live per-GPU load: NVML ctypes -> nvidia-smi fallback -> macOS Apple sensors."""
139
173
  nvml_rows = _read_nvml()
140
174
  if nvml_rows is not None:
141
- return nvml_rows
175
+ return _attach_wddm_spill(nvml_rows)
142
176
  smi_rows = _read_nvidia_smi()
143
177
  if smi_rows:
144
- return smi_rows
178
+ return _attach_wddm_spill(smi_rows)
145
179
  if sys.platform == "darwin":
146
180
  return _read_apple()
147
181
  return []