@simplexai/localmodels-darwin-arm64 0.1.0-dev.49 → 0.1.0-dev.50
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 +51 -45
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/catalog.json +416 -2
- package/modules/localmodels/download-mirrors.json +47 -0
- package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +79 -0
- package/modules/localmodels/gateway.py +23 -6
- package/modules/localmodels/gateway_bifrost.py +6 -2
- package/modules/localmodels/harness.py +8 -2
- package/modules/localmodels/harness_gateway.py +78 -17
- package/modules/localmodels/harness_probe.py +5 -1
- package/modules/localmodels/hosts.py +52 -5
- package/modules/localmodels/library_floor.py +76 -0
- package/modules/localmodels/library_jobs.py +38 -6
- package/modules/localmodels/library_poly.py +272 -0
- package/modules/localmodels/library_pricing.py +24 -35
- package/modules/localmodels/library_serve.py +7 -0
- package/modules/localmodels/library_state.py +16 -0
- package/modules/localmodels/library_status.py +27 -7
- package/modules/localmodels/llm_rank.py +14 -0
- package/modules/localmodels/magpie_windows.py +312 -0
- package/modules/localmodels/probe.py +1 -1
- package/modules/localmodels/remote_ops.py +11 -0
- package/modules/localmodels/remote_ops_download.py +30 -5
- package/modules/localmodels/reuse.py +13 -6
- package/modules/localmodels/runtime_io.py +32 -18
- package/modules/localmodels/setup_inspection.py +83 -79
- package/modules/localmodels/setup_inspection_harness.py +147 -0
- package/modules/localmodels/setup_text.py +12 -0
- package/modules/localmodels/setup_upgrade.py +11 -1
- package/modules/localmodels/stack.py +3 -1
- package/modules/localmodels/stack_auto.py +6 -2
- package/modules/localmodels/stack_clients.py +1 -1
- package/modules/localmodels/stack_down.py +25 -16
- package/modules/localmodels/stack_hardware.py +12 -1
- package/modules/localmodels/stack_picks.py +28 -13
- package/modules/localmodels/stack_remove.py +3 -1
- package/modules/localmodels/stack_suite.py +29 -8
- package/modules/localmodels/strata-poly-serve-0.2.19-poly.1.txt +428 -0
- package/modules/localmodels/strata_poly_server.py +14 -2
- package/modules/localmodels/suite.py +19 -3
- package/modules/localmodels/tool_archive.py +4 -0
- package/modules/localmodels/vision.py +4 -2
- package/modules/localmodels/win_probe.py +24 -7
- package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/RECORD +48 -42
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""PolyStrata (``strata-poly``) LLM recipes for the model library.
|
|
2
|
+
|
|
3
|
+
Validated ``strata-poly`` chat recipes that declare model-card metadata (``display_name``,
|
|
4
|
+
``description``, ``family``, ``publisher``, ``parameters``) join ``localmodels library`` on
|
|
5
|
+
supported NVIDIA Linux and Windows hosts alongside ``llama.cpp`` models. Pricing runs
|
|
6
|
+
``suite.build_plan`` so CUDA 13 driver checks, glibc checks, vision reader placement and host
|
|
7
|
+
RAM ceilings stay identical to ``stack plan``.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from localmodels import (
|
|
13
|
+
budget,
|
|
14
|
+
catalog_recipes,
|
|
15
|
+
deploy,
|
|
16
|
+
engines,
|
|
17
|
+
hosts,
|
|
18
|
+
plan_envelope,
|
|
19
|
+
stack_suite,
|
|
20
|
+
suite,
|
|
21
|
+
vision,
|
|
22
|
+
)
|
|
23
|
+
from localmodels import catalog as cat
|
|
24
|
+
from localmodels.context_policy import AgentPosture
|
|
25
|
+
from localmodels.estimator import PhysicsRefusal
|
|
26
|
+
from localmodels.library_model import Reason, split_id
|
|
27
|
+
from localmodels.probe import GPU, HostFacts
|
|
28
|
+
from localmodels.records import Plan
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def strata_ids() -> set[str]:
|
|
32
|
+
"""Every catalog component id of a Strata/PolyStrata runtime."""
|
|
33
|
+
return {
|
|
34
|
+
c["id"] for c in catalog_recipes.components() if c["runtime"] in ("strata", "strata-poly")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def engine_blocker(exc: plan_envelope.PlanError) -> Reason | None:
|
|
39
|
+
"""Structured unavailability reason for CUDA driver or runtime library refusals."""
|
|
40
|
+
if isinstance(exc, engines.CudaDriverError):
|
|
41
|
+
reason: Reason = {"code": "DRIVER_UPDATE_REQUIRED"}
|
|
42
|
+
if exc.required_cuda:
|
|
43
|
+
reason["required_cuda"] = exc.required_cuda
|
|
44
|
+
if exc.detected_cuda:
|
|
45
|
+
reason["detected_cuda"] = exc.detected_cuda
|
|
46
|
+
if exc.driver_version:
|
|
47
|
+
reason["driver_version"] = exc.driver_version
|
|
48
|
+
return reason
|
|
49
|
+
if isinstance(exc, engines.EngineUnavailableError):
|
|
50
|
+
reason = {"code": "RUNTIME_DEPENDENCY_MISSING"}
|
|
51
|
+
if exc.missing_libraries:
|
|
52
|
+
reason["missing_libraries"] = list(exc.missing_libraries)
|
|
53
|
+
if exc.required_glibc:
|
|
54
|
+
reason["required_glibc"] = exc.required_glibc
|
|
55
|
+
if exc.detected_glibc:
|
|
56
|
+
reason["detected_glibc"] = exc.detected_glibc
|
|
57
|
+
return reason
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def is_library_recipe(recipe: suite.SuiteRecipe) -> bool:
|
|
62
|
+
"""True when a ``strata-poly`` LLM component carries complete model-card metadata."""
|
|
63
|
+
return (
|
|
64
|
+
recipe["runtime"] == "strata-poly"
|
|
65
|
+
and recipe["task"] == "llm"
|
|
66
|
+
and bool(recipe.get("display_name"))
|
|
67
|
+
and bool(recipe.get("description"))
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _validated_for(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
72
|
+
if recipe.get("status") != "validated" or not stack_suite.built_for(recipe, platform):
|
|
73
|
+
return False
|
|
74
|
+
scope = recipe.get("validated_on")
|
|
75
|
+
if not scope:
|
|
76
|
+
return True
|
|
77
|
+
# Decision 48: Linux CUDA evidence also validates native Windows x64 CUDA builds.
|
|
78
|
+
return platform in scope or (platform == "win32" and "linux" in scope)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def eligible(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
82
|
+
"""Whether ``recipe`` should be shown by ``library status`` on ``platform``."""
|
|
83
|
+
return is_library_recipe(recipe) and _validated_for(recipe, platform)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def in_library(recipe_id: str, facts: HostFacts) -> bool:
|
|
87
|
+
"""Whether ``recipe_id`` is exposed as a downloadable model in the library on this host."""
|
|
88
|
+
return any(
|
|
89
|
+
r["id"] == recipe_id and eligible(r, facts["platform"]) for r in suite.recipes("llm")
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def is_poly_plan(plan: Plan) -> bool:
|
|
94
|
+
"""True when ``plan`` deploys a ``strata-poly`` server."""
|
|
95
|
+
if str(plan["engine"].get("build") or "").startswith("strata-poly"):
|
|
96
|
+
return True
|
|
97
|
+
return str(plan["launch"].get("frontend_requirements") or "").startswith("strata-poly")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVariant]:
|
|
101
|
+
"""Build a ``CatalogEntry`` + ``QuantVariant`` view of a ``strata-poly`` recipe so
|
|
102
|
+
``library_status`` and ``library_gateway`` render its model card without special cases."""
|
|
103
|
+
alias = recipe.get("alias") or recipe["id"]
|
|
104
|
+
weight_files = tuple(
|
|
105
|
+
cat.AssetFile(
|
|
106
|
+
path=f"{alias}.gguf" if i == 0 else str(f.get("local_name") or f["path"]),
|
|
107
|
+
size_bytes=int(f["size_bytes"]),
|
|
108
|
+
local=str(f.get("local_name") or "") or None,
|
|
109
|
+
revision=str(f.get("revision") or recipe["revision"]),
|
|
110
|
+
sha256=str(f["sha256"]),
|
|
111
|
+
)
|
|
112
|
+
for i, f in enumerate(recipe["files"])
|
|
113
|
+
if not f.get("vision")
|
|
114
|
+
)
|
|
115
|
+
vision_files = [f for f in recipe["files"] if f.get("vision")]
|
|
116
|
+
mmproj = (
|
|
117
|
+
cat.AssetFile(
|
|
118
|
+
path=str(vision_files[0]["path"]),
|
|
119
|
+
size_bytes=int(vision_files[0]["size_bytes"]),
|
|
120
|
+
local=str(vision_files[0].get("local_name") or "") or None,
|
|
121
|
+
revision=str(vision_files[0].get("revision") or recipe["revision"]),
|
|
122
|
+
sha256=str(vision_files[0]["sha256"]),
|
|
123
|
+
)
|
|
124
|
+
if vision_files
|
|
125
|
+
else None
|
|
126
|
+
)
|
|
127
|
+
variant = cat.QuantVariant(
|
|
128
|
+
quant=recipe["version"],
|
|
129
|
+
files=weight_files,
|
|
130
|
+
validated=recipe.get("status") == "validated",
|
|
131
|
+
)
|
|
132
|
+
quality_doc = recipe.get("quality")
|
|
133
|
+
score = int(quality_doc["score"]) if isinstance(quality_doc, dict) else 0
|
|
134
|
+
entry = cat.CatalogEntry(
|
|
135
|
+
id=recipe["id"],
|
|
136
|
+
display_name=recipe.get("display_name") or alias,
|
|
137
|
+
description=recipe.get("description") or "",
|
|
138
|
+
repo=recipe["repo"],
|
|
139
|
+
variants=(variant,),
|
|
140
|
+
n_ctx_train=int(recipe.get("context") or 65536),
|
|
141
|
+
full_layers=0,
|
|
142
|
+
recurrent_layers=0,
|
|
143
|
+
per_layer_f16=0,
|
|
144
|
+
moe=bool(recipe.get("moe", True)),
|
|
145
|
+
mmproj=mmproj,
|
|
146
|
+
quality=score,
|
|
147
|
+
license=recipe.get("license") or "",
|
|
148
|
+
license_url=recipe.get("license_url") or "",
|
|
149
|
+
status=recipe.get("status") or "",
|
|
150
|
+
tasks=tuple(recipe.get("tasks") or ("llm",)),
|
|
151
|
+
evidence=tuple(recipe.get("evidence") or ()),
|
|
152
|
+
validated_on=tuple(recipe.get("validated_on") or ()),
|
|
153
|
+
reasoning_efforts=tuple(recipe.get("reasoning_efforts") or ()),
|
|
154
|
+
runtime="strata-poly",
|
|
155
|
+
family=recipe.get("family") or "",
|
|
156
|
+
publisher=recipe.get("publisher") or "",
|
|
157
|
+
parameters=recipe.get("parameters") or "",
|
|
158
|
+
active_parameters=recipe.get("active_parameters") or "",
|
|
159
|
+
)
|
|
160
|
+
return entry, variant
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def shown_entries(facts: HostFacts) -> list[tuple[cat.CatalogEntry, cat.QuantVariant]]:
|
|
164
|
+
"""Every ``strata-poly`` library model visible on this host."""
|
|
165
|
+
platform = facts["platform"]
|
|
166
|
+
return [as_entry(r) for r in suite.recipes("llm") if eligible(r, platform)]
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def find_entry(model_id: str) -> tuple[cat.CatalogEntry, cat.QuantVariant] | None:
|
|
170
|
+
"""Resolve ``id:QUANT`` (or bare ``id``) to a ``strata-poly`` library model, or None."""
|
|
171
|
+
catalog_id, quant = split_id(model_id)
|
|
172
|
+
for recipe in suite.recipes("llm"):
|
|
173
|
+
if recipe["id"] == catalog_id and is_library_recipe(recipe):
|
|
174
|
+
if not quant or quant == recipe["version"]:
|
|
175
|
+
return as_entry(recipe)
|
|
176
|
+
return None
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _gpu_for_pool(facts: HostFacts, pool: str) -> GPU:
|
|
180
|
+
if not pool.startswith("gpu:"):
|
|
181
|
+
raise plan_envelope.PlanError(f"PolyStrata recipes need a discrete NVIDIA GPU, not {pool}")
|
|
182
|
+
index = int(pool.split(":", 1)[1])
|
|
183
|
+
gpu = next(
|
|
184
|
+
(g for g in facts.get("gpus") or [] if g["index"] == index and g.get("vendor") == "nvidia"),
|
|
185
|
+
None,
|
|
186
|
+
)
|
|
187
|
+
if gpu is None:
|
|
188
|
+
raise plan_envelope.PlanError(f"this computer has no NVIDIA GPU for pool {pool}")
|
|
189
|
+
return gpu
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def price(
|
|
193
|
+
facts: HostFacts,
|
|
194
|
+
recipe_id: str,
|
|
195
|
+
pool: str,
|
|
196
|
+
base_dir: str,
|
|
197
|
+
port: int,
|
|
198
|
+
posture: AgentPosture,
|
|
199
|
+
*,
|
|
200
|
+
require_live: bool = False,
|
|
201
|
+
) -> Plan:
|
|
202
|
+
"""Price one ``strata-poly`` library model on discrete pool ``pool``."""
|
|
203
|
+
if facts["platform"] not in ("linux", "win32"):
|
|
204
|
+
raise plan_envelope.PlanError(
|
|
205
|
+
"PolyStrata recipes run on Linux and Windows NVIDIA GPUs only"
|
|
206
|
+
)
|
|
207
|
+
gpu = _gpu_for_pool(facts, pool)
|
|
208
|
+
recipe = suite.recipe(recipe_id)
|
|
209
|
+
if not stack_suite.built_for(recipe, facts["platform"]):
|
|
210
|
+
raise plan_envelope.PlanError(f"{recipe_id} has no engine build for {facts['platform']}")
|
|
211
|
+
spec = recipe.get("vision") or {}
|
|
212
|
+
reader = vision.strata_mode(posture.vision, gpu["total_bytes"], bool(spec))
|
|
213
|
+
reserve = stack_suite.poly_reserve_mib(recipe, gpu, 0)
|
|
214
|
+
opts = suite.SuiteOptions(
|
|
215
|
+
base_dir=base_dir,
|
|
216
|
+
hf_endpoint=deploy.hf_endpoint(),
|
|
217
|
+
gpu=gpu,
|
|
218
|
+
port=port,
|
|
219
|
+
vram_reserve_mib=reserve,
|
|
220
|
+
vision_reader=reader,
|
|
221
|
+
)
|
|
222
|
+
plan = suite.build_plan(hosts.LOCAL_ID, facts, recipe, opts)
|
|
223
|
+
if facts["platform"] == "win32":
|
|
224
|
+
plan = suite.unbounded(plan)
|
|
225
|
+
need_vram = int(recipe.get("vram_bytes") or 0)
|
|
226
|
+
if need_vram > gpu["total_bytes"]:
|
|
227
|
+
msg = f"{recipe_id} needs {need_vram} bytes of VRAM, exceeding {gpu['total_bytes']} bytes"
|
|
228
|
+
raise deploy.AgentMemoryError(
|
|
229
|
+
msg, PhysicsRefusal(need_vram, gpu["total_bytes"], msg), "GPU memory"
|
|
230
|
+
)
|
|
231
|
+
min_free = int(recipe.get("min_vram_free_bytes") or need_vram)
|
|
232
|
+
if require_live and min_free > gpu["free_bytes"]:
|
|
233
|
+
msg = (
|
|
234
|
+
f"{recipe_id} needs at least {min_free} bytes of free VRAM now, "
|
|
235
|
+
f"only {gpu['free_bytes']} bytes free"
|
|
236
|
+
)
|
|
237
|
+
raise deploy.AgentMemoryError(
|
|
238
|
+
msg, PhysicsRefusal(min_free, gpu["free_bytes"], msg), "GPU memory"
|
|
239
|
+
)
|
|
240
|
+
if not require_live and min_free > gpu["free_bytes"]:
|
|
241
|
+
msg = (
|
|
242
|
+
f"{recipe_id} needs at least {min_free} bytes of loadable VRAM, "
|
|
243
|
+
f"only {gpu['free_bytes']} bytes available"
|
|
244
|
+
)
|
|
245
|
+
raise deploy.AgentMemoryError(
|
|
246
|
+
msg, PhysicsRefusal(min_free, gpu["free_bytes"], msg), "GPU memory"
|
|
247
|
+
)
|
|
248
|
+
min_total_ram = int(recipe.get("min_ram_total_bytes") or 0)
|
|
249
|
+
total_ram = facts["ram"]["total_bytes"]
|
|
250
|
+
if min_total_ram > total_ram:
|
|
251
|
+
msg = (
|
|
252
|
+
f"{recipe_id} recommends at least {min_total_ram} bytes of system memory, "
|
|
253
|
+
f"this host has {total_ram} bytes"
|
|
254
|
+
)
|
|
255
|
+
raise deploy.AgentMemoryError(
|
|
256
|
+
msg, PhysicsRefusal(min_total_ram, total_ram, msg), "system memory"
|
|
257
|
+
)
|
|
258
|
+
needed_ram = suite.bounded_ram(plan) + budget.HARNESS_RAM + budget.RAM_FLOOR
|
|
259
|
+
_, avail_ram = budget.host_ram(facts)
|
|
260
|
+
if needed_ram > avail_ram:
|
|
261
|
+
msg = (
|
|
262
|
+
f"{recipe_id} needs {needed_ram} bytes of system memory, "
|
|
263
|
+
f"exceeding {avail_ram} bytes available"
|
|
264
|
+
)
|
|
265
|
+
raise deploy.AgentMemoryError(
|
|
266
|
+
msg, PhysicsRefusal(needed_ram, avail_ram, msg), "system memory"
|
|
267
|
+
)
|
|
268
|
+
# PolyStrata's expert cache fills free VRAM up to the recipe's full-VRAM footprint.
|
|
269
|
+
full_vram = int(str(plan["launch"].get("vram_bytes") or 0))
|
|
270
|
+
if full_vram > gpu["free_bytes"]:
|
|
271
|
+
plan["launch"]["vram_bytes"] = gpu["free_bytes"]
|
|
272
|
+
return plan
|
|
@@ -23,17 +23,18 @@ from typing import Any, Literal
|
|
|
23
23
|
|
|
24
24
|
from localmodels import (
|
|
25
25
|
budget,
|
|
26
|
-
catalog_recipes,
|
|
27
26
|
context_policy,
|
|
28
27
|
deploy,
|
|
29
28
|
engines,
|
|
30
29
|
hosts,
|
|
30
|
+
library_poly,
|
|
31
31
|
library_vram,
|
|
32
32
|
llm_rank,
|
|
33
33
|
metal,
|
|
34
34
|
plan_envelope,
|
|
35
35
|
stack_hardware,
|
|
36
36
|
stack_llm_ram,
|
|
37
|
+
suite,
|
|
37
38
|
vision,
|
|
38
39
|
)
|
|
39
40
|
from localmodels import catalog as cat
|
|
@@ -86,8 +87,9 @@ def is_chat(entry: cat.CatalogEntry) -> bool:
|
|
|
86
87
|
|
|
87
88
|
|
|
88
89
|
def shown(facts: HostFacts, catalog: Iterable[cat.CatalogEntry]) -> list[Model]:
|
|
89
|
-
"""Validated chat models, library candidates, Mac ladder,
|
|
90
|
-
|
|
90
|
+
"""Validated chat models, library candidates, Mac ladder, Windows fallback, and
|
|
91
|
+
supported PolyStrata LLM recipes."""
|
|
92
|
+
rows = [
|
|
91
93
|
Model(e, v)
|
|
92
94
|
for e in catalog
|
|
93
95
|
if is_chat(e)
|
|
@@ -99,6 +101,8 @@ def shown(facts: HostFacts, catalog: Iterable[cat.CatalogEntry]) -> list[Model]:
|
|
|
99
101
|
)
|
|
100
102
|
for v in e.variants
|
|
101
103
|
]
|
|
104
|
+
rows += [Model(e, v) for e, v in library_poly.shown_entries(facts)]
|
|
105
|
+
return rows
|
|
102
106
|
|
|
103
107
|
|
|
104
108
|
def find(model_id: str, catalog: Iterable[cat.CatalogEntry]) -> Model:
|
|
@@ -110,6 +114,8 @@ def find(model_id: str, catalog: Iterable[cat.CatalogEntry]) -> Model:
|
|
|
110
114
|
if not quant or variant.quant == quant:
|
|
111
115
|
if quant or variant is entry.variants[-1]:
|
|
112
116
|
return Model(entry, variant)
|
|
117
|
+
if poly := library_poly.find_entry(model_id):
|
|
118
|
+
return Model(*poly)
|
|
113
119
|
raise LibraryError("MODEL_UNKNOWN", f"the catalog has no chat model {model_id}")
|
|
114
120
|
|
|
115
121
|
|
|
@@ -320,7 +326,9 @@ class LiveMemoryUnavailable(plan_envelope.PlanError):
|
|
|
320
326
|
|
|
321
327
|
|
|
322
328
|
def host_ram_bytes(plan: Plan, catalog: tuple[cat.CatalogEntry, ...]) -> int:
|
|
323
|
-
"""Host RAM held by one discrete-GPU llama.cpp
|
|
329
|
+
"""Host RAM held by one discrete-GPU model (llama.cpp or PolyStrata)."""
|
|
330
|
+
if library_poly.is_poly_plan(plan):
|
|
331
|
+
return suite.bounded_ram(plan)
|
|
324
332
|
min_cache_bytes = (
|
|
325
333
|
(posture().prompt_cache_min_mib << 20) if posture().prompt_cache_mib > 0 else 0
|
|
326
334
|
)
|
|
@@ -345,6 +353,10 @@ def price(
|
|
|
345
353
|
placement = pools(facts).get(pool)
|
|
346
354
|
if placement is None:
|
|
347
355
|
raise plan_envelope.PlanError(f"this computer has no pool {pool}")
|
|
356
|
+
if model.entry.runtime == "strata-poly":
|
|
357
|
+
return library_poly.price(
|
|
358
|
+
facts, model.entry.id, pool, base_dir, port, posture(), require_live=require_live
|
|
359
|
+
)
|
|
348
360
|
if require_live and pool == "unified" and metal.supported(facts):
|
|
349
361
|
if problem := metal.problem(facts):
|
|
350
362
|
raise LiveMemoryUnavailable(problem)
|
|
@@ -418,31 +430,11 @@ class Priced:
|
|
|
418
430
|
reclaim_bytes: int = 0 # approximate VRAM to free when reclaimable_desktop_vram is True
|
|
419
431
|
|
|
420
432
|
|
|
421
|
-
def _engine_blocker(exc: plan_envelope.PlanError) -> Reason | None:
|
|
422
|
-
if isinstance(exc, engines.CudaDriverError):
|
|
423
|
-
reason: Reason = {"code": "DRIVER_UPDATE_REQUIRED"}
|
|
424
|
-
if exc.required_cuda:
|
|
425
|
-
reason["required_cuda"] = exc.required_cuda
|
|
426
|
-
if exc.detected_cuda:
|
|
427
|
-
reason["detected_cuda"] = exc.detected_cuda
|
|
428
|
-
if exc.driver_version:
|
|
429
|
-
reason["driver_version"] = exc.driver_version
|
|
430
|
-
return reason
|
|
431
|
-
if isinstance(exc, engines.EngineUnavailableError):
|
|
432
|
-
reason = {"code": "RUNTIME_DEPENDENCY_MISSING"}
|
|
433
|
-
if exc.missing_libraries:
|
|
434
|
-
reason["missing_libraries"] = list(exc.missing_libraries)
|
|
435
|
-
if exc.required_glibc:
|
|
436
|
-
reason["required_glibc"] = exc.required_glibc
|
|
437
|
-
if exc.detected_glibc:
|
|
438
|
-
reason["detected_glibc"] = exc.detected_glibc
|
|
439
|
-
return reason
|
|
440
|
-
return None
|
|
441
|
-
|
|
442
|
-
|
|
443
433
|
def _min_pool_need(model: Model, pool: str, exc: deploy.AgentMemoryError, facts: HostFacts) -> int:
|
|
444
434
|
"""Exact pool-aligned free bytes required at the agent floor when ``available_bytes`` clamped
|
|
445
435
|
to zero inside ``agent_budget`` or ``vision.priced``."""
|
|
436
|
+
if model.entry.runtime == "strata-poly":
|
|
437
|
+
return exc.needed_bytes
|
|
446
438
|
if gpu_index(pool) is not None:
|
|
447
439
|
return exc.needed_bytes + AGENT_VRAM_RESERVE_BYTES
|
|
448
440
|
if pool == "unified" and metal.supported(facts):
|
|
@@ -542,7 +534,7 @@ def judge(
|
|
|
542
534
|
shortfall = gap
|
|
543
535
|
continue
|
|
544
536
|
except (engines.CudaDriverError, engines.EngineUnavailableError) as exc:
|
|
545
|
-
blocker = blocker or
|
|
537
|
+
blocker = blocker or library_poly.engine_blocker(exc)
|
|
546
538
|
continue
|
|
547
539
|
except plan_envelope.PlanError:
|
|
548
540
|
continue
|
|
@@ -654,12 +646,6 @@ def download_reason(facts: HostFacts, priced: Priced, disk_free: int) -> Reason
|
|
|
654
646
|
return None
|
|
655
647
|
|
|
656
648
|
|
|
657
|
-
def _strata_ids() -> set[str]:
|
|
658
|
-
return {
|
|
659
|
-
c["id"] for c in catalog_recipes.components() if c["runtime"] in ("strata", "strata-poly")
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
649
|
def _smartest_library_fallback(facts: HostFacts, base_dir: str) -> tuple[str, str] | None:
|
|
664
650
|
"""Best live-fitting llama.cpp library model ranked by ``llm_rank.choose()``."""
|
|
665
651
|
catalog = entries()
|
|
@@ -673,7 +659,8 @@ def _smartest_library_fallback(facts: HostFacts, base_dir: str) -> tuple[str, st
|
|
|
673
659
|
fallback_ids: set[str] = set()
|
|
674
660
|
for model in shown(facts, catalog):
|
|
675
661
|
if (
|
|
676
|
-
|
|
662
|
+
model.entry.runtime != "llama.cpp"
|
|
663
|
+
or not llm_rank.automatic_here(model.entry, facts)
|
|
677
664
|
or model.variant is not model.entry.variants[-1]
|
|
678
665
|
):
|
|
679
666
|
continue
|
|
@@ -718,7 +705,9 @@ def smartest(facts: HostFacts, base_dir: str = deploy.DEFAULT_BASE_DIR) -> tuple
|
|
|
718
705
|
(p for p in view.get("picks") or [] if p["role"] == "smartest" and not p.get("shared")),
|
|
719
706
|
None,
|
|
720
707
|
)
|
|
721
|
-
if pick is not None and
|
|
708
|
+
if pick is not None and (
|
|
709
|
+
pick["id"] not in library_poly.strata_ids() or library_poly.in_library(pick["id"], seen)
|
|
710
|
+
):
|
|
722
711
|
return (pick["id"], pick["quant"])
|
|
723
712
|
if pick is not None or _cuda_uma(seen) is not None:
|
|
724
713
|
return _smartest_library_fallback(seen, base_dir)
|
|
@@ -21,6 +21,7 @@ from localmodels import (
|
|
|
21
21
|
app,
|
|
22
22
|
deploy,
|
|
23
23
|
engines,
|
|
24
|
+
frontend,
|
|
24
25
|
harness,
|
|
25
26
|
hosts,
|
|
26
27
|
library_gateway,
|
|
@@ -269,6 +270,12 @@ def _start(
|
|
|
269
270
|
handle.update("load", done, len(steps), load_step=load_step)
|
|
270
271
|
progress(model.id, "load", done, len(steps), load_step=load_step)
|
|
271
272
|
|
|
273
|
+
if reqs := plan["launch"].get("frontend_requirements"):
|
|
274
|
+
try:
|
|
275
|
+
frontend.install(str(plan["launch"]["frontend_base_dir"]), str(reqs))
|
|
276
|
+
except frontend.FrontendError as exc:
|
|
277
|
+
raise _fail(record, LibraryError("ENGINE_START_FAILED", str(exc))) from None
|
|
278
|
+
|
|
272
279
|
finished = app.run_deploy(hosts.LOCAL_ID, plan, on_event=seen)
|
|
273
280
|
if not finished["ok"]:
|
|
274
281
|
error = LibraryError(_start_code(finished), str(finished.get("error") or "start failed"))
|
|
@@ -76,6 +76,7 @@ class _JobSince20261113(TypedDict, total=False):
|
|
|
76
76
|
source: str # download source label: huggingface | modelscope | custom | cache
|
|
77
77
|
connections: int # active parallel download connections
|
|
78
78
|
load_step: str # load sub-step: prepare | start | load | warm
|
|
79
|
+
error: Problem # a download that stopped cleanly: status shows why; cancel discards it
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
class Job(_JobSince20261113):
|
|
@@ -233,6 +234,21 @@ def clear_job(model: str) -> None:
|
|
|
233
234
|
path.unlink(missing_ok=True)
|
|
234
235
|
|
|
235
236
|
|
|
237
|
+
def fail_job(job: Job, error: Problem) -> None:
|
|
238
|
+
"""Under ``locked()``: end the job's live claim while keeping its record and error on disk so
|
|
239
|
+
``status`` reports why it stopped, ``cancel`` discards its partials, and a new download
|
|
240
|
+
resumes them."""
|
|
241
|
+
job["error"] = error
|
|
242
|
+
job["updated_at"] = utc_now()
|
|
243
|
+
hosts.save_private(job_path(job["model"]), job)
|
|
244
|
+
for path in (
|
|
245
|
+
cancel_path(job["model"]),
|
|
246
|
+
pid_path(job["model"]),
|
|
247
|
+
Path(str(pid_path(job["model"])) + ".identity.json"),
|
|
248
|
+
):
|
|
249
|
+
path.unlink(missing_ok=True)
|
|
250
|
+
|
|
251
|
+
|
|
236
252
|
class JobHandle:
|
|
237
253
|
"""This process's job: progress written for ``status``, at most once a second."""
|
|
238
254
|
|
|
@@ -14,6 +14,7 @@ from localmodels import (
|
|
|
14
14
|
__version__,
|
|
15
15
|
debug_mode,
|
|
16
16
|
hosts,
|
|
17
|
+
library_floor,
|
|
17
18
|
library_gateway,
|
|
18
19
|
library_pricing,
|
|
19
20
|
library_state,
|
|
@@ -149,7 +150,9 @@ def _state(lib: Library, model: str, record: Record | None) -> tuple[str, Proble
|
|
|
149
150
|
job, alive = lib.jobs.get(model, (None, False))
|
|
150
151
|
if job is not None and alive:
|
|
151
152
|
return ("downloading" if job["kind"] == "download" else "loading"), None
|
|
152
|
-
if job is not None: # its process ended without clearing it
|
|
153
|
+
if job is not None: # its process ended without clearing it, or it failed and kept its partials
|
|
154
|
+
if isinstance(err := job.get("error"), dict) and isinstance(err.get("code"), str):
|
|
155
|
+
return "failed", {"code": err["code"], "detail": str(err.get("detail") or "")}
|
|
153
156
|
code = "DOWNLOAD_FAILED" if job["kind"] == "download" else "ENGINE_START_FAILED"
|
|
154
157
|
return "failed", {"code": code, "detail": f"the {job['kind']} process ended early"}
|
|
155
158
|
if record is None:
|
|
@@ -300,7 +303,14 @@ def row(lib: Library, model: Model) -> Row:
|
|
|
300
303
|
state, problem = _state(lib, model.id, record)
|
|
301
304
|
plan = _plan_of(lib, model, record, priced)
|
|
302
305
|
job, alive = lib.jobs.get(model.id, (None, False))
|
|
303
|
-
|
|
306
|
+
fallback_memory, fallback_window, fallback_vision, fallback_download = (
|
|
307
|
+
library_floor.floor_metadata(
|
|
308
|
+
lib.facts, model, priced.need_bytes, memory_kind=priced.memory_kind
|
|
309
|
+
)
|
|
310
|
+
if plan is None
|
|
311
|
+
else (0, 0, False, 0)
|
|
312
|
+
)
|
|
313
|
+
memory = library_pricing.memory_bytes(plan) if plan is not None else fallback_memory
|
|
304
314
|
if record is None and job is not None and alive:
|
|
305
315
|
memory = job["memory_bytes"] or memory
|
|
306
316
|
if record is not None and record["state"] != "loaded" and record.get("memory_bytes"):
|
|
@@ -318,11 +328,13 @@ def row(lib: Library, model: Model) -> Row:
|
|
|
318
328
|
"name": model.name,
|
|
319
329
|
"description": model.entry.description,
|
|
320
330
|
"quant": model.variant.quant,
|
|
321
|
-
"context_tokens": int(str(launch.get("window") or 0))
|
|
322
|
-
|
|
331
|
+
"context_tokens": int(str(launch.get("window") or 0))
|
|
332
|
+
if plan is not None
|
|
333
|
+
else fallback_window,
|
|
334
|
+
"vision": vision.reads_pictures(launch) if plan is not None else fallback_vision,
|
|
323
335
|
"download_bytes": sum(f["size_bytes"] for f in plan["files"])
|
|
324
336
|
if plan is not None
|
|
325
|
-
else
|
|
337
|
+
else fallback_download,
|
|
326
338
|
"memory_bytes": memory,
|
|
327
339
|
"fit": priced.fit, # type: ignore[typeddict-item]
|
|
328
340
|
"recommended": False,
|
|
@@ -441,11 +453,19 @@ def host(lib: Library) -> Host:
|
|
|
441
453
|
os_info.get("distro")
|
|
442
454
|
or " ".join(str(os_info.get(k) or "") for k in ("system", "release")).strip()
|
|
443
455
|
)
|
|
444
|
-
|
|
456
|
+
engines = [p.plan["engine"] for p in lib.priced.values() if p.plan is not None]
|
|
457
|
+
engine = next(
|
|
458
|
+
(e for e in engines if not str(e.get("build") or "").startswith("strata")),
|
|
459
|
+
engines[0] if engines else None,
|
|
460
|
+
)
|
|
445
461
|
backend = {"cuda": "CUDA", "metal": "Metal", "cpu": "CPU"}
|
|
446
462
|
engine_label = "llama.cpp"
|
|
447
463
|
if engine is not None:
|
|
448
|
-
|
|
464
|
+
build = str(engine.get("build") or "")
|
|
465
|
+
if build.startswith("strata-poly-"):
|
|
466
|
+
engine_label = f"PolyStrata {build.removeprefix('strata-poly-')}".strip()
|
|
467
|
+
else:
|
|
468
|
+
engine_label = f"llama.cpp {build}".strip()
|
|
449
469
|
if (kind := engine.get("backend")) in backend:
|
|
450
470
|
engine_label += f" · {backend[str(kind)]}"
|
|
451
471
|
found: Host = {
|
|
@@ -65,6 +65,20 @@ def strata_bar(llama_score: int, options: Mapping[str, object]) -> int:
|
|
|
65
65
|
return llama_score + TIE_BAND
|
|
66
66
|
|
|
67
67
|
|
|
68
|
+
def strata_recipe_bar(
|
|
69
|
+
llama_score: int, options: Mapping[str, object], *, prefer_over_llama: bool = False
|
|
70
|
+
) -> int:
|
|
71
|
+
"""The installed score one Strata/PolyStrata recipe must reach to replace the llama.cpp pick:
|
|
72
|
+
a recipe marked ``prefer_over_llama`` (such as PolyStrata Inkling 2 Mini on CUDA 13+, which
|
|
73
|
+
offers higher-precision quants and faster decode/prefill on NVIDIA cards) wins ties against
|
|
74
|
+
llama.cpp under ``smartest``, while keeping ``--prefer fastest`` on llama.cpp when one fits."""
|
|
75
|
+
if options.get("prefer") == "fastest" and llama_score >= 0:
|
|
76
|
+
return 1 << 30
|
|
77
|
+
if prefer_over_llama:
|
|
78
|
+
return max(0, llama_score)
|
|
79
|
+
return llama_score + TIE_BAND
|
|
80
|
+
|
|
81
|
+
|
|
68
82
|
PRODUCT_DEFAULTS = {
|
|
69
83
|
("win32", "cuda", "NVIDIA RTX Spark N1X"): "qwen3.8-27b",
|
|
70
84
|
}
|