@simplexai/localmodels-darwin-x64 0.1.0-dev.104 → 0.1.0-dev.106
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 +84 -82
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +204 -86
- package/modules/localmodels/apple_sensors.py +23 -0
- package/modules/localmodels/approval.py +25 -2
- package/modules/localmodels/catalog.json +454 -31
- package/modules/localmodels/catalog.py +11 -0
- package/modules/localmodels/catalog_recipes.py +61 -3
- package/modules/localmodels/cli_help.py +10 -0
- package/modules/localmodels/cli_parser.py +313 -230
- package/modules/localmodels/component.py +20 -2
- package/modules/localmodels/custom_probe.py +4 -2
- package/modules/localmodels/deploy.py +11 -1
- package/modules/localmodels/engine_adapters/suite_plan.py +21 -21
- package/modules/localmodels/host_sensors.py +25 -2
- package/modules/localmodels/hosts.py +26 -5
- package/modules/localmodels/library_cli.py +34 -16
- package/modules/localmodels/library_custom.py +9 -1
- package/modules/localmodels/library_direct.py +41 -1
- package/modules/localmodels/library_jobs.py +23 -4
- package/modules/localmodels/library_model.py +146 -1
- package/modules/localmodels/library_order.py +175 -69
- package/modules/localmodels/library_poly.py +42 -11
- package/modules/localmodels/library_presentation.py +485 -0
- package/modules/localmodels/library_pricing.py +3 -1
- package/modules/localmodels/library_serve.py +208 -3
- package/modules/localmodels/library_state.py +47 -10
- package/modules/localmodels/library_status.py +29 -16
- package/modules/localmodels/llm_rank.py +9 -3
- package/modules/localmodels/plan_envelope.py +11 -2
- package/modules/localmodels/probe.py +34 -7
- package/modules/localmodels/quant_formats.py +9 -2
- package/modules/localmodels/records.py +19 -2
- package/modules/localmodels/remote_ops_verify.py +91 -24
- package/modules/localmodels/runtime_index.py +303 -0
- package/modules/localmodels/setup_inspection.py +22 -3
- package/modules/localmodels/sidecar_http.py +6 -2
- package/modules/localmodels/speech_cli.py +23 -17
- package/modules/localmodels/speech_jobs.py +4 -0
- package/modules/localmodels/speech_model.py +1 -1
- package/modules/localmodels/speech_serve.py +9 -2
- package/modules/localmodels/speech_server.py +3 -0
- package/modules/localmodels/stack_args.py +270 -139
- package/modules/localmodels/stack_auto.py +90 -5
- package/modules/localmodels/stack_cli.py +117 -116
- package/modules/localmodels/stack_compose.py +5 -1
- package/modules/localmodels/stack_debug.py +14 -4
- package/modules/localmodels/stack_down.py +2 -0
- package/modules/localmodels/stack_hardware.py +14 -12
- package/modules/localmodels/stack_mlx.py +8 -1
- package/modules/localmodels/stack_picks.py +19 -20
- package/modules/localmodels/stack_plan.py +3 -2
- package/modules/localmodels/stack_review.py +28 -7
- package/modules/localmodels/stack_suite.py +11 -9
- package/modules/localmodels/stack_up.py +2 -0
- package/modules/localmodels/stack_view.py +180 -35
- package/modules/localmodels/stack_view_demo.py +2 -0
- package/modules/localmodels/stack_view_gpu.py +36 -2
- package/modules/localmodels/stack_view_schema.py +26 -3
- package/modules/localmodels/stack_view_slots.py +3 -1
- package/modules/localmodels/stack_view_telemetry.py +90 -4
- package/modules/localmodels/stack_view_tick.py +246 -40
- package/modules/localmodels/stack_view_words.py +7 -0
- package/modules/localmodels/stack_whatif_html.py +9 -12
- package/modules/localmodels/suite.py +129 -2
- package/modules/localmodels/telemetry_math.py +458 -18
- package/modules/localmodels/transport.py +8 -1
- package/modules/localmodels/tts_cli.py +29 -25
- package/modules/localmodels/tts_jobs.py +5 -0
- package/modules/localmodels/tts_serve.py +9 -2
- package/modules/localmodels/tts_sidecar.py +3 -0
- package/modules/localmodels/web/whatif/app.js +1 -1
- package/modules/localmodels/web/whatif/sim.js +8 -14
- package/modules/localmodels/win_probe.py +89 -16
- package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/RECORD +80 -78
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/licenses/LICENSE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev106.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -10,62 +10,24 @@ import re
|
|
|
10
10
|
import sys
|
|
11
11
|
from collections.abc import Callable
|
|
12
12
|
from pathlib import Path
|
|
13
|
-
from typing import Any
|
|
14
|
-
|
|
15
|
-
from localmodels import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
stack_card,
|
|
23
|
-
stack_down,
|
|
24
|
-
stack_events,
|
|
25
|
-
stack_hardware_text,
|
|
26
|
-
stack_ledger,
|
|
27
|
-
stack_mcp,
|
|
28
|
-
stack_memory,
|
|
29
|
-
stack_progress,
|
|
30
|
-
stack_rollback,
|
|
31
|
-
stack_run,
|
|
32
|
-
stack_try,
|
|
33
|
-
stack_up,
|
|
34
|
-
stack_update,
|
|
35
|
-
stack_view_agent,
|
|
36
|
-
stack_view_hub_cli,
|
|
37
|
-
stack_warm,
|
|
38
|
-
stack_whatif,
|
|
39
|
-
stack_whatif_html,
|
|
40
|
-
)
|
|
41
|
-
from localmodels import stack_decision as decide
|
|
42
|
-
from localmodels import stack_doctor as day2_mod
|
|
43
|
-
from localmodels import stack_hardware as hardware
|
|
44
|
-
from localmodels import stack_view_serve as board
|
|
45
|
-
from localmodels.approval import digest
|
|
46
|
-
from localmodels.contracts import decode
|
|
47
|
-
from localmodels.plan_envelope import PlanError
|
|
48
|
-
from localmodels.probe import HostFacts
|
|
49
|
-
from localmodels.stack_args import options_from_args
|
|
50
|
-
from localmodels.stack_compose import agent_posture
|
|
51
|
-
from localmodels.stack_console import Board
|
|
52
|
-
from localmodels.stack_plan import (
|
|
53
|
-
StackError,
|
|
54
|
-
StackGuardError,
|
|
55
|
-
StackOptions,
|
|
56
|
-
StackPlan,
|
|
57
|
-
StackRecord,
|
|
58
|
-
command,
|
|
59
|
-
default_options,
|
|
60
|
-
guard_details,
|
|
61
|
-
)
|
|
62
|
-
from localmodels.stack_progress import JsonlObserver
|
|
63
|
-
from localmodels.stack_summary import styled, summary
|
|
64
|
-
from localmodels.stack_view_service import ServiceError
|
|
13
|
+
from typing import TYPE_CHECKING, Any
|
|
14
|
+
|
|
15
|
+
from localmodels import cli_help, console, stack_args
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from localmodels import stack_events
|
|
19
|
+
from localmodels.probe import HostFacts
|
|
20
|
+
from localmodels.stack_console import Board
|
|
21
|
+
from localmodels.stack_plan import StackOptions, StackPlan, StackRecord
|
|
65
22
|
|
|
66
23
|
|
|
67
24
|
def _hardware(facts: HostFacts | None, as_json: bool, unified_memory: str | None = None) -> int:
|
|
68
25
|
"""``stack hardware``: the readings and per-card fits, priced as ``stack plan`` would."""
|
|
26
|
+
from localmodels import app, hosts, stack_hardware_text
|
|
27
|
+
from localmodels import stack_hardware as hardware
|
|
28
|
+
from localmodels.stack_compose import agent_posture
|
|
29
|
+
from localmodels.stack_plan import default_options
|
|
30
|
+
|
|
69
31
|
options = default_options()
|
|
70
32
|
if facts is None:
|
|
71
33
|
with console.status("Probing this computer's hardware…"):
|
|
@@ -76,7 +38,7 @@ def _hardware(facts: HostFacts | None, as_json: bool, unified_memory: str | None
|
|
|
76
38
|
json.dump(seen, sys.stdout, ensure_ascii=False, indent=1)
|
|
77
39
|
sys.stdout.write("\n")
|
|
78
40
|
else:
|
|
79
|
-
print("\n".join(stack_hardware_text.lines(seen, command())))
|
|
41
|
+
print("\n".join(stack_hardware_text.lines(seen, cli_help.command())))
|
|
80
42
|
return 0
|
|
81
43
|
|
|
82
44
|
|
|
@@ -89,23 +51,11 @@ _WAITS = {
|
|
|
89
51
|
"up": "Starting services that are not running and waiting for health checks…",
|
|
90
52
|
"down": "Stopping the stack's services…",
|
|
91
53
|
}
|
|
54
|
+
_DAY2_ALL = stack_args.DOCTOR_COMMANDS | frozenset(stack_args.DAY2_LOADERS)
|
|
92
55
|
|
|
93
56
|
|
|
94
57
|
def day2(args: argparse.Namespace) -> int:
|
|
95
|
-
|
|
96
|
-
"up": stack_up.cli,
|
|
97
|
-
"down": stack_down.cli,
|
|
98
|
-
"warm": stack_warm.cli,
|
|
99
|
-
"try": stack_try.cli,
|
|
100
|
-
"arena": stack_arena.cli,
|
|
101
|
-
"ledger": stack_ledger.cli,
|
|
102
|
-
"card": stack_card.cli,
|
|
103
|
-
"rollback": stack_rollback.cli,
|
|
104
|
-
"view": board.cli,
|
|
105
|
-
"view-hub": stack_view_hub_cli.cli,
|
|
106
|
-
"view-agent": stack_view_agent.cli,
|
|
107
|
-
}
|
|
108
|
-
run = handlers.get(args.stack_command, day2_mod.cli)
|
|
58
|
+
run: Callable[[argparse.Namespace], int] = stack_args.day2_module(args.stack_command).cli
|
|
109
59
|
if getattr(args, "json", False) or args.stack_command not in _WAITS:
|
|
110
60
|
return run(args)
|
|
111
61
|
with console.status(_WAITS[args.stack_command]):
|
|
@@ -115,6 +65,9 @@ def day2(args: argparse.Namespace) -> int:
|
|
|
115
65
|
def _mistyped_code(exc: BaseException, plan: StackPlan | None) -> bool:
|
|
116
66
|
"""The approval failed while the plan file is intact: the code given was wrong, so the plan's
|
|
117
67
|
own apply line can be shown (an edited plan has no valid code to show)."""
|
|
68
|
+
from localmodels.approval import digest
|
|
69
|
+
from localmodels.stack_plan import StackGuardError
|
|
70
|
+
|
|
118
71
|
return (
|
|
119
72
|
isinstance(exc, StackGuardError)
|
|
120
73
|
and exc.cause_code == "STACK_APPROVAL_MISMATCH"
|
|
@@ -130,6 +83,12 @@ def apply_cli(
|
|
|
130
83
|
apply: Callable[..., StackRecord],
|
|
131
84
|
report: Callable[..., int],
|
|
132
85
|
) -> int:
|
|
86
|
+
from localmodels import stack_progress, stack_run
|
|
87
|
+
from localmodels.plan_envelope import PlanError
|
|
88
|
+
from localmodels.stack_console import Board
|
|
89
|
+
from localmodels.stack_plan import StackError, guard_details
|
|
90
|
+
from localmodels.stack_progress import JsonlObserver
|
|
91
|
+
|
|
133
92
|
machine = args.json
|
|
134
93
|
jsonl = getattr(args, "jsonl", False)
|
|
135
94
|
attempt_ids: list[str] = []
|
|
@@ -189,7 +148,7 @@ def apply_cli(
|
|
|
189
148
|
if _mistyped_code(exc, loaded):
|
|
190
149
|
assert loaded is not None
|
|
191
150
|
print(
|
|
192
|
-
f" this plan's apply line: {command()} stack apply {args.plan} "
|
|
151
|
+
f" this plan's apply line: {cli_help.command()} stack apply {args.plan} "
|
|
193
152
|
f"--approve {loaded['plan_id']}",
|
|
194
153
|
file=sys.stderr,
|
|
195
154
|
)
|
|
@@ -240,7 +199,9 @@ def _plan_error_payload(exc: BaseException) -> dict[str, object]:
|
|
|
240
199
|
"event": "error",
|
|
241
200
|
"code": code,
|
|
242
201
|
}
|
|
243
|
-
|
|
202
|
+
from localmodels.plan_envelope import HubUnreachableError
|
|
203
|
+
|
|
204
|
+
if isinstance(exc, HubUnreachableError):
|
|
244
205
|
hosts_tried = [
|
|
245
206
|
host
|
|
246
207
|
for host, _ in exc.failures
|
|
@@ -251,54 +212,77 @@ def _plan_error_payload(exc: BaseException) -> dict[str, object]:
|
|
|
251
212
|
return payload
|
|
252
213
|
|
|
253
214
|
|
|
254
|
-
def
|
|
215
|
+
def _handled_error_types() -> tuple[type[BaseException], ...]:
|
|
216
|
+
types: list[type[BaseException]] = [ValueError, KeyError]
|
|
217
|
+
for mod_name, attr in (
|
|
218
|
+
("localmodels.stack_plan", "StackError"),
|
|
219
|
+
("localmodels.plan_envelope", "PlanError"),
|
|
220
|
+
("localmodels.stack_view_service", "ServiceError"),
|
|
221
|
+
):
|
|
222
|
+
mod = sys.modules.get(mod_name)
|
|
223
|
+
if mod is not None and isinstance(cls := getattr(mod, attr, None), type):
|
|
224
|
+
types.append(cls)
|
|
225
|
+
return tuple(types)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _what_if(args: argparse.Namespace) -> int:
|
|
229
|
+
if getattr(args, "html", None):
|
|
230
|
+
from localmodels import stack_whatif_html
|
|
231
|
+
|
|
232
|
+
return stack_whatif_html.cli_html(args)
|
|
233
|
+
from localmodels import stack_whatif
|
|
234
|
+
|
|
235
|
+
return stack_whatif.cli(args)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def _dispatch_stack(
|
|
255
239
|
args: argparse.Namespace,
|
|
256
240
|
*,
|
|
257
|
-
build: Callable[..., StackPlan],
|
|
258
|
-
save: Callable[[StackPlan, Any], Any],
|
|
259
|
-
load: Callable[[Path], StackPlan],
|
|
260
|
-
apply: Callable[..., StackRecord],
|
|
261
|
-
report: Callable[..., int],
|
|
241
|
+
build: Callable[..., StackPlan] | None = None,
|
|
242
|
+
save: Callable[[StackPlan, Any], Any] | None = None,
|
|
243
|
+
load: Callable[[Path], StackPlan] | None = None,
|
|
244
|
+
apply: Callable[..., StackRecord] | None = None,
|
|
245
|
+
report: Callable[..., int] | None = None,
|
|
262
246
|
day2_fn: Callable[[argparse.Namespace], int] = day2,
|
|
263
247
|
) -> int:
|
|
264
248
|
if args.stack_command == "capabilities":
|
|
249
|
+
from localmodels import stack_run
|
|
250
|
+
|
|
265
251
|
stack_run.capabilities()
|
|
266
252
|
return 0
|
|
267
253
|
if args.stack_command == "mcp":
|
|
254
|
+
from localmodels import stack_mcp
|
|
255
|
+
|
|
268
256
|
return stack_mcp.cli(args)
|
|
269
257
|
try:
|
|
270
|
-
if args.stack_command in
|
|
271
|
-
*day2_mod.COMMANDS,
|
|
272
|
-
"up",
|
|
273
|
-
"down",
|
|
274
|
-
"warm",
|
|
275
|
-
"try",
|
|
276
|
-
"arena",
|
|
277
|
-
"ledger",
|
|
278
|
-
"card",
|
|
279
|
-
"rollback",
|
|
280
|
-
"view",
|
|
281
|
-
"view-hub",
|
|
282
|
-
"view-agent",
|
|
283
|
-
):
|
|
258
|
+
if args.stack_command in _DAY2_ALL:
|
|
284
259
|
return day2_fn(args)
|
|
285
260
|
if args.stack_command == "decisions":
|
|
261
|
+
from localmodels import stack_decision as decide
|
|
262
|
+
|
|
286
263
|
print(decide.listing())
|
|
287
264
|
return 0
|
|
288
265
|
if args.stack_command == "memory":
|
|
266
|
+
from localmodels import stack_memory
|
|
267
|
+
|
|
289
268
|
return stack_memory.cli(args)
|
|
290
269
|
if args.stack_command == "what-if":
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
)
|
|
270
|
+
return _what_if(args)
|
|
271
|
+
facts: HostFacts | None = None
|
|
272
|
+
if getattr(args, "facts", None):
|
|
273
|
+
from localmodels.contracts import decode
|
|
274
|
+
from localmodels.probe import HostFacts as _HostFacts
|
|
275
|
+
|
|
276
|
+
facts = decode(json.loads(args.facts.read_text(encoding="utf-8")), _HostFacts)
|
|
299
277
|
if args.stack_command == "hardware":
|
|
300
278
|
return _hardware(facts, args.json, args.unified_memory)
|
|
279
|
+
from localmodels import stack
|
|
280
|
+
|
|
301
281
|
if args.stack_command == "plan":
|
|
282
|
+
from localmodels import stack_update
|
|
283
|
+
from localmodels.stack_args import options_from_args
|
|
284
|
+
from localmodels.stack_summary import styled, summary
|
|
285
|
+
|
|
302
286
|
options: StackOptions = stack_update.requested(
|
|
303
287
|
options_from_args(args), args.update, getattr(args, "component_selections", ())
|
|
304
288
|
)
|
|
@@ -307,23 +291,27 @@ def run_cli(
|
|
|
307
291
|
if facts is None
|
|
308
292
|
else "Pricing the whole stack…"
|
|
309
293
|
):
|
|
310
|
-
plan = build(options, facts=facts)
|
|
311
|
-
path = save(plan, args.out)
|
|
294
|
+
plan = (build or stack.build)(options, facts=facts)
|
|
295
|
+
path = (save or stack.save)(plan, args.out)
|
|
312
296
|
if args.json:
|
|
313
297
|
json.dump(plan, sys.stdout, ensure_ascii=False, indent=1)
|
|
314
298
|
sys.stdout.write("\n")
|
|
315
299
|
else:
|
|
316
300
|
print(styled(summary(plan, path)))
|
|
317
301
|
return 0
|
|
318
|
-
return apply_cli(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
302
|
+
return apply_cli(
|
|
303
|
+
args,
|
|
304
|
+
load=load or stack.load,
|
|
305
|
+
apply=apply or stack.apply,
|
|
306
|
+
report=report or stack.report,
|
|
307
|
+
)
|
|
308
|
+
except Exception as exc:
|
|
309
|
+
if not isinstance(exc, _handled_error_types()):
|
|
310
|
+
raise
|
|
326
311
|
if getattr(args, "jsonl", False):
|
|
312
|
+
from localmodels import stack_progress
|
|
313
|
+
from localmodels.stack_plan import guard_details
|
|
314
|
+
|
|
327
315
|
return stack_progress.error(2, guard_details(exc))
|
|
328
316
|
if args.stack_command == "plan" and getattr(args, "json", False):
|
|
329
317
|
print(json.dumps(_plan_error_payload(exc), separators=(",", ":")))
|
|
@@ -331,14 +319,27 @@ def run_cli(
|
|
|
331
319
|
return 2
|
|
332
320
|
|
|
333
321
|
|
|
334
|
-
def
|
|
335
|
-
|
|
336
|
-
|
|
322
|
+
def run_cli(
|
|
323
|
+
args: argparse.Namespace,
|
|
324
|
+
*,
|
|
325
|
+
build: Callable[..., StackPlan],
|
|
326
|
+
save: Callable[[StackPlan, Any], Any],
|
|
327
|
+
load: Callable[[Path], StackPlan],
|
|
328
|
+
apply: Callable[..., StackRecord],
|
|
329
|
+
report: Callable[..., int],
|
|
330
|
+
day2_fn: Callable[[argparse.Namespace], int] = day2,
|
|
331
|
+
) -> int:
|
|
332
|
+
return _dispatch_stack(
|
|
337
333
|
args,
|
|
338
|
-
build=
|
|
339
|
-
save=
|
|
340
|
-
load=
|
|
341
|
-
apply=
|
|
342
|
-
report=
|
|
343
|
-
day2_fn=
|
|
334
|
+
build=build,
|
|
335
|
+
save=save,
|
|
336
|
+
load=load,
|
|
337
|
+
apply=apply,
|
|
338
|
+
report=report,
|
|
339
|
+
day2_fn=day2_fn,
|
|
344
340
|
)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def cli(args: argparse.Namespace) -> int:
|
|
344
|
+
"""Entry point for ``localmodels stack`` subcommands."""
|
|
345
|
+
return _dispatch_stack(args, day2_fn=day2)
|
|
@@ -241,7 +241,11 @@ def choose_parts(
|
|
|
241
241
|
f"--context sets a llama.cpp LLM's window; the Strata recipe {strata['id']} fixes "
|
|
242
242
|
"its own. Leave out --context, or name a llama.cpp LLM with --llm"
|
|
243
243
|
)
|
|
244
|
-
stack_debug.check(
|
|
244
|
+
stack_debug.check(
|
|
245
|
+
options,
|
|
246
|
+
strata is not None,
|
|
247
|
+
strata_quant=strata["version"] if strata is not None else None,
|
|
248
|
+
)
|
|
245
249
|
parts: Parts | None = None
|
|
246
250
|
if options.get("profile") == "macos-mlx-preview":
|
|
247
251
|
parts = stack_mlx.parts(facts, options, listening=listening, previous=previous)
|
|
@@ -69,9 +69,10 @@ def variant(entry: cat.CatalogEntry, quant: str) -> cat.QuantVariant:
|
|
|
69
69
|
return found
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def check(options: Options, strata: bool) -> None:
|
|
73
|
-
"""Refuse overrides the plan cannot honour
|
|
74
|
-
|
|
72
|
+
def check(options: Options, strata: bool, *, strata_quant: str | None = None) -> None:
|
|
73
|
+
"""Refuse overrides the plan cannot honour. ``--kv`` is llama.cpp-only; ``--quant`` is
|
|
74
|
+
accepted on a named Strata/PolyStrata recipe when it matches the recipe's pinned version
|
|
75
|
+
(case-insensitive) and refused with the pinned version otherwise."""
|
|
75
76
|
found = given(options)
|
|
76
77
|
if not found:
|
|
77
78
|
return
|
|
@@ -84,7 +85,16 @@ def check(options: Options, strata: bool) -> None:
|
|
|
84
85
|
f"{flags}: name the model with --llm ID (see python3 -m localmodels models)"
|
|
85
86
|
)
|
|
86
87
|
if strata:
|
|
87
|
-
|
|
88
|
+
if "kv" in found:
|
|
89
|
+
raise PlanError(f"{flags}: {llm} is a Strata recipe; these pin llama.cpp only")
|
|
90
|
+
if "quant" in found:
|
|
91
|
+
wanted = str(found["quant"])
|
|
92
|
+
if strata_quant is None:
|
|
93
|
+
raise PlanError(f"{flags}: {llm} is a Strata recipe; these pin llama.cpp only")
|
|
94
|
+
if wanted.lower() != strata_quant.lower():
|
|
95
|
+
raise PlanError(
|
|
96
|
+
f"--quant {wanted}: {llm} pins {strata_quant}; add a variant to the catalog first"
|
|
97
|
+
)
|
|
88
98
|
|
|
89
99
|
|
|
90
100
|
def refusal(
|
|
@@ -18,6 +18,7 @@ from localmodels import (
|
|
|
18
18
|
deploy,
|
|
19
19
|
deployment_lifecycle,
|
|
20
20
|
hosts,
|
|
21
|
+
runtime_index,
|
|
21
22
|
speech_state,
|
|
22
23
|
tts_state,
|
|
23
24
|
)
|
|
@@ -99,6 +100,7 @@ def _down(out: Out) -> DownReport:
|
|
|
99
100
|
f"{'✗' if action == 'failed' else '…'} {sidecar_name} "
|
|
100
101
|
f"{'failed to stop' if action == 'failed' else 'stopped'}"
|
|
101
102
|
)
|
|
103
|
+
runtime_index.refresh()
|
|
102
104
|
return {
|
|
103
105
|
"schema": SCHEMA,
|
|
104
106
|
"ok": all(p["action"] != "failed" for p in parts),
|
|
@@ -326,27 +326,29 @@ def llm_fits(
|
|
|
326
326
|
tok_s = float(fit["decode_tok_s"]) if fit["decode_tok_s"] is not None else -1.0
|
|
327
327
|
found.append((((0 if unscored else entry.quality), tok_s), fit))
|
|
328
328
|
|
|
329
|
+
usable_llama_scores = [
|
|
330
|
+
f["quality"]
|
|
331
|
+
for _, f in found
|
|
332
|
+
if not f.get("candidate_fallback")
|
|
333
|
+
and f["decode_tok_s"] is not None
|
|
334
|
+
and f["decode_tok_s"] >= cat.USABLE_FLOOR_TOK_S
|
|
335
|
+
]
|
|
329
336
|
llama_score = max(
|
|
330
|
-
|
|
337
|
+
usable_llama_scores or [f["quality"] for _, f in found if not f.get("candidate_fallback")],
|
|
338
|
+
default=-1,
|
|
331
339
|
)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
for c in catalog_recipes.components()
|
|
335
|
-
if c["runtime"] in ("strata", "strata-poly") and c.get("prefer_over_llama")
|
|
336
|
-
}
|
|
337
|
-
strata_vram = {
|
|
338
|
-
c["id"]: int(str(c.get("vram_bytes") or 0))
|
|
339
|
-
for c in catalog_recipes.components()
|
|
340
|
-
if c["runtime"] in ("strata", "strata-poly")
|
|
340
|
+
strata_by_id = {
|
|
341
|
+
r["id"]: r for r in suite.recipes("llm") if r["runtime"] in suite.STRATA_RUNTIMES
|
|
341
342
|
}
|
|
342
343
|
for fit in stack_auto.card_fits(facts, index, options, llama_score):
|
|
343
344
|
_apply_fit_measurement(facts, index, fit)
|
|
344
|
-
|
|
345
|
+
recipe = strata_by_id.get(fit["id"])
|
|
346
|
+
tie = suite.strata_smart_tie(recipe) if recipe is not None else -1e9
|
|
345
347
|
found.append(((fit["quality"], tie), fit))
|
|
346
348
|
found = [row for row in found if not row[1].get("candidate_fallback")] or found
|
|
347
349
|
default_id = llm_rank.listed_default(facts, [(f["id"], f["quality"]) for _, f in found])
|
|
348
350
|
if default_id is None and found:
|
|
349
|
-
strata_ids = set(
|
|
351
|
+
strata_ids = set(strata_by_id)
|
|
350
352
|
fallback_ids = {f["id"] for _, f in found if f.get("candidate_fallback")}
|
|
351
353
|
slow_ids = {
|
|
352
354
|
f["id"]
|
|
@@ -181,7 +181,14 @@ def _model_plan(facts: HostFacts, options: StackOptions, entry: catalog.CatalogE
|
|
|
181
181
|
"frontend_bytes": 1 << 30,
|
|
182
182
|
},
|
|
183
183
|
service={"argv": argv, "env": {"HF_HUB_OFFLINE": "1", "TOKENIZERS_PARALLELISM": "false"}},
|
|
184
|
-
endpoint={
|
|
184
|
+
endpoint={
|
|
185
|
+
"model": model_dir,
|
|
186
|
+
"contract": "openai-chat",
|
|
187
|
+
"health_path": "/health",
|
|
188
|
+
"slots_path": None,
|
|
189
|
+
"metrics_path": None,
|
|
190
|
+
"metrics_requires_auth": False,
|
|
191
|
+
},
|
|
185
192
|
warnings=list(WARNINGS),
|
|
186
193
|
)
|
|
187
194
|
plan["service"]["kind"] = "launchd-user"
|
|
@@ -17,7 +17,7 @@ from collections.abc import Sequence
|
|
|
17
17
|
from typing import TypedDict
|
|
18
18
|
|
|
19
19
|
from localmodels import catalog as cat
|
|
20
|
-
from localmodels import
|
|
20
|
+
from localmodels import llm_rank, suite
|
|
21
21
|
|
|
22
22
|
# A second choice has to be worth offering: at least this much faster than the smartest.
|
|
23
23
|
WORTH_FASTER = 1.2
|
|
@@ -70,17 +70,16 @@ def picks(cards: Sequence[CardFits], ladder: llm_rank.MacLadder | None = None) -
|
|
|
70
70
|
found.setdefault(
|
|
71
71
|
fit["id"], {**fit, "role": "", "card": card["index"], "shared": not free}
|
|
72
72
|
)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if c["runtime"] in ("strata", "strata-poly")
|
|
73
|
+
strata_recipes = [r for r in suite.recipes("llm") if r["runtime"] in suite.STRATA_RUNTIMES]
|
|
74
|
+
strata_by_id = {r["id"]: r for r in strata_recipes}
|
|
75
|
+
strata_ids = set(strata_by_id)
|
|
76
|
+
preferred_strata = {r["id"] for r in strata_recipes if r.get("prefer_over_llama")}
|
|
77
|
+
poly_fastest_ids = {
|
|
78
|
+
r["id"]
|
|
79
|
+
for r in strata_recipes
|
|
80
|
+
if r["runtime"] == "strata-poly"
|
|
81
|
+
and r.get("prefer_over_llama")
|
|
82
|
+
and suite.effective_parallel(r, r.get("card_args") or ()) >= 2
|
|
84
83
|
}
|
|
85
84
|
llama_scores = [
|
|
86
85
|
p["quality"]
|
|
@@ -102,9 +101,8 @@ def picks(cards: Sequence[CardFits], ladder: llm_rank.MacLadder | None = None) -
|
|
|
102
101
|
return []
|
|
103
102
|
|
|
104
103
|
def _smart_tie(p: Pick) -> float:
|
|
105
|
-
if p["id"]
|
|
106
|
-
|
|
107
|
-
return (1e9 if p["id"] in preferred_strata else -1e9) + gib_rank
|
|
104
|
+
if (recipe := strata_by_id.get(p["id"])) is not None:
|
|
105
|
+
return suite.strata_smart_tie(recipe)
|
|
108
106
|
return -1.0 if p["decode_tok_s"] is None else p["decode_tok_s"]
|
|
109
107
|
|
|
110
108
|
ranked = [((p["quality"], _smart_tie(p)), p["id"], p["card"]) for p in eligible]
|
|
@@ -119,18 +117,19 @@ def picks(cards: Sequence[CardFits], ladder: llm_rank.MacLadder | None = None) -
|
|
|
119
117
|
smartest = found[
|
|
120
118
|
llm_rank.choose(ranked, "smartest", ladder, fallback_ids=fallback_ids, slow_ids=slow_ids)[0]
|
|
121
119
|
]
|
|
122
|
-
|
|
120
|
+
speed_ranked = [
|
|
123
121
|
((p["quality"], float(p["decode_tok_s"])), p["id"], p["card"])
|
|
124
|
-
for p in
|
|
125
|
-
if p["
|
|
122
|
+
for p in found.values()
|
|
123
|
+
if p["decode_tok_s"] is not None
|
|
124
|
+
and (p["id"] not in strata_ids or p["id"] in poly_fastest_ids)
|
|
126
125
|
]
|
|
127
126
|
fastest = (
|
|
128
127
|
found[
|
|
129
128
|
llm_rank.choose(
|
|
130
|
-
|
|
129
|
+
speed_ranked, "fastest", ladder, fallback_ids=fallback_ids, slow_ids=slow_ids
|
|
131
130
|
)[0]
|
|
132
131
|
]
|
|
133
|
-
if
|
|
132
|
+
if speed_ranked
|
|
134
133
|
else smartest
|
|
135
134
|
)
|
|
136
135
|
offered: list[Pick] = [{**smartest, "role": "smartest"}]
|
|
@@ -8,7 +8,6 @@ import datetime as dt
|
|
|
8
8
|
import json
|
|
9
9
|
import os
|
|
10
10
|
import subprocess
|
|
11
|
-
import sys
|
|
12
11
|
from collections.abc import Callable
|
|
13
12
|
from pathlib import Path
|
|
14
13
|
from typing import Literal, TypedDict, cast
|
|
@@ -524,7 +523,9 @@ def deployments(plan: StackPlan) -> list[Plan]:
|
|
|
524
523
|
|
|
525
524
|
def command() -> str:
|
|
526
525
|
"""How the operator ran this tool, for commands it tells them to run next."""
|
|
527
|
-
|
|
526
|
+
from localmodels import cli_help
|
|
527
|
+
|
|
528
|
+
return cli_help.command()
|
|
528
529
|
|
|
529
530
|
|
|
530
531
|
NOTHING_HERE = (
|
|
@@ -7,7 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
from typing import TypedDict
|
|
8
8
|
from urllib.parse import urlsplit, urlunsplit
|
|
9
9
|
|
|
10
|
-
from localmodels import catalog_license, stack
|
|
10
|
+
from localmodels import catalog_license, library_presentation, stack
|
|
11
11
|
from localmodels.contracts import decode
|
|
12
12
|
from localmodels.planning import budget
|
|
13
13
|
from localmodels.setup_text import Lang, join, text
|
|
@@ -26,10 +26,7 @@ class PlanGPU(TypedDict):
|
|
|
26
26
|
roles: list[str] # llm, llm_fast, decision: the models the plan places on this card
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
class
|
|
30
|
-
"""What a plan installs and needs, read from the plan alone: the recommendation an installer
|
|
31
|
-
shows. ``gpus`` lists every card the plan places a model on, the LLM's first."""
|
|
32
|
-
|
|
29
|
+
class _PlanSummaryRequired(TypedDict):
|
|
33
30
|
llm: str # catalog model ID
|
|
34
31
|
llmName: str # display name and quantization
|
|
35
32
|
contextWindow: int
|
|
@@ -43,6 +40,16 @@ class PlanSummary(TypedDict):
|
|
|
43
40
|
text: str # one sentence in the requested language
|
|
44
41
|
|
|
45
42
|
|
|
43
|
+
class PlanSummary(_PlanSummaryRequired, total=False):
|
|
44
|
+
"""What a plan installs and needs, read from the plan alone: the recommendation an installer
|
|
45
|
+
shows. ``gpus`` lists every card the plan places a model on, the LLM's first."""
|
|
46
|
+
|
|
47
|
+
engine: str
|
|
48
|
+
quant: str
|
|
49
|
+
quant_fidelity: str
|
|
50
|
+
recommendation_reasons: list[str]
|
|
51
|
+
|
|
52
|
+
|
|
46
53
|
class _StackReview(TypedDict):
|
|
47
54
|
schema: str
|
|
48
55
|
planId: str
|
|
@@ -144,10 +151,11 @@ def summarize(plan: StackPlan, lang: Lang = "zh") -> PlanSummary:
|
|
|
144
151
|
ram, download = decode(need["ram_needed_bytes"], int), decode(need["download_bytes"], int)
|
|
145
152
|
disk = decode(need["disk_needed_bytes"], int)
|
|
146
153
|
gib = budget.gib
|
|
147
|
-
|
|
154
|
+
context_window = decode(llm["launch"]["window"], int)
|
|
155
|
+
summary: PlanSummary = {
|
|
148
156
|
"llm": model["id"],
|
|
149
157
|
"llmName": name,
|
|
150
|
-
"contextWindow":
|
|
158
|
+
"contextWindow": context_window,
|
|
151
159
|
"gpus": gpus,
|
|
152
160
|
"placement": str(llm["placement"].get("label") or ""),
|
|
153
161
|
"memoryKind": "unified" if unified else "discrete",
|
|
@@ -166,6 +174,19 @@ def summarize(plan: StackPlan, lang: Lang = "zh") -> PlanSummary:
|
|
|
166
174
|
disk=gib(disk),
|
|
167
175
|
),
|
|
168
176
|
}
|
|
177
|
+
extra = library_presentation.plan_presentation(
|
|
178
|
+
llm, context_window=context_window, gpus=gpus, unified=unified
|
|
179
|
+
)
|
|
180
|
+
if isinstance(engine := extra.get("engine"), str):
|
|
181
|
+
summary["engine"] = engine
|
|
182
|
+
if isinstance(quant := extra.get("quant"), str) and quant:
|
|
183
|
+
summary["quant"] = quant
|
|
184
|
+
if isinstance(fidelity := extra.get("quant_fidelity"), str):
|
|
185
|
+
summary["quant_fidelity"] = fidelity
|
|
186
|
+
reasons = extra.get("recommendation_reasons")
|
|
187
|
+
if isinstance(reasons, list) and reasons:
|
|
188
|
+
summary["recommendation_reasons"] = [str(r) for r in reasons]
|
|
189
|
+
return summary
|
|
169
190
|
|
|
170
191
|
|
|
171
192
|
def review_plan(path: Path, lang: Lang = "zh") -> StackReview:
|
|
@@ -168,15 +168,14 @@ def poly_reserve_mib(recipe: suite.SuiteRecipe, gpu: GPU, beside_mib: int) -> in
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
def auto_strata_wanted(facts: HostFacts, options: StackOptions) -> bool:
|
|
171
|
-
"""Whether ``--llm auto`` also weighs Strata recipes: on Linux and Windows (a Mac
|
|
172
|
-
strata-poly recipe
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
"""Whether ``--llm auto`` also weighs Strata/PolyStrata recipes: on Linux and Windows (a Mac
|
|
172
|
+
runs a strata-poly recipe only when ``--llm`` names it; on Windows only recipes whose engine
|
|
173
|
+
has a Windows build, see auto_strata_candidates), and never under ``--context`` (Strata
|
|
174
|
+
recipes fix their own window). Under ``--prefer concurrent``, ``stack_auto`` further filters
|
|
175
|
+
candidates to full-VRAM-resident ``strata-poly`` recipes with ``parallel >= 2``."""
|
|
176
176
|
return (
|
|
177
177
|
options["llm"] == "auto"
|
|
178
178
|
and facts["platform"] in ("linux", "win32")
|
|
179
|
-
and options.get("prefer") != "concurrent"
|
|
180
179
|
and not options.get("context")
|
|
181
180
|
)
|
|
182
181
|
|
|
@@ -203,7 +202,11 @@ def auto_strata_candidates(
|
|
|
203
202
|
if llama_score is None:
|
|
204
203
|
return at_least
|
|
205
204
|
return llm_rank.strata_recipe_bar(
|
|
206
|
-
llama_score,
|
|
205
|
+
llama_score,
|
|
206
|
+
opts,
|
|
207
|
+
prefer_over_llama=bool(r.get("prefer_over_llama")),
|
|
208
|
+
allow_poly_fastest=r.get("runtime") == "strata-poly"
|
|
209
|
+
and r.get("decode_fraction") is not None,
|
|
207
210
|
)
|
|
208
211
|
|
|
209
212
|
found = [
|
|
@@ -219,8 +222,7 @@ def auto_strata_candidates(
|
|
|
219
222
|
found,
|
|
220
223
|
key=lambda r: (
|
|
221
224
|
-r["quality"]["score"],
|
|
222
|
-
-
|
|
223
|
-
-r.get("vram_bytes", 0),
|
|
225
|
+
-suite.strata_smart_tie(r),
|
|
224
226
|
),
|
|
225
227
|
)
|
|
226
228
|
|