@simplexai/localmodels-linux-x64 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.
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +141 -99
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +4 -0
- package/modules/localmodels/app.py +7 -2
- package/modules/localmodels/approval.py +4 -4
- package/modules/localmodels/bifrost_checks.py +121 -3
- package/modules/localmodels/bifrost_provider.py +53 -0
- package/modules/localmodels/bifrost_unit.py +32 -1
- package/modules/localmodels/budget.py +7 -1
- package/modules/localmodels/catalog.json +286 -12
- package/modules/localmodels/catalog.py +30 -29
- package/modules/localmodels/catalog_add.py +1 -0
- package/modules/localmodels/cli_parser.py +10 -2
- package/modules/localmodels/component.py +7 -1
- package/modules/localmodels/decode_calibration.json +6 -0
- package/modules/localmodels/decode_calibration.py +104 -0
- package/modules/localmodels/deploy.py +44 -7
- package/modules/localmodels/deploy_steps.py +10 -1
- package/modules/localmodels/engines-strata-0.1.49.2.json +31 -0
- package/modules/localmodels/engines-strata-0.1.59.1.json +31 -0
- package/modules/localmodels/engines.json +57 -1
- package/modules/localmodels/engines.py +6 -2
- package/modules/localmodels/estimator.py +21 -7
- package/modules/localmodels/frontend.py +4 -4
- package/modules/localmodels/gateway.py +14 -4
- package/modules/localmodels/gateway_app_bifrost.py +4 -3
- package/modules/localmodels/gateway_bifrost.py +70 -57
- package/modules/localmodels/gateway_probe.py +3 -4
- package/modules/localmodels/gguf.py +7 -0
- package/modules/localmodels/harness.py +24 -25
- package/modules/localmodels/harness_gateway.py +19 -10
- package/modules/localmodels/harness_probe.py +33 -6
- package/modules/localmodels/hosts.py +73 -9
- package/modules/localmodels/install.py +36 -6
- package/modules/localmodels/library_cli.py +179 -0
- package/modules/localmodels/library_convert.py +132 -0
- package/modules/localmodels/library_gateway.py +471 -0
- package/modules/localmodels/library_jobs.py +314 -0
- package/modules/localmodels/library_model.py +246 -0
- package/modules/localmodels/library_pricing.py +347 -0
- package/modules/localmodels/library_serve.py +348 -0
- package/modules/localmodels/library_state.py +373 -0
- package/modules/localmodels/library_status.py +349 -0
- package/modules/localmodels/llm_rank.py +77 -8
- package/modules/localmodels/memcalc.py +7 -30
- package/modules/localmodels/metal.py +26 -0
- package/modules/localmodels/metal_probe.py +11 -7
- package/modules/localmodels/plan_envelope.py +4 -1
- package/modules/localmodels/preparation.py +49 -0
- package/modules/localmodels/probe.py +8 -8
- package/modules/localmodels/process_identity.py +536 -9
- package/modules/localmodels/quant_formats.py +123 -0
- package/modules/localmodels/recommend.py +32 -3
- package/modules/localmodels/recommend_cli.py +8 -4
- package/modules/localmodels/records.py +1 -0
- package/modules/localmodels/remote_ops.py +104 -6
- package/modules/localmodels/remote_ops_download.py +17 -2
- package/modules/localmodels/remote_ops_prepare.py +425 -0
- package/modules/localmodels/remote_ops_remove.py +40 -7
- package/modules/localmodels/remote_ops_service.py +110 -8
- package/modules/localmodels/remote_ops_verify.py +15 -2
- package/modules/localmodels/runtime_auth.py +31 -1
- package/modules/localmodels/runtime_cli.py +3 -4
- package/modules/localmodels/runtime_io.py +50 -6
- package/modules/localmodels/service_autostart.py +45 -1
- package/modules/localmodels/service_control.py +13 -0
- package/modules/localmodels/service_deployment.py +12 -3
- package/modules/localmodels/service_jobs.py +33 -4
- package/modules/localmodels/service_probe.py +67 -13
- package/modules/localmodels/service_stop.py +152 -0
- package/modules/localmodels/service_worker.py +9 -1
- package/modules/localmodels/services_cli.py +50 -6
- package/modules/localmodels/setup_inspection.py +34 -25
- package/modules/localmodels/setup_text.py +118 -0
- package/modules/localmodels/sizecalc.py +625 -0
- package/modules/localmodels/sizecalc_cli.py +249 -0
- package/modules/localmodels/stack.py +69 -17
- package/modules/localmodels/stack_args.py +91 -19
- package/modules/localmodels/stack_auto.py +78 -0
- package/modules/localmodels/stack_binding.py +23 -35
- package/modules/localmodels/stack_card.py +195 -0
- package/modules/localmodels/stack_cleanup.py +379 -0
- package/modules/localmodels/stack_clients.py +4 -1
- package/modules/localmodels/stack_compose.py +173 -206
- package/modules/localmodels/stack_console.py +2 -0
- package/modules/localmodels/stack_decision.py +3 -2
- package/modules/localmodels/stack_down.py +189 -0
- package/modules/localmodels/stack_events.py +54 -0
- package/modules/localmodels/stack_hardware.py +30 -34
- package/modules/localmodels/stack_journal.py +29 -8
- package/modules/localmodels/stack_ledger.py +411 -0
- package/modules/localmodels/stack_lifecycle.py +162 -167
- package/modules/localmodels/stack_llm_ram.py +57 -5
- package/modules/localmodels/stack_memory.py +721 -0
- package/modules/localmodels/stack_picks.py +147 -0
- package/modules/localmodels/stack_plan.py +143 -25
- package/modules/localmodels/stack_ports.py +22 -0
- package/modules/localmodels/stack_preflight.py +699 -0
- package/modules/localmodels/stack_review.py +123 -5
- package/modules/localmodels/stack_rollback.py +2 -0
- package/modules/localmodels/stack_route.py +256 -0
- package/modules/localmodels/stack_run.py +11 -0
- package/modules/localmodels/stack_suite.py +107 -20
- package/modules/localmodels/stack_summary.py +65 -4
- package/modules/localmodels/stack_try.py +354 -0
- package/modules/localmodels/stack_try_client.py +194 -0
- package/modules/localmodels/stack_try_docs.py +139 -0
- package/modules/localmodels/stack_up.py +8 -1
- package/modules/localmodels/stack_update.py +29 -4
- package/modules/localmodels/stack_verify.py +3 -1
- package/modules/localmodels/stack_view.py +10 -11
- package/modules/localmodels/stack_view_apply.py +4 -2
- package/modules/localmodels/stack_view_events.py +2 -1
- package/modules/localmodels/stack_view_serve.py +3 -0
- package/modules/localmodels/stack_view_text.py +1 -1
- package/modules/localmodels/stack_view_words.py +4 -1
- package/modules/localmodels/stack_warm.py +574 -0
- package/modules/localmodels/stack_whatif.py +558 -0
- package/modules/localmodels/suite.py +48 -39
- package/modules/localmodels/tool_archive.py +40 -0
- package/modules/localmodels/tools.json +8 -0
- package/modules/localmodels/transport.py +1 -0
- package/modules/localmodels/vision.py +8 -1
- package/modules/localmodels/web/sizecalc/app.js +431 -0
- package/modules/localmodels/web/sizecalc/calc.js +269 -0
- package/modules/localmodels/web/sizecalc/page.html +362 -0
- package/modules/localmodels/web/view/ASSET-SOURCES.md +11 -0
- package/modules/localmodels/web/view/i18n.js +1 -1
- package/modules/localmodels/web/view/logo-claude.svg +3 -0
- package/modules/localmodels/web/view/logo-codex.png +0 -0
- package/modules/localmodels/web/view/logo-pi.svg +6 -0
- package/modules/localmodels/web/view/view.css +4 -0
- package/modules/localmodels/web/view/view.js +15 -6
- package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/METADATA +1 -1
- package/modules/simplex_localmodels-0.1.0.dev36.dist-info/RECORD +242 -0
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/simplex_localmodels-0.1.0.dev32.dist-info/RECORD +0 -200
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/licenses/NOTICE +0 -0
- /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,147 @@
|
|
|
1
|
+
"""The two LLMs ``stack`` offers for one computer: the smartest that fits, and the fastest.
|
|
2
|
+
|
|
3
|
+
Both come from the per-card lists ``stack hardware`` prints (stack_hardware.llm_fits): eligible
|
|
4
|
+
models that pass the agent gate on a card ``--llm auto`` may take, so nothing here prices or
|
|
5
|
+
probes again. ``smartest`` is what ``--prefer smartest`` (the default) installs. ``fastest`` is
|
|
6
|
+
what ``--prefer fastest`` installs: the highest decode speed that fits, whatever its score. One
|
|
7
|
+
pick is returned when the same model is both, or when the faster one gains less than
|
|
8
|
+
WORTH_FASTER. Speeds are the catalog's: measured on the same device model where a measurement
|
|
9
|
+
exists, an estimate otherwise (memory bandwidth over the bytes read per token, with no
|
|
10
|
+
speculative decoding); the basis travels with each pick and is printed. An estimate is not a
|
|
11
|
+
bound: with MTP on, Qwen3.8-27B decoded prose faster than its estimate on local-118 (CYC2).
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from collections.abc import Sequence
|
|
17
|
+
from typing import TypedDict
|
|
18
|
+
|
|
19
|
+
from localmodels import catalog as cat
|
|
20
|
+
from localmodels import llm_rank
|
|
21
|
+
|
|
22
|
+
# A second choice has to be worth offering: at least this much faster than the smartest.
|
|
23
|
+
WORTH_FASTER = 1.2
|
|
24
|
+
ROLES = ("smartest", "fastest")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class _FitPolicy(TypedDict, total=False):
|
|
28
|
+
candidate_fallback: bool
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Fit(_FitPolicy):
|
|
32
|
+
"""An automatic LLM fit on one card; candidate_fallback never competes with a primary.
|
|
33
|
+
stack_plan names it LlmFit."""
|
|
34
|
+
|
|
35
|
+
id: str
|
|
36
|
+
quant: str
|
|
37
|
+
quality: int
|
|
38
|
+
decode_tok_s: float # calibrated estimate, or a same-device measurement
|
|
39
|
+
decode_basis: str # a catalog.DECODE_BASES key
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Pick(Fit):
|
|
43
|
+
"""One offered LLM. ``role`` is also the ``--prefer`` value that plans it."""
|
|
44
|
+
|
|
45
|
+
role: str
|
|
46
|
+
card: int
|
|
47
|
+
shared: bool # the card runs another program's service: the plan needs --share-gpu
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CardFits(TypedDict):
|
|
51
|
+
"""The fields of stack_plan.Card the picks read."""
|
|
52
|
+
|
|
53
|
+
index: int
|
|
54
|
+
free_bytes: int
|
|
55
|
+
auto: bool
|
|
56
|
+
llm: list[Fit]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def picks(cards: Sequence[CardFits], default: str | None = None) -> list[Pick]:
|
|
60
|
+
"""The smartest fitting LLM, then the fastest when it is another model and worth it. Each
|
|
61
|
+
model counts on the first card that holds it, in the order ``--llm auto`` tries cards (most
|
|
62
|
+
free memory first); ``default`` is the small-Mac default (llm_rank.mac_default). When every
|
|
63
|
+
card that holds a model runs another program's service (a shared Mac's one GPU), the picks
|
|
64
|
+
are what sharing it would install and say so. Empty when nothing eligible fits."""
|
|
65
|
+
free = [c for c in cards if c["auto"] and c["llm"]]
|
|
66
|
+
found: dict[str, Pick] = {}
|
|
67
|
+
for card in sorted(free or cards, key=lambda c: (-c["free_bytes"], c["index"])):
|
|
68
|
+
for fit in card["llm"]:
|
|
69
|
+
found.setdefault(
|
|
70
|
+
fit["id"], {**fit, "role": "", "card": card["index"], "shared": not free}
|
|
71
|
+
)
|
|
72
|
+
if not found:
|
|
73
|
+
return []
|
|
74
|
+
ranked = [((p["quality"], p["decode_tok_s"]), p["id"], p["card"]) for p in found.values()]
|
|
75
|
+
fallback_ids = {p["id"] for p in found.values() if p.get("candidate_fallback")}
|
|
76
|
+
smartest = found[llm_rank.choose(ranked, "smartest", default, fallback_ids=fallback_ids)[0]]
|
|
77
|
+
fastest = found[llm_rank.choose(ranked, "fastest", fallback_ids=fallback_ids)[0]]
|
|
78
|
+
offered: list[Pick] = [{**smartest, "role": "smartest"}]
|
|
79
|
+
if (
|
|
80
|
+
fastest["id"] != smartest["id"]
|
|
81
|
+
and fastest["decode_tok_s"] >= smartest["decode_tok_s"] * WORTH_FASTER
|
|
82
|
+
):
|
|
83
|
+
offered.append({**fastest, "role": "fastest"})
|
|
84
|
+
return offered
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def second(offered: list[Pick], chosen: str) -> Pick | None:
|
|
88
|
+
"""The pick to offer beside a plan whose LLM is ``chosen``: the other one. A plan may hold
|
|
89
|
+
an LLM that is neither (a Strata recipe that beat the smartest llama.cpp model): then the
|
|
90
|
+
fastest pick is the other choice."""
|
|
91
|
+
if chosen in [p["id"] for p in offered]:
|
|
92
|
+
others = [p for p in offered if p["id"] != chosen]
|
|
93
|
+
return others[0] if others else None
|
|
94
|
+
return next((p for p in offered if p["role"] == "fastest"), None)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def label(pick: Fit) -> str:
|
|
98
|
+
"""One pick in a line: model, score, speed and what the speed rests on."""
|
|
99
|
+
score = f"score {pick['quality']}" if pick["quality"] else "no SimplexAI score"
|
|
100
|
+
measured = pick["decode_basis"] == "measured-decode"
|
|
101
|
+
speed = f"{pick['decode_tok_s']:.0f} tok/s " + ("measured" if measured else "estimated")
|
|
102
|
+
candidate = " · candidate product fallback" if pick.get("candidate_fallback") else ""
|
|
103
|
+
return f"{pick['id']} {pick['quant']} · {score} · {speed}{candidate}"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def lines(offered: list[Pick], command: str | None) -> list[str]:
|
|
107
|
+
"""The ``choices`` rows of ``stack hardware``: each pick and the command that installs it;
|
|
108
|
+
``command`` None on a platform that can read its hardware but not install the stack."""
|
|
109
|
+
if not offered:
|
|
110
|
+
return []
|
|
111
|
+
out: list[str] = []
|
|
112
|
+
for pick in offered:
|
|
113
|
+
option = "" if pick["role"] == "smartest" else f" --prefer {pick['role']}"
|
|
114
|
+
head = " choices " if not out else " "
|
|
115
|
+
how = f"; {command} install{option}" if command else ""
|
|
116
|
+
out.append(f"{head}{pick['role']:<9} {label(pick)}{how}")
|
|
117
|
+
if len(offered) == 1:
|
|
118
|
+
out.append(
|
|
119
|
+
" one choice: no other validated LLM that fits is at least "
|
|
120
|
+
f"{WORTH_FASTER:g}x faster"
|
|
121
|
+
)
|
|
122
|
+
if any(p["shared"] for p in offered):
|
|
123
|
+
out.append(
|
|
124
|
+
" the card runs another program's service: once sharing it is "
|
|
125
|
+
"confirmed, add --share-gpu (with --gpu N on an NVIDIA card)"
|
|
126
|
+
)
|
|
127
|
+
if any(p.get("candidate_fallback") for p in offered):
|
|
128
|
+
out.append(f" {llm_rank.WINDOWS_FALLBACK_WARNING}")
|
|
129
|
+
if any(p["decode_basis"] != "measured-decode" for p in offered):
|
|
130
|
+
bases = sorted({p["decode_basis"] for p in offered} - {"measured-decode"})
|
|
131
|
+
out.append(
|
|
132
|
+
" estimated speeds come from "
|
|
133
|
+
+ "; ".join(cat.DECODE_BASES[b] for b in bases)
|
|
134
|
+
+ ", without speculative decoding; stack warm measures the installed one"
|
|
135
|
+
)
|
|
136
|
+
return out
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def alternative_line(offered: list[Pick], chosen: str, command: str) -> str | None:
|
|
140
|
+
"""The plan summary's pointer to the other choice, None when the plan has no second pick."""
|
|
141
|
+
other = second(offered, chosen)
|
|
142
|
+
if other is None:
|
|
143
|
+
return None
|
|
144
|
+
return (
|
|
145
|
+
f" choice also fits, {other['role']}: {label(other)}; plan it with "
|
|
146
|
+
f"{command} stack plan --prefer {other['role']}"
|
|
147
|
+
)
|
|
@@ -12,18 +12,21 @@ from collections.abc import Callable
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
from typing import Literal, TypedDict, cast
|
|
14
14
|
|
|
15
|
-
from localmodels import approval, deploy, gateway, harness, hosts, reuse, vision
|
|
15
|
+
from localmodels import approval, deploy, gateway, harness, hosts, preparation, reuse, vision
|
|
16
|
+
from localmodels.budget import HARNESS_RAM as HARNESS_RAM
|
|
17
|
+
from localmodels.budget import RAM_FLOOR as RAM_FLOOR
|
|
16
18
|
from localmodels.budget import gib
|
|
19
|
+
from localmodels.gateway_bifrost import FAST_PROVIDER
|
|
17
20
|
from localmodels.plan_envelope import PlanError, resolved_name
|
|
18
21
|
from localmodels.plan_envelope import verified_in_place as verified_in_place
|
|
19
|
-
from localmodels.probe import ServiceManager
|
|
22
|
+
from localmodels.probe import HostFacts, ServiceManager
|
|
20
23
|
from localmodels.records import Plan, ReleaseEngine
|
|
24
|
+
from localmodels.stack_picks import Fit, Pick
|
|
21
25
|
|
|
22
26
|
SCHEMA = "localmodels.stack-plan/v1"
|
|
23
27
|
GIB = 1 << 30
|
|
24
|
-
RAM_FLOOR = 4 * GIB # the baseline's host MemAvailable floor
|
|
25
28
|
# A Mac's floor beside the stack (2026-11-09 user decision, from MLO1's recommendation): the
|
|
26
|
-
# memory "available" there
|
|
29
|
+
# memory "available" there counts free + inactive + speculative pages, and macOS reclaims beyond
|
|
27
30
|
# it, so Linux's 4 GiB floor held back a second margin. A 24 GiB Mac ran Ling 128K and 64K with
|
|
28
31
|
# pi for 20+ minutes from 8.4–8.9 GB available, pressure 1 and no swap growth, where the 4 GiB
|
|
29
32
|
# floor refused it (evidence/2026-11-05-mac-llm-only-tiers/REPORT.md). The live gates stay: a
|
|
@@ -35,7 +38,7 @@ METAL_RAM_FLOOR = 1 * GIB
|
|
|
35
38
|
# so a reply that would think without end (14,000 tokens of thinking, no answer, on local-119
|
|
36
39
|
# 2026-11-05) closes its thinking and answers. `--reasoning-budget` overrides it, 0 removes it.
|
|
37
40
|
REASONING_BUDGET = 8192
|
|
38
|
-
|
|
41
|
+
FRONT_ENV_BYTES = 200 << 20 # a decision front's environment: 110 MB source archive plus wheels
|
|
39
42
|
|
|
40
43
|
|
|
41
44
|
def ram_floor(metal: bool) -> int:
|
|
@@ -78,14 +81,22 @@ def guard_details(exc: BaseException) -> dict[str, object]:
|
|
|
78
81
|
|
|
79
82
|
def platform_error(platform: str, profile: str | None = None, arch: str | None = "") -> str | None:
|
|
80
83
|
"""Executable stack recipes, not the controller's ability to inspect a host: Linux, Apple
|
|
81
|
-
Silicon Macs (Metal; an unknown ``arch`` is taken as one)
|
|
82
|
-
MLX installation
|
|
84
|
+
Silicon Macs (Metal; an unknown ``arch`` is taken as one), 64-bit Windows (roadmap decision
|
|
85
|
+
48; an unknown ``arch`` is taken as x64) and the explicit Apple Silicon MLX installation
|
|
86
|
+
preview."""
|
|
83
87
|
if profile == "macos-mlx-preview":
|
|
84
88
|
if platform == "darwin" and arch == "arm64":
|
|
85
89
|
return None
|
|
86
90
|
return "macos-mlx-preview supports Apple Silicon macOS only"
|
|
87
91
|
if platform.startswith("linux"):
|
|
88
92
|
return None
|
|
93
|
+
if platform == "win32" and arch in (None, "", "x64"):
|
|
94
|
+
return None
|
|
95
|
+
if platform == "win32":
|
|
96
|
+
return (
|
|
97
|
+
"on Windows the local model stack supports 64-bit x64 only; this computer's "
|
|
98
|
+
f"architecture is {arch}. Hardware facts can still be inspected."
|
|
99
|
+
)
|
|
89
100
|
if platform == "darwin" and arch in (None, "", "arm64"):
|
|
90
101
|
return None
|
|
91
102
|
if platform == "darwin":
|
|
@@ -94,7 +105,8 @@ def platform_error(platform: str, profile: str | None = None, arch: str | None =
|
|
|
94
105
|
f"architecture is {arch}. Hardware facts can still be inspected."
|
|
95
106
|
)
|
|
96
107
|
return (
|
|
97
|
-
"the local model stack supports Linux
|
|
108
|
+
"the local model stack supports Linux, Apple Silicon Macs and 64-bit Windows only; this"
|
|
109
|
+
" platform is "
|
|
98
110
|
f"{platform}. Hardware facts can still be inspected."
|
|
99
111
|
)
|
|
100
112
|
|
|
@@ -141,10 +153,14 @@ class _OptionsSince20261022(TypedDict, total=False):
|
|
|
141
153
|
# "K/V" and the catalog variant. Absent: the plan chooses them, as every older plan did.
|
|
142
154
|
kv: str
|
|
143
155
|
quant: str
|
|
156
|
+
route: str # opt-in fastest target for easy Bifrost turns; absent preserves older plans
|
|
157
|
+
llm_fast_port: int # resolved when route is enabled, bound by approval
|
|
144
158
|
|
|
145
159
|
|
|
146
160
|
# The scenarios a user picks instead of weights (roadmap decision 26, docs/local-models/model-scoring.md).
|
|
147
|
-
|
|
161
|
+
# Since 2026-11-12 (decision 45): fastest, the highest decode speed that fits whatever its score,
|
|
162
|
+
# the second choice `stack` offers beside smartest (stack_picks).
|
|
163
|
+
PREFERENCES = ("smartest", "concurrent", "fast", "fastest")
|
|
148
164
|
|
|
149
165
|
|
|
150
166
|
class StackOptions(_OptionsSince20261022):
|
|
@@ -173,14 +189,7 @@ class DecisionOption(TypedDict):
|
|
|
173
189
|
commercial_use: bool
|
|
174
190
|
|
|
175
191
|
|
|
176
|
-
|
|
177
|
-
"""A validated LLM that passes the agent gate on one card (stack_hardware.llm_fits)."""
|
|
178
|
-
|
|
179
|
-
id: str
|
|
180
|
-
quant: str
|
|
181
|
-
quality: int
|
|
182
|
-
decode_tok_s: float # estimate: bandwidth over bytes read per token, an upper bound
|
|
183
|
-
decode_basis: str # a catalog.DECODE_BASES key
|
|
192
|
+
LlmFit = Fit
|
|
184
193
|
|
|
185
194
|
|
|
186
195
|
class _CardSince20261028(TypedDict, total=False):
|
|
@@ -220,7 +229,13 @@ class _HardwareSince20261031(_HardwareSince20261029, total=False):
|
|
|
220
229
|
service_manager: ServiceManager
|
|
221
230
|
|
|
222
231
|
|
|
223
|
-
class
|
|
232
|
+
class _HardwareSince20261112(_HardwareSince20261031, total=False):
|
|
233
|
+
# The LLMs offered for this computer, smartest first, then the fastest when it is another
|
|
234
|
+
# model (stack_picks.picks). A plan's snapshot keeps them so its summary names the other.
|
|
235
|
+
picks: list[Pick]
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class Hardware(_HardwareSince20261112):
|
|
224
239
|
"""What stack_hardware reads from the host; a plan keeps it as ``hardware``."""
|
|
225
240
|
|
|
226
241
|
hostname: str
|
|
@@ -238,7 +253,7 @@ class Hardware(_HardwareSince20261031):
|
|
|
238
253
|
class UpdateChange(TypedDict):
|
|
239
254
|
"""One component of an update plan against the accepted plan it updates."""
|
|
240
255
|
|
|
241
|
-
role: str # llm | decision | decision_front | an auxiliary contract
|
|
256
|
+
role: str # llm | llm_fast | decision | decision_front | an auxiliary contract
|
|
242
257
|
action: str # keep | replace | add | retire
|
|
243
258
|
old: str | None # its deployment in the base plan
|
|
244
259
|
new: str | None # its deployment in this plan
|
|
@@ -255,6 +270,26 @@ class Update(TypedDict):
|
|
|
255
270
|
retire: list[str]
|
|
256
271
|
|
|
257
272
|
|
|
273
|
+
class PreflightFinding(TypedDict):
|
|
274
|
+
"""One read-only check of the computer the plan will run on (stack_preflight)."""
|
|
275
|
+
|
|
276
|
+
check: str # a stable id: preflight.memory, preflight.gpu, ...
|
|
277
|
+
level: str # pass | warn | fail (a str, not a Literal: contracts.decode does not take them)
|
|
278
|
+
detail: str # what was read; never a key, a prompt, an answer or a log line
|
|
279
|
+
fix: str # what to do next; empty when nothing is needed
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class Preflight(TypedDict):
|
|
283
|
+
"""What ``stack plan`` read about this computer before it asked for approval. An
|
|
284
|
+
observation, like ``hardware``: approving a plan does not bind it, and a changed reading
|
|
285
|
+
never invalidates an approval."""
|
|
286
|
+
|
|
287
|
+
schema: str
|
|
288
|
+
live: bool # False: saved --facts were checked, not this computer now
|
|
289
|
+
counts: dict[str, int] # pass, warn, fail
|
|
290
|
+
findings: list[PreflightFinding]
|
|
291
|
+
|
|
292
|
+
|
|
258
293
|
class _PlanSince20261022(TypedDict, total=False):
|
|
259
294
|
decision_front: Plan | None # startlux-decide in front of the decision llama-server
|
|
260
295
|
# Reserved plans for the background worker: the decision model and its front; on unified
|
|
@@ -264,6 +299,9 @@ class _PlanSince20261022(TypedDict, total=False):
|
|
|
264
299
|
# Since 2026-10-28: the readings the plan was priced against, shown in its summary; not a
|
|
265
300
|
# section approval binds.
|
|
266
301
|
hardware: Hardware
|
|
302
|
+
# Since 2026-11-09: checks of this computer made beside the plan (stack_preflight), shown in
|
|
303
|
+
# its summary; an observation too, never a section approval binds.
|
|
304
|
+
preflight: Preflight
|
|
267
305
|
update: Update # since 2026-11-03: what an update plan changes against its base
|
|
268
306
|
|
|
269
307
|
|
|
@@ -271,6 +309,7 @@ class _PlanSince20261110(_PlanSince20261022, total=False):
|
|
|
271
309
|
# A fresh plan's earlier stack deployments of the same base directory whose roles it takes
|
|
272
310
|
# over under other names; apply removes them (model files and logs stay) first.
|
|
273
311
|
replaces: list[str]
|
|
312
|
+
llm_fast: Plan # optional second LLM, only with --route fastest
|
|
274
313
|
|
|
275
314
|
|
|
276
315
|
class StackPlan(_PlanSince20261110): # plans saved before 2026-10-22 lack the optional keys
|
|
@@ -302,7 +341,13 @@ class DecisionChoice(TypedDict):
|
|
|
302
341
|
options: list[DecisionOption]
|
|
303
342
|
|
|
304
343
|
|
|
305
|
-
class
|
|
344
|
+
class _RouteParts(TypedDict, total=False):
|
|
345
|
+
llm_fast: Plan
|
|
346
|
+
llm_fast_running: bool
|
|
347
|
+
llm_fast_ram: int
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class Parts(_RouteParts):
|
|
306
351
|
"""What one branch of ``stack plan`` picks; stack_compose.assemble prices it as one stack."""
|
|
307
352
|
|
|
308
353
|
llm: Plan
|
|
@@ -345,6 +390,11 @@ class StackRecord(_RunFields):
|
|
|
345
390
|
deployments: list[str] # names of the deployments this apply ran; stack remove's scope
|
|
346
391
|
|
|
347
392
|
|
|
393
|
+
def default_gateway(platform: str = sys.platform) -> str:
|
|
394
|
+
"""Bifrost, except on Windows: no Windows Bifrost build is pinned, Magpie's is (decision 32)."""
|
|
395
|
+
return "magpie" if platform == "win32" else harness.DEFAULT_GATEWAY
|
|
396
|
+
|
|
397
|
+
|
|
348
398
|
def default_options() -> StackOptions:
|
|
349
399
|
return {
|
|
350
400
|
"llm": "auto",
|
|
@@ -364,7 +414,7 @@ def default_options() -> StackOptions:
|
|
|
364
414
|
"tts": False,
|
|
365
415
|
"search": True,
|
|
366
416
|
"reasoning_budget": REASONING_BUDGET,
|
|
367
|
-
"gateway":
|
|
417
|
+
"gateway": default_gateway(),
|
|
368
418
|
"vision": vision.DEFAULT,
|
|
369
419
|
}
|
|
370
420
|
|
|
@@ -383,6 +433,7 @@ def gateway_lines(plan: StackPlan) -> list[str]:
|
|
|
383
433
|
bifrost = harness.gateway_kind(gw) == "bifrost"
|
|
384
434
|
lines = [
|
|
385
435
|
f" gateway {'Bifrost' if bifrost else 'Magpie'} {gw['addr']}: {gw['llm_provider']}"
|
|
436
|
+
+ (f", {FAST_PROVIDER}" if gw.get("llm_fast") else "")
|
|
386
437
|
+ (f", {gw['decision_provider']}" if gw["decision"] else "")
|
|
387
438
|
+ "".join(f", {pid}" for pid in aux_providers)
|
|
388
439
|
+ (
|
|
@@ -407,7 +458,13 @@ def gateway_lines(plan: StackPlan) -> list[str]:
|
|
|
407
458
|
def deployments(plan: StackPlan) -> list[Plan]:
|
|
408
459
|
"""Every deployment a stack plan holds: the LLM, the decision model and its front, and the
|
|
409
460
|
auxiliaries. Planning, apply and stack remove all take a plan's parts from here."""
|
|
410
|
-
parts = [
|
|
461
|
+
parts = [
|
|
462
|
+
plan["llm"],
|
|
463
|
+
plan.get("llm_fast"),
|
|
464
|
+
plan["decision"],
|
|
465
|
+
plan.get("decision_front"),
|
|
466
|
+
*plan.get("aux", []),
|
|
467
|
+
]
|
|
411
468
|
return [p for p in parts if p is not None]
|
|
412
469
|
|
|
413
470
|
|
|
@@ -483,17 +540,78 @@ def reuse_copies(
|
|
|
483
540
|
for f in part["files"]:
|
|
484
541
|
copy = copies.get(f["path"].rsplit("/", 1)[-1])
|
|
485
542
|
if verified_in_place(f) or f.get("reuse"):
|
|
486
|
-
|
|
543
|
+
if not f.get("generated"):
|
|
544
|
+
saved += f["size_bytes"]
|
|
487
545
|
elif copy:
|
|
488
546
|
f["reuse"] = copy
|
|
489
|
-
|
|
547
|
+
if not f.get("generated"):
|
|
548
|
+
saved += f["size_bytes"]
|
|
490
549
|
notes.append(
|
|
491
550
|
f"reusing {copy} on this computer ({gib(f['size_bytes'])}): its SHA256 is "
|
|
492
|
-
"checked first and it is hard-linked only on a match, else
|
|
551
|
+
"checked first and it is hard-linked only on a match, else "
|
|
552
|
+
+ ("prepared from pinned inputs" if f.get("generated") else "downloaded")
|
|
493
553
|
)
|
|
494
554
|
return saved, notes
|
|
495
555
|
|
|
496
556
|
|
|
557
|
+
def engine_download_bytes(parts: list[Plan]) -> int:
|
|
558
|
+
"""Engine archives to fetch, once per engine directory (several components share a build)."""
|
|
559
|
+
by_dir = {
|
|
560
|
+
str(p["engine"].get("dir") or id(p)): sum(a["size_bytes"] for a in p["engine"]["assets"])
|
|
561
|
+
for p in parts
|
|
562
|
+
if p["engine"].get("assets")
|
|
563
|
+
}
|
|
564
|
+
return sum(by_dir.values())
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def download_budget(
|
|
568
|
+
facts: HostFacts,
|
|
569
|
+
fresh: list[Plan],
|
|
570
|
+
tools: harness.HarnessPlan,
|
|
571
|
+
front: Plan | None,
|
|
572
|
+
copies: Callable[[dict[str, tuple[int, str]]], dict[str, str]],
|
|
573
|
+
) -> tuple[dict[str, object], list[str]]:
|
|
574
|
+
"""Network and peak disk for fresh components, including verified reuse and preparation."""
|
|
575
|
+
front_env = FRONT_ENV_BYTES if any(front is p for p in fresh) else 0
|
|
576
|
+
# Installed venvs also occupy the installer's cache; engine and tool archives stay on disk.
|
|
577
|
+
venvs = sum(int(str(p["launch"].get("frontend_bytes", 0))) for p in fresh)
|
|
578
|
+
engine_bytes = engine_download_bytes(fresh)
|
|
579
|
+
saved, notes = reuse_copies(fresh, copies)
|
|
580
|
+
preparations = [preparation.cost(p) for p in fresh]
|
|
581
|
+
preparation_downloads = sum(p.download_bytes for p in preparations)
|
|
582
|
+
preparation_disk = sum(p.disk_bytes for p in preparations)
|
|
583
|
+
downloads = (
|
|
584
|
+
sum(p["model"]["download_bytes"] for p in fresh)
|
|
585
|
+
+ engine_bytes
|
|
586
|
+
+ tools["download_bytes"]
|
|
587
|
+
+ front_env
|
|
588
|
+
+ venvs
|
|
589
|
+
+ preparation_downloads
|
|
590
|
+
- saved
|
|
591
|
+
)
|
|
592
|
+
disk_needed = (
|
|
593
|
+
downloads
|
|
594
|
+
- preparation_downloads
|
|
595
|
+
+ preparation_disk
|
|
596
|
+
+ engine_bytes
|
|
597
|
+
+ tools["download_bytes"]
|
|
598
|
+
+ 3 * front_env
|
|
599
|
+
+ venvs
|
|
600
|
+
)
|
|
601
|
+
free = facts["disk"]["free_bytes"]
|
|
602
|
+
if free is not None and disk_needed > free:
|
|
603
|
+
raise StackError(
|
|
604
|
+
f"not enough disk space: the stack needs about {gib(disk_needed)}, "
|
|
605
|
+
f"{facts['disk']['path']} has only {gib(free)} free"
|
|
606
|
+
)
|
|
607
|
+
return {
|
|
608
|
+
"disk_free_bytes": free,
|
|
609
|
+
"disk_needed_bytes": disk_needed,
|
|
610
|
+
"download_bytes": downloads,
|
|
611
|
+
"reused_bytes": saved,
|
|
612
|
+
}, notes
|
|
613
|
+
|
|
614
|
+
|
|
497
615
|
def engine_line(part: Plan) -> str:
|
|
498
616
|
"""The engine the component runs on: a pinned build with what it needs, or a host binary."""
|
|
499
617
|
e = part["engine"]
|
|
@@ -86,6 +86,28 @@ def private_previous(
|
|
|
86
86
|
return None
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
def failed_own_port(model_ids: Sequence[str], base_dir: str) -> int | None:
|
|
90
|
+
"""The port of this root's newest deployment of these models when its last apply failed
|
|
91
|
+
and its directory is still there. Its service can still be running and holding the port; a
|
|
92
|
+
new plan on another port would leave it behind, so the retry replaces it in place (install
|
|
93
|
+
proves the running process is that deployment's before stopping it)."""
|
|
94
|
+
base = Path(base_dir).expanduser().resolve() / "deployments"
|
|
95
|
+
for record in reversed(hosts.records(hosts.LOCAL_ID)):
|
|
96
|
+
plan = record["plan"]
|
|
97
|
+
service = plan["service"]
|
|
98
|
+
directory = Path(service["deploy_dir"]).expanduser().resolve()
|
|
99
|
+
if (
|
|
100
|
+
plan["model"]["id"] not in model_ids
|
|
101
|
+
or directory.parent != base
|
|
102
|
+
or plan["name"] != own_name(plan["model"]["id"], service["port"], base_dir)
|
|
103
|
+
):
|
|
104
|
+
continue
|
|
105
|
+
if record["ok"] or not (directory / "deployment.json").is_file():
|
|
106
|
+
return None
|
|
107
|
+
return int(service["port"])
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
|
|
89
111
|
def loopback_listening(port: int) -> bool:
|
|
90
112
|
"""Keep planning failures typed while sharing the lower-level listener proof."""
|
|
91
113
|
try:
|