@simplexai/localmodels-linux-x64 0.1.0-dev.55 → 0.1.0-dev.56
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 +41 -36
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/bifrost_admin.py +336 -0
- package/modules/localmodels/bifrost_checks.py +12 -2
- package/modules/localmodels/bifrost_config.py +13 -5
- package/modules/localmodels/catalog.json +2 -1
- package/modules/localmodels/engines.py +24 -1
- package/modules/localmodels/library_floor.py +3 -1
- package/modules/localmodels/library_gateway.py +26 -4
- package/modules/localmodels/library_jobs.py +44 -6
- package/modules/localmodels/library_kept.py +117 -0
- package/modules/localmodels/library_model.py +1 -0
- package/modules/localmodels/library_order.py +234 -0
- package/modules/localmodels/library_poly.py +20 -16
- package/modules/localmodels/library_pricing.py +8 -1
- package/modules/localmodels/library_serve.py +9 -3
- package/modules/localmodels/library_state.py +12 -2
- package/modules/localmodels/library_status.py +2 -0
- package/modules/localmodels/llm_rank.py +11 -8
- package/modules/localmodels/mirrors.py +464 -0
- package/modules/localmodels/recommend.py +2 -2
- package/modules/localmodels/records.py +1 -0
- package/modules/localmodels/region.py +457 -42
- package/modules/localmodels/remote_ops.py +130 -33
- package/modules/localmodels/remote_ops_download.py +313 -273
- package/modules/localmodels/remote_ops_mirrors.py +290 -0
- package/modules/localmodels/runtime-lock.json +19 -19
- package/modules/localmodels/runtime_io.py +2 -4
- package/modules/localmodels/setup_inspection.py +4 -0
- package/modules/localmodels/stack_auto.py +38 -5
- package/modules/localmodels/stack_compose.py +2 -1
- package/modules/localmodels/stack_try.py +4 -1
- package/modules/localmodels/transport.py +1 -0
- package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/RECORD +38 -33
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -47,6 +47,24 @@ class EngineUnavailableError(PlanError):
|
|
|
47
47
|
self.missing_libraries = missing_libraries
|
|
48
48
|
|
|
49
49
|
|
|
50
|
+
# Minimum NVIDIA display driver branch supporting each CUDA minor version
|
|
51
|
+
# (NVIDIA CUDA Compatibility Table). Unmapped versions return "" rather than
|
|
52
|
+
# guessing a driver branch.
|
|
53
|
+
_MIN_DRIVER_BY_CUDA: dict[tuple[int, int], str] = {
|
|
54
|
+
(12, 4): "550",
|
|
55
|
+
(12, 6): "560",
|
|
56
|
+
(12, 8): "570",
|
|
57
|
+
(12, 9): "575",
|
|
58
|
+
(13, 0): "580",
|
|
59
|
+
(13, 1): "580",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def min_driver_for_cuda(required_cuda: str) -> str:
|
|
64
|
+
"""Minimum NVIDIA display driver branch supporting ``required_cuda``, or empty."""
|
|
65
|
+
return _MIN_DRIVER_BY_CUDA.get(_cuda_tuple(required_cuda), "")
|
|
66
|
+
|
|
67
|
+
|
|
50
68
|
class CudaDriverError(PlanError):
|
|
51
69
|
"""The host's NVIDIA driver supports too old a CUDA version, or none could be detected."""
|
|
52
70
|
|
|
@@ -57,11 +75,13 @@ class CudaDriverError(PlanError):
|
|
|
57
75
|
required_cuda: str,
|
|
58
76
|
detected_cuda: str = "",
|
|
59
77
|
driver_version: str = "",
|
|
78
|
+
required_driver: str = "",
|
|
60
79
|
) -> None:
|
|
61
80
|
super().__init__(message)
|
|
62
81
|
self.required_cuda = required_cuda
|
|
63
82
|
self.detected_cuda = detected_cuda
|
|
64
83
|
self.driver_version = driver_version
|
|
84
|
+
self.required_driver = required_driver or min_driver_for_cuda(required_cuda)
|
|
65
85
|
|
|
66
86
|
|
|
67
87
|
def _version(text: str | None) -> tuple[int, ...]:
|
|
@@ -161,7 +181,9 @@ def select_engine_build(
|
|
|
161
181
|
)
|
|
162
182
|
if not builds:
|
|
163
183
|
if backend == "cuda" and platform_builds:
|
|
164
|
-
|
|
184
|
+
oldest_build = min(platform_builds, key=lambda b: _cuda_tuple(b["min_cuda"]))
|
|
185
|
+
oldest = oldest_build["min_cuda"]
|
|
186
|
+
required_driver = oldest_build.get("min_driver") or min_driver_for_cuda(oldest)
|
|
165
187
|
driver_version = ((facts.get("nvidia") or {}).get("driver_version") or "").strip()
|
|
166
188
|
if driver == (0, 0):
|
|
167
189
|
detail = f" (could not detect the driver's CUDA version; requires CUDA >= {oldest})"
|
|
@@ -178,6 +200,7 @@ def select_engine_build(
|
|
|
178
200
|
required_cuda=oldest,
|
|
179
201
|
detected_cuda=detected,
|
|
180
202
|
driver_version=driver_version,
|
|
203
|
+
required_driver=required_driver,
|
|
181
204
|
)
|
|
182
205
|
raise PlanError(
|
|
183
206
|
f"no {lock['tag']} prebuilt engine for {platform}/{facts.get('arch')}/{backend}"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from localmodels import budget, context_policy, library_pricing, metal, suite, vision
|
|
5
|
+
from localmodels import budget, context_policy, library_kept, library_pricing, metal, suite, vision
|
|
6
6
|
from localmodels.estimator import agent_footprint_bytes, eager
|
|
7
7
|
from localmodels.library_pricing import Model
|
|
8
8
|
from localmodels.probe import HostFacts
|
|
@@ -22,6 +22,8 @@ def floor_metadata(
|
|
|
22
22
|
unified memory, and avoids mixing host RAM shortfalls (``memory_kind == "ram"``) into VRAM
|
|
23
23
|
floor bytes.
|
|
24
24
|
"""
|
|
25
|
+
if library_kept.retired(model.entry): # no recipe left to price; only what was on disk
|
|
26
|
+
return shortfall_bytes, 0, False, sum(f.size_bytes for f in model.variant.files)
|
|
25
27
|
if model.entry.runtime == "strata-poly":
|
|
26
28
|
recipe = suite.recipe(model.entry.id)
|
|
27
29
|
window = int(recipe.get("context") or model.entry.n_ctx_train)
|
|
@@ -23,6 +23,7 @@ from pathlib import Path
|
|
|
23
23
|
from typing import Any
|
|
24
24
|
|
|
25
25
|
from localmodels import (
|
|
26
|
+
bifrost_admin,
|
|
26
27
|
bifrost_config,
|
|
27
28
|
bifrost_datasheet,
|
|
28
29
|
bifrost_models,
|
|
@@ -163,12 +164,33 @@ def read_sheet(app: Path) -> dict[str, Any]:
|
|
|
163
164
|
|
|
164
165
|
|
|
165
166
|
def apply_config(record: hosts.OwnedBifrost, config: dict[str, Any], sheet: dict[str, Any]) -> None:
|
|
166
|
-
"""
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
"""Apply updated config and datasheet to the gateway.
|
|
168
|
+
|
|
169
|
+
When the owned Bifrost is already running and only hot-reloadable state changed (providers,
|
|
170
|
+
routing rules, removing the complexity analyzer, or model context windows), push the delta
|
|
171
|
+
through Bifrost's Admin API and persist ``config.json``/datasheets without dropping
|
|
172
|
+
``config.db`` or restarting the process — keeping active streams on other models alive.
|
|
173
|
+
Any Admin API error or non-hot-reloadable change falls back to the cold-restart path. A
|
|
174
|
+
gateway left with no provider at all (no library model, and nothing of the stack such as
|
|
175
|
+
its LLM, decision model or foundation services) serves nobody: it is stopped instead, its
|
|
176
|
+
record and config kept, and the next load starts it again."""
|
|
170
177
|
app = Path(record["app_dir"])
|
|
171
178
|
params = {bifrost_datasheet.DATASHEET: sheet, bifrost_datasheet.PARAMETERS: {}}
|
|
179
|
+
if config.get("providers") and bifrost_config.differs(app, config, params):
|
|
180
|
+
before = gateway_bifrost.read_config(app)
|
|
181
|
+
before_sheet = read_sheet(app)
|
|
182
|
+
if gateway_bifrost._healthy_owned(record) and bifrost_admin.can_hot_reload(before, config):
|
|
183
|
+
try:
|
|
184
|
+
bifrost_admin.sync_live(
|
|
185
|
+
record,
|
|
186
|
+
before,
|
|
187
|
+
config,
|
|
188
|
+
params,
|
|
189
|
+
sheet_changed=(sheet != before_sheet),
|
|
190
|
+
)
|
|
191
|
+
return
|
|
192
|
+
except bifrost_admin.AdminError:
|
|
193
|
+
pass # fall back to cold restart so config.json and config.db converge cleanly
|
|
172
194
|
if (
|
|
173
195
|
STOP_BEFORE_CONFIG_CHANGE
|
|
174
196
|
and record["how"] != "unit"
|
|
@@ -179,8 +179,9 @@ def _download_telemetry(phase: str, event: dict[str, object]) -> tuple[str | Non
|
|
|
179
179
|
|
|
180
180
|
|
|
181
181
|
class _Counter:
|
|
182
|
-
"""Bytes of the whole model
|
|
183
|
-
|
|
182
|
+
"""Bytes of the whole model (plus engine archives whenever the engine step downloads them):
|
|
183
|
+
the files already verified (or partially downloaded on disk) count as done; each progress
|
|
184
|
+
event moves its file's counter for the phase it reports."""
|
|
184
185
|
|
|
185
186
|
def __init__(self, model: str, plan: Plan, handle: JobHandle) -> None:
|
|
186
187
|
self.model, self.handle = model, handle
|
|
@@ -198,20 +199,55 @@ class _Counter:
|
|
|
198
199
|
)
|
|
199
200
|
for f in plan["files"]
|
|
200
201
|
}
|
|
202
|
+
self.engine_sizes: dict[str, int] = {}
|
|
203
|
+
self.engine_done: dict[str, int] = {}
|
|
204
|
+
self._include_engine = False
|
|
205
|
+
engine_spec = plan.get("engine")
|
|
206
|
+
if isinstance(engine_spec, dict) and engine_spec.get("source") == "release":
|
|
207
|
+
engine_dir = os.path.expanduser(str(engine_spec.get("dir") or ""))
|
|
208
|
+
archive_cache = os.path.join(os.path.dirname(engine_dir), ".archives")
|
|
209
|
+
for asset in engine_spec.get("assets") or ():
|
|
210
|
+
name = str(asset["name"])
|
|
211
|
+
size = int(asset["size_bytes"])
|
|
212
|
+
self.engine_sizes[name] = size
|
|
213
|
+
archive = os.path.join(archive_cache, name)
|
|
214
|
+
if os.path.isfile(archive) and os.path.getsize(archive) == size:
|
|
215
|
+
self.engine_done[name] = size
|
|
216
|
+
else:
|
|
217
|
+
self.engine_done[name] = min(
|
|
218
|
+
size, remote_ops_download.kept_bytes(archive + ".part", size)
|
|
219
|
+
)
|
|
201
220
|
|
|
202
221
|
@property
|
|
203
222
|
def total(self) -> int:
|
|
204
|
-
|
|
223
|
+
base = sum(self.sizes.values())
|
|
224
|
+
return base + sum(self.engine_sizes.values()) if self._include_engine else base
|
|
225
|
+
|
|
226
|
+
def finish_engine(self) -> None:
|
|
227
|
+
"""Mark engine assets complete once the engine step succeeds, keeping progress monotonic."""
|
|
228
|
+
if not self._include_engine:
|
|
229
|
+
return
|
|
230
|
+
for name, size in self.engine_sizes.items():
|
|
231
|
+
self.engine_done[name] = size
|
|
205
232
|
|
|
206
233
|
def __call__(self, event: dict[str, object]) -> None:
|
|
207
234
|
label = str(event.get("file") or "")
|
|
208
|
-
if event.get("event") != "progress"
|
|
235
|
+
if event.get("event") != "progress":
|
|
236
|
+
return
|
|
237
|
+
if label in self.sizes:
|
|
238
|
+
target_done, target_sizes = self.done, self.sizes
|
|
239
|
+
elif label in self.engine_sizes:
|
|
240
|
+
self._include_engine = True
|
|
241
|
+
target_done, target_sizes = self.engine_done, self.engine_sizes
|
|
242
|
+
else:
|
|
209
243
|
return
|
|
210
244
|
phase: Phase = "verify" if event.get("phase") == "verify" else "download"
|
|
211
245
|
done = event.get("done")
|
|
212
246
|
speed = event.get("bytes_per_s")
|
|
213
|
-
|
|
247
|
+
target_done[label] = min(target_sizes[label], int(done) if isinstance(done, int) else 0)
|
|
214
248
|
finished = sum(min(n, self.sizes[k]) for k, n in self.done.items())
|
|
249
|
+
if self._include_engine:
|
|
250
|
+
finished += sum(min(n, self.engine_sizes[k]) for k, n in self.engine_done.items())
|
|
215
251
|
rate = int(speed) if isinstance(speed, int) and phase == "download" else 0
|
|
216
252
|
source, connections = _download_telemetry(phase, event)
|
|
217
253
|
self.handle.update(
|
|
@@ -273,13 +309,15 @@ def fetch(
|
|
|
273
309
|
steps = ("engine", *steps)
|
|
274
310
|
mine: Plan = {**plan, "files": _with_reuse(files) if files else files}
|
|
275
311
|
for step in steps:
|
|
276
|
-
on_event = counter if step
|
|
312
|
+
on_event = counter if step in ("engine", "download") else None
|
|
277
313
|
outcome, result = run.run_action(
|
|
278
314
|
step, deploy_steps.step_params(mine, step, ""), on_event=on_event or (lambda _e: None)
|
|
279
315
|
)
|
|
280
316
|
if result.returncode != 0 or outcome.get("event") != "result":
|
|
281
317
|
message = str(outcome.get("message") or result.stderr.strip()[-500:] or "failed")
|
|
282
318
|
raise LibraryError(_code(message), message, failed=True)
|
|
319
|
+
if step == "engine":
|
|
320
|
+
counter.finish_engine()
|
|
283
321
|
if engine and (reqs := plan["launch"].get("frontend_requirements")):
|
|
284
322
|
try:
|
|
285
323
|
frontend.install(str(plan["launch"]["frontend_base_dir"]), str(reqs))
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Library models on disk that this version's catalog no longer offers as library models.
|
|
2
|
+
|
|
3
|
+
A Quick Install stack an older version accepted can leave a library record whose id the current
|
|
4
|
+
catalog does not list as a library model: dev37-dev49 kits picked ``qwen3.6-35b-a3b-q3-poly`` and
|
|
5
|
+
``qwen3.6-35b-a3b-q4-poly`` (PolyStrata components without a model card), and dev37-dev40 kits
|
|
6
|
+
picked fast LLMs since retired (``lfm3-1.7b``, ``spark-x2.6-1.7b``). The first library command
|
|
7
|
+
adopted them, so ``library status``, ``unload``, ``remove`` and ``source apply`` meet their ids.
|
|
8
|
+
|
|
9
|
+
Such a record resolves through what is on disk. A PolyStrata recipe the catalog still ships under
|
|
10
|
+
the same id and quant is that recipe (the same pinned weights, so ``load`` starts it on today's
|
|
11
|
+
engine without downloading them again). When the recipe states no model card, it takes the card
|
|
12
|
+
of the catalog chat model from the same repository. Anything else is ``retired``: described by
|
|
13
|
+
its recorded plan, listed, unloadable and removable, and refused by ``load``.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import dataclasses
|
|
19
|
+
from collections.abc import Iterable
|
|
20
|
+
|
|
21
|
+
from localmodels import catalog as cat
|
|
22
|
+
from localmodels import library_poly, library_state, suite
|
|
23
|
+
from localmodels.library_state import Record
|
|
24
|
+
|
|
25
|
+
RETIRED = "retired"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _recipe(record: Record) -> suite.SuiteRecipe | None:
|
|
29
|
+
for recipe in suite.recipes("llm"):
|
|
30
|
+
if (
|
|
31
|
+
recipe["id"] == record["catalog_id"]
|
|
32
|
+
and recipe["version"] == record["quant"]
|
|
33
|
+
and recipe["runtime"] == "strata-poly"
|
|
34
|
+
):
|
|
35
|
+
return recipe
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _named(entry: cat.CatalogEntry, catalog: Iterable[cat.CatalogEntry]) -> cat.CatalogEntry:
|
|
40
|
+
"""``entry`` with the model card of the llama.cpp chat model from the same repository."""
|
|
41
|
+
twin = next(
|
|
42
|
+
(
|
|
43
|
+
e
|
|
44
|
+
for e in catalog
|
|
45
|
+
if e.runtime == "llama.cpp" and e.repo == entry.repo and e.display_name
|
|
46
|
+
),
|
|
47
|
+
None,
|
|
48
|
+
)
|
|
49
|
+
if twin is None:
|
|
50
|
+
return entry
|
|
51
|
+
return dataclasses.replace(
|
|
52
|
+
entry,
|
|
53
|
+
display_name=f"{twin.display_name} PolyStrata", # never the llama.cpp row's name
|
|
54
|
+
description=twin.description,
|
|
55
|
+
family=twin.family,
|
|
56
|
+
publisher=twin.publisher,
|
|
57
|
+
parameters=twin.parameters,
|
|
58
|
+
active_parameters=twin.active_parameters,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _runtime(record: Record) -> str:
|
|
63
|
+
build = str(record["plan"]["engine"].get("build") or "")
|
|
64
|
+
if build.startswith("strata-poly"):
|
|
65
|
+
return "strata-poly"
|
|
66
|
+
if build.startswith("strata"):
|
|
67
|
+
return "strata"
|
|
68
|
+
return "llama.cpp"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _retired(record: Record) -> tuple[cat.CatalogEntry, cat.QuantVariant]:
|
|
72
|
+
plan = record["plan"]
|
|
73
|
+
spec = plan["model"]
|
|
74
|
+
files = tuple(
|
|
75
|
+
cat.AssetFile(
|
|
76
|
+
path=str(f.get("path") or f.get("local_name") or ""),
|
|
77
|
+
size_bytes=int(f.get("size_bytes") or 0),
|
|
78
|
+
local=str(f.get("local_name") or "") or None,
|
|
79
|
+
revision=str(f.get("revision") or "main"),
|
|
80
|
+
sha256=str(f.get("sha256") or "") or None,
|
|
81
|
+
)
|
|
82
|
+
for f in plan["files"]
|
|
83
|
+
)
|
|
84
|
+
variant = cat.QuantVariant(quant=record["quant"], files=files)
|
|
85
|
+
entry = cat.CatalogEntry(
|
|
86
|
+
id=record["catalog_id"],
|
|
87
|
+
display_name=str(spec.get("display_name") or record["catalog_id"]),
|
|
88
|
+
description="",
|
|
89
|
+
repo=str(spec.get("repo") or ""),
|
|
90
|
+
variants=(variant,),
|
|
91
|
+
n_ctx_train=int(str(plan["launch"].get("window") or 0)),
|
|
92
|
+
full_layers=0,
|
|
93
|
+
recurrent_layers=0,
|
|
94
|
+
per_layer_f16=0,
|
|
95
|
+
status=RETIRED,
|
|
96
|
+
tasks=("llm",),
|
|
97
|
+
runtime=_runtime(record),
|
|
98
|
+
)
|
|
99
|
+
return entry, variant
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def find_entry(
|
|
103
|
+
model_id: str, catalog: Iterable[cat.CatalogEntry]
|
|
104
|
+
) -> tuple[cat.CatalogEntry, cat.QuantVariant] | None:
|
|
105
|
+
"""The model a library record on disk names by its full ``id:QUANT``, or None."""
|
|
106
|
+
record = library_state.load(model_id)
|
|
107
|
+
if record is None or record["id"] != model_id:
|
|
108
|
+
return None
|
|
109
|
+
if (recipe := _recipe(record)) is not None:
|
|
110
|
+
entry, variant = library_poly.as_entry(recipe)
|
|
111
|
+
return (entry if recipe.get("display_name") else _named(entry, catalog)), variant
|
|
112
|
+
return _retired(record)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def retired(entry: cat.CatalogEntry) -> bool:
|
|
116
|
+
"""Whether ``entry`` is a kept model this version cannot load."""
|
|
117
|
+
return entry.status == RETIRED
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"""Suitability ordering for ``library status`` rows across Apple Silicon, Linux and Windows.
|
|
2
|
+
|
|
3
|
+
Apple Silicon Macs order rows around the Mac small-memory ladder (Decision 68). Linux and
|
|
4
|
+
Windows hosts order rows around validated intelligence, context window, quantization precision,
|
|
5
|
+
actionable driver/runtime upgrades and memory shortfall, demoting the Windows small-card
|
|
6
|
+
fallback below validated models whenever a validated model fits (Decision 69).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from localmodels import budget, library_pricing, llm_rank, metal
|
|
12
|
+
from localmodels import catalog as cat
|
|
13
|
+
from localmodels.estimator import HardwareBudget
|
|
14
|
+
from localmodels.library_model import Row
|
|
15
|
+
from localmodels.library_pricing import Model
|
|
16
|
+
from localmodels.probe import HostFacts
|
|
17
|
+
|
|
18
|
+
_ACTIONABLE_UNAVAILABLE = frozenset({"DRIVER_UPDATE_REQUIRED", "RUNTIME_DEPENDENCY_MISSING"})
|
|
19
|
+
_LONG_CONTEXT_FLOOR = 131_072
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _mac_suitability_key(
|
|
23
|
+
model: Model,
|
|
24
|
+
row_doc: Row,
|
|
25
|
+
hw: HardwareBudget | None,
|
|
26
|
+
smartest_rungs: tuple[str, ...],
|
|
27
|
+
) -> tuple[object, ...]:
|
|
28
|
+
"""Order Apple Silicon library rows by machine-tailored suitability.
|
|
29
|
+
|
|
30
|
+
Recommended comes first, then fitting/active models ranked from high-intelligence validated
|
|
31
|
+
models (>= yield score) through the primary Mac ladder rung (Ornith 1.5 9B), secondary
|
|
32
|
+
validated models, fallback ladder rungs (Spark 4B), and ladder-replaced legacy entries
|
|
33
|
+
(Ling 3.0 tiny). Models that do not fit this Mac follow from smallest memory requirement up.
|
|
34
|
+
"""
|
|
35
|
+
entry, variant = model.entry, model.variant
|
|
36
|
+
is_recommended = 0 if row_doc["recommended"] else 1
|
|
37
|
+
if row_doc["state"] != "absent" or (
|
|
38
|
+
row_doc["fit"] != "none" and row_doc["availability"]["downloadable"]
|
|
39
|
+
):
|
|
40
|
+
avail_bucket = 0
|
|
41
|
+
elif row_doc["fit"] != "none":
|
|
42
|
+
avail_bucket = 1
|
|
43
|
+
else:
|
|
44
|
+
avail_bucket = 2
|
|
45
|
+
est_tok_s = round(cat.decode_estimate(entry, variant, hw).tok_s, 1) if hw else 0.0
|
|
46
|
+
if entry.id in llm_rank.MAC_LADDER_REPLACES:
|
|
47
|
+
tier = 4
|
|
48
|
+
rank_tuple: tuple[float, ...] = (
|
|
49
|
+
-entry.quality,
|
|
50
|
+
-est_tok_s,
|
|
51
|
+
-row_doc["context_tokens"],
|
|
52
|
+
-variant.size_bytes,
|
|
53
|
+
)
|
|
54
|
+
elif entry.id in smartest_rungs:
|
|
55
|
+
rung_idx = smartest_rungs.index(entry.id)
|
|
56
|
+
tier = 1 if rung_idx == 0 else 3
|
|
57
|
+
rank_tuple = (
|
|
58
|
+
float(rung_idx),
|
|
59
|
+
-est_tok_s,
|
|
60
|
+
-row_doc["context_tokens"],
|
|
61
|
+
-variant.size_bytes,
|
|
62
|
+
)
|
|
63
|
+
elif entry.quality >= llm_rank.MAC_DEFAULT_YIELD_SCORE:
|
|
64
|
+
tier = 0
|
|
65
|
+
rank_tuple = (
|
|
66
|
+
-entry.quality,
|
|
67
|
+
-est_tok_s,
|
|
68
|
+
-row_doc["context_tokens"],
|
|
69
|
+
-variant.size_bytes,
|
|
70
|
+
)
|
|
71
|
+
else:
|
|
72
|
+
tier = 2
|
|
73
|
+
rank_tuple = (
|
|
74
|
+
-entry.quality,
|
|
75
|
+
-variant.size_bytes,
|
|
76
|
+
-est_tok_s,
|
|
77
|
+
-row_doc["context_tokens"],
|
|
78
|
+
)
|
|
79
|
+
if avail_bucket == 2:
|
|
80
|
+
return (
|
|
81
|
+
is_recommended,
|
|
82
|
+
avail_bucket,
|
|
83
|
+
row_doc["memory_bytes"],
|
|
84
|
+
tier,
|
|
85
|
+
rank_tuple,
|
|
86
|
+
row_doc["id"],
|
|
87
|
+
)
|
|
88
|
+
return (is_recommended, avail_bucket, tier, rank_tuple, row_doc["id"])
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _best_cuda_budget(facts: HostFacts) -> HardwareBudget | None:
|
|
92
|
+
shown_cards = library_pricing.visible(facts)
|
|
93
|
+
cuda_placements = [
|
|
94
|
+
p
|
|
95
|
+
for p in budget.placements(facts, planning=True)
|
|
96
|
+
if not p.pooled
|
|
97
|
+
and p.backend == "cuda"
|
|
98
|
+
and (
|
|
99
|
+
not p.gpu_indices
|
|
100
|
+
or shown_cards is None
|
|
101
|
+
or all(idx in shown_cards for idx in p.gpu_indices)
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
if not cuda_placements:
|
|
105
|
+
return None
|
|
106
|
+
best = max(cuda_placements, key=lambda p: p.budget.total_device_bytes)
|
|
107
|
+
return budget.agent_budget(best, facts) or best.budget
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _max_visible_nvidia_bytes(facts: HostFacts) -> int:
|
|
111
|
+
shown_cards = library_pricing.visible(facts)
|
|
112
|
+
return max(
|
|
113
|
+
(
|
|
114
|
+
g["total_bytes"]
|
|
115
|
+
for g in facts.get("gpus") or []
|
|
116
|
+
if g.get("vendor") == "nvidia" and (shown_cards is None or g["index"] in shown_cards)
|
|
117
|
+
),
|
|
118
|
+
default=0,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _desktop_suitability_key(
|
|
123
|
+
facts: HostFacts,
|
|
124
|
+
model: Model,
|
|
125
|
+
row_doc: Row,
|
|
126
|
+
hw: HardwareBudget | None,
|
|
127
|
+
max_gpu_bytes: int,
|
|
128
|
+
) -> tuple[object, ...]:
|
|
129
|
+
"""Order Linux and Windows library rows by suitability for this machine.
|
|
130
|
+
|
|
131
|
+
Recommended always comes first. Fitting/active rows follow in validated-intelligence,
|
|
132
|
+
context-tier, MoE efficiency and quantization-precision order, followed by optional library
|
|
133
|
+
candidates (such as Ornith 1.5 9B) and then the Windows small-card fallback (Spark-X2.6 4B)
|
|
134
|
+
whenever stronger models fit. Unavailable rows surface actionable driver/runtime upgrades
|
|
135
|
+
(preferring variants whose VRAM floor fits this GPU) before memory/hardware-blocked rows
|
|
136
|
+
ordered from smallest shortfall up.
|
|
137
|
+
"""
|
|
138
|
+
entry, variant = model.entry, model.variant
|
|
139
|
+
is_recommended = 0 if row_doc["recommended"] else 1
|
|
140
|
+
reason = row_doc["availability"].get("reason")
|
|
141
|
+
reason_code = reason["code"] if reason is not None else ""
|
|
142
|
+
if row_doc["state"] != "absent" or (
|
|
143
|
+
row_doc["fit"] != "none" and row_doc["availability"]["downloadable"]
|
|
144
|
+
):
|
|
145
|
+
avail_bucket = 0
|
|
146
|
+
elif row_doc["fit"] != "none":
|
|
147
|
+
avail_bucket = 1
|
|
148
|
+
elif reason_code in _ACTIONABLE_UNAVAILABLE:
|
|
149
|
+
avail_bucket = 2
|
|
150
|
+
else:
|
|
151
|
+
avail_bucket = 3
|
|
152
|
+
|
|
153
|
+
est_tok_s = round(cat.decode_estimate(entry, variant, hw).tok_s, 1) if hw else 0.0
|
|
154
|
+
if llm_rank.windows_fallback(entry, facts):
|
|
155
|
+
tier = 3
|
|
156
|
+
rank_tuple: tuple[float, ...] = (
|
|
157
|
+
-row_doc["context_tokens"],
|
|
158
|
+
-variant.size_bytes,
|
|
159
|
+
-est_tok_s,
|
|
160
|
+
)
|
|
161
|
+
elif entry.status != "validated":
|
|
162
|
+
tier = 2
|
|
163
|
+
rank_tuple = (
|
|
164
|
+
-row_doc["context_tokens"],
|
|
165
|
+
-variant.size_bytes,
|
|
166
|
+
-est_tok_s,
|
|
167
|
+
)
|
|
168
|
+
elif entry.quality >= llm_rank.MAC_DEFAULT_YIELD_SCORE:
|
|
169
|
+
tier = 0
|
|
170
|
+
rank_tuple = (
|
|
171
|
+
-entry.quality,
|
|
172
|
+
0.0 if row_doc["context_tokens"] >= _LONG_CONTEXT_FLOOR else 1.0,
|
|
173
|
+
0.0 if entry.moe else 1.0,
|
|
174
|
+
-variant.size_bytes,
|
|
175
|
+
-row_doc["context_tokens"],
|
|
176
|
+
-est_tok_s,
|
|
177
|
+
)
|
|
178
|
+
else:
|
|
179
|
+
tier = 1
|
|
180
|
+
rank_tuple = (
|
|
181
|
+
-entry.quality,
|
|
182
|
+
-variant.size_bytes,
|
|
183
|
+
-row_doc["context_tokens"],
|
|
184
|
+
-est_tok_s,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
if avail_bucket == 2:
|
|
188
|
+
fits_card_vram = (
|
|
189
|
+
0 if (max_gpu_bytes > 0 and row_doc["memory_bytes"] <= max_gpu_bytes) else 1
|
|
190
|
+
)
|
|
191
|
+
return (
|
|
192
|
+
is_recommended,
|
|
193
|
+
avail_bucket,
|
|
194
|
+
fits_card_vram,
|
|
195
|
+
tier,
|
|
196
|
+
rank_tuple,
|
|
197
|
+
row_doc["id"],
|
|
198
|
+
)
|
|
199
|
+
if avail_bucket == 3:
|
|
200
|
+
need_bytes = reason.get("need_bytes", 0) if reason is not None else 0
|
|
201
|
+
have_bytes = reason.get("have_bytes", 0) if reason is not None else 0
|
|
202
|
+
shortfall = max(0, need_bytes - have_bytes) if need_bytes > 0 else row_doc["memory_bytes"]
|
|
203
|
+
need = need_bytes if need_bytes > 0 else row_doc["memory_bytes"]
|
|
204
|
+
return (
|
|
205
|
+
is_recommended,
|
|
206
|
+
avail_bucket,
|
|
207
|
+
shortfall,
|
|
208
|
+
need,
|
|
209
|
+
tier,
|
|
210
|
+
rank_tuple,
|
|
211
|
+
row_doc["id"],
|
|
212
|
+
)
|
|
213
|
+
return (is_recommended, avail_bucket, tier, rank_tuple, row_doc["id"])
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def order_rows(facts: HostFacts, models: list[Model], rows: list[Row]) -> list[Row]:
|
|
217
|
+
"""Order ``library status`` rows by suitability for this host."""
|
|
218
|
+
pairs = list(zip(models, rows, strict=True))
|
|
219
|
+
if metal.supported(facts):
|
|
220
|
+
placement = next(
|
|
221
|
+
(p for p in budget.placements(facts, planning=True) if p.backend == "metal"),
|
|
222
|
+
None,
|
|
223
|
+
)
|
|
224
|
+
hw = (budget.agent_budget(placement, facts) or placement.budget) if placement else None
|
|
225
|
+
ladder = llm_rank.mac_ladder(facts)
|
|
226
|
+
smartest_rungs = ladder.smartest if ladder is not None else ()
|
|
227
|
+
pairs.sort(key=lambda pair: _mac_suitability_key(pair[0], pair[1], hw, smartest_rungs))
|
|
228
|
+
return [row_doc for _, row_doc in pairs]
|
|
229
|
+
hw = _best_cuda_budget(facts)
|
|
230
|
+
max_gpu_bytes = _max_visible_nvidia_bytes(facts)
|
|
231
|
+
pairs.sort(
|
|
232
|
+
key=lambda pair: _desktop_suitability_key(facts, pair[0], pair[1], hw, max_gpu_bytes)
|
|
233
|
+
)
|
|
234
|
+
return [row_doc for _, row_doc in pairs]
|
|
@@ -41,6 +41,8 @@ def engine_blocker(exc: plan_envelope.PlanError) -> Reason | None:
|
|
|
41
41
|
reason: Reason = {"code": "DRIVER_UPDATE_REQUIRED"}
|
|
42
42
|
if exc.required_cuda:
|
|
43
43
|
reason["required_cuda"] = exc.required_cuda
|
|
44
|
+
if exc.required_driver:
|
|
45
|
+
reason["required_driver"] = exc.required_driver
|
|
44
46
|
if exc.detected_cuda:
|
|
45
47
|
reason["detected_cuda"] = exc.detected_cuda
|
|
46
48
|
if exc.driver_version:
|
|
@@ -266,6 +268,24 @@ def price(
|
|
|
266
268
|
recipe = suite.recipe(recipe_id)
|
|
267
269
|
if not stack_suite.built_for(recipe, facts["platform"]):
|
|
268
270
|
raise plan_envelope.PlanError(f"{recipe_id} has no engine build for {facts['platform']}")
|
|
271
|
+
# Reject immutable hardware capacity shortfalls before checking the CUDA driver so an
|
|
272
|
+
# outdated driver never promises that a 24 GB recipe will unlock on an 8 GB card.
|
|
273
|
+
need_vram = int(recipe.get("vram_bytes") or 0)
|
|
274
|
+
if need_vram > gpu["total_bytes"]:
|
|
275
|
+
msg = f"{recipe_id} needs {need_vram} bytes of VRAM, exceeding {gpu['total_bytes']} bytes"
|
|
276
|
+
raise deploy.AgentMemoryError(
|
|
277
|
+
msg, PhysicsRefusal(need_vram, gpu["total_bytes"], msg), "GPU memory"
|
|
278
|
+
)
|
|
279
|
+
min_total_ram = int(recipe.get("min_ram_total_bytes") or 0)
|
|
280
|
+
total_ram = facts["ram"]["total_bytes"]
|
|
281
|
+
if min_total_ram > total_ram:
|
|
282
|
+
msg = (
|
|
283
|
+
f"{recipe_id} recommends at least {min_total_ram} bytes of system memory, "
|
|
284
|
+
f"this host has {total_ram} bytes"
|
|
285
|
+
)
|
|
286
|
+
raise deploy.AgentMemoryError(
|
|
287
|
+
msg, PhysicsRefusal(min_total_ram, total_ram, msg), "system memory"
|
|
288
|
+
)
|
|
269
289
|
spec = recipe.get("vision") or {}
|
|
270
290
|
reader = vision.strata_mode(posture.vision, gpu["total_bytes"], bool(spec))
|
|
271
291
|
reserve = stack_suite.poly_reserve_mib(recipe, gpu, 0)
|
|
@@ -281,12 +301,6 @@ def price(
|
|
|
281
301
|
if facts["platform"] == "win32":
|
|
282
302
|
plan = suite.unbounded(plan)
|
|
283
303
|
_calibrate_host_ram(plan, recipe, gpu)
|
|
284
|
-
need_vram = int(recipe.get("vram_bytes") or 0)
|
|
285
|
-
if need_vram > gpu["total_bytes"]:
|
|
286
|
-
msg = f"{recipe_id} needs {need_vram} bytes of VRAM, exceeding {gpu['total_bytes']} bytes"
|
|
287
|
-
raise deploy.AgentMemoryError(
|
|
288
|
-
msg, PhysicsRefusal(need_vram, gpu["total_bytes"], msg), "GPU memory"
|
|
289
|
-
)
|
|
290
304
|
min_free = int(recipe.get("min_vram_free_bytes") or need_vram)
|
|
291
305
|
if require_live and min_free > gpu["free_bytes"]:
|
|
292
306
|
msg = (
|
|
@@ -304,16 +318,6 @@ def price(
|
|
|
304
318
|
raise deploy.AgentMemoryError(
|
|
305
319
|
msg, PhysicsRefusal(min_free, gpu["free_bytes"], msg), "GPU memory"
|
|
306
320
|
)
|
|
307
|
-
min_total_ram = int(recipe.get("min_ram_total_bytes") or 0)
|
|
308
|
-
total_ram = facts["ram"]["total_bytes"]
|
|
309
|
-
if min_total_ram > total_ram:
|
|
310
|
-
msg = (
|
|
311
|
-
f"{recipe_id} recommends at least {min_total_ram} bytes of system memory, "
|
|
312
|
-
f"this host has {total_ram} bytes"
|
|
313
|
-
)
|
|
314
|
-
raise deploy.AgentMemoryError(
|
|
315
|
-
msg, PhysicsRefusal(min_total_ram, total_ram, msg), "system memory"
|
|
316
|
-
)
|
|
317
321
|
needed_ram = suite.bounded_ram(plan) + budget.HARNESS_RAM + budget.RAM_FLOOR
|
|
318
322
|
_, avail_ram = budget.host_ram(facts)
|
|
319
323
|
if needed_ram > avail_ram:
|
|
@@ -27,6 +27,7 @@ from localmodels import (
|
|
|
27
27
|
deploy,
|
|
28
28
|
engines,
|
|
29
29
|
hosts,
|
|
30
|
+
library_kept,
|
|
30
31
|
library_poly,
|
|
31
32
|
library_vram,
|
|
32
33
|
llm_rank,
|
|
@@ -106,7 +107,9 @@ def shown(facts: HostFacts, catalog: Iterable[cat.CatalogEntry]) -> list[Model]:
|
|
|
106
107
|
|
|
107
108
|
|
|
108
109
|
def find(model_id: str, catalog: Iterable[cat.CatalogEntry]) -> Model:
|
|
109
|
-
"""The catalog row a library id names (``id:QUANT``; a bare id is its last variant)
|
|
110
|
+
"""The catalog row a library id names (``id:QUANT``; a bare id is its last variant), else
|
|
111
|
+
the model a library record on disk holds under that id (library_kept)."""
|
|
112
|
+
catalog = tuple(catalog)
|
|
110
113
|
catalog_id, quant = split_id(model_id)
|
|
111
114
|
for entry in catalog:
|
|
112
115
|
if entry.id == catalog_id and is_chat(entry):
|
|
@@ -116,6 +119,8 @@ def find(model_id: str, catalog: Iterable[cat.CatalogEntry]) -> Model:
|
|
|
116
119
|
return Model(entry, variant)
|
|
117
120
|
if poly := library_poly.find_entry(model_id):
|
|
118
121
|
return Model(*poly)
|
|
122
|
+
if kept := library_kept.find_entry(model_id, catalog):
|
|
123
|
+
return Model(*kept)
|
|
119
124
|
raise LibraryError("MODEL_UNKNOWN", f"the catalog has no chat model {model_id}")
|
|
120
125
|
|
|
121
126
|
|
|
@@ -353,6 +358,8 @@ def price(
|
|
|
353
358
|
placement = pools(facts).get(pool)
|
|
354
359
|
if placement is None:
|
|
355
360
|
raise plan_envelope.PlanError(f"this computer has no pool {pool}")
|
|
361
|
+
if library_kept.retired(model.entry):
|
|
362
|
+
raise plan_envelope.PlanError(f"this version no longer ships {model.id}")
|
|
356
363
|
if model.entry.runtime == "strata-poly":
|
|
357
364
|
return library_poly.price(
|
|
358
365
|
facts, model.entry.id, pool, base_dir, port, posture(), require_live=require_live
|