@simplexai/localmodels-win32-x64 0.1.0-dev.106 → 0.1.0-dev.108
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.
- package/README.md +1 -1
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +64 -61
- package/modules/localmodels/__init__.py +2 -5
- package/modules/localmodels/catalog.json +317 -111
- package/modules/localmodels/catalog.py +13 -4
- package/modules/localmodels/catalog_recipes.py +16 -1
- package/modules/localmodels/context_policy.py +3 -4
- package/modules/localmodels/engine_adapters/__init__.py +1 -2
- package/modules/localmodels/engine_adapters/llama_cpp.py +11 -5
- package/modules/localmodels/engine_adapters/strata_poly.py +1 -1
- package/modules/localmodels/engines-b11583.json +4 -4
- package/modules/localmodels/engines-b12973.json +248 -0
- package/modules/localmodels/engines-prism-b12178-03ec600.json +7 -7
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.1.json +1 -1
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.9.json +5 -2
- package/modules/localmodels/engines-whisper-b5454.json +5 -5
- package/modules/localmodels/engines.json +4 -4
- package/modules/localmodels/estimator.py +0 -1
- package/modules/localmodels/gguf.py +0 -1
- package/modules/localmodels/library_cli.py +68 -1
- package/modules/localmodels/library_elastic.py +1 -1
- package/modules/localmodels/library_order.py +2 -2
- package/modules/localmodels/library_poly.py +1 -1
- package/modules/localmodels/library_pricing.py +1 -2
- package/modules/localmodels/library_unload.py +274 -0
- package/modules/localmodels/llm_rank.py +5 -5
- package/modules/localmodels/metal.py +5 -5
- package/modules/localmodels/planning/__init__.py +1 -2
- package/modules/localmodels/planning/budget.py +1 -1
- package/modules/localmodels/probe.py +98 -7
- package/modules/localmodels/remote_ops_download.py +32 -7
- package/modules/localmodels/remote_ops_ranges.py +1 -1
- package/modules/localmodels/remote_ops_remove.py +1 -1
- package/modules/localmodels/remote_ops_verify.py +1 -1
- package/modules/localmodels/runtime-lock.json +1 -1
- package/modules/localmodels/service_deployment.py +1 -1
- package/modules/localmodels/service_roots.py +148 -0
- package/modules/localmodels/service_upgrade.py +46 -1
- package/modules/localmodels/services_cli.py +8 -28
- package/modules/localmodels/speech_workers.py +4 -4
- package/modules/localmodels/stack_args.py +11 -4
- package/modules/localmodels/stack_auto.py +3 -3
- package/modules/localmodels/stack_cleanup.py +3 -3
- package/modules/localmodels/stack_compose.py +6 -7
- package/modules/localmodels/stack_down.py +368 -42
- package/modules/localmodels/stack_memory.py +1 -1
- package/modules/localmodels/stack_plan.py +5 -5
- package/modules/localmodels/stack_preflight.py +2 -2
- package/modules/localmodels/stack_suite.py +2 -2
- package/modules/localmodels/stack_view_hub_cli.py +1 -1
- package/modules/localmodels/stack_view_llm.py +2 -2
- package/modules/localmodels/suite.py +1 -1
- package/modules/localmodels/tts_backend_speechcpp.py +2 -2
- package/modules/localmodels/tts_workers.py +3 -3
- package/modules/localmodels/vision.py +2 -2
- package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/RECORD +60 -57
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/licenses/LICENSE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev106.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"""``stack down``: stop the stack's processes without uninstalling it, the counterpart of ``up``.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Default ``stack down`` stops every deployment a ``stack apply`` under this state directory
|
|
4
|
+
deployed (plus recorded voice sidecars), each only through its own receipt or unit
|
|
5
|
+
(``remote_ops`` refuses anything else). Units stay enabled and nothing is deleted or forgotten:
|
|
6
|
+
``stack up`` starts the same stack again.
|
|
7
|
+
|
|
8
|
+
``stack down --all`` performs a single-call full shutdown across every localmodels-managed
|
|
9
|
+
subsystem under this state directory: foundations controllers (stopped first so they cannot
|
|
10
|
+
respawn services), stack members, library-loaded LLMs and active library jobs, voice sidecars
|
|
11
|
+
(speech/TTS), and optional foundation model deployments, finishing with a synchronous
|
|
12
|
+
``runtime-index.json`` refresh.
|
|
6
13
|
"""
|
|
7
14
|
|
|
8
15
|
from __future__ import annotations
|
|
@@ -10,7 +17,8 @@ from __future__ import annotations
|
|
|
10
17
|
import argparse
|
|
11
18
|
import json
|
|
12
19
|
import sys
|
|
13
|
-
from collections.abc import Callable
|
|
20
|
+
from collections.abc import Callable, Sequence
|
|
21
|
+
from pathlib import Path
|
|
14
22
|
from typing import Literal, TypedDict
|
|
15
23
|
|
|
16
24
|
from localmodels import (
|
|
@@ -23,9 +31,11 @@ from localmodels import (
|
|
|
23
31
|
tts_state,
|
|
24
32
|
)
|
|
25
33
|
from localmodels import stack_lifecycle as lifecycle
|
|
34
|
+
from localmodels.records import FinishedRecord
|
|
26
35
|
from localmodels.stack_plan import StackError, platform_error
|
|
27
36
|
|
|
28
37
|
SCHEMA: Literal["localmodels.stack-down/v1"] = "localmodels.stack-down/v1"
|
|
38
|
+
FOUNDATION_CONTRACTS = frozenset({"systemone", "health", "embedding", "rerank"})
|
|
29
39
|
Out = Callable[[str], None]
|
|
30
40
|
|
|
31
41
|
|
|
@@ -43,50 +53,86 @@ class DownReport(TypedDict):
|
|
|
43
53
|
notes: list[str]
|
|
44
54
|
|
|
45
55
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
with hosts.stack_apply_lock():
|
|
51
|
-
return _down(out)
|
|
52
|
-
except hosts.LockedError as exc:
|
|
53
|
-
raise StackError("another stack apply is running") from exc
|
|
56
|
+
class SubsystemError(TypedDict):
|
|
57
|
+
name: str
|
|
58
|
+
code: str
|
|
59
|
+
detail: str
|
|
54
60
|
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
class SubsystemSummary(TypedDict):
|
|
63
|
+
stopped: list[str]
|
|
64
|
+
skipped: list[str]
|
|
65
|
+
errors: list[SubsystemError]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class SubsystemsSummary(TypedDict):
|
|
69
|
+
stack: SubsystemSummary
|
|
70
|
+
library: SubsystemSummary
|
|
71
|
+
sidecars: SubsystemSummary
|
|
72
|
+
foundations: SubsystemSummary
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class DownAllReport(DownReport):
|
|
76
|
+
scope: Literal["all"]
|
|
77
|
+
subsystems: SubsystemsSummary
|
|
78
|
+
runtime_index_refreshed: bool
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _empty_subsystem() -> SubsystemSummary:
|
|
82
|
+
return {"stopped": [], "skipped": [], "errors": []}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _stop_deployment_record(record: FinishedRecord, out: Out) -> Part:
|
|
86
|
+
plan = record["plan"]
|
|
87
|
+
row: Part = {
|
|
88
|
+
"name": plan["name"],
|
|
89
|
+
"task": plan["endpoint"].get("contract", "chat"),
|
|
90
|
+
"action": "not-running",
|
|
91
|
+
"detail": "",
|
|
92
|
+
}
|
|
93
|
+
state, _ = lifecycle.liveness(plan)
|
|
94
|
+
if deployment_lifecycle.needs_stop(state):
|
|
95
|
+
executor = hosts.executor(hosts.get_device(hosts.LOCAL_ID))
|
|
96
|
+
event = deploy.service_action(executor, plan, "stop")
|
|
97
|
+
state, _ = lifecycle.liveness(plan)
|
|
98
|
+
did_fail = event.get("event") == "error" or deployment_lifecycle.needs_stop(state)
|
|
99
|
+
row["action"] = "failed" if did_fail else "stopped"
|
|
100
|
+
row["detail"] = (
|
|
101
|
+
str(event.get("message") or f"service is still {state} after stop")[-300:]
|
|
102
|
+
if did_fail
|
|
103
|
+
else ""
|
|
104
|
+
)
|
|
105
|
+
out(
|
|
106
|
+
f"{'✗' if did_fail else '…'} {plan['name']} "
|
|
107
|
+
f"{'failed to stop' if did_fail else 'stopped'}"
|
|
108
|
+
)
|
|
109
|
+
return row
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _stop_deployment_isolated(record: FinishedRecord, out: Out) -> Part:
|
|
113
|
+
plan = record["plan"]
|
|
114
|
+
try:
|
|
115
|
+
return _stop_deployment_record(record, out)
|
|
116
|
+
except (OSError, RuntimeError, ValueError) as exc:
|
|
117
|
+
detail = (str(exc) or type(exc).__name__)[-300:]
|
|
118
|
+
out(f"✗ {plan['name']} failed to stop")
|
|
119
|
+
return {
|
|
64
120
|
"name": plan["name"],
|
|
65
121
|
"task": plan["endpoint"].get("contract", "chat"),
|
|
66
|
-
"action": "
|
|
67
|
-
"detail":
|
|
122
|
+
"action": "failed",
|
|
123
|
+
"detail": detail,
|
|
68
124
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
event = deploy.service_action(executor, plan, "stop")
|
|
73
|
-
state, _ = lifecycle.liveness(plan)
|
|
74
|
-
failed = event.get("event") == "error" or deployment_lifecycle.needs_stop(state)
|
|
75
|
-
row["action"] = "failed" if failed else "stopped"
|
|
76
|
-
row["detail"] = (
|
|
77
|
-
str(event.get("message") or f"service is still {state} after stop")[-300:]
|
|
78
|
-
if failed
|
|
79
|
-
else ""
|
|
80
|
-
)
|
|
81
|
-
out(
|
|
82
|
-
f"{'✗' if failed else '…'} {plan['name']} {'failed to stop' if failed else 'stopped'}"
|
|
83
|
-
)
|
|
84
|
-
parts.append(row)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _stop_sidecars(parts: list[Part], summary: SubsystemSummary | None, out: Out) -> None:
|
|
85
128
|
for sidecar_name, task_name, stop_fn in (
|
|
86
129
|
("speech-sidecar", "stt", speech_state.stop_sidecar_if_recorded),
|
|
87
130
|
("tts-sidecar", "tts", tts_state.stop_sidecar_if_recorded),
|
|
88
131
|
):
|
|
89
|
-
|
|
132
|
+
try:
|
|
133
|
+
action, detail = stop_fn()
|
|
134
|
+
except (OSError, RuntimeError, ValueError) as exc:
|
|
135
|
+
action, detail = "failed", (str(exc) or type(exc).__name__)[-300:]
|
|
90
136
|
if action == "stopped" or action == "failed":
|
|
91
137
|
parts.append(
|
|
92
138
|
{
|
|
@@ -100,6 +146,202 @@ def _down(out: Out) -> DownReport:
|
|
|
100
146
|
f"{'✗' if action == 'failed' else '…'} {sidecar_name} "
|
|
101
147
|
f"{'failed to stop' if action == 'failed' else 'stopped'}"
|
|
102
148
|
)
|
|
149
|
+
if summary is None:
|
|
150
|
+
continue
|
|
151
|
+
if action == "stopped":
|
|
152
|
+
summary["stopped"].append(sidecar_name)
|
|
153
|
+
elif action == "not-running":
|
|
154
|
+
summary["skipped"].append(sidecar_name)
|
|
155
|
+
elif action == "failed":
|
|
156
|
+
summary["errors"].append(
|
|
157
|
+
{"name": sidecar_name, "code": "SIDECAR_STOP_FAILED", "detail": detail}
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _controller_label(root: Path, total: int) -> str:
|
|
162
|
+
if total <= 1:
|
|
163
|
+
return "foundations-controller"
|
|
164
|
+
from localmodels import service_autostart
|
|
165
|
+
|
|
166
|
+
return f"foundations-controller:{service_autostart.unit_name(root)[-12:]}"
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _stop_foundations_controllers(
|
|
170
|
+
foundations_roots: Sequence[Path],
|
|
171
|
+
parts: list[Part],
|
|
172
|
+
summary: SubsystemSummary,
|
|
173
|
+
out: Out,
|
|
174
|
+
) -> None:
|
|
175
|
+
from localmodels import service_roots, service_upgrade
|
|
176
|
+
|
|
177
|
+
try:
|
|
178
|
+
discovered = service_roots.discover_roots(hosts.state_dir(), foundations_roots)
|
|
179
|
+
except (OSError, ValueError) as exc:
|
|
180
|
+
detail = (str(exc) or type(exc).__name__)[-300:]
|
|
181
|
+
parts.append(
|
|
182
|
+
{
|
|
183
|
+
"name": "foundations-controller",
|
|
184
|
+
"task": "foundations",
|
|
185
|
+
"action": "failed",
|
|
186
|
+
"detail": detail,
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
summary["errors"].append(
|
|
190
|
+
{
|
|
191
|
+
"name": "foundations-controller",
|
|
192
|
+
"code": "CONTROLLER_DISCOVERY_FAILED",
|
|
193
|
+
"detail": detail,
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
out("✗ foundations-controller failed to stop")
|
|
197
|
+
return
|
|
198
|
+
|
|
199
|
+
for root, _is_explicit in discovered:
|
|
200
|
+
label = _controller_label(root, len(discovered))
|
|
201
|
+
try:
|
|
202
|
+
result = service_upgrade.stop_controller(root)
|
|
203
|
+
except (OSError, RuntimeError, ValueError) as exc:
|
|
204
|
+
detail = (str(exc) or type(exc).__name__)[-300:]
|
|
205
|
+
parts.append(
|
|
206
|
+
{"name": label, "task": "foundations", "action": "failed", "detail": detail}
|
|
207
|
+
)
|
|
208
|
+
summary["errors"].append(
|
|
209
|
+
{"name": label, "code": "CONTROLLER_STOP_FAILED", "detail": detail}
|
|
210
|
+
)
|
|
211
|
+
out(f"✗ {label} failed to stop")
|
|
212
|
+
continue
|
|
213
|
+
if result.get("ok", True) is False:
|
|
214
|
+
detail = str(result.get("error") or "controller failed to stop")[-300:]
|
|
215
|
+
code = str(result.get("code") or "CONTROLLER_STOP_FAILED")
|
|
216
|
+
parts.append(
|
|
217
|
+
{"name": label, "task": "foundations", "action": "failed", "detail": detail}
|
|
218
|
+
)
|
|
219
|
+
summary["errors"].append({"name": label, "code": code, "detail": detail})
|
|
220
|
+
out(f"✗ {label} failed to stop")
|
|
221
|
+
elif result.get("stopped"):
|
|
222
|
+
parts.append({"name": label, "task": "foundations", "action": "stopped", "detail": ""})
|
|
223
|
+
summary["stopped"].append(label)
|
|
224
|
+
out(f"… {label} stopped")
|
|
225
|
+
else:
|
|
226
|
+
summary["skipped"].append(label)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _stop_stack_members(
|
|
230
|
+
all_records: Sequence[FinishedRecord],
|
|
231
|
+
parts: list[Part],
|
|
232
|
+
summary: SubsystemSummary,
|
|
233
|
+
out: Out,
|
|
234
|
+
) -> set[str]:
|
|
235
|
+
members = lifecycle.stack_members()
|
|
236
|
+
handled: set[str] = set()
|
|
237
|
+
for record in all_records:
|
|
238
|
+
name = record["plan"]["name"]
|
|
239
|
+
if name not in members:
|
|
240
|
+
continue
|
|
241
|
+
handled.add(name)
|
|
242
|
+
row = _stop_deployment_isolated(record, out)
|
|
243
|
+
parts.append(row)
|
|
244
|
+
if row["action"] == "stopped":
|
|
245
|
+
summary["stopped"].append(name)
|
|
246
|
+
elif row["action"] == "not-running":
|
|
247
|
+
summary["skipped"].append(name)
|
|
248
|
+
else:
|
|
249
|
+
summary["errors"].append({"name": name, "code": "STOP_FAILED", "detail": row["detail"]})
|
|
250
|
+
return handled
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def _stop_library_models(parts: list[Part], summary: SubsystemSummary, out: Out) -> set[str]:
|
|
254
|
+
from localmodels import library_state, library_unload
|
|
255
|
+
|
|
256
|
+
deployment_names: set[str] = set()
|
|
257
|
+
try:
|
|
258
|
+
for rec in library_state.records():
|
|
259
|
+
if plan_name := rec["plan"].get("name"):
|
|
260
|
+
deployment_names.add(plan_name)
|
|
261
|
+
if (baseline := rec.get("baseline_plan")) is not None and (
|
|
262
|
+
base_name := baseline.get("name")
|
|
263
|
+
):
|
|
264
|
+
deployment_names.add(base_name)
|
|
265
|
+
except (OSError, ValueError):
|
|
266
|
+
pass
|
|
267
|
+
|
|
268
|
+
try:
|
|
269
|
+
report = library_unload.unload_all()
|
|
270
|
+
except (OSError, RuntimeError, ValueError) as exc:
|
|
271
|
+
detail = (str(exc) or type(exc).__name__)[-300:]
|
|
272
|
+
parts.append({"name": "library", "task": "library", "action": "failed", "detail": detail})
|
|
273
|
+
summary["errors"].append(
|
|
274
|
+
{"name": "library", "code": "LIBRARY_UNLOAD_FAILED", "detail": detail}
|
|
275
|
+
)
|
|
276
|
+
out("✗ library failed to stop")
|
|
277
|
+
return deployment_names
|
|
278
|
+
|
|
279
|
+
for item in report["unloaded"]:
|
|
280
|
+
detail = f"cancelled {item['previous_state']} job" if item["action"] == "cancelled" else ""
|
|
281
|
+
parts.append({"name": item["id"], "task": "library", "action": "stopped", "detail": detail})
|
|
282
|
+
summary["stopped"].append(item["id"])
|
|
283
|
+
out(f"… {item['id']} {item['action']}")
|
|
284
|
+
for skip in report["skipped"]:
|
|
285
|
+
summary["skipped"].append(skip["id"])
|
|
286
|
+
for err in report["errors"]:
|
|
287
|
+
parts.append(
|
|
288
|
+
{"name": err["id"], "task": "library", "action": "failed", "detail": err["detail"]}
|
|
289
|
+
)
|
|
290
|
+
summary["errors"].append({"name": err["id"], "code": err["code"], "detail": err["detail"]})
|
|
291
|
+
out(f"✗ {err['id']} failed to stop")
|
|
292
|
+
return deployment_names
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def _stop_foundation_deployments(
|
|
296
|
+
handled: set[str],
|
|
297
|
+
parts: list[Part],
|
|
298
|
+
summary: SubsystemSummary,
|
|
299
|
+
out: Out,
|
|
300
|
+
) -> None:
|
|
301
|
+
for record in hosts.records(hosts.LOCAL_ID):
|
|
302
|
+
plan = record["plan"]
|
|
303
|
+
name = plan["name"]
|
|
304
|
+
if name in handled:
|
|
305
|
+
continue
|
|
306
|
+
if plan["endpoint"].get("contract") not in FOUNDATION_CONTRACTS:
|
|
307
|
+
continue
|
|
308
|
+
row = _stop_deployment_isolated(record, out)
|
|
309
|
+
parts.append(row)
|
|
310
|
+
if row["action"] == "stopped":
|
|
311
|
+
summary["stopped"].append(name)
|
|
312
|
+
elif row["action"] == "not-running":
|
|
313
|
+
summary["skipped"].append(name)
|
|
314
|
+
else:
|
|
315
|
+
summary["errors"].append({"name": name, "code": "STOP_FAILED", "detail": row["detail"]})
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def down(out: Out = print) -> DownReport:
|
|
319
|
+
if sys.platform != "darwin" and (error := platform_error(sys.platform)):
|
|
320
|
+
raise StackError(error)
|
|
321
|
+
try:
|
|
322
|
+
with hosts.stack_apply_lock():
|
|
323
|
+
return _down(out)
|
|
324
|
+
except hosts.LockedError as exc:
|
|
325
|
+
raise StackError("another stack apply is running") from exc
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def down_all(out: Out = print, *, foundations_roots: Sequence[Path] = ()) -> DownAllReport:
|
|
329
|
+
"""Stop stack members, library models/jobs, voice sidecars, and foundations in one call."""
|
|
330
|
+
if sys.platform != "darwin" and (error := platform_error(sys.platform)):
|
|
331
|
+
raise StackError(error)
|
|
332
|
+
try:
|
|
333
|
+
with hosts.stack_apply_lock():
|
|
334
|
+
return _down_all(out, foundations_roots=foundations_roots)
|
|
335
|
+
except hosts.LockedError as exc:
|
|
336
|
+
raise StackError("another stack apply is running") from exc
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def _down(out: Out) -> DownReport:
|
|
340
|
+
members = lifecycle.stack_members()
|
|
341
|
+
records = [r for r in hosts.records(hosts.LOCAL_ID) if r["plan"]["name"] in members]
|
|
342
|
+
notes: list[str] = []
|
|
343
|
+
parts: list[Part] = [_stop_deployment_record(record, out) for record in records]
|
|
344
|
+
_stop_sidecars(parts, None, out)
|
|
103
345
|
runtime_index.refresh()
|
|
104
346
|
return {
|
|
105
347
|
"schema": SCHEMA,
|
|
@@ -109,8 +351,47 @@ def _down(out: Out) -> DownReport:
|
|
|
109
351
|
}
|
|
110
352
|
|
|
111
353
|
|
|
354
|
+
def _down_all(out: Out, *, foundations_roots: Sequence[Path] = ()) -> DownAllReport:
|
|
355
|
+
notes: list[str] = []
|
|
356
|
+
parts: list[Part] = []
|
|
357
|
+
subsystems: SubsystemsSummary = {
|
|
358
|
+
"stack": _empty_subsystem(),
|
|
359
|
+
"library": _empty_subsystem(),
|
|
360
|
+
"sidecars": _empty_subsystem(),
|
|
361
|
+
"foundations": _empty_subsystem(),
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
# Stop foundations controller(s) first so their scheduler cannot respawn stopped services.
|
|
365
|
+
_stop_foundations_controllers(foundations_roots, parts, subsystems["foundations"], out)
|
|
366
|
+
handled = _stop_stack_members(hosts.records(hosts.LOCAL_ID), parts, subsystems["stack"], out)
|
|
367
|
+
handled |= _stop_library_models(parts, subsystems["library"], out)
|
|
368
|
+
_stop_sidecars(parts, subsystems["sidecars"], out)
|
|
369
|
+
_stop_foundation_deployments(handled, parts, subsystems["foundations"], out)
|
|
370
|
+
|
|
371
|
+
refreshed = runtime_index.refresh() is not None
|
|
372
|
+
all_subsystems: tuple[SubsystemSummary, ...] = (
|
|
373
|
+
subsystems["stack"],
|
|
374
|
+
subsystems["library"],
|
|
375
|
+
subsystems["sidecars"],
|
|
376
|
+
subsystems["foundations"],
|
|
377
|
+
)
|
|
378
|
+
ok = all(p["action"] != "failed" for p in parts) and all(
|
|
379
|
+
not summary["errors"] for summary in all_subsystems
|
|
380
|
+
)
|
|
381
|
+
return {
|
|
382
|
+
"schema": SCHEMA,
|
|
383
|
+
"scope": "all",
|
|
384
|
+
"ok": ok,
|
|
385
|
+
"parts": parts,
|
|
386
|
+
"notes": notes,
|
|
387
|
+
"subsystems": subsystems,
|
|
388
|
+
"runtime_index_refreshed": refreshed,
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
|
|
112
392
|
def print_report(report: DownReport, out: Out = print) -> int:
|
|
113
393
|
t = console.term(sys.stdout)
|
|
394
|
+
is_all = report.get("scope") == "all"
|
|
114
395
|
for row in report["parts"]:
|
|
115
396
|
mark = t.mark("fail" if row["action"] == "failed" else "ok")
|
|
116
397
|
did = {"stopped": "stopped", "not-running": "was not running", "failed": "failed to stop"}
|
|
@@ -121,16 +402,46 @@ def print_report(report: DownReport, out: Out = print) -> int:
|
|
|
121
402
|
for note in report["notes"]:
|
|
122
403
|
out(f"note {note}")
|
|
123
404
|
if not report["parts"]:
|
|
124
|
-
out(
|
|
405
|
+
out(
|
|
406
|
+
"No localmodels services, library models, sidecars, or foundations were running"
|
|
407
|
+
if is_all
|
|
408
|
+
else "No stack processes of this tool under this state directory"
|
|
409
|
+
)
|
|
125
410
|
if report["ok"]:
|
|
126
|
-
out(
|
|
411
|
+
out(
|
|
412
|
+
t.paint(
|
|
413
|
+
"All localmodels services, library models, sidecars, and foundations are stopped"
|
|
414
|
+
if is_all
|
|
415
|
+
else "The stack is stopped; `stack up` starts it again",
|
|
416
|
+
"green",
|
|
417
|
+
"bold",
|
|
418
|
+
)
|
|
419
|
+
)
|
|
127
420
|
return 0
|
|
128
421
|
out(t.paint("Some processes did not stop", "red", "bold"))
|
|
129
422
|
return 1
|
|
130
423
|
|
|
131
424
|
|
|
132
425
|
def cli(args: argparse.Namespace) -> int:
|
|
133
|
-
|
|
426
|
+
use_all = bool(getattr(args, "all", False))
|
|
427
|
+
raw_roots: list[Path] = list(getattr(args, "foundations_root", None) or ())
|
|
428
|
+
if raw_roots and not use_all:
|
|
429
|
+
print("stack down: --foundations-root requires --all", file=sys.stderr)
|
|
430
|
+
return 2
|
|
431
|
+
resolved_roots: list[Path] = []
|
|
432
|
+
for root in raw_roots:
|
|
433
|
+
expanded = root.expanduser()
|
|
434
|
+
if not expanded.is_absolute():
|
|
435
|
+
print(
|
|
436
|
+
f"stack down: --foundations-root must be an absolute path: {root}",
|
|
437
|
+
file=sys.stderr,
|
|
438
|
+
)
|
|
439
|
+
return 2
|
|
440
|
+
resolved_roots.append(expanded)
|
|
441
|
+
out: Out = (lambda _m: None) if args.json else print
|
|
442
|
+
report: DownReport = (
|
|
443
|
+
down_all(out=out, foundations_roots=resolved_roots) if use_all else down(out=out)
|
|
444
|
+
)
|
|
134
445
|
if args.json:
|
|
135
446
|
print(json.dumps(report, ensure_ascii=False, indent=1))
|
|
136
447
|
return 0 if report["ok"] else 1
|
|
@@ -142,4 +453,19 @@ def add_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]) ->
|
|
|
142
453
|
"down",
|
|
143
454
|
help="stop the stack's services; nothing is removed",
|
|
144
455
|
)
|
|
456
|
+
p.add_argument(
|
|
457
|
+
"--all",
|
|
458
|
+
action="store_true",
|
|
459
|
+
help="also unload library models, stop voice sidecars, and stop foundations controllers "
|
|
460
|
+
"and services",
|
|
461
|
+
)
|
|
462
|
+
p.add_argument(
|
|
463
|
+
"--foundations-root",
|
|
464
|
+
type=Path,
|
|
465
|
+
action="append",
|
|
466
|
+
default=[],
|
|
467
|
+
metavar="DIR",
|
|
468
|
+
help="absolute foundations controller root to stop alongside discovered roots "
|
|
469
|
+
"(requires --all; repeatable)",
|
|
470
|
+
)
|
|
145
471
|
p.add_argument("--json", action="store_true", help="print one result as JSON")
|
|
@@ -134,7 +134,7 @@ def _from_entry(entry: catalog.CatalogEntry, quant: str | None, source: str) ->
|
|
|
134
134
|
name=entry.id,
|
|
135
135
|
source=source,
|
|
136
136
|
quant=variant.quant,
|
|
137
|
-
profile=
|
|
137
|
+
profile=entry.agent_profile(variant),
|
|
138
138
|
weights_source=f"{variant.quant} files, {variant.size_bytes / GIB:.2f} GiB",
|
|
139
139
|
projector_bytes=entry.mmproj.size_bytes if entry.mmproj else 0,
|
|
140
140
|
runtime=entry.runtime,
|
|
@@ -88,8 +88,8 @@ METAL_RAM_FLOOR = 1 * GIB
|
|
|
88
88
|
# The thinking cap new plans give the LLM. An estimate, not a measurement:
|
|
89
89
|
# the only measured cap is 2,048 (MM64, Ling 3.0 tiny on a 24 GB Mac: basic and long-input checks
|
|
90
90
|
# unchanged); 8,192 is four times that and the whole-reply budget agent clients already send,
|
|
91
|
-
# so a reply that would think without end (14,000 tokens
|
|
92
|
-
#
|
|
91
|
+
# so a reply that would think without end (observed at 14,000+ thinking tokens with no answer
|
|
92
|
+
# on macOS) closes its thinking and answers. `--reasoning-budget` overrides it, 0 removes it.
|
|
93
93
|
REASONING_BUDGET = 8192
|
|
94
94
|
FRONT_ENV_BYTES = 200 << 20 # a decision front's environment: 110 MB source archive plus wheels
|
|
95
95
|
|
|
@@ -231,8 +231,8 @@ class _OptionsSince20261022(TypedDict, total=False):
|
|
|
231
231
|
llm_fast_port: int # resolved when route is enabled, bound by approval
|
|
232
232
|
|
|
233
233
|
|
|
234
|
-
# The scenarios a user picks instead of weights (
|
|
235
|
-
#
|
|
234
|
+
# The scenarios a user picks instead of weights (smartest, concurrent, fast, fastest).
|
|
235
|
+
# fastest chooses the highest decode speed that fits regardless of score,
|
|
236
236
|
# the second choice `stack` offers beside smartest (stack_picks).
|
|
237
237
|
PREFERENCES = ("smartest", "concurrent", "fast", "fastest")
|
|
238
238
|
|
|
@@ -244,7 +244,7 @@ class StackOptions(_OptionsSince20261022):
|
|
|
244
244
|
decision_port: int # 0 means omitted intent; deferred template ports remain unallocated.
|
|
245
245
|
share_gpu: bool
|
|
246
246
|
hf_endpoint: str
|
|
247
|
-
aux: bool # the optional embedding, reranker and STT; off by default
|
|
247
|
+
aux: bool # the optional embedding, reranker and STT; off by default
|
|
248
248
|
base_dir: str # where engines, weights and deployments live
|
|
249
249
|
suite_memory: str # the slice ceiling for every suite service together, e.g. 60G
|
|
250
250
|
reuse_from: list[str] # directories that may hold the suite's files at their catalog paths
|
|
@@ -34,7 +34,7 @@ from localmodels import deploy, hosts, metal
|
|
|
34
34
|
from localmodels.context_policy import AGENT
|
|
35
35
|
from localmodels.planning import llm_ram
|
|
36
36
|
from localmodels.planning.budget import gib
|
|
37
|
-
from localmodels.probe import HostFacts
|
|
37
|
+
from localmodels.probe import HostFacts, logical_cores
|
|
38
38
|
from localmodels.stack_plan import (
|
|
39
39
|
Finding,
|
|
40
40
|
Preflight,
|
|
@@ -186,7 +186,7 @@ def _load(facts: HostFacts, live: bool) -> list[Finding]:
|
|
|
186
186
|
load = os.getloadavg()[0]
|
|
187
187
|
except OSError:
|
|
188
188
|
return []
|
|
189
|
-
cores = int((facts.get("cpu") or {}).get("logical_cores") or
|
|
189
|
+
cores = int((facts.get("cpu") or {}).get("logical_cores") or logical_cores() or 0)
|
|
190
190
|
detail = f"1-minute load average {load:.2f} on {cores or '?'} logical cores"
|
|
191
191
|
if cores and load > cores:
|
|
192
192
|
return [
|
|
@@ -139,9 +139,9 @@ def expert_cache(
|
|
|
139
139
|
|
|
140
140
|
``auto`` sizes the cache from the VRAM free when the LLM starts, so a decision model that
|
|
141
141
|
is already loaded beside it (an LLM restart, a reboot that starts it second) is counted on
|
|
142
|
-
top of its reservation
|
|
142
|
+
top of its reservation (leaving up to ~4.1 GiB idle). A fixed slot count takes
|
|
143
143
|
the same VRAM in either start order; the decision model's share stays out of it, and Strata
|
|
144
|
-
keeps only its own free margin. ``reader_mib`` is the GPU picture reader's VRAM
|
|
144
|
+
keeps only its own free margin. ``reader_mib`` is the GPU picture reader's VRAM,
|
|
145
145
|
held back from the cache like the decision model's. Auto also reserves the real card's
|
|
146
146
|
memory excluded by ``--gpu-memory``. Fixed-slot sizing below uses the priced card's total."""
|
|
147
147
|
auto_reserve = reserve_mib + reader_mib + (gpu_memory.left_out_bytes(gpu) >> 20)
|
|
@@ -192,7 +192,7 @@ def add_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]) ->
|
|
|
192
192
|
uninstall_p = acts.add_parser("uninstall", help="stop the hub service; computers are kept")
|
|
193
193
|
status_p = acts.add_parser("status", help="does the hub service run and answer")
|
|
194
194
|
add = acts.add_parser("add", help="let a computer send; prints its token and install line")
|
|
195
|
-
add.add_argument("name", help="how the board names it, e.g. the
|
|
195
|
+
add.add_argument("name", help="how the board names it, e.g. the host computer name")
|
|
196
196
|
add.add_argument("--new-token", action="store_true", help="replace the token of a known name")
|
|
197
197
|
add.add_argument("--hub-url", help="the address agents reach this hub at (default: guessed)")
|
|
198
198
|
add.add_argument("--port", type=int, default=DEFAULT_PORT, help="for the guessed address")
|
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
from localmodels import catalog as cat
|
|
8
8
|
from localmodels.context_policy import AGENT
|
|
9
|
-
from localmodels.estimator import agent_footprint_parts
|
|
9
|
+
from localmodels.estimator import agent_footprint_parts
|
|
10
10
|
from localmodels.records import Plan
|
|
11
11
|
|
|
12
12
|
|
|
@@ -34,7 +34,7 @@ def llm_parts(part: Plan, window: int | None = None) -> dict[str, int]:
|
|
|
34
34
|
return {}
|
|
35
35
|
if not isinstance(slots, int) or not isinstance(kv_types, list) or len(kv_types) != 2:
|
|
36
36
|
return {}
|
|
37
|
-
profile =
|
|
37
|
+
profile = entry.agent_profile(variant)
|
|
38
38
|
parts = dict(
|
|
39
39
|
agent_footprint_parts(
|
|
40
40
|
profile,
|
|
@@ -128,7 +128,7 @@ class SuiteRecipe(cat.ComponentRecipe, total=False):
|
|
|
128
128
|
# Strata recipes since 2026-11-03: the installed SimplexAI score that lets ``--llm auto``
|
|
129
129
|
# weigh the recipe against the llama.cpp pick (stack_suite).
|
|
130
130
|
quality: cat.QualityData
|
|
131
|
-
# PolyStrata recipes that should be preferred over a same-score llama.cpp pick
|
|
131
|
+
# PolyStrata recipes that should be preferred over a same-score llama.cpp pick.
|
|
132
132
|
prefer_over_llama: bool
|
|
133
133
|
# Minimum live free VRAM (bytes) for library pricing on cards with desktop WDDM overhead.
|
|
134
134
|
min_vram_free_bytes: int
|
|
@@ -29,7 +29,7 @@ from localmodels import (
|
|
|
29
29
|
tts_model,
|
|
30
30
|
tts_state,
|
|
31
31
|
)
|
|
32
|
-
from localmodels.probe import HostFacts
|
|
32
|
+
from localmodels.probe import HostFacts, logical_cores
|
|
33
33
|
from localmodels.records import ReleaseEngine
|
|
34
34
|
from localmodels.sidecar_http import SidecarWorkerError, wrap_pcm16_wav
|
|
35
35
|
from localmodels.tts_admission import TtsDeviceDecision
|
|
@@ -439,7 +439,7 @@ class SpeechCppBackend:
|
|
|
439
439
|
model_path = str(
|
|
440
440
|
sidecar_downloads.model_file_dest(base_dir, "tts", spec.id, spec.files[0].path)
|
|
441
441
|
)
|
|
442
|
-
num_threads = min(SPEECHCPP_MAX_CPU_THREADS, max(1,
|
|
442
|
+
num_threads = min(SPEECHCPP_MAX_CPU_THREADS, max(1, logical_cores() or 1))
|
|
443
443
|
argv = [
|
|
444
444
|
str(binary),
|
|
445
445
|
"serve",
|
|
@@ -34,7 +34,7 @@ from localmodels import (
|
|
|
34
34
|
tts_worker_kokoro,
|
|
35
35
|
tts_worker_moss,
|
|
36
36
|
)
|
|
37
|
-
from localmodels.probe import HostFacts
|
|
37
|
+
from localmodels.probe import HostFacts, logical_cores
|
|
38
38
|
from localmodels.records import ReleaseEngine
|
|
39
39
|
from localmodels.sidecar_http import (
|
|
40
40
|
WORKER_READY_TIMEOUT_S,
|
|
@@ -199,7 +199,7 @@ def _worker_argv(
|
|
|
199
199
|
*,
|
|
200
200
|
threads: int | None = None,
|
|
201
201
|
) -> list[str]:
|
|
202
|
-
num_threads = threads if threads is not None else min(4, max(1,
|
|
202
|
+
num_threads = threads if threads is not None else min(4, max(1, logical_cores() or 1))
|
|
203
203
|
capped = min(4, max(1, num_threads))
|
|
204
204
|
return [
|
|
205
205
|
python_bin,
|
|
@@ -502,7 +502,7 @@ class OnnxMossBackend:
|
|
|
502
502
|
_ = (decision, state_dir)
|
|
503
503
|
py_bin = resolve_moss_python(base_dir)
|
|
504
504
|
mdir = str(sidecar_downloads.model_dir(base_dir, "tts", spec.id))
|
|
505
|
-
threads = min(tts_worker_moss.MAX_THREADS, max(1,
|
|
505
|
+
threads = min(tts_worker_moss.MAX_THREADS, max(1, logical_cores() or 1))
|
|
506
506
|
argv = moss_argv(py_bin, mdir, spec.id, port, threads=threads)
|
|
507
507
|
env = dict(os.environ)
|
|
508
508
|
for key in (
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Default image-input policy: every new stack plan takes images when the
|
|
4
4
|
model can read them, even at a small VRAM cost. Where the reader runs follows Strata's own
|
|
5
|
-
rule (``strata_control/vision_reader.py`` in engines 0.1.47-0.1.49
|
|
5
|
+
rule (``strata_control/vision_reader.py`` in engines 0.1.47-0.1.49):
|
|
6
6
|
on the GPU for a card of 23.5 GiB and more, on the CPU below that, on the GPU of a Mac's
|
|
7
7
|
unified memory. ``stack plan --vision gpu|cpu|off`` overrides it. A plan saved before the
|
|
8
8
|
option existed has no ``vision`` key and stays text-only, so its approval digest is unchanged.
|
|
@@ -91,7 +91,7 @@ def launch_keys(mmproj: AssetFile, mode: str) -> dict[str, object]:
|
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
def reads_pictures(launch: Mapping[str, object]) -> bool:
|
|
94
|
-
"""Whether a plan's launch has its picture reader on
|
|
94
|
+
"""Whether a plan's launch has its picture reader on: readiness reads one."""
|
|
95
95
|
mode = launch.get("vision")
|
|
96
96
|
return bool(mode) and mode != "off"
|
|
97
97
|
|