@simplexai/localmodels-darwin-arm64 0.1.0-dev.37 → 0.1.0-dev.39
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 +85 -78
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +4 -0
- package/modules/localmodels/bifrost_checks.py +9 -6
- package/modules/localmodels/bifrost_config.py +35 -1
- package/modules/localmodels/bifrost_datasheet.py +12 -2
- package/modules/localmodels/catalog.json +155 -8
- package/modules/localmodels/catalog.py +19 -1
- package/modules/localmodels/catalog_recipes.py +33 -2
- package/modules/localmodels/cli_parser.py +26 -3
- package/modules/localmodels/deploy.py +37 -9
- package/modules/localmodels/deploy_steps.py +6 -3
- package/modules/localmodels/download-mirrors.json +52 -4
- package/modules/localmodels/engines-b11583.json +20 -4
- package/modules/localmodels/engines-b12167.json +5 -1
- package/modules/localmodels/engines-strata-0.1.47.json +5 -1
- package/modules/localmodels/engines-strata-0.1.49.2.json +5 -1
- package/modules/localmodels/engines-strata-0.1.59.1.json +5 -1
- package/modules/localmodels/engines-strata-poly-0.1.45-poly.9.json +5 -1
- package/modules/localmodels/engines-whisper-b5454.json +5 -1
- package/modules/localmodels/engines.json +55 -11
- package/modules/localmodels/frontend.py +5 -2
- package/modules/localmodels/gateway_bifrost.py +11 -9
- package/modules/localmodels/gateway_cli.py +4 -2
- package/modules/localmodels/guard.py +15 -6
- package/modules/localmodels/harness.py +65 -33
- package/modules/localmodels/harness_gateway.py +9 -3
- package/modules/localmodels/hf_repo.py +15 -8
- package/modules/localmodels/library_gateway.py +26 -13
- package/modules/localmodels/library_jobs.py +51 -3
- package/modules/localmodels/library_model.py +10 -0
- package/modules/localmodels/library_pricing.py +29 -22
- package/modules/localmodels/library_serve.py +5 -0
- package/modules/localmodels/library_state.py +9 -1
- package/modules/localmodels/library_status.py +30 -0
- package/modules/localmodels/llm_rank.py +83 -30
- package/modules/localmodels/metal_probe.py +16 -6
- package/modules/localmodels/npm_signatures.py +131 -0
- package/modules/localmodels/npm_transport.py +26 -10
- package/modules/localmodels/process_identity.py +32 -5
- package/modules/localmodels/recommend.py +5 -2
- package/modules/localmodels/region.py +244 -0
- package/modules/localmodels/remote_ops.py +69 -13
- package/modules/localmodels/remote_ops_download.py +210 -10
- package/modules/localmodels/remote_ops_prepare.py +61 -8
- package/modules/localmodels/runtime-lock.json +13 -13
- package/modules/localmodels/runtime_args.py +4 -2
- package/modules/localmodels/runtime_cli.py +19 -37
- package/modules/localmodels/runtime_discovery.py +30 -0
- package/modules/localmodels/runtime_install.py +81 -6
- package/modules/localmodels/runtime_io.py +61 -5
- package/modules/localmodels/runtime_pi.py +79 -0
- package/modules/localmodels/runtime_process.py +99 -15
- package/modules/localmodels/runtime_releases.py +51 -71
- package/modules/localmodels/search_server.py +5 -1
- package/modules/localmodels/service_probe.py +62 -4
- package/modules/localmodels/setup_inspection.py +21 -4
- package/modules/localmodels/setup_text.py +6 -0
- package/modules/localmodels/source_byok.py +484 -0
- package/modules/localmodels/source_byok_probe.py +275 -0
- package/modules/localmodels/source_cli.py +426 -0
- package/modules/localmodels/stack.py +31 -14
- package/modules/localmodels/stack_args.py +8 -4
- package/modules/localmodels/stack_binding.py +47 -4
- package/modules/localmodels/stack_cli.py +2 -0
- package/modules/localmodels/stack_compose.py +5 -5
- package/modules/localmodels/stack_events.py +3 -0
- package/modules/localmodels/stack_hardware.py +21 -6
- package/modules/localmodels/stack_llm_ram.py +16 -6
- package/modules/localmodels/stack_picks.py +4 -4
- package/modules/localmodels/stack_progress.py +9 -1
- package/modules/localmodels/stack_run.py +29 -0
- package/modules/localmodels/stack_suite.py +10 -3
- package/modules/localmodels/stack_warm.py +45 -4
- package/modules/localmodels/tools.json +1396 -32
- package/modules/localmodels/transport.py +40 -13
- package/modules/localmodels/windows_job.py +69 -0
- package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/RECORD +82 -75
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -11,16 +11,14 @@ from urllib.error import HTTPError
|
|
|
11
11
|
from urllib.parse import quote, urlsplit
|
|
12
12
|
from urllib.request import Request
|
|
13
13
|
|
|
14
|
-
from localmodels import npm_transport, runtime_process
|
|
14
|
+
from localmodels import npm_signatures, npm_transport, region, runtime_process
|
|
15
15
|
|
|
16
16
|
CLAUDE_BASE = "https://downloads.claude.ai/claude-code-releases"
|
|
17
17
|
CLAUDE_PACKAGE = "@anthropic-ai/claude-code"
|
|
18
|
-
PI_PACKAGE = "@earendil-works/pi-coding-agent"
|
|
19
|
-
PI_IMAGE_MODULE = "@silvia-odwyer/photon-node"
|
|
20
|
-
PI_ENTRY = "dist/bundle/cli.js"
|
|
21
18
|
MINIMUM = {"codex": "0.100.0", "claude": "2.1.282", "pi": "1.2.0"}
|
|
22
19
|
STABLE = re.compile(r"[0-9]+\.[0-9]+\.[0-9]+")
|
|
23
|
-
REGISTRY = "https://registry.npmjs.org"
|
|
20
|
+
REGISTRY = "https://registry.npmjs.org" # metadata and artifact URLs; downloads add the mirror
|
|
21
|
+
MIRROR = "https://registry.npmmirror.com" # metadata only when REGISTRY is unreachable
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
def _object(value: Any) -> dict[str, Any]:
|
|
@@ -47,36 +45,52 @@ def _read(url: str, limit: int, accept: str = "application/json") -> bytes:
|
|
|
47
45
|
|
|
48
46
|
|
|
49
47
|
def _npm(package: str, tag: str | None) -> dict[str, Any]:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
"""Package metadata. Versions and their ``dist.integrity`` come from the npm registry in
|
|
49
|
+
every region (the documents are small; npmmirror serves only the tarball bytes, see
|
|
50
|
+
runtime_io.download_urls). When the registry cannot be reached (not when it answers 404),
|
|
51
|
+
npmmirror's document is used, and a version document only when its ``dist.signatures``
|
|
52
|
+
verify against npm's pinned registry keys (npm_signatures), so the mirror never decides a
|
|
53
|
+
digest. A package's version list (``tag`` None) only names candidates; each one used is
|
|
54
|
+
read again by version."""
|
|
55
|
+
try:
|
|
56
|
+
return _document(REGISTRY, package, tag)
|
|
57
|
+
except HTTPError:
|
|
58
|
+
raise
|
|
59
|
+
except OSError as error:
|
|
60
|
+
unreachable = error
|
|
61
|
+
try:
|
|
62
|
+
value = _document(MIRROR, package, tag)
|
|
63
|
+
except OSError:
|
|
64
|
+
raise unreachable from None
|
|
65
|
+
if tag is not None and not npm_signatures.signed_by_npm(
|
|
66
|
+
package, _text(value.get("version")), _object(value.get("dist"))
|
|
67
|
+
):
|
|
68
|
+
raise ValueError("npm mirror metadata lacks a valid npm registry signature")
|
|
69
|
+
if region.current_region() == "global":
|
|
70
|
+
region.fallback_to("cn")
|
|
71
|
+
return value
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _document(registry: str, package: str, tag: str | None) -> dict[str, Any]:
|
|
75
|
+
base = f"{registry}/{quote(package, safe='@')}"
|
|
76
|
+
data = (
|
|
77
|
+
_read(base, 16 * 1024 * 1024, "application/vnd.npm.install-v1+json")
|
|
78
|
+
if tag is None
|
|
79
|
+
else _read(f"{base}/{quote(tag, safe='')}", 1024 * 1024)
|
|
57
80
|
)
|
|
81
|
+
value = _object(json.loads(data))
|
|
58
82
|
if value.get("name") != package:
|
|
59
83
|
raise ValueError("Unexpected npm package")
|
|
60
84
|
return value
|
|
61
85
|
|
|
62
86
|
|
|
63
|
-
def
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
algorithm, _, value = _text(dist.get("integrity")).partition("-")
|
|
69
|
-
digest = base64.b64decode(value, validate=True)
|
|
70
|
-
if algorithm != "sha512" or len(digest) != 64 or _text(dist.get("tarball")) != url:
|
|
87
|
+
def _tarball(dist: dict[str, Any], package: str, filename: str) -> str:
|
|
88
|
+
"""The npm registry URL of the tarball ``dist`` names on either registry; the download
|
|
89
|
+
tries the mirror per region (runtime_io.download_urls)."""
|
|
90
|
+
tail = f"/{package}/-/{filename}"
|
|
91
|
+
if _text(dist.get("tarball")) not in (REGISTRY + tail, MIRROR + tail):
|
|
71
92
|
raise ValueError("Invalid npm artifact integrity")
|
|
72
|
-
return
|
|
73
|
-
url=url,
|
|
74
|
-
algorithm=algorithm,
|
|
75
|
-
digest=digest.hex(),
|
|
76
|
-
maxBytes=64 * 1024**2,
|
|
77
|
-
format="tar",
|
|
78
|
-
destination=destination,
|
|
79
|
-
)
|
|
93
|
+
return REGISTRY + tail
|
|
80
94
|
|
|
81
95
|
|
|
82
96
|
def _claude_artifacts(platform: str, version: str) -> list[dict[str, Any]] | None:
|
|
@@ -110,31 +124,6 @@ def _claude_artifacts(platform: str, version: str) -> list[dict[str, Any]] | Non
|
|
|
110
124
|
]
|
|
111
125
|
|
|
112
126
|
|
|
113
|
-
def _pi_artifacts(version: str, node_version: str | None) -> list[dict[str, Any]] | None:
|
|
114
|
-
release = _npm(PI_PACKAGE, version)
|
|
115
|
-
minimum = re.fullmatch(
|
|
116
|
-
r">=\s*([0-9]+\.[0-9]+\.[0-9]+)",
|
|
117
|
-
_text(_object(release.get("engines", {})).get("node", "")),
|
|
118
|
-
)
|
|
119
|
-
if (
|
|
120
|
-
release["version"] != version
|
|
121
|
-
or release.get("deprecated")
|
|
122
|
-
or not minimum
|
|
123
|
-
or (node_version is not None and not runtime_process.version_ok(node_version, minimum[1]))
|
|
124
|
-
or _object(release.get("bin", {})).get("pi") != PI_ENTRY
|
|
125
|
-
):
|
|
126
|
-
return None
|
|
127
|
-
# Pi ships a bundled CLI; the image module it loads at runtime is published
|
|
128
|
-
# separately. Resolve the exact dependency declared by each Pi release.
|
|
129
|
-
image_version = _text(_object(release.get("dependencies")).get(PI_IMAGE_MODULE, ""))
|
|
130
|
-
if not STABLE.fullmatch(image_version):
|
|
131
|
-
return None
|
|
132
|
-
image = _npm(PI_IMAGE_MODULE, image_version)
|
|
133
|
-
if image["version"] != image_version or image.get("deprecated"):
|
|
134
|
-
return None
|
|
135
|
-
return [_archive(release, ""), _archive(image, f"package/node_modules/{PI_IMAGE_MODULE}")]
|
|
136
|
-
|
|
137
|
-
|
|
138
127
|
def version_key(version: str) -> tuple[int, ...]:
|
|
139
128
|
if not isinstance(version, str) or not STABLE.fullmatch(version):
|
|
140
129
|
raise ValueError("Not a stable runtime version")
|
|
@@ -147,20 +136,19 @@ def resolve(
|
|
|
147
136
|
version: str | None = None,
|
|
148
137
|
*,
|
|
149
138
|
before_version: str | None = None,
|
|
150
|
-
node_version: str | None = None,
|
|
151
139
|
) -> tuple[str, list[dict[str, Any]]]:
|
|
152
|
-
|
|
140
|
+
"""A Claude release from Anthropic's stable channel. Pi has one pinned release with its
|
|
141
|
+
whole dependency tree (tools.json); it is never resolved here."""
|
|
142
|
+
if runtime != "claude":
|
|
143
|
+
raise ValueError(f"{runtime} releases are pinned, not resolved")
|
|
144
|
+
package = CLAUDE_PACKAGE
|
|
153
145
|
|
|
154
146
|
def artifacts(candidate: str) -> list[dict[str, Any]] | None:
|
|
155
147
|
version_key(candidate)
|
|
156
148
|
if not runtime_process.version_ok(candidate, MINIMUM[runtime]):
|
|
157
149
|
return None
|
|
158
150
|
try:
|
|
159
|
-
return (
|
|
160
|
-
_claude_artifacts(platform, candidate)
|
|
161
|
-
if runtime == "claude"
|
|
162
|
-
else _pi_artifacts(candidate, node_version)
|
|
163
|
-
)
|
|
151
|
+
return _claude_artifacts(platform, candidate)
|
|
164
152
|
except HTTPError as error:
|
|
165
153
|
if error.code == 404:
|
|
166
154
|
return None
|
|
@@ -172,11 +160,7 @@ def resolve(
|
|
|
172
160
|
return version, exact
|
|
173
161
|
raise ValueError(f"Approved {runtime} release is unavailable")
|
|
174
162
|
|
|
175
|
-
latest = (
|
|
176
|
-
_read(f"{CLAUDE_BASE}/stable", 100, "text/plain").decode().strip()
|
|
177
|
-
if runtime == "claude"
|
|
178
|
-
else _text(_npm(package, "latest").get("version"))
|
|
179
|
-
)
|
|
163
|
+
latest = _read(f"{CLAUDE_BASE}/stable", 100, "text/plain").decode().strip()
|
|
180
164
|
bound = version_key(latest)
|
|
181
165
|
if before_version is None or bound < version_key(before_version):
|
|
182
166
|
first = artifacts(latest)
|
|
@@ -239,14 +223,10 @@ def _codex_platform_release(native_platform: str, version: str) -> dict[str, Any
|
|
|
239
223
|
):
|
|
240
224
|
return None
|
|
241
225
|
dist = _object(release.get("dist"))
|
|
242
|
-
url =
|
|
226
|
+
url = _tarball(dist, "@openai/codex", f"codex-{platform_version}.tgz")
|
|
243
227
|
integrity = _text(dist.get("integrity"))
|
|
244
228
|
digest = base64.b64decode(integrity.removeprefix("sha512-"), validate=True)
|
|
245
|
-
if (
|
|
246
|
-
_text(dist.get("tarball")) != url
|
|
247
|
-
or len(digest) != 64
|
|
248
|
-
or not integrity.startswith("sha512-")
|
|
249
|
-
):
|
|
229
|
+
if len(digest) != 64 or not integrity.startswith("sha512-"):
|
|
250
230
|
raise ValueError("Codex registry integrity metadata is invalid")
|
|
251
231
|
return dict(
|
|
252
232
|
url=url,
|
|
@@ -38,7 +38,11 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
|
38
38
|
from io import BufferedIOBase
|
|
39
39
|
from typing import Any, Protocol, TypedDict, cast
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
# DuckDuckGo first, always; Bing last. From home-m6's network (Apple M6, 2026-11-17, ddgs 9.16.1,
|
|
42
|
+
# 10 queries each) DuckDuckGo, Brave and Mojeek answered none and Yahoo half (anti-bot pages read
|
|
43
|
+
# as no results), so a stack apply's search checks failed about one apply in four; Bing answered
|
|
44
|
+
# 7 of 10 at about 12 s. Asked only after every other engine found nothing.
|
|
45
|
+
ENGINES = "duckduckgo,yahoo,brave,mojeek,bing"
|
|
42
46
|
MAX_QUERY_CHARS = 512
|
|
43
47
|
MAX_RESULTS = 10
|
|
44
48
|
REST_S = 120.0
|
|
@@ -87,7 +87,7 @@ def _at(root: str, path: str) -> str:
|
|
|
87
87
|
def _reason(text: str) -> str:
|
|
88
88
|
"""A fixed category for a failed query; the raw error may carry paths or addresses."""
|
|
89
89
|
low = text.lower()
|
|
90
|
-
if any(s in low for s in ("permission", "access denied", "not permitted")):
|
|
90
|
+
if any(s in low for s in ("permission", "access denied", "access is denied", "not permitted")):
|
|
91
91
|
return "permission-denied"
|
|
92
92
|
if any(s in low for s in ("cannot connect", "failed to connect", "timed out", "no such file")):
|
|
93
93
|
return "unreachable"
|
|
@@ -227,6 +227,8 @@ def _windows_owned(pid: int, deployments: str = WINDOWS_DEPLOYMENTS) -> bool | N
|
|
|
227
227
|
"""Windows: a live receipt of one of this user's nohup deployments names the process."""
|
|
228
228
|
try:
|
|
229
229
|
found = process_identity.inspect(pid)
|
|
230
|
+
except PermissionError:
|
|
231
|
+
return False # protected or elevated process of another token: never this user's
|
|
230
232
|
except OSError:
|
|
231
233
|
return None
|
|
232
234
|
if found is None:
|
|
@@ -380,6 +382,50 @@ def _darwin_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
|
380
382
|
return None, "failed"
|
|
381
383
|
|
|
382
384
|
|
|
385
|
+
_WINDOWS_DESKTOP_EXES = frozenset(
|
|
386
|
+
{
|
|
387
|
+
"applicationframehost.exe",
|
|
388
|
+
"csrss.exe",
|
|
389
|
+
"ctfmon.exe",
|
|
390
|
+
"dwm.exe",
|
|
391
|
+
"explorer.exe",
|
|
392
|
+
"fontdrvhost.exe",
|
|
393
|
+
"lockapp.exe",
|
|
394
|
+
"logonui.exe",
|
|
395
|
+
"searchapp.exe",
|
|
396
|
+
"searchhost.exe",
|
|
397
|
+
"shellexperiencehost.exe",
|
|
398
|
+
"shellhost.exe",
|
|
399
|
+
"sihost.exe",
|
|
400
|
+
"startmenuexperiencehost.exe",
|
|
401
|
+
"systemsettings.exe",
|
|
402
|
+
"tabtip.exe",
|
|
403
|
+
"textinputhost.exe",
|
|
404
|
+
"widgets.exe",
|
|
405
|
+
"winlogon.exe",
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def _filter_windows_compute(found: list[dict[str, object]], table: str) -> list[dict[str, object]]:
|
|
411
|
+
"""Drop Windows desktop WDDM clients, resolving names hidden as [Insufficient Permissions]."""
|
|
412
|
+
desktop = windows_graphics_pids(table)
|
|
413
|
+
kept = [p for p in found if p["pid"] not in desktop]
|
|
414
|
+
if not any(str(p["name"]).startswith("[") for p in kept):
|
|
415
|
+
return kept
|
|
416
|
+
names = process_identity.windows_process_names()
|
|
417
|
+
resolved: list[dict[str, object]] = []
|
|
418
|
+
for p in kept:
|
|
419
|
+
pid = int(str(p["pid"]))
|
|
420
|
+
exe = names.get(pid, "")
|
|
421
|
+
if exe and exe.lower() in _WINDOWS_DESKTOP_EXES:
|
|
422
|
+
continue
|
|
423
|
+
if exe and str(p["name"]).startswith("["):
|
|
424
|
+
p = {**p, "name": exe}
|
|
425
|
+
resolved.append(p)
|
|
426
|
+
return resolved
|
|
427
|
+
|
|
428
|
+
|
|
383
429
|
def _compute_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
384
430
|
if sys.platform == "darwin":
|
|
385
431
|
return _darwin_processes()
|
|
@@ -392,8 +438,7 @@ def _compute_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
|
392
438
|
return None, _reason(err or out)
|
|
393
439
|
found = parse_compute_apps(out)
|
|
394
440
|
if sys.platform == "win32":
|
|
395
|
-
|
|
396
|
-
found = [p for p in found if p["pid"] not in desktop]
|
|
441
|
+
found = _filter_windows_compute(found, _run([exe])[1])
|
|
397
442
|
return found, None
|
|
398
443
|
|
|
399
444
|
|
|
@@ -507,6 +552,17 @@ def container_record(inspect: dict[str, object]) -> dict[str, object] | None:
|
|
|
507
552
|
}
|
|
508
553
|
|
|
509
554
|
|
|
555
|
+
def _windows_docker_stopped(text: str) -> bool:
|
|
556
|
+
"""Windows: docker.exe failed to open a missing Docker Desktop named pipe (daemon stopped)."""
|
|
557
|
+
norm = text.replace("\\", "/").lower()
|
|
558
|
+
if "//./pipe/docker" not in norm or _reason(text) == "permission-denied":
|
|
559
|
+
return False
|
|
560
|
+
return not any(
|
|
561
|
+
os.path.exists(rf"\\.\pipe\{name}")
|
|
562
|
+
for name in ("docker_engine", "dockerDesktopLinuxEngine", "dockerDesktopWindowsEngine")
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
|
|
510
566
|
def _containers() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
511
567
|
if sys.platform == "darwin":
|
|
512
568
|
return [], None # containers run in a Linux VM there, without the Mac's Metal GPU
|
|
@@ -514,7 +570,9 @@ def _containers() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
|
514
570
|
return None, "not-installed"
|
|
515
571
|
rc, out, err = _run(["docker", "ps", "-q", "--no-trunc"], timeout=5)
|
|
516
572
|
if rc != 0 or not out.split():
|
|
517
|
-
|
|
573
|
+
if rc == 0 or (sys.platform == "win32" and _windows_docker_stopped(err or out)):
|
|
574
|
+
return [], None
|
|
575
|
+
return None, _reason(err or out)
|
|
518
576
|
# A container that exits between ps and inspect fails the call; the others still print.
|
|
519
577
|
rc, out, err = _run(["docker", "inspect", *out.split()], timeout=10)
|
|
520
578
|
try:
|
|
@@ -77,6 +77,12 @@ class SetupReport(TypedDict):
|
|
|
77
77
|
recommendation: str
|
|
78
78
|
|
|
79
79
|
|
|
80
|
+
def _plan_reason(error: PlanError | StackError | harness.HarnessError, lang: Lang) -> Reason:
|
|
81
|
+
if isinstance(error, stack_hardware.GpuOwnershipError):
|
|
82
|
+
return {"code": "gpu-ownership-unknown", "message": text("gpu-ownership-unknown", lang)}
|
|
83
|
+
return {"code": "plan-unavailable", "message": str(error)}
|
|
84
|
+
|
|
85
|
+
|
|
80
86
|
def _stack(
|
|
81
87
|
root: Path,
|
|
82
88
|
facts: HostFacts,
|
|
@@ -111,12 +117,19 @@ def _stack(
|
|
|
111
117
|
try:
|
|
112
118
|
plan = stack.build(options, facts=facts)
|
|
113
119
|
except (PlanError, stack.StackError, harness.HarnessError) as exc:
|
|
114
|
-
reason =
|
|
115
|
-
if
|
|
120
|
+
reason = _plan_reason(exc, lang)
|
|
121
|
+
if (
|
|
122
|
+
not share_gpu
|
|
123
|
+
and budget.holders(facts)
|
|
124
|
+
and (
|
|
125
|
+
not budget.unknown_services(facts)
|
|
126
|
+
or (not metal.supported(facts) and budget.gpu_conflicts(facts))
|
|
127
|
+
)
|
|
128
|
+
):
|
|
116
129
|
try:
|
|
117
130
|
stack.build({**options, "share_gpu": True}, facts=facts)
|
|
118
131
|
except (PlanError, stack.StackError, harness.HarnessError) as shared_exc:
|
|
119
|
-
reason =
|
|
132
|
+
reason = _plan_reason(shared_exc, lang)
|
|
120
133
|
else:
|
|
121
134
|
reason = {
|
|
122
135
|
"code": "gpu-sharing-required",
|
|
@@ -233,7 +246,9 @@ def _classify(availability: StackAvailability, facts: HostFacts) -> None:
|
|
|
233
246
|
availability["state"], availability["hardwareCapable"] = "blocked-now", True
|
|
234
247
|
else:
|
|
235
248
|
availability["state"] = "unavailable"
|
|
236
|
-
availability["hardwareCapable"] =
|
|
249
|
+
availability["hardwareCapable"] = (
|
|
250
|
+
None if codes & {"facts-unavailable", "gpu-ownership-unknown"} else False
|
|
251
|
+
)
|
|
237
252
|
plan, summary = availability["plan"], availability.get("summary")
|
|
238
253
|
if availability.get("basis") != "capacity" or plan is None or summary is None:
|
|
239
254
|
return
|
|
@@ -343,6 +358,8 @@ INSPECT = (
|
|
|
343
358
|
INSPECT_REASONS = (
|
|
344
359
|
"unsupported-platform · facts-unavailable · plan-unavailable · gpu-sharing-required\n"
|
|
345
360
|
"(the last: a plan fits only beside known busy GPUs; ask, then rerun with --share-gpu)\n"
|
|
361
|
+
"gpu-ownership-unknown: GPU ownership could not be checked, so sharing is refused. "
|
|
362
|
+
"Current free VRAM is in facts.gpus[].free_bytes.\n"
|
|
346
363
|
"free-memory-required (stack.state is blocked-now, stack.basis is capacity: the plan fits "
|
|
347
364
|
"this computer once other programs release the memory they hold now; stack.memory gives "
|
|
348
365
|
"the RAM free and needed). On a Mac whose hardware fits only once another inference app "
|
|
@@ -36,6 +36,12 @@ MESSAGES: dict[str, tuple[str, str]] = {
|
|
|
36
36
|
"Other work is running on the GPUs. If you allow sharing them, the plan uses the GPU "
|
|
37
37
|
"memory free now; no other process is stopped.",
|
|
38
38
|
),
|
|
39
|
+
"gpu-ownership-unknown": (
|
|
40
|
+
"无法核实哪些程序正在使用 GPU,暂不能安全共用。请确认显卡状态可读取,"
|
|
41
|
+
"或先关闭你自己启动的 GPU 任务再重新检查。",
|
|
42
|
+
"The installer could not verify what is using the GPU, so it cannot share it. "
|
|
43
|
+
"Check that GPU status is readable, or close your own GPU workloads and inspect again.",
|
|
44
|
+
),
|
|
39
45
|
"free-memory-required": (
|
|
40
46
|
"这台电脑的硬件可以运行本地模型,但其他程序目前占用了所需的内存(当前 {held})。"
|
|
41
47
|
"安装前请关闭其他程序;安装时会按当时的空闲内存重新规划,不会停止任何进程。",
|