@simplexai/localmodels-linux-x64 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
|
@@ -18,6 +18,7 @@ from localmodels import (
|
|
|
18
18
|
metal,
|
|
19
19
|
probe,
|
|
20
20
|
service_probe,
|
|
21
|
+
setup_inspection_harness,
|
|
21
22
|
setup_text,
|
|
22
23
|
setup_upgrade,
|
|
23
24
|
stack,
|
|
@@ -33,7 +34,6 @@ from localmodels.probe import HostFacts, Services
|
|
|
33
34
|
from localmodels.runtime_cli import inspect_runtimes
|
|
34
35
|
from localmodels.setup_text import Lang, text
|
|
35
36
|
from localmodels.stack_plan import (
|
|
36
|
-
RAM_FLOOR,
|
|
37
37
|
StackError,
|
|
38
38
|
StackOptions,
|
|
39
39
|
StackPlan,
|
|
@@ -104,9 +104,10 @@ class SetupReport(TypedDict):
|
|
|
104
104
|
|
|
105
105
|
_DRIVER_REASON_CODES = frozenset({"cuda-driver-update-required", "cuda-driver-version-unknown"})
|
|
106
106
|
_VERSION_RE = re.compile(r"^\d+(?:\.\d+){0,2}$")
|
|
107
|
+
_capacity_facts = setup_inspection_harness.capacity_facts
|
|
107
108
|
|
|
108
109
|
|
|
109
|
-
def _plan_reason(error: PlanError | StackError
|
|
110
|
+
def _plan_reason(error: PlanError | StackError) -> Reason:
|
|
110
111
|
return {"code": "plan-unavailable", "message": str(error)}
|
|
111
112
|
|
|
112
113
|
|
|
@@ -141,19 +142,29 @@ def _cuda_driver_reason(error: CudaDriverError, lang: Lang) -> Reason:
|
|
|
141
142
|
return reason
|
|
142
143
|
|
|
143
144
|
|
|
145
|
+
def _plans_hardware(options: StackOptions, facts: HostFacts) -> bool:
|
|
146
|
+
try:
|
|
147
|
+
stack.build(options, facts=facts)
|
|
148
|
+
except (PlanError, stack.StackError):
|
|
149
|
+
return False
|
|
150
|
+
except harness.HarnessError:
|
|
151
|
+
return True
|
|
152
|
+
return True
|
|
153
|
+
|
|
154
|
+
|
|
144
155
|
def _fits_with_required_cuda(options: StackOptions, facts: HostFacts, required_cuda: str) -> bool:
|
|
145
156
|
"""Whether this computer's hardware fits a local stack once the NVIDIA driver supports
|
|
146
157
|
``required_cuda`` (live or once other programs free memory)."""
|
|
147
158
|
upgraded = copy.deepcopy(facts)
|
|
148
159
|
upgraded["nvidia"] = {**(upgraded.get("nvidia") or {}), "cuda_version": required_cuda}
|
|
149
|
-
if
|
|
160
|
+
if _plans_hardware(options, upgraded):
|
|
150
161
|
return True
|
|
151
162
|
roomy = _capacity_facts(upgraded)
|
|
152
|
-
return roomy is not None and
|
|
163
|
+
return roomy is not None and _plans_hardware(options, roomy)
|
|
153
164
|
|
|
154
165
|
|
|
155
166
|
def _driver_block(
|
|
156
|
-
error: PlanError | StackError |
|
|
167
|
+
error: PlanError | StackError | None,
|
|
157
168
|
options: StackOptions,
|
|
158
169
|
facts: HostFacts,
|
|
159
170
|
lang: Lang,
|
|
@@ -177,7 +188,7 @@ def _capacity_availability(
|
|
|
177
188
|
return None
|
|
178
189
|
try:
|
|
179
190
|
plan = stack.build(options, facts=roomy)
|
|
180
|
-
except (PlanError, stack.StackError
|
|
191
|
+
except (PlanError, stack.StackError) as roomy_exc:
|
|
181
192
|
if blocked := _driver_block(roomy_exc, options, roomy, lang):
|
|
182
193
|
return blocked
|
|
183
194
|
# The hardware itself is too small and the live refusal stands, unless only another
|
|
@@ -209,41 +220,29 @@ def _capacity_availability(
|
|
|
209
220
|
}
|
|
210
221
|
|
|
211
222
|
|
|
212
|
-
def
|
|
213
|
-
|
|
214
|
-
facts: HostFacts,
|
|
215
|
-
offline: bool,
|
|
216
|
-
defer_services: bool = False,
|
|
217
|
-
share_gpu: bool = False,
|
|
218
|
-
decision: Literal["auto", "none"] = "none",
|
|
219
|
-
unified_memory: str | None = None,
|
|
220
|
-
lang: Lang = "zh",
|
|
223
|
+
def _harness_availability(
|
|
224
|
+
options: StackOptions, facts: HostFacts, exc: harness.HarnessError, lang: Lang
|
|
221
225
|
) -> StackAvailability:
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
options["decision"] = decision
|
|
239
|
-
if defer_services:
|
|
240
|
-
options["defer_services"] = True
|
|
241
|
-
if unified_memory:
|
|
242
|
-
options["unified_memory"] = unified_memory
|
|
226
|
+
"""Classify a gateway/tool HarnessError separately from hardware incapability."""
|
|
227
|
+
code, capable, message = setup_inspection_harness.classify_harness_error(
|
|
228
|
+
options, facts, exc, lang
|
|
229
|
+
)
|
|
230
|
+
return {
|
|
231
|
+
"available": False,
|
|
232
|
+
"reasons": [{"code": code, "message": message}],
|
|
233
|
+
"plan": None,
|
|
234
|
+
"hardwareCapable": capable,
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def _plan_stack(
|
|
239
|
+
options: StackOptions, facts: HostFacts, share_gpu: bool, lang: Lang
|
|
240
|
+
) -> StackAvailability:
|
|
241
|
+
try:
|
|
243
242
|
try:
|
|
244
243
|
plan = stack.build(options, facts=facts)
|
|
245
|
-
except (PlanError, stack.StackError
|
|
246
|
-
last_error: PlanError | StackError |
|
|
244
|
+
except (PlanError, stack.StackError) as exc:
|
|
245
|
+
last_error: PlanError | StackError | None = exc
|
|
247
246
|
last_options = options
|
|
248
247
|
reason = _plan_reason(exc)
|
|
249
248
|
# Consent decides by free VRAM whoever else uses a card (roadmap decision 60), so
|
|
@@ -256,7 +255,7 @@ def _stack(
|
|
|
256
255
|
shared_options: StackOptions = {**options, "share_gpu": True}
|
|
257
256
|
try:
|
|
258
257
|
stack.build(shared_options, facts=facts)
|
|
259
|
-
except (PlanError, stack.StackError
|
|
258
|
+
except (PlanError, stack.StackError) as shared_exc:
|
|
260
259
|
last_error, last_options = shared_exc, shared_options
|
|
261
260
|
reason = _plan_reason(shared_exc)
|
|
262
261
|
else:
|
|
@@ -270,66 +269,62 @@ def _stack(
|
|
|
270
269
|
if reason["code"] == "plan-unavailable":
|
|
271
270
|
if capacity := _capacity_availability(options, facts, lang):
|
|
272
271
|
return capacity
|
|
272
|
+
return {"available": False, "reasons": [reason], "plan": None}
|
|
273
273
|
else:
|
|
274
274
|
availability: StackAvailability = {"available": True, "reasons": [], "plan": plan}
|
|
275
275
|
if upgrade := setup_upgrade.upgrade_hint(options, facts, plan, lang, _capacity_facts):
|
|
276
276
|
availability["upgrade"] = upgrade
|
|
277
277
|
return availability
|
|
278
|
+
except harness.HarnessError as exc:
|
|
279
|
+
return _harness_availability(options, facts, exc, lang)
|
|
278
280
|
|
|
279
|
-
return {"available": plan is not None, "reasons": [reason] if reason else [], "plan": plan}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
def _capacity_facts(facts: HostFacts) -> HostFacts | None:
|
|
283
|
-
"""``facts`` once the user's other programs are closed, or None when that frees nothing.
|
|
284
281
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
282
|
+
def _stack(
|
|
283
|
+
root: Path,
|
|
284
|
+
facts: HostFacts,
|
|
285
|
+
offline: bool,
|
|
286
|
+
defer_services: bool = False,
|
|
287
|
+
share_gpu: bool = False,
|
|
288
|
+
decision: Literal["auto", "none"] = "none",
|
|
289
|
+
unified_memory: str | None = None,
|
|
290
|
+
lang: Lang = "zh",
|
|
291
|
+
) -> StackAvailability:
|
|
292
|
+
if error := platform_error(facts["platform"], arch=facts.get("arch")):
|
|
293
|
+
reason: Reason = {"code": "unsupported-platform", "message": error}
|
|
294
|
+
elif facts["ram"]["total_bytes"] <= 0 or facts["disk"]["free_bytes"] is None:
|
|
295
|
+
reason = {"code": "facts-unavailable", "message": text("facts-unavailable", lang)}
|
|
296
|
+
elif _nvidia_cards_unmeasured(facts):
|
|
297
|
+
reason = {"code": "facts-unavailable", "message": text("nvidia-unmeasured", lang)}
|
|
297
298
|
else:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if
|
|
306
|
-
|
|
307
|
-
|
|
299
|
+
options = stack.default_options()
|
|
300
|
+
options["base_dir"] = str(root)
|
|
301
|
+
options["offline"] = offline
|
|
302
|
+
options["share_gpu"] = share_gpu
|
|
303
|
+
options["decision"] = decision
|
|
304
|
+
if defer_services:
|
|
305
|
+
options["defer_services"] = True
|
|
306
|
+
if unified_memory:
|
|
307
|
+
options["unified_memory"] = unified_memory
|
|
308
|
+
return _plan_stack(options, facts, share_gpu, lang)
|
|
309
|
+
return {"available": False, "reasons": [reason], "plan": None}
|
|
308
310
|
|
|
309
311
|
|
|
310
312
|
def _fits_without_other_inference(options: StackOptions, roomy: HostFacts) -> StackPlan | None:
|
|
311
313
|
"""A Mac's capacity plan once the inference apps this tool does not own on its GPU
|
|
312
314
|
(``metal.conflicts``) are quit as well, or None when it still does not fit."""
|
|
313
|
-
|
|
315
|
+
alone = setup_inspection_harness.without_other_inference(roomy)
|
|
316
|
+
if alone is None:
|
|
314
317
|
return None
|
|
315
|
-
alone = copy.deepcopy(roomy)
|
|
316
|
-
services = alone["services"]
|
|
317
|
-
assert services is not None # conflicts come from service discovery
|
|
318
|
-
services["compute_processes"] = [
|
|
319
|
-
p
|
|
320
|
-
for p in services.get("compute_processes") or []
|
|
321
|
-
if p["gpu_uuid"] != metal.METAL_UUID or p["owned"] is True
|
|
322
|
-
]
|
|
323
318
|
try:
|
|
324
319
|
return stack.build(options, facts=alone)
|
|
325
|
-
except (PlanError, stack.StackError
|
|
320
|
+
except (PlanError, stack.StackError):
|
|
326
321
|
return None
|
|
327
322
|
|
|
328
323
|
|
|
329
324
|
def _plans(options: StackOptions, facts: HostFacts) -> bool:
|
|
330
325
|
try:
|
|
331
326
|
stack.build(options, facts=facts)
|
|
332
|
-
except (PlanError, stack.StackError
|
|
327
|
+
except (PlanError, stack.StackError):
|
|
333
328
|
return False
|
|
334
329
|
return True
|
|
335
330
|
|
|
@@ -418,11 +413,16 @@ def _classify(availability: StackAvailability, facts: HostFacts) -> None:
|
|
|
418
413
|
availability.get("basis") == "capacity"
|
|
419
414
|
or "gpu-sharing-required" in codes
|
|
420
415
|
or bool(codes & _DRIVER_REASON_CODES)
|
|
416
|
+
or (
|
|
417
|
+
bool(codes & setup_inspection_harness.HARNESS_CODES)
|
|
418
|
+
and availability.get("hardwareCapable") is True
|
|
419
|
+
)
|
|
421
420
|
):
|
|
422
421
|
availability["state"], availability["hardwareCapable"] = "blocked-now", True
|
|
423
422
|
else:
|
|
424
423
|
availability["state"] = "unavailable"
|
|
425
|
-
|
|
424
|
+
if "hardwareCapable" not in availability:
|
|
425
|
+
availability["hardwareCapable"] = None if "facts-unavailable" in codes else False
|
|
426
426
|
plan, summary = availability["plan"], availability.get("summary")
|
|
427
427
|
if availability.get("basis") != "capacity" or plan is None or summary is None:
|
|
428
428
|
return
|
|
@@ -537,13 +537,17 @@ INSPECT = (
|
|
|
537
537
|
)
|
|
538
538
|
INSPECT_REASONS = (
|
|
539
539
|
"unsupported-platform · facts-unavailable · plan-unavailable · gpu-sharing-required\n"
|
|
540
|
-
"cuda-driver-update-required · cuda-driver-version-unknown
|
|
540
|
+
"cuda-driver-update-required · cuda-driver-version-unknown · gateway-port-in-use · "
|
|
541
|
+
"harness-unavailable\n"
|
|
541
542
|
"(gpu-sharing-required: a plan fits only beside other GPU work, its owner known or not; ask, "
|
|
542
543
|
"then rerun with --share-gpu, which plans by the free VRAM)\n"
|
|
543
544
|
"cuda-driver-update-required / cuda-driver-version-unknown (stack.state is blocked-now, "
|
|
544
545
|
"hardwareCapable is true: the GPU can run local models, but the NVIDIA driver's CUDA version "
|
|
545
546
|
"is older than requiredCudaVersion or could not be read; detectedCudaVersion, "
|
|
546
547
|
"requiredCudaVersion and driverVersion carry the versions)\n"
|
|
548
|
+
"gateway-port-in-use / harness-unavailable (stack.state is blocked-now with "
|
|
549
|
+
"hardwareCapable true when the hardware fits, but the gateway port is held or tool checks "
|
|
550
|
+
"failed; free the port or fix the tool issue and check again)\n"
|
|
547
551
|
"gpu-memory-required (stack.state is blocked-now, stack.basis is capacity: other programs "
|
|
548
552
|
"use the GPU memory the plan needs; close them and check again; gpuIndex, freeBytes and "
|
|
549
553
|
"requiredBytes give the card and its free and needed VRAM)\n"
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""Classify ``HarnessError`` in ``setup inspect`` separately from hardware incapability."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import copy
|
|
6
|
+
|
|
7
|
+
from localmodels import (
|
|
8
|
+
budget,
|
|
9
|
+
deploy,
|
|
10
|
+
harness,
|
|
11
|
+
metal,
|
|
12
|
+
stack,
|
|
13
|
+
stack_compose,
|
|
14
|
+
stack_gpu_memory,
|
|
15
|
+
stack_hardware,
|
|
16
|
+
stack_suite,
|
|
17
|
+
)
|
|
18
|
+
from localmodels.plan_envelope import PlanError
|
|
19
|
+
from localmodels.probe import HostFacts
|
|
20
|
+
from localmodels.setup_text import Lang, text
|
|
21
|
+
from localmodels.stack_plan import RAM_FLOOR, StackOptions, platform_error
|
|
22
|
+
|
|
23
|
+
HARNESS_CODES = frozenset({"gateway-port-in-use", "harness-unavailable"})
|
|
24
|
+
_PORT_CONFLICT_HINTS = (
|
|
25
|
+
"is held by",
|
|
26
|
+
"ports 3425..3456 are all in use",
|
|
27
|
+
"port still listening",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def capacity_facts(facts: HostFacts) -> HostFacts | None:
|
|
32
|
+
"""``facts`` once the user's other programs are closed, or None when that frees nothing.
|
|
33
|
+
|
|
34
|
+
A Mac keeps what an idle one leaves to macOS and applications (``metal.in_use``) and is at
|
|
35
|
+
normal pressure; a Linux host keeps the planner's own floor a second time for its desktop.
|
|
36
|
+
An NVIDIA card keeps an idle driver context, unless serving work this tool does not own
|
|
37
|
+
runs on it: that memory needs sharing consent, and closing applications does not free it.
|
|
38
|
+
"""
|
|
39
|
+
roomy = copy.deepcopy(facts)
|
|
40
|
+
ram = roomy["ram"]
|
|
41
|
+
total = ram["total_bytes"]
|
|
42
|
+
if metal.supported(facts):
|
|
43
|
+
room = total - metal.in_use(total)
|
|
44
|
+
ram["pressure_level"] = 1
|
|
45
|
+
ram.pop("pressure_kept_bytes", None)
|
|
46
|
+
else:
|
|
47
|
+
room = total - RAM_FLOOR
|
|
48
|
+
ram["available_bytes"] = max(ram["available_bytes"], room)
|
|
49
|
+
served = budget.gpu_conflicts(facts)
|
|
50
|
+
for gpu in roomy.get("gpus") or []:
|
|
51
|
+
if served.get(gpu["uuid"]):
|
|
52
|
+
continue
|
|
53
|
+
idle = max(0, gpu["total_bytes"] - budget.IDLE_USED_BYTES)
|
|
54
|
+
if gpu["free_bytes"] < idle:
|
|
55
|
+
gpu["free_bytes"], gpu["used_bytes"] = idle, gpu["total_bytes"] - idle
|
|
56
|
+
return None if roomy == facts else roomy
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def harness_code(error: harness.HarnessError) -> str:
|
|
60
|
+
if error.code in HARNESS_CODES:
|
|
61
|
+
return error.code
|
|
62
|
+
lowered = str(error).lower()
|
|
63
|
+
if any(hint in lowered for hint in _PORT_CONFLICT_HINTS):
|
|
64
|
+
return "gateway-port-in-use"
|
|
65
|
+
return "harness-unavailable"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def fits_hardware_once(options: StackOptions, facts: HostFacts) -> bool:
|
|
69
|
+
"""Whether ``facts`` can fit a verified local stack ignoring gateway/harness conflicts."""
|
|
70
|
+
try:
|
|
71
|
+
seen = stack_hardware.assumed(facts, options.get("unified_memory"))
|
|
72
|
+
if platform_error(seen["platform"], options.get("profile"), seen["arch"]):
|
|
73
|
+
return False
|
|
74
|
+
if options.get("profile") != "macos-mlx-preview" and metal.problem(seen):
|
|
75
|
+
return False
|
|
76
|
+
if metal.supported(seen) and options.get("profile") != "macos-mlx-preview":
|
|
77
|
+
seen = metal.reclaimed(seen)
|
|
78
|
+
seen, _ = metal.pressured(seen)
|
|
79
|
+
seen, _ = stack_gpu_memory.capped(seen, options)
|
|
80
|
+
resolver = deploy.catalog_pins if options.get("offline") else deploy.resolve_files
|
|
81
|
+
parts, chosen = stack_compose.choose_parts(
|
|
82
|
+
seen,
|
|
83
|
+
options,
|
|
84
|
+
resolver=resolver,
|
|
85
|
+
listening=lambda _port: False,
|
|
86
|
+
previous=lambda _name, _port: None,
|
|
87
|
+
existing=lambda _recipes: [],
|
|
88
|
+
owned_ram=lambda: 0,
|
|
89
|
+
)
|
|
90
|
+
if chosen.get("defer_services"):
|
|
91
|
+
parts["decision"] = {
|
|
92
|
+
**parts["decision"],
|
|
93
|
+
"plan": None,
|
|
94
|
+
"front": None,
|
|
95
|
+
"existing": None,
|
|
96
|
+
"options": [],
|
|
97
|
+
}
|
|
98
|
+
named = stack_suite.named_foundations(chosen)
|
|
99
|
+
parts["aux"] = [p for p in parts["aux"] if stack_suite.task_of(p) not in named]
|
|
100
|
+
stack_compose.ram_budget(parts)
|
|
101
|
+
except (PlanError, stack.StackError):
|
|
102
|
+
return False
|
|
103
|
+
return True
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def without_other_inference(roomy: HostFacts) -> HostFacts | None:
|
|
107
|
+
"""``roomy`` with foreign Metal inference apps stripped, or None when none are present."""
|
|
108
|
+
if not metal.supported(roomy) or not metal.conflicts(roomy):
|
|
109
|
+
return None
|
|
110
|
+
alone = copy.deepcopy(roomy)
|
|
111
|
+
services = alone["services"]
|
|
112
|
+
assert services is not None # conflicts come from service discovery
|
|
113
|
+
services["compute_processes"] = [
|
|
114
|
+
p
|
|
115
|
+
for p in services.get("compute_processes") or []
|
|
116
|
+
if p["gpu_uuid"] != metal.METAL_UUID or p["owned"] is True
|
|
117
|
+
]
|
|
118
|
+
return alone
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def hardware_capable_without_harness(options: StackOptions, facts: HostFacts) -> bool:
|
|
122
|
+
"""True when the computer's hardware fits a stack once gateway/harness blockers clear."""
|
|
123
|
+
if fits_hardware_once(options, facts):
|
|
124
|
+
return True
|
|
125
|
+
if (
|
|
126
|
+
not options.get("share_gpu")
|
|
127
|
+
and budget.holders(facts)
|
|
128
|
+
and (not budget.unknown_services(facts) or not metal.supported(facts))
|
|
129
|
+
and fits_hardware_once({**options, "share_gpu": True}, facts)
|
|
130
|
+
):
|
|
131
|
+
return True
|
|
132
|
+
if roomy := capacity_facts(facts):
|
|
133
|
+
if fits_hardware_once(options, roomy):
|
|
134
|
+
return True
|
|
135
|
+
if (alone := without_other_inference(roomy)) is not None:
|
|
136
|
+
return fits_hardware_once(options, alone)
|
|
137
|
+
return False
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def classify_harness_error(
|
|
141
|
+
options: StackOptions, facts: HostFacts, exc: harness.HarnessError, lang: Lang
|
|
142
|
+
) -> tuple[str, bool, str]:
|
|
143
|
+
"""Return ``(reason_code, hardware_capable, message)`` for a gateway/tool ``HarnessError``."""
|
|
144
|
+
code = harness_code(exc)
|
|
145
|
+
capable = hardware_capable_without_harness(options, facts)
|
|
146
|
+
message = text(code, lang, detail=str(exc)) if capable else str(exc)
|
|
147
|
+
return code, capable, message
|
|
@@ -86,6 +86,18 @@ MESSAGES: dict[str, tuple[str, str]] = {
|
|
|
86
86
|
"(requires CUDA {required} or newer). Update or reinstall the NVIDIA driver and check "
|
|
87
87
|
"again.",
|
|
88
88
|
),
|
|
89
|
+
"gateway-port-in-use": (
|
|
90
|
+
"这台电脑的硬件可以运行本地模型,但网关端口当前被其他程序占用({detail})。"
|
|
91
|
+
"请停止占用该端口的程序,或设置其他网关地址后重新检查。",
|
|
92
|
+
"This computer's hardware can run local models, but the gateway port is currently in use "
|
|
93
|
+
"({detail}). Stop that program or set another gateway address, then check again.",
|
|
94
|
+
),
|
|
95
|
+
"harness-unavailable": (
|
|
96
|
+
"这台电脑的硬件可以运行本地模型,但网关或工具环境检查未通过({detail})。"
|
|
97
|
+
"请先处理该问题后重新检查。",
|
|
98
|
+
"This computer's hardware can run local models, but gateway or tool preparation is "
|
|
99
|
+
"currently blocked ({detail}). Resolve this issue and check again.",
|
|
100
|
+
),
|
|
89
101
|
"plan-invalid": (
|
|
90
102
|
"批准计划不存在、无效或摘要不一致。",
|
|
91
103
|
"The approved plan is missing or invalid, or its digest does not match.",
|
|
@@ -96,10 +96,20 @@ def upgrade_hint(
|
|
|
96
96
|
gib = budget.gib
|
|
97
97
|
reasons: list[UpgradeReason] = []
|
|
98
98
|
live_gpus = {g["index"]: g for g in facts.get("gpus") or []}
|
|
99
|
+
is_strata = str(roomy_plan["llm"]["engine"].get("build") or "").startswith("strata")
|
|
100
|
+
idle_cap = (
|
|
101
|
+
budget.DESKTOP_VRAM_BASELINE_CAP_BYTES
|
|
102
|
+
if facts.get("platform") == "win32" and facts.get("services") is not None
|
|
103
|
+
else budget.IDLE_USED_BYTES
|
|
104
|
+
)
|
|
99
105
|
for index, vram in _vram_by_card(roomy_plan).items():
|
|
100
106
|
card = live_gpus.get(index)
|
|
107
|
+
if card is None:
|
|
108
|
+
continue
|
|
101
109
|
required = vram + AGENT_VRAM_RESERVE_BYTES
|
|
102
|
-
if
|
|
110
|
+
if is_strata and not options.get("share_gpu"):
|
|
111
|
+
required = max(required, max(0, card["total_bytes"] - idle_cap))
|
|
112
|
+
if card["free_bytes"] >= required:
|
|
103
113
|
continue
|
|
104
114
|
reasons.append(
|
|
105
115
|
{
|
|
@@ -112,7 +112,9 @@ def build(
|
|
|
112
112
|
== Path(options["base_dir"]).expanduser()
|
|
113
113
|
):
|
|
114
114
|
context = accepted
|
|
115
|
-
tools_dir =
|
|
115
|
+
tools_dir = hosts.tools_dir(
|
|
116
|
+
context["harness"]["tools_dir"] if context else harness.DEFAULT_TOOLS_DIR
|
|
117
|
+
)
|
|
116
118
|
tools = harness.inspect(
|
|
117
119
|
tools_dir=tools_dir, approved=context["harness"] if context else None, private_clients=True
|
|
118
120
|
)
|
|
@@ -77,7 +77,9 @@ def strata_parts(
|
|
|
77
77
|
added to ``passed_over`` for the llama.cpp plan's warnings."""
|
|
78
78
|
bar, llama_id = llama
|
|
79
79
|
skipped: list[str] = []
|
|
80
|
-
for recipe in stack_suite.auto_strata_candidates(
|
|
80
|
+
for recipe in stack_suite.auto_strata_candidates(
|
|
81
|
+
facts, llm_rank.strata_bar(bar, options), llama_score=bar, options=options
|
|
82
|
+
):
|
|
81
83
|
score = recipe["quality"]["score"]
|
|
82
84
|
why = (
|
|
83
85
|
f"LLM: auto picks Strata {recipe['id']} (installed SimplexAI score {score}"
|
|
@@ -154,7 +156,9 @@ def card_fits(
|
|
|
154
156
|
share = bool(options.get("share_gpu", False) or gpu_conflicts(facts).get(gpu["uuid"]))
|
|
155
157
|
bar = llm_rank.strata_bar(llama_score, probe_opts)
|
|
156
158
|
fits: list[LlmFit] = []
|
|
157
|
-
for recipe in stack_suite.auto_strata_candidates(
|
|
159
|
+
for recipe in stack_suite.auto_strata_candidates(
|
|
160
|
+
facts, bar, llama_score=llama_score, options=probe_opts
|
|
161
|
+
):
|
|
158
162
|
candidate_options: StackOptions = {
|
|
159
163
|
**probe_opts,
|
|
160
164
|
"gpu": index,
|
|
@@ -95,7 +95,7 @@ def plan_tools(
|
|
|
95
95
|
actions: list[harness.ToolAction] = []
|
|
96
96
|
native: dict[str, dict[str, Any]] = {}
|
|
97
97
|
native_arch = {"x86_64": "x64", "aarch64": "arm64"}.get(arch, arch)
|
|
98
|
-
root = Path(tools_dir).expanduser().absolute() / "clients"
|
|
98
|
+
root = Path(hosts.tools_dir(tools_dir)).expanduser().absolute() / "clients"
|
|
99
99
|
owned = {tool["path"]: tool for tool in hosts.load_owned(tools_dir)["tools"]}
|
|
100
100
|
for client, seen in planned_clients(state).items():
|
|
101
101
|
wrapper = Path(harness.BIN_DIR).expanduser() / client
|
|
@@ -57,16 +57,24 @@ def _bifrost(record: hosts.OwnedBifrost) -> str:
|
|
|
57
57
|
return f"failed: {exc}"
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def _magpie(doc: hosts.Owned, plan: StackPlan, notes: list[str]) -> str:
|
|
60
|
+
def _magpie(doc: hosts.Owned, plan: StackPlan | None, notes: list[str]) -> str:
|
|
61
61
|
started = doc["gateway"]["started"]
|
|
62
|
+
owned_magpie = doc["gateway"].get("magpie")
|
|
62
63
|
if started == "daemon":
|
|
63
64
|
notes.append("the global magpie.service is not proven to be this tool's; left running")
|
|
64
65
|
return "kept: global magpie.service"
|
|
65
|
-
if started != "serve":
|
|
66
|
+
if started != "serve" and owned_magpie is None:
|
|
66
67
|
return "none"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if owned_magpie is not None:
|
|
69
|
+
tools_dir = owned_magpie["tools_dir"]
|
|
70
|
+
target = harness_gateway.owned_magpie_target(owned_magpie)
|
|
71
|
+
magpie = owned_magpie["binary"] or gateway.magpie_binary(doc)
|
|
72
|
+
elif plan is not None:
|
|
73
|
+
tools_dir = plan["harness"]["tools_dir"]
|
|
74
|
+
target = harness_gateway.magpie_target(tools_dir) or plan["harness"]
|
|
75
|
+
magpie = gateway.magpie_binary(doc)
|
|
76
|
+
else:
|
|
77
|
+
return "failed: saved stack plan unavailable; gateway left untouched"
|
|
70
78
|
if magpie is None:
|
|
71
79
|
return "failed: the Magpie binary this tool installed is missing"
|
|
72
80
|
check = gateway.stop_gateway(magpie, "serve", tools_dir, plan=target, forget=False)
|
|
@@ -76,21 +84,22 @@ def _magpie(doc: hosts.Owned, plan: StackPlan, notes: list[str]) -> str:
|
|
|
76
84
|
|
|
77
85
|
|
|
78
86
|
def _gateway(plan: StackPlan | None, notes: list[str]) -> tuple[str, str]:
|
|
79
|
-
"""Stop the gateway this tool started. Bifrost's own record
|
|
80
|
-
|
|
81
|
-
uninstall, GitHub linger#178). A Magpie
|
|
82
|
-
directory and is left untouched without it."""
|
|
87
|
+
"""Stop the gateway this tool started. Bifrost's own record and a recorded private Magpie
|
|
88
|
+
instance each prove themselves ours even without a saved stack plan (Linger's quit and
|
|
89
|
+
uninstall, GitHub linger#178 / WHI-887). A legacy Magpie manifest without an instance record
|
|
90
|
+
still needs the saved plan's tools directory and is left untouched without it."""
|
|
83
91
|
doc = hosts.load_owned(plan["harness"]["tools_dir"] if plan else hosts.TOOLS_DIR)
|
|
84
92
|
record = doc["gateway"].get("bifrost")
|
|
85
93
|
results: list[tuple[str, str]] = []
|
|
86
94
|
if record:
|
|
87
95
|
results.append((_bifrost(record), "Bifrost"))
|
|
88
|
-
if doc["gateway"]["started"]:
|
|
89
|
-
|
|
90
|
-
(_magpie(doc, plan, notes), "Magpie")
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
if doc["gateway"]["started"] or doc["gateway"].get("magpie"):
|
|
97
|
+
if plan is not None or doc["gateway"].get("magpie") is not None:
|
|
98
|
+
results.append((_magpie(doc, plan, notes), "Magpie"))
|
|
99
|
+
else:
|
|
100
|
+
results.append(
|
|
101
|
+
("failed: saved stack plan unavailable; gateway left untouched", "unknown")
|
|
102
|
+
)
|
|
94
103
|
for prefix in ("failed", "stopped", "kept", "not-running"):
|
|
95
104
|
found = next((r for r in results if r[0].startswith(prefix)), None)
|
|
96
105
|
if found:
|
|
@@ -120,7 +129,7 @@ def _down(out: Out) -> DownReport:
|
|
|
120
129
|
records = [r for r in hosts.records(hosts.LOCAL_ID) if r["plan"]["name"] in members]
|
|
121
130
|
notes: list[str] = []
|
|
122
131
|
# The gateway first: it routes to the services, as up starts it after them.
|
|
123
|
-
gate, kind = _gateway(_latest()
|
|
132
|
+
gate, kind = _gateway(_latest(), notes)
|
|
124
133
|
if gate in ("stopped", "not-running") and _library_loaded():
|
|
125
134
|
notes.append(
|
|
126
135
|
"models the library loaded keep running without the gateway; unload them "
|
|
@@ -354,9 +354,20 @@ def llm_fits(
|
|
|
354
354
|
llama_score = max(
|
|
355
355
|
(f["quality"] for _, f in found if not f.get("candidate_fallback")), default=-1
|
|
356
356
|
)
|
|
357
|
+
preferred_strata = {
|
|
358
|
+
c["id"]
|
|
359
|
+
for c in catalog_recipes.components()
|
|
360
|
+
if c["runtime"] in ("strata", "strata-poly") and c.get("prefer_over_llama")
|
|
361
|
+
}
|
|
362
|
+
strata_vram = {
|
|
363
|
+
c["id"]: int(str(c.get("vram_bytes") or 0))
|
|
364
|
+
for c in catalog_recipes.components()
|
|
365
|
+
if c["runtime"] in ("strata", "strata-poly")
|
|
366
|
+
}
|
|
357
367
|
for fit in stack_auto.card_fits(facts, index, options, llama_score):
|
|
358
368
|
_apply_fit_measurement(facts, index, fit)
|
|
359
|
-
|
|
369
|
+
tie = (1e9 if fit["id"] in preferred_strata else -1e9) + strata_vram.get(fit["id"], 0) / GIB
|
|
370
|
+
found.append(((fit["quality"], tie), fit))
|
|
360
371
|
found = [row for row in found if not row[1].get("candidate_fallback")] or found
|
|
361
372
|
default_id = llm_rank.listed_default(facts, [(f["id"], f["quality"]) for _, f in found])
|
|
362
373
|
return [
|