@simplexai/localmodels-darwin-arm64 0.1.0-dev.32.build.git9f03dd7a81cec1338df8eaf613ec9e3013365c9c → 0.1.0-dev.36

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 (143) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +141 -99
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +4 -0
  5. package/modules/localmodels/app.py +7 -2
  6. package/modules/localmodels/approval.py +4 -4
  7. package/modules/localmodels/bifrost_checks.py +121 -3
  8. package/modules/localmodels/bifrost_provider.py +53 -0
  9. package/modules/localmodels/bifrost_unit.py +32 -1
  10. package/modules/localmodels/budget.py +7 -1
  11. package/modules/localmodels/catalog.json +286 -12
  12. package/modules/localmodels/catalog.py +30 -29
  13. package/modules/localmodels/catalog_add.py +1 -0
  14. package/modules/localmodels/cli_parser.py +10 -2
  15. package/modules/localmodels/component.py +7 -1
  16. package/modules/localmodels/decode_calibration.json +6 -0
  17. package/modules/localmodels/decode_calibration.py +104 -0
  18. package/modules/localmodels/deploy.py +44 -7
  19. package/modules/localmodels/deploy_steps.py +10 -1
  20. package/modules/localmodels/engines-strata-0.1.49.2.json +31 -0
  21. package/modules/localmodels/engines-strata-0.1.59.1.json +31 -0
  22. package/modules/localmodels/engines.json +57 -1
  23. package/modules/localmodels/engines.py +6 -2
  24. package/modules/localmodels/estimator.py +21 -7
  25. package/modules/localmodels/frontend.py +4 -4
  26. package/modules/localmodels/gateway.py +14 -4
  27. package/modules/localmodels/gateway_app_bifrost.py +4 -3
  28. package/modules/localmodels/gateway_bifrost.py +70 -57
  29. package/modules/localmodels/gateway_probe.py +3 -4
  30. package/modules/localmodels/gguf.py +7 -0
  31. package/modules/localmodels/harness.py +24 -25
  32. package/modules/localmodels/harness_gateway.py +19 -10
  33. package/modules/localmodels/harness_probe.py +33 -6
  34. package/modules/localmodels/hosts.py +73 -9
  35. package/modules/localmodels/install.py +36 -6
  36. package/modules/localmodels/library_cli.py +179 -0
  37. package/modules/localmodels/library_convert.py +132 -0
  38. package/modules/localmodels/library_gateway.py +471 -0
  39. package/modules/localmodels/library_jobs.py +314 -0
  40. package/modules/localmodels/library_model.py +246 -0
  41. package/modules/localmodels/library_pricing.py +347 -0
  42. package/modules/localmodels/library_serve.py +348 -0
  43. package/modules/localmodels/library_state.py +373 -0
  44. package/modules/localmodels/library_status.py +349 -0
  45. package/modules/localmodels/llm_rank.py +77 -8
  46. package/modules/localmodels/memcalc.py +7 -30
  47. package/modules/localmodels/metal.py +26 -0
  48. package/modules/localmodels/metal_probe.py +11 -7
  49. package/modules/localmodels/plan_envelope.py +4 -1
  50. package/modules/localmodels/preparation.py +49 -0
  51. package/modules/localmodels/probe.py +8 -8
  52. package/modules/localmodels/process_identity.py +536 -9
  53. package/modules/localmodels/quant_formats.py +123 -0
  54. package/modules/localmodels/recommend.py +32 -3
  55. package/modules/localmodels/recommend_cli.py +8 -4
  56. package/modules/localmodels/records.py +1 -0
  57. package/modules/localmodels/remote_ops.py +104 -6
  58. package/modules/localmodels/remote_ops_download.py +17 -2
  59. package/modules/localmodels/remote_ops_prepare.py +425 -0
  60. package/modules/localmodels/remote_ops_remove.py +40 -7
  61. package/modules/localmodels/remote_ops_service.py +110 -8
  62. package/modules/localmodels/remote_ops_verify.py +15 -2
  63. package/modules/localmodels/runtime_auth.py +31 -1
  64. package/modules/localmodels/runtime_cli.py +3 -4
  65. package/modules/localmodels/runtime_io.py +50 -6
  66. package/modules/localmodels/service_autostart.py +45 -1
  67. package/modules/localmodels/service_control.py +13 -0
  68. package/modules/localmodels/service_deployment.py +12 -3
  69. package/modules/localmodels/service_jobs.py +33 -4
  70. package/modules/localmodels/service_probe.py +67 -13
  71. package/modules/localmodels/service_stop.py +152 -0
  72. package/modules/localmodels/service_worker.py +9 -1
  73. package/modules/localmodels/services_cli.py +50 -6
  74. package/modules/localmodels/setup_inspection.py +34 -25
  75. package/modules/localmodels/setup_text.py +118 -0
  76. package/modules/localmodels/sizecalc.py +625 -0
  77. package/modules/localmodels/sizecalc_cli.py +249 -0
  78. package/modules/localmodels/stack.py +69 -17
  79. package/modules/localmodels/stack_args.py +91 -19
  80. package/modules/localmodels/stack_auto.py +78 -0
  81. package/modules/localmodels/stack_binding.py +23 -35
  82. package/modules/localmodels/stack_card.py +195 -0
  83. package/modules/localmodels/stack_cleanup.py +379 -0
  84. package/modules/localmodels/stack_clients.py +4 -1
  85. package/modules/localmodels/stack_compose.py +173 -206
  86. package/modules/localmodels/stack_console.py +2 -0
  87. package/modules/localmodels/stack_decision.py +3 -2
  88. package/modules/localmodels/stack_down.py +189 -0
  89. package/modules/localmodels/stack_events.py +54 -0
  90. package/modules/localmodels/stack_hardware.py +30 -34
  91. package/modules/localmodels/stack_journal.py +29 -8
  92. package/modules/localmodels/stack_ledger.py +411 -0
  93. package/modules/localmodels/stack_lifecycle.py +162 -167
  94. package/modules/localmodels/stack_llm_ram.py +57 -5
  95. package/modules/localmodels/stack_memory.py +721 -0
  96. package/modules/localmodels/stack_picks.py +147 -0
  97. package/modules/localmodels/stack_plan.py +143 -25
  98. package/modules/localmodels/stack_ports.py +22 -0
  99. package/modules/localmodels/stack_preflight.py +699 -0
  100. package/modules/localmodels/stack_review.py +123 -5
  101. package/modules/localmodels/stack_rollback.py +2 -0
  102. package/modules/localmodels/stack_route.py +256 -0
  103. package/modules/localmodels/stack_run.py +11 -0
  104. package/modules/localmodels/stack_suite.py +107 -20
  105. package/modules/localmodels/stack_summary.py +65 -4
  106. package/modules/localmodels/stack_try.py +354 -0
  107. package/modules/localmodels/stack_try_client.py +194 -0
  108. package/modules/localmodels/stack_try_docs.py +139 -0
  109. package/modules/localmodels/stack_up.py +8 -1
  110. package/modules/localmodels/stack_update.py +29 -4
  111. package/modules/localmodels/stack_verify.py +3 -1
  112. package/modules/localmodels/stack_view.py +10 -11
  113. package/modules/localmodels/stack_view_apply.py +4 -2
  114. package/modules/localmodels/stack_view_events.py +2 -1
  115. package/modules/localmodels/stack_view_serve.py +3 -0
  116. package/modules/localmodels/stack_view_text.py +1 -1
  117. package/modules/localmodels/stack_view_words.py +4 -1
  118. package/modules/localmodels/stack_warm.py +574 -0
  119. package/modules/localmodels/stack_whatif.py +558 -0
  120. package/modules/localmodels/suite.py +48 -39
  121. package/modules/localmodels/tool_archive.py +40 -0
  122. package/modules/localmodels/tools.json +8 -0
  123. package/modules/localmodels/transport.py +1 -0
  124. package/modules/localmodels/vision.py +8 -1
  125. package/modules/localmodels/web/sizecalc/app.js +431 -0
  126. package/modules/localmodels/web/sizecalc/calc.js +269 -0
  127. package/modules/localmodels/web/sizecalc/page.html +362 -0
  128. package/modules/localmodels/web/view/ASSET-SOURCES.md +11 -0
  129. package/modules/localmodels/web/view/i18n.js +1 -1
  130. package/modules/localmodels/web/view/logo-claude.svg +3 -0
  131. package/modules/localmodels/web/view/logo-codex.png +0 -0
  132. package/modules/localmodels/web/view/logo-pi.svg +6 -0
  133. package/modules/localmodels/web/view/view.css +4 -0
  134. package/modules/localmodels/web/view/view.js +15 -6
  135. package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/METADATA +1 -1
  136. package/modules/simplex_localmodels-0.1.0.dev36.dist-info/RECORD +242 -0
  137. package/package.json +1 -1
  138. package/tool.json +1 -1
  139. package/modules/simplex_localmodels-0.1.0.dev32.dist-info/RECORD +0 -200
  140. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/WHEEL +0 -0
  141. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/entry_points.txt +0 -0
  142. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/licenses/NOTICE +0 -0
  143. /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -0,0 +1,189 @@
1
+ """``stack down``: stop the stack's processes without uninstalling it, the counterpart of ``up``.
2
+
3
+ It stops the gateway this tool started, then every deployment a ``stack apply`` under this
4
+ state directory deployed, each only through its own receipt or unit (``remote_ops`` refuses
5
+ anything else). Units stay enabled and nothing is deleted or forgotten: ``stack up`` starts
6
+ the same stack again. An uninstaller calls it before replacing or deleting the files.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+ import sys
14
+ from collections.abc import Callable
15
+ from typing import Literal, TypedDict
16
+
17
+ from localmodels import console, deploy, gateway, gateway_bifrost, harness, harness_gateway, hosts
18
+ from localmodels import stack_lifecycle as lifecycle
19
+ from localmodels.contracts import decode
20
+ from localmodels.stack_plan import StackError, StackPlan, platform_error
21
+
22
+ SCHEMA: Literal["localmodels.stack-down/v1"] = "localmodels.stack-down/v1"
23
+ Out = Callable[[str], None]
24
+ DOWN = ("inactive", "failed", "dead") # service states with no process to stop
25
+
26
+
27
+ class Part(TypedDict):
28
+ name: str
29
+ task: str
30
+ action: Literal["stopped", "not-running", "failed"]
31
+ detail: str
32
+
33
+
34
+ class DownReport(TypedDict):
35
+ schema: Literal["localmodels.stack-down/v1"]
36
+ ok: bool
37
+ parts: list[Part]
38
+ gateway: str # stopped | not-running | none | kept: why | failed: why
39
+ gateway_kind: str # Bifrost | Magpie | none
40
+ notes: list[str]
41
+
42
+
43
+ def _latest() -> StackPlan | None:
44
+ """The newest stack plan saved under this state directory, accepted or not."""
45
+ for _, saved in reversed(hosts.stack_runs()):
46
+ try:
47
+ return decode(saved, StackPlan)
48
+ except ValueError:
49
+ continue
50
+ return None
51
+
52
+
53
+ def _bifrost(record: hosts.OwnedBifrost) -> str:
54
+ try:
55
+ return gateway_bifrost.pause(record)
56
+ except harness.HarnessError as exc:
57
+ return f"failed: {exc}"
58
+
59
+
60
+ def _magpie(doc: hosts.Owned, plan: StackPlan, notes: list[str]) -> str:
61
+ started = doc["gateway"]["started"]
62
+ if started == "daemon":
63
+ notes.append("the global magpie.service is not proven to be this tool's; left running")
64
+ return "kept: global magpie.service"
65
+ if started != "serve":
66
+ return "none"
67
+ magpie = gateway.magpie_binary(doc)
68
+ tools_dir = plan["harness"]["tools_dir"]
69
+ target = harness_gateway.magpie_target(tools_dir) or plan["harness"]
70
+ if magpie is None:
71
+ return "failed: the Magpie binary this tool installed is missing"
72
+ check = gateway.stop_gateway(magpie, "serve", tools_dir, plan=target, forget=False)
73
+ if not check["ok"]:
74
+ return f"failed: {check['detail']}"
75
+ return "stopped" if check["detail"] == "magpie serve stopped" else "not-running"
76
+
77
+
78
+ def _gateway(plan: StackPlan | None, notes: list[str]) -> tuple[str, str]:
79
+ if plan is None:
80
+ doc = hosts.load_owned()
81
+ if doc["gateway"].get("bifrost") or doc["gateway"]["started"]:
82
+ return "failed: saved stack plan unavailable; gateway left untouched", "unknown"
83
+ return "none", "none"
84
+ doc = hosts.load_owned(plan["harness"]["tools_dir"])
85
+ record = doc["gateway"].get("bifrost")
86
+ results: list[tuple[str, str]] = []
87
+ if record:
88
+ results.append((_bifrost(record), "Bifrost"))
89
+ if doc["gateway"]["started"]:
90
+ results.append((_magpie(doc, plan, notes), "Magpie"))
91
+ for prefix in ("failed", "stopped", "kept", "not-running"):
92
+ found = next((r for r in results if r[0].startswith(prefix)), None)
93
+ if found:
94
+ return found
95
+ return "none", "none"
96
+
97
+
98
+ def down(out: Out = print) -> DownReport:
99
+ if sys.platform != "darwin" and (error := platform_error(sys.platform)):
100
+ raise StackError(error)
101
+ try:
102
+ with hosts.stack_apply_lock():
103
+ return _down(out)
104
+ except hosts.LockedError as exc:
105
+ raise StackError("another stack apply is running") from exc
106
+
107
+
108
+ def _down(out: Out) -> DownReport:
109
+ members = lifecycle.stack_members()
110
+ records = [r for r in hosts.records(hosts.LOCAL_ID) if r["plan"]["name"] in members]
111
+ notes: list[str] = []
112
+ # The gateway first: it routes to the services, as up starts it after them.
113
+ gate, kind = _gateway(_latest() if members else None, notes)
114
+ if gate.startswith("failed"):
115
+ out(f"✗ gateway {gate}")
116
+ parts: list[Part] = []
117
+ for record in records:
118
+ plan = record["plan"]
119
+ row: Part = {
120
+ "name": plan["name"],
121
+ "task": plan["endpoint"].get("contract", "chat"),
122
+ "action": "not-running",
123
+ "detail": "",
124
+ }
125
+ state, _ = lifecycle.liveness(plan)
126
+ if state not in DOWN:
127
+ executor = hosts.executor(hosts.get_device(hosts.LOCAL_ID))
128
+ event = deploy.service_action(executor, plan, "stop")
129
+ state, _ = lifecycle.liveness(plan)
130
+ failed = event.get("event") == "error" or state not in DOWN
131
+ row["action"] = "failed" if failed else "stopped"
132
+ row["detail"] = (
133
+ str(event.get("message") or f"service is still {state} after stop")[-300:]
134
+ if failed
135
+ else ""
136
+ )
137
+ out(
138
+ f"{'✗' if failed else '…'} {plan['name']} {'failed to stop' if failed else 'stopped'}"
139
+ )
140
+ parts.append(row)
141
+ return {
142
+ "schema": SCHEMA,
143
+ "ok": not gate.startswith("failed") and all(p["action"] != "failed" for p in parts),
144
+ "parts": parts,
145
+ "gateway": gate,
146
+ "gateway_kind": kind,
147
+ "notes": notes,
148
+ }
149
+
150
+
151
+ def print_report(report: DownReport, out: Out = print) -> int:
152
+ t = console.term(sys.stdout)
153
+ for row in report["parts"]:
154
+ mark = t.mark("fail" if row["action"] == "failed" else "ok")
155
+ did = {"stopped": "stopped", "not-running": "was not running", "failed": "failed to stop"}
156
+ out(
157
+ f"{mark} {row['name']} {row['task']} {did[row['action']]}"
158
+ + (f": {row['detail']}" if row["detail"] else "")
159
+ )
160
+ gate = report["gateway"]
161
+ if gate != "none":
162
+ out(
163
+ f"{t.mark('fail' if gate.startswith('failed') else 'ok')} {report['gateway_kind']} gateway {gate}"
164
+ )
165
+ for note in report["notes"]:
166
+ out(f"note {note}")
167
+ if not report["parts"] and gate == "none":
168
+ out("No stack processes of this tool under this state directory")
169
+ if report["ok"]:
170
+ out(t.paint("The stack is stopped; `stack up` starts it again", "green", "bold"))
171
+ return 0
172
+ out(t.paint("Some processes did not stop", "red", "bold"))
173
+ return 1
174
+
175
+
176
+ def cli(args: argparse.Namespace) -> int:
177
+ report = down(out=(lambda _m: None) if args.json else print)
178
+ if args.json:
179
+ print(json.dumps(report, ensure_ascii=False, indent=1))
180
+ return 0 if report["ok"] else 1
181
+ return print_report(report)
182
+
183
+
184
+ def add_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
185
+ p = actions.add_parser(
186
+ "down",
187
+ help="stop the stack's services and the gateway this tool started; nothing is removed",
188
+ )
189
+ p.add_argument("--json", action="store_true", help="print one result as JSON")
@@ -9,6 +9,7 @@ MAX_SAFE_INTEGER = 9_007_199_254_740_991
9
9
  MAX_EVENT_CHARS = 65_536
10
10
  STACK_PLAN_SECTIONS = (
11
11
  "llm",
12
+ "llm_fast",
12
13
  "decision",
13
14
  "decision_front",
14
15
  "deferred_services",
@@ -18,10 +19,22 @@ STACK_PLAN_SECTIONS = (
18
19
  "budget",
19
20
  "options",
20
21
  )
22
+ APPLY_ORDER = (
23
+ "decision",
24
+ "llm",
25
+ "llm_fast",
26
+ "embedding",
27
+ "rerank",
28
+ "stt",
29
+ "tts",
30
+ "search",
31
+ "gateway",
32
+ )
21
33
  COMPONENTS = frozenset(
22
34
  {
23
35
  "tools",
24
36
  "llm",
37
+ "llm_fast",
25
38
  "decision",
26
39
  "embedding",
27
40
  "rerank",
@@ -38,6 +51,7 @@ PHASES = frozenset({"download", "verify", "loading"})
38
51
 
39
52
  SOURCES = frozenset({"huggingface", "modelscope", "custom"})
40
53
  MAX_CONNECTIONS = 64
54
+ MAX_FILES = 4096
41
55
 
42
56
 
43
57
  class _ProgressEvent(TypedDict):
@@ -56,6 +70,16 @@ class ProgressEvent(_ProgressEvent, total=False):
56
70
  bytes_per_second: int
57
71
  source: str
58
72
  connections: int
73
+ # Optional on phase download (since 2026-11-13). ``done``/``total`` count the current file;
74
+ # a component's step of several files (an engine's archives, a model's weights and
75
+ # projector) also names the file (1-based, of file_count) and counts the component's bytes
76
+ # across all of them: on disk, finished files included (component_done), and in all.
77
+ # eta_seconds is the component's (else the file's) remaining bytes at the current rate.
78
+ file_index: int
79
+ file_count: int
80
+ component_done: int
81
+ component_total: int
82
+ eta_seconds: int
59
83
 
60
84
 
61
85
  class _PublicProgress(TypedDict):
@@ -71,6 +95,11 @@ class PublicProgress(_PublicProgress, total=False):
71
95
  bytes_per_second: int # the optional download fields of ProgressEvent
72
96
  source: str
73
97
  connections: int
98
+ file_index: int
99
+ file_count: int
100
+ component_done: int
101
+ component_total: int
102
+ eta_seconds: int
74
103
 
75
104
 
76
105
  @runtime_checkable
@@ -145,6 +174,31 @@ def _download_fields(safe: ProgressEvent | PublicProgress, event: dict[str, obje
145
174
  safe["source"] = source
146
175
  if type(connections) is int and 1 <= connections <= MAX_CONNECTIONS:
147
176
  safe["connections"] = connections
177
+ index, count = event.get("file_index"), event.get("file_count")
178
+ component_done, component_total = event.get("component_done"), event.get("component_total")
179
+ done, total = safe["done"], safe["total"]
180
+ if (
181
+ type(index) is int
182
+ and type(count) is int
183
+ and type(component_done) is int
184
+ and type(component_total) is int
185
+ and done is not None
186
+ and total is not None
187
+ and 1 <= index <= count <= MAX_FILES
188
+ and done <= component_done <= component_total <= MAX_SAFE_INTEGER
189
+ and total <= component_total
190
+ and component_total - component_done >= total - done
191
+ ):
192
+ safe["file_index"], safe["file_count"] = index, count
193
+ safe["component_done"], safe["component_total"] = component_done, component_total
194
+ rate = safe.get("bytes_per_second")
195
+ if rate and done is not None and total is not None:
196
+ left = (
197
+ safe["component_total"] - safe["component_done"]
198
+ if "component_total" in safe
199
+ else total - done
200
+ )
201
+ safe["eta_seconds"] = -(-left // rate)
148
202
 
149
203
 
150
204
  class Output:
@@ -1,15 +1,8 @@
1
- """What ``stack`` reads from this computer's hardware, and what it can install on each card.
2
-
3
- ``stack hardware`` prints it read-only: per NVIDIA card the model, architecture, memory (total,
4
- used, free, driver-reserved) and the share an agent-posture LLM may take, the card model's spec
5
- bandwidth, who holds the card, and the validated LLMs that pass the agent gate there; then host
6
- RAM, disk and the hardware tier. A Mac shows its Metal GPU as card 0 (metal.device): the working
7
- set and the part of the unified memory available now, priced once; ``--unified-memory`` reads
8
- it as a smaller Mac. The card budgets are the ones ``stack plan --llm auto`` ranks
9
- with (stack_compose uses ``cards`` and ``llm_budget`` from here), so with default options
10
- (``--decision none``, two slots) the listing and the plan agree. Every figure but the probe's readings is an estimate; spec bandwidths come from
11
- gpu_specs and are not measurements. ``snapshot`` is the short copy a stack plan keeps so its
12
- summary can show what it was priced against; approving the plan does not bind it.
1
+ """Read-only hardware readings, card budgets and automatic llama.cpp candidates.
2
+
3
+ ``stack plan`` uses the same card budgets, plus whole-stack RAM and disk checks for Strata.
4
+ A Mac shares unified memory; ``--unified-memory`` prices it as a smaller Mac.
5
+ Only probe readings are measurements. ``snapshot`` preserves them without binding approval.
13
6
  """
14
7
 
15
8
  from __future__ import annotations
@@ -32,6 +25,9 @@ from localmodels.estimator import (
32
25
  )
33
26
  from localmodels.probe import GPU, HostFacts
34
27
  from localmodels.records import Plan
28
+ from localmodels.stack_picks import label as fit_label
29
+ from localmodels.stack_picks import lines as pick_lines
30
+ from localmodels.stack_picks import picks
35
31
  from localmodels.stack_plan import (
36
32
  Card,
37
33
  DecisionChoice,
@@ -281,11 +277,8 @@ def llm_budget(
281
277
  entry: cat.CatalogEntry | None = None,
282
278
  posture: AgentPosture = AGENT,
283
279
  ) -> tuple[HardwareBudget, int]:
284
- """(what an agent-posture LLM may use on card ``index`` now, the decision reserve held
285
- back): free memory less the agent safety and display reserves and the smallest decision tier the card's
286
- auto budget keeps. It carries the card's spec bandwidth for the speed estimate. On a Mac
287
- the free memory also holds the entry's host embeddings and prompt-cache floor.
288
- Without an entry this reports a generic hardware budget."""
280
+ """Live agent budget and minimum decision reserve; deduct safety and display reserves.
281
+ On a Mac also reserve embeddings and the cache floor; carry bandwidth for speed estimates."""
289
282
  gpu = device(facts, index)
290
283
  on_mac = gpu["uuid"] == metal.METAL_UUID
291
284
  reserve = decision_reserve(component.auto_budget(gpu["total_bytes"]), options)
@@ -324,16 +317,19 @@ def llm_fits(
324
317
  ):
325
318
  variant = entry.variants[-1]
326
319
  budget, _ = llm_budget(facts, index, options, entry=entry, posture=posture)
327
- if llm_rank.agent_ready(entry, variant, budget, posture):
320
+ if llm_rank.automatic_fit(entry, facts, budget, posture, options):
328
321
  speed = cat.decode_estimate(entry, variant, budget)
329
322
  fit: LlmFit = {
330
323
  "id": entry.id,
331
324
  "quant": variant.quant,
332
- "quality": entry.quality,
325
+ "quality": 0 if llm_rank.windows_fallback(entry, facts) else entry.quality,
333
326
  "decode_tok_s": round(speed.tok_s, 1),
334
327
  "decode_basis": speed.basis,
335
328
  }
329
+ if llm_rank.windows_fallback(entry, facts):
330
+ fit["candidate_fallback"] = True
336
331
  found.append((llm_rank.rank_key(entry, variant, budget), fit))
332
+ found = [row for row in found if not row[1].get("candidate_fallback")] or found
337
333
  default_id = llm_rank.listed_default(facts, [(f["id"], f["quality"]) for _, f in found])
338
334
  return [
339
335
  fit
@@ -462,7 +458,13 @@ def view(facts: HostFacts, options: StackOptions, posture: AgentPosture | None)
462
458
  )
463
459
  if part
464
460
  )
465
- notes = []
461
+ notes = (
462
+ [
463
+ "per-card LLM lists cover llama.cpp; stack plan also checks Strata's whole-stack RAM and disk"
464
+ ]
465
+ if posture is not None and facts["platform"] == "linux"
466
+ else []
467
+ )
466
468
  if error := platform_error(facts["platform"], options.get("profile"), facts["arch"]):
467
469
  notes.append(error)
468
470
  if options.get("profile") != "macos-mlx-preview" and (error := metal.problem(facts)):
@@ -522,6 +524,8 @@ def view(facts: HostFacts, options: StackOptions, posture: AgentPosture | None)
522
524
  card["llm"], card["auto"] = [], False
523
525
  if manager := facts.get("service_manager"):
524
526
  seen["service_manager"] = manager
527
+ if posture is not None:
528
+ seen["picks"] = picks(seen["cards"], llm_rank.mac_default(facts))
525
529
  return seen
526
530
 
527
531
 
@@ -605,14 +609,11 @@ def lines(hw: Hardware, command: str) -> list[str]:
605
609
  )
606
610
  if c["held_by"]:
607
611
  out.append(" held by: " + "; ".join(c["held_by"]))
608
- fits = [
609
- f"{f['id']} {f['quant']} (agent quality {f['quality']}, estimated decode ceiling "
610
- f"{f['decode_tok_s']:g} tok/s)"
611
- for f in c["llm"][:3]
612
- ]
612
+ fits = [fit_label(f) for f in c["llm"][:3]]
613
613
  shown = f"top 3 of {len(c['llm'])}" if len(c["llm"]) > 3 else f"{len(fits)} in all"
614
614
  out.append(
615
- f" LLMs that fit (agent posture, validated, {shown}): " + ", ".join(fits)
615
+ f" llama.cpp LLMs that fit (agent posture, automatic eligibility, {shown}): "
616
+ + ", ".join(fits)
616
617
  if fits
617
618
  else " LLMs that fit: no validated LLM fits this card in the agent posture"
618
619
  )
@@ -627,7 +628,7 @@ def lines(hw: Hardware, command: str) -> list[str]:
627
628
  slow = [f for f in c["llm"][:1] if f["decode_tok_s"] < cat.PLEASANT_FLOOR_TOK_S]
628
629
  if slow:
629
630
  out.append(
630
- " note: the first choice's estimated decode ceiling is below the "
631
+ " note: the first choice's estimated decode is below the "
631
632
  f"pleasant floor of {cat.PLEASANT_FLOOR_TOK_S:g} tok/s"
632
633
  )
633
634
  out.append(
@@ -638,6 +639,8 @@ def lines(hw: Hardware, command: str) -> list[str]:
638
639
  f" disk {hw['disk_path']}: {gib(free) if free is not None else 'unknown'} free"
639
640
  )
640
641
  out.append(f" tier {hw['tier']}")
642
+ refused = platform_error(hw.get("platform", "linux"), arch=hw.get("arch"))
643
+ out += pick_lines(hw.get("picks") or [], None if refused else command)
641
644
  out += [f" note {n}" for n in hw["notes"]]
642
645
  mac = any(c.get("uuid") == metal.METAL_UUID for c in hw["cards"])
643
646
  out.append(
@@ -741,10 +744,3 @@ def agent_label(llm: Plan) -> str:
741
744
  kv = launch.get("kv_types")
742
745
  pair = [str(t) for t in kv] if isinstance(kv, list) else ["q8_0", "q8_0"]
743
746
  return f"{launch.get('slots')} parallel sessions sharing the KV ({'/'.join(pair)}), "
744
-
745
-
746
- def conversation_cache(value: str) -> str:
747
- value = value.strip().lower()
748
- if value in ("auto", "off") or (value.isdigit() and int(value) > 0):
749
- return value
750
- raise argparse.ArgumentTypeError("auto, off, or a positive whole number of MiB, e.g. 4096")
@@ -26,10 +26,20 @@ from typing import TypedDict
26
26
 
27
27
  from localmodels import hosts
28
28
  from localmodels.plan_envelope import utc_now
29
- from localmodels.stack_events import ProgressEvent
29
+ from localmodels.stack_events import ProgressEvent, validate_progress
30
30
 
31
31
  SCHEMA = "localmodels.stack-apply-progress/v1"
32
32
  EVERY_S = 0.5
33
+ OPTIONAL = (
34
+ "bytes_per_second",
35
+ "source",
36
+ "connections",
37
+ "file_index",
38
+ "file_count",
39
+ "component_done",
40
+ "component_total",
41
+ "eta_seconds",
42
+ )
33
43
 
34
44
 
35
45
  class _Counter(TypedDict):
@@ -44,6 +54,11 @@ class Counter(_Counter, total=False):
44
54
  bytes_per_second: int # download only: rate, source label and parallel connections
45
55
  source: str
46
56
  connections: int
57
+ file_index: int # download only: file i of n, the component's bytes, the time left
58
+ file_count: int
59
+ component_done: int
60
+ component_total: int
61
+ eta_seconds: int
47
62
 
48
63
 
49
64
  class Snapshot(TypedDict):
@@ -114,12 +129,9 @@ class Journal:
114
129
  "total": event["total"],
115
130
  "at": utc_now(),
116
131
  }
117
- if "bytes_per_second" in event:
118
- row["bytes_per_second"] = event["bytes_per_second"]
119
- if "source" in event:
120
- row["source"] = event["source"]
121
- if "connections" in event:
122
- row["connections"] = event["connections"]
132
+ for key in OPTIONAL:
133
+ if key in event:
134
+ row[key] = event[key] # type: ignore[literal-required]
123
135
  rows[event["component"]] = row
124
136
  moved = before is None or (before["step"], before["phase"]) != (
125
137
  event["step"],
@@ -160,13 +172,22 @@ def _counters(raw: object) -> dict[str, Counter]:
160
172
  continue
161
173
  done, total = row.get("done"), row.get("total")
162
174
  if type(done) is int and type(total) is int and 0 <= done <= total:
163
- found[str(name)] = {
175
+ counter: Counter = {
164
176
  "step": str(row.get("step", "")),
165
177
  "phase": str(row.get("phase", "")),
166
178
  "done": done,
167
179
  "total": total,
168
180
  "at": str(row.get("at", "")),
169
181
  }
182
+ safe = validate_progress(
183
+ str(name),
184
+ counter["step"],
185
+ {**row, "event": "progress", "bytes_per_s": row.get("bytes_per_second")},
186
+ )
187
+ for key in OPTIONAL:
188
+ if safe is not None and key in safe:
189
+ counter[key] = safe[key] # type: ignore[literal-required]
190
+ found[str(name)] = counter
170
191
  return found
171
192
 
172
193