@simplexai/localmodels-darwin-x64 0.1.0-dev.104 → 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 (81) hide show
  1. package/README.md +1 -1
  2. package/bootstrap.identity +1 -1
  3. package/bootstrap.sha256 +80 -78
  4. package/modules/localmodels/__init__.py +1 -1
  5. package/modules/localmodels/__main__.py +204 -86
  6. package/modules/localmodels/apple_sensors.py +23 -0
  7. package/modules/localmodels/approval.py +25 -2
  8. package/modules/localmodels/catalog.json +454 -31
  9. package/modules/localmodels/catalog.py +11 -0
  10. package/modules/localmodels/catalog_recipes.py +61 -3
  11. package/modules/localmodels/cli_help.py +10 -0
  12. package/modules/localmodels/cli_parser.py +313 -230
  13. package/modules/localmodels/component.py +20 -2
  14. package/modules/localmodels/custom_probe.py +4 -2
  15. package/modules/localmodels/deploy.py +11 -1
  16. package/modules/localmodels/engine_adapters/suite_plan.py +21 -21
  17. package/modules/localmodels/host_sensors.py +25 -2
  18. package/modules/localmodels/hosts.py +26 -5
  19. package/modules/localmodels/library_cli.py +34 -16
  20. package/modules/localmodels/library_custom.py +9 -1
  21. package/modules/localmodels/library_direct.py +41 -1
  22. package/modules/localmodels/library_jobs.py +23 -4
  23. package/modules/localmodels/library_model.py +146 -1
  24. package/modules/localmodels/library_order.py +175 -69
  25. package/modules/localmodels/library_poly.py +42 -11
  26. package/modules/localmodels/library_presentation.py +485 -0
  27. package/modules/localmodels/library_pricing.py +3 -1
  28. package/modules/localmodels/library_serve.py +208 -3
  29. package/modules/localmodels/library_state.py +47 -10
  30. package/modules/localmodels/library_status.py +29 -16
  31. package/modules/localmodels/llm_rank.py +9 -3
  32. package/modules/localmodels/plan_envelope.py +11 -2
  33. package/modules/localmodels/probe.py +34 -7
  34. package/modules/localmodels/quant_formats.py +9 -2
  35. package/modules/localmodels/records.py +19 -2
  36. package/modules/localmodels/remote_ops_verify.py +91 -24
  37. package/modules/localmodels/runtime_index.py +303 -0
  38. package/modules/localmodels/setup_inspection.py +22 -3
  39. package/modules/localmodels/speech_cli.py +20 -14
  40. package/modules/localmodels/speech_serve.py +9 -2
  41. package/modules/localmodels/speech_server.py +3 -0
  42. package/modules/localmodels/stack_args.py +270 -139
  43. package/modules/localmodels/stack_auto.py +90 -5
  44. package/modules/localmodels/stack_cli.py +117 -116
  45. package/modules/localmodels/stack_compose.py +5 -1
  46. package/modules/localmodels/stack_debug.py +14 -4
  47. package/modules/localmodels/stack_down.py +2 -0
  48. package/modules/localmodels/stack_hardware.py +14 -12
  49. package/modules/localmodels/stack_mlx.py +8 -1
  50. package/modules/localmodels/stack_picks.py +19 -20
  51. package/modules/localmodels/stack_plan.py +3 -2
  52. package/modules/localmodels/stack_review.py +28 -7
  53. package/modules/localmodels/stack_suite.py +11 -9
  54. package/modules/localmodels/stack_up.py +2 -0
  55. package/modules/localmodels/stack_view.py +180 -35
  56. package/modules/localmodels/stack_view_demo.py +2 -0
  57. package/modules/localmodels/stack_view_gpu.py +36 -2
  58. package/modules/localmodels/stack_view_schema.py +26 -3
  59. package/modules/localmodels/stack_view_slots.py +3 -1
  60. package/modules/localmodels/stack_view_telemetry.py +90 -4
  61. package/modules/localmodels/stack_view_tick.py +246 -40
  62. package/modules/localmodels/stack_view_words.py +7 -0
  63. package/modules/localmodels/stack_whatif_html.py +9 -12
  64. package/modules/localmodels/suite.py +129 -2
  65. package/modules/localmodels/telemetry_math.py +458 -18
  66. package/modules/localmodels/transport.py +8 -1
  67. package/modules/localmodels/tts_cli.py +24 -20
  68. package/modules/localmodels/tts_serve.py +9 -2
  69. package/modules/localmodels/tts_sidecar.py +3 -0
  70. package/modules/localmodels/web/whatif/app.js +1 -1
  71. package/modules/localmodels/web/whatif/sim.js +8 -14
  72. package/modules/localmodels/win_probe.py +89 -16
  73. package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/METADATA +1 -1
  74. package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +76 -74
  75. package/package.json +1 -1
  76. package/tool.json +1 -1
  77. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
  78. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
  79. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/LICENSE +0 -0
  80. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/NOTICE +0 -0
  81. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -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
 
@@ -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 []
@@ -8,6 +8,7 @@ from localmodels import hosts
8
8
  from localmodels import stack_journal as journal
9
9
  from localmodels import stack_view_apply as running
10
10
  from localmodels.host_sensors import HostSensors
11
+ from localmodels.records import Plan
11
12
  from localmodels.stack_plan import Hardware, StackPlan, command
12
13
  from localmodels.stack_view_events import Event
13
14
  from localmodels.stack_view_gpu import GpuLoad
@@ -46,7 +47,11 @@ class Fit(TypedDict):
46
47
  decode_tok_s: float | None # the planner's calibrated decode estimate, None when unavailable
47
48
 
48
49
 
49
- class Gpu(TypedDict):
50
+ class _GpuV11(TypedDict, total=False):
51
+ wddm_shared_spill_bytes: int | None
52
+
53
+
54
+ class Gpu(_GpuV11):
50
55
  index: int
51
56
  name: str
52
57
  total_bytes: int
@@ -68,6 +73,15 @@ class _CountersV11(TypedDict, total=False):
68
73
  kv_cache_usage_ratio: float | None
69
74
  prompt_tokens_seconds: float | None
70
75
  predicted_tokens_seconds: float | None
76
+ prompt_tokens_cached: float | None
77
+ n_tokens_max: float | None
78
+ n_busy_slots_per_decode: float | None
79
+ spec_decode_drafts: float | None
80
+ spec_decode_draft_tokens: float | None
81
+ spec_decode_accepted_tokens: float | None
82
+ spec_decode_acceptance_pct: float | None
83
+ expert_cache_hit_pct: float | None
84
+ pcie_share_pct: float | None
71
85
 
72
86
 
73
87
  class Counters(_CountersV11):
@@ -91,8 +105,12 @@ class Perf(TypedDict):
91
105
  counters: Counters | None
92
106
 
93
107
 
94
- class Component(TypedDict):
95
- id: str # llm | decision | embedding | rerank | stt | tts
108
+ class _ComponentV11(TypedDict, total=False):
109
+ library_id: str
110
+
111
+
112
+ class Component(_ComponentV11):
113
+ id: str # llm | decision | embedding | rerank | stt | tts | library:<model_id>
96
114
  role: str
97
115
  title: str
98
116
  model: str
@@ -182,6 +200,9 @@ class _StackViewV11(TypedDict, total=False):
182
200
  prefix_hit_pct: Figure
183
201
  requests_deferred: Figure
184
202
  kv_cache_usage_ratio: Figure
203
+ spec_decode_acceptance_pct: Figure
204
+ expert_cache_hit_pct: Figure
205
+ pcie_share_pct: Figure
185
206
  in_flight: int
186
207
  client_lanes: dict[str, int]
187
208
 
@@ -210,6 +231,8 @@ class StackView(_StackViewV11):
210
231
  class _ReadingV11(TypedDict, total=False):
211
232
  sensors: HostSensors | None
212
233
  waterfall: list[WaterfallEntry]
234
+ library_parts: list[tuple[str, Plan]]
235
+ library_ids: dict[str, str]
213
236
 
214
237
 
215
238
  class Reading(_ReadingV11):
@@ -29,6 +29,7 @@ PHASES = ("idle", "prefill", "decoding", "queued")
29
29
 
30
30
  class Slot(TypedDict):
31
31
  id: int
32
+ id_task: int | None # llama-server task id for two-frame delta keying (slot.id, id_task)
32
33
  n_ctx: int | None
33
34
  busy: bool
34
35
  phase: str # idle | prefill | decoding | queued
@@ -39,7 +40,7 @@ class Slot(TypedDict):
39
40
  n_prompt: int | None # v1.1 alias for prompt_tokens
40
41
  cached_prefix_tokens: int | None # v1.1 alias for cached
41
42
  n_decoded: int | None # v1.1 alias for decoded
42
- tok_s: float | None # live decode speed for this slot when emitted
43
+ tok_s: float | None # live decode speed for this slot when emitted or derived via delta
43
44
  ttft_ms: float | None # live prefill/TTFT milliseconds for this slot when emitted
44
45
 
45
46
 
@@ -139,6 +140,7 @@ def parse(text: str) -> list[Slot] | None:
139
140
  found.append(
140
141
  {
141
142
  "id": int(row["id"]),
143
+ "id_task": _count(row.get("id_task")),
142
144
  "n_ctx": _count(row.get("n_ctx")),
143
145
  "busy": busy,
144
146
  "phase": _phase(