@simplexai/localmodels-darwin-arm64 0.1.0-dev.38 → 0.1.0-dev.40
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 +81 -73
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +4 -0
- package/modules/localmodels/auth_proxy.py +74 -16
- package/modules/localmodels/bifrost_config.py +19 -0
- package/modules/localmodels/budget.py +27 -18
- package/modules/localmodels/catalog.json +18 -6
- package/modules/localmodels/chat_template.py +35 -0
- package/modules/localmodels/cli_parser.py +26 -3
- package/modules/localmodels/deploy.py +44 -10
- 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.py +2 -0
- package/modules/localmodels/gateway_bifrost.py +3 -0
- package/modules/localmodels/gateway_home.py +132 -0
- package/modules/localmodels/guard.py +15 -6
- package/modules/localmodels/harness.py +104 -37
- package/modules/localmodels/harness_gateway.py +9 -3
- package/modules/localmodels/harness_probe.py +5 -1
- package/modules/localmodels/hf_repo.py +15 -8
- package/modules/localmodels/library_gateway.py +28 -15
- package/modules/localmodels/library_jobs.py +7 -1
- package/modules/localmodels/library_serve.py +5 -0
- package/modules/localmodels/metal.py +29 -12
- 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/probe.py +4 -0
- package/modules/localmodels/process_identity.py +21 -5
- package/modules/localmodels/region.py +244 -0
- package/modules/localmodels/remote_ops.py +69 -13
- package/modules/localmodels/remote_ops_download.py +217 -10
- package/modules/localmodels/remote_ops_prepare.py +61 -8
- package/modules/localmodels/remote_ops_remove.py +15 -0
- package/modules/localmodels/remote_ops_service.py +10 -0
- package/modules/localmodels/runtime-lock.json +13 -13
- package/modules/localmodels/runtime_args.py +4 -2
- package/modules/localmodels/runtime_cli.py +76 -74
- package/modules/localmodels/runtime_discovery.py +58 -0
- package/modules/localmodels/runtime_install.py +103 -7
- package/modules/localmodels/runtime_io.py +64 -7
- package/modules/localmodels/runtime_pi.py +122 -0
- package/modules/localmodels/runtime_process.py +101 -15
- package/modules/localmodels/runtime_releases.py +51 -71
- package/modules/localmodels/service_deployment.py +5 -3
- package/modules/localmodels/service_probe.py +146 -31
- package/modules/localmodels/setup_inspection.py +110 -14
- package/modules/localmodels/setup_text.py +13 -0
- package/modules/localmodels/slot_cache.py +467 -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_args.py +2 -1
- package/modules/localmodels/stack_binding.py +125 -5
- package/modules/localmodels/stack_capacity.py +3 -3
- package/modules/localmodels/stack_down.py +22 -7
- package/modules/localmodels/stack_events.py +62 -0
- package/modules/localmodels/stack_hardware.py +20 -17
- package/modules/localmodels/stack_lifecycle.py +12 -3
- package/modules/localmodels/stack_rollback.py +9 -4
- package/modules/localmodels/stack_up.py +27 -20
- package/modules/localmodels/stack_update.py +3 -1
- package/modules/localmodels/tools.json +1365 -14
- package/modules/localmodels/transport.py +2 -0
- package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/RECORD +78 -70
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev40.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -25,6 +25,7 @@ import shlex
|
|
|
25
25
|
import shutil
|
|
26
26
|
import socket
|
|
27
27
|
import stat
|
|
28
|
+
import struct
|
|
28
29
|
import subprocess
|
|
29
30
|
import sys
|
|
30
31
|
import urllib.error
|
|
@@ -87,7 +88,7 @@ def _at(root: str, path: str) -> str:
|
|
|
87
88
|
def _reason(text: str) -> str:
|
|
88
89
|
"""A fixed category for a failed query; the raw error may carry paths or addresses."""
|
|
89
90
|
low = text.lower()
|
|
90
|
-
if any(s in low for s in ("permission", "access denied", "not permitted")):
|
|
91
|
+
if any(s in low for s in ("permission", "access denied", "access is denied", "not permitted")):
|
|
91
92
|
return "permission-denied"
|
|
92
93
|
if any(s in low for s in ("cannot connect", "failed to connect", "timed out", "no such file")):
|
|
93
94
|
return "unreachable"
|
|
@@ -227,6 +228,8 @@ def _windows_owned(pid: int, deployments: str = WINDOWS_DEPLOYMENTS) -> bool | N
|
|
|
227
228
|
"""Windows: a live receipt of one of this user's nohup deployments names the process."""
|
|
228
229
|
try:
|
|
229
230
|
found = process_identity.inspect(pid)
|
|
231
|
+
except PermissionError:
|
|
232
|
+
return False # protected or elevated process of another token: never this user's
|
|
230
233
|
except OSError:
|
|
231
234
|
return None
|
|
232
235
|
if found is None:
|
|
@@ -301,10 +304,18 @@ def _posix_owned(pid: int, root: str) -> bool | None:
|
|
|
301
304
|
return False
|
|
302
305
|
|
|
303
306
|
|
|
304
|
-
def parse_darwin_ps(
|
|
307
|
+
def parse_darwin_ps(
|
|
308
|
+
text: str,
|
|
309
|
+
me: str,
|
|
310
|
+
args: Callable[[int], str],
|
|
311
|
+
parent: Callable[[int], int | None] | None = None,
|
|
312
|
+
footprint: Callable[[int], int | None] = lambda pid: None,
|
|
313
|
+
) -> list[dict[str, object]]:
|
|
305
314
|
"""Serving engines from ``ps -axo pid=,rss=,user=,comm=`` on macOS. Every process there shares
|
|
306
|
-
the one Metal GPU, so each is listed on it with its resident memory
|
|
307
|
-
|
|
315
|
+
the one Metal GPU, so each is listed on it with its resident memory, and (when macOS tells
|
|
316
|
+
its physical footprint) the part of it that is file cache. Python servers need their
|
|
317
|
+
module/script argument to identify the engine; no arguments or model paths are kept.
|
|
318
|
+
``parent`` gives a process's parent, for an engine its deployment's launcher started."""
|
|
308
319
|
found: list[dict[str, object]] = []
|
|
309
320
|
for line in text.splitlines():
|
|
310
321
|
cols = line.split(None, 3)
|
|
@@ -314,17 +325,19 @@ def parse_darwin_ps(text: str, me: str, args: Callable[[int], str]) -> list[dict
|
|
|
314
325
|
name, argv = _darwin_engine(comm, pid, args)
|
|
315
326
|
if name is None:
|
|
316
327
|
continue
|
|
317
|
-
owned = user == me and _beside_deployment(argv, pid)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
+
owned = user == me and _beside_deployment(argv, pid, parent)
|
|
329
|
+
row: dict[str, object] = {
|
|
330
|
+
"gpu_uuid": METAL_UUID,
|
|
331
|
+
"pid": pid,
|
|
332
|
+
"name": name,
|
|
333
|
+
"used_bytes": rss << 10,
|
|
334
|
+
"owned": owned,
|
|
335
|
+
"in_suite": owned,
|
|
336
|
+
}
|
|
337
|
+
physical = footprint(pid)
|
|
338
|
+
if physical is not None:
|
|
339
|
+
row["cached_bytes"] = max(0, (rss << 10) - physical)
|
|
340
|
+
found.append(row)
|
|
328
341
|
return found
|
|
329
342
|
|
|
330
343
|
|
|
@@ -346,20 +359,62 @@ def _darwin_engine(
|
|
|
346
359
|
return (match.group(0).lower() if match else None), argv
|
|
347
360
|
|
|
348
361
|
|
|
349
|
-
def
|
|
362
|
+
def _receipt_pids(directory: str) -> set[int]:
|
|
363
|
+
"""The live processes a deployment directory's own receipts name (nohup, launchd)."""
|
|
364
|
+
held: set[int] = set()
|
|
365
|
+
state, pid = process_identity.status(directory + "/server.pid")
|
|
366
|
+
if state == "active" and pid is not None:
|
|
367
|
+
held.add(pid)
|
|
368
|
+
if os.path.isfile(directory + "/launchd.plist"):
|
|
369
|
+
try:
|
|
370
|
+
state, pid = remote_ops_launchd.status(directory)
|
|
371
|
+
if state == "active" and pid is not None:
|
|
372
|
+
held.add(pid)
|
|
373
|
+
except (OSError, RuntimeError):
|
|
374
|
+
pass
|
|
375
|
+
return held
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def _beside_deployment(
|
|
379
|
+
argv: Sequence[str], pid: int, parent: Callable[[int], int | None] | None = None
|
|
380
|
+
) -> bool:
|
|
381
|
+
"""A deployment's receipt names this process, or names its parent: a launcher in front of
|
|
382
|
+
the server (slot_cache.py) is the recorded process and the server is its child, as the
|
|
383
|
+
Linux check follows a process's ancestors to the recorded command (_posix_owned)."""
|
|
350
384
|
values = (arg.split("=", 1)[-1] for arg in argv[:256])
|
|
385
|
+
held: set[int] = set()
|
|
351
386
|
for directory in {os.path.dirname(v) for v in values if v[:1] == "/"}:
|
|
352
|
-
if
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
387
|
+
if os.path.isfile(directory + "/deployment.json"):
|
|
388
|
+
held |= _receipt_pids(directory)
|
|
389
|
+
if pid in held:
|
|
390
|
+
return True
|
|
391
|
+
if not held or parent is None:
|
|
392
|
+
return False
|
|
393
|
+
above = parent(pid)
|
|
394
|
+
return above is not None and above > 1 and above in held
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
LIBPROC = "/usr/lib/libproc.dylib"
|
|
398
|
+
# struct rusage_info_v0: a 16-byte uuid, then ten uint64 counters; ri_wired_size,
|
|
399
|
+
# ri_resident_size and ri_phys_footprint are the 6th, 7th and 8th.
|
|
400
|
+
_RUSAGE_V0_BYTES = 16 + 10 * 8
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def darwin_footprint(pid: int) -> int | None:
|
|
404
|
+
"""The process's physical footprint (Activity Monitor's "Memory"): its anonymous, wired and
|
|
405
|
+
compressed memory, without the clean file-backed pages it maps; at least its wired memory.
|
|
406
|
+
None when macOS does not tell (another user's process)."""
|
|
407
|
+
try:
|
|
408
|
+
import ctypes
|
|
409
|
+
|
|
410
|
+
libproc = ctypes.cdll.LoadLibrary(LIBPROC)
|
|
411
|
+
buffer = ctypes.create_string_buffer(_RUSAGE_V0_BYTES)
|
|
412
|
+
if libproc.proc_pid_rusage(ctypes.c_int(pid), ctypes.c_int(0), buffer) != 0:
|
|
413
|
+
return None
|
|
414
|
+
except (OSError, AttributeError, ImportError):
|
|
415
|
+
return None
|
|
416
|
+
wired, _resident, physical = struct.unpack_from("<3Q", buffer.raw, 16 + 5 * 8)
|
|
417
|
+
return int(max(wired, physical))
|
|
363
418
|
|
|
364
419
|
|
|
365
420
|
def _darwin_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
@@ -374,12 +429,60 @@ def _darwin_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
|
374
429
|
raise OSError("process arguments unavailable")
|
|
375
430
|
return text if done == 0 else ""
|
|
376
431
|
|
|
432
|
+
def parent(pid: int) -> int | None:
|
|
433
|
+
done, text, _ = _run(["/bin/ps", "-o", "ppid=", "-p", str(pid)])
|
|
434
|
+
return int(text) if done == 0 and text.strip().isdigit() else None
|
|
435
|
+
|
|
377
436
|
try:
|
|
378
|
-
return parse_darwin_ps(out, me, args), None
|
|
437
|
+
return parse_darwin_ps(out, me, args, parent, darwin_footprint), None
|
|
379
438
|
except OSError:
|
|
380
439
|
return None, "failed"
|
|
381
440
|
|
|
382
441
|
|
|
442
|
+
_WINDOWS_DESKTOP_EXES = frozenset(
|
|
443
|
+
{
|
|
444
|
+
"applicationframehost.exe",
|
|
445
|
+
"csrss.exe",
|
|
446
|
+
"ctfmon.exe",
|
|
447
|
+
"dwm.exe",
|
|
448
|
+
"explorer.exe",
|
|
449
|
+
"fontdrvhost.exe",
|
|
450
|
+
"lockapp.exe",
|
|
451
|
+
"logonui.exe",
|
|
452
|
+
"searchapp.exe",
|
|
453
|
+
"searchhost.exe",
|
|
454
|
+
"shellexperiencehost.exe",
|
|
455
|
+
"shellhost.exe",
|
|
456
|
+
"sihost.exe",
|
|
457
|
+
"startmenuexperiencehost.exe",
|
|
458
|
+
"systemsettings.exe",
|
|
459
|
+
"tabtip.exe",
|
|
460
|
+
"textinputhost.exe",
|
|
461
|
+
"widgets.exe",
|
|
462
|
+
"winlogon.exe",
|
|
463
|
+
}
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def _filter_windows_compute(found: list[dict[str, object]], table: str) -> list[dict[str, object]]:
|
|
468
|
+
"""Drop Windows desktop WDDM clients, resolving names hidden as [Insufficient Permissions]."""
|
|
469
|
+
desktop = windows_graphics_pids(table)
|
|
470
|
+
kept = [p for p in found if p["pid"] not in desktop]
|
|
471
|
+
if not any(str(p["name"]).startswith("[") for p in kept):
|
|
472
|
+
return kept
|
|
473
|
+
names = process_identity.windows_process_names()
|
|
474
|
+
resolved: list[dict[str, object]] = []
|
|
475
|
+
for p in kept:
|
|
476
|
+
pid = int(str(p["pid"]))
|
|
477
|
+
exe = names.get(pid, "")
|
|
478
|
+
if exe and exe.lower() in _WINDOWS_DESKTOP_EXES:
|
|
479
|
+
continue
|
|
480
|
+
if exe and str(p["name"]).startswith("["):
|
|
481
|
+
p = {**p, "name": exe}
|
|
482
|
+
resolved.append(p)
|
|
483
|
+
return resolved
|
|
484
|
+
|
|
485
|
+
|
|
383
486
|
def _compute_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
384
487
|
if sys.platform == "darwin":
|
|
385
488
|
return _darwin_processes()
|
|
@@ -392,8 +495,7 @@ def _compute_processes() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
|
392
495
|
return None, _reason(err or out)
|
|
393
496
|
found = parse_compute_apps(out)
|
|
394
497
|
if sys.platform == "win32":
|
|
395
|
-
|
|
396
|
-
found = [p for p in found if p["pid"] not in desktop]
|
|
498
|
+
found = _filter_windows_compute(found, _run([exe])[1])
|
|
397
499
|
return found, None
|
|
398
500
|
|
|
399
501
|
|
|
@@ -507,6 +609,17 @@ def container_record(inspect: dict[str, object]) -> dict[str, object] | None:
|
|
|
507
609
|
}
|
|
508
610
|
|
|
509
611
|
|
|
612
|
+
def _windows_docker_stopped(text: str) -> bool:
|
|
613
|
+
"""Windows: docker.exe failed to open a missing Docker Desktop named pipe (daemon stopped)."""
|
|
614
|
+
norm = text.replace("\\", "/").lower()
|
|
615
|
+
if "//./pipe/docker" not in norm or _reason(text) == "permission-denied":
|
|
616
|
+
return False
|
|
617
|
+
return not any(
|
|
618
|
+
os.path.exists(rf"\\.\pipe\{name}")
|
|
619
|
+
for name in ("docker_engine", "dockerDesktopLinuxEngine", "dockerDesktopWindowsEngine")
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
|
|
510
623
|
def _containers() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
511
624
|
if sys.platform == "darwin":
|
|
512
625
|
return [], None # containers run in a Linux VM there, without the Mac's Metal GPU
|
|
@@ -514,7 +627,9 @@ def _containers() -> tuple[list[dict[str, object]] | None, str | None]:
|
|
|
514
627
|
return None, "not-installed"
|
|
515
628
|
rc, out, err = _run(["docker", "ps", "-q", "--no-trunc"], timeout=5)
|
|
516
629
|
if rc != 0 or not out.split():
|
|
517
|
-
|
|
630
|
+
if rc == 0 or (sys.platform == "win32" and _windows_docker_stopped(err or out)):
|
|
631
|
+
return [], None
|
|
632
|
+
return None, _reason(err or out)
|
|
518
633
|
# A container that exits between ps and inspect fails the call; the others still print.
|
|
519
634
|
rc, out, err = _run(["docker", "inspect", *out.split()], timeout=10)
|
|
520
635
|
try:
|
|
@@ -24,14 +24,31 @@ from localmodels import (
|
|
|
24
24
|
stack_review,
|
|
25
25
|
)
|
|
26
26
|
from localmodels.contracts import decode
|
|
27
|
+
from localmodels.estimator import AGENT_VRAM_RESERVE_BYTES
|
|
27
28
|
from localmodels.plan_envelope import PlanError
|
|
28
29
|
from localmodels.probe import HostFacts, Services
|
|
29
30
|
from localmodels.runtime_cli import inspect_runtimes
|
|
30
31
|
from localmodels.setup_text import Lang, text
|
|
31
|
-
from localmodels.stack_plan import
|
|
32
|
+
from localmodels.stack_plan import (
|
|
33
|
+
RAM_FLOOR,
|
|
34
|
+
StackError,
|
|
35
|
+
StackOptions,
|
|
36
|
+
StackPlan,
|
|
37
|
+
deployments,
|
|
38
|
+
platform_error,
|
|
39
|
+
)
|
|
40
|
+
|
|
32
41
|
|
|
42
|
+
class _ReasonSince014(TypedDict, total=False):
|
|
43
|
+
# Since 0.1.4 (roadmap decision 60), on gpu-memory-required and free-memory-required: the
|
|
44
|
+
# memory free now (measured) and the memory the install needs free (the plan's estimate,
|
|
45
|
+
# with the planner's safety reserve on a GPU), in bytes; gpuIndex names the card.
|
|
46
|
+
gpuIndex: int
|
|
47
|
+
freeBytes: int
|
|
48
|
+
requiredBytes: int
|
|
33
49
|
|
|
34
|
-
|
|
50
|
+
|
|
51
|
+
class Reason(_ReasonSince014):
|
|
35
52
|
code: str
|
|
36
53
|
message: str
|
|
37
54
|
|
|
@@ -77,6 +94,10 @@ class SetupReport(TypedDict):
|
|
|
77
94
|
recommendation: str
|
|
78
95
|
|
|
79
96
|
|
|
97
|
+
def _plan_reason(error: PlanError | StackError | harness.HarnessError) -> Reason:
|
|
98
|
+
return {"code": "plan-unavailable", "message": str(error)}
|
|
99
|
+
|
|
100
|
+
|
|
80
101
|
def _stack(
|
|
81
102
|
root: Path,
|
|
82
103
|
facts: HostFacts,
|
|
@@ -111,12 +132,18 @@ def _stack(
|
|
|
111
132
|
try:
|
|
112
133
|
plan = stack.build(options, facts=facts)
|
|
113
134
|
except (PlanError, stack.StackError, harness.HarnessError) as exc:
|
|
114
|
-
reason =
|
|
115
|
-
|
|
135
|
+
reason = _plan_reason(exc)
|
|
136
|
+
# Consent decides by free VRAM whoever else uses a card (roadmap decision 60), so
|
|
137
|
+
# only a Mac, whose sharing still needs every discovery section, skips the retry.
|
|
138
|
+
if (
|
|
139
|
+
not share_gpu
|
|
140
|
+
and budget.holders(facts)
|
|
141
|
+
and (not budget.unknown_services(facts) or not metal.supported(facts))
|
|
142
|
+
):
|
|
116
143
|
try:
|
|
117
144
|
stack.build({**options, "share_gpu": True}, facts=facts)
|
|
118
145
|
except (PlanError, stack.StackError, harness.HarnessError) as shared_exc:
|
|
119
|
-
reason =
|
|
146
|
+
reason = _plan_reason(shared_exc)
|
|
120
147
|
else:
|
|
121
148
|
reason = {
|
|
122
149
|
"code": "gpu-sharing-required",
|
|
@@ -150,7 +177,7 @@ def _stack(
|
|
|
150
177
|
# refuse, so the stack is not available; the plan shows what it needs.
|
|
151
178
|
return {
|
|
152
179
|
"available": False,
|
|
153
|
-
"reasons":
|
|
180
|
+
"reasons": _held_reasons(options, facts, roomy, plan, lang),
|
|
154
181
|
"plan": plan,
|
|
155
182
|
"basis": "capacity",
|
|
156
183
|
}
|
|
@@ -205,6 +232,70 @@ def _fits_without_other_inference(options: StackOptions, roomy: HostFacts) -> St
|
|
|
205
232
|
return None
|
|
206
233
|
|
|
207
234
|
|
|
235
|
+
def _plans(options: StackOptions, facts: HostFacts) -> bool:
|
|
236
|
+
try:
|
|
237
|
+
stack.build(options, facts=facts)
|
|
238
|
+
except (PlanError, stack.StackError, harness.HarnessError):
|
|
239
|
+
return False
|
|
240
|
+
return True
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _held_reasons(
|
|
244
|
+
options: StackOptions, facts: HostFacts, roomy: HostFacts, plan: StackPlan, lang: Lang
|
|
245
|
+
) -> list[Reason]:
|
|
246
|
+
"""What other programs must release for the capacity ``plan`` to install now: GPU memory
|
|
247
|
+
(``gpu-memory-required``, close programs that use the GPU), RAM (``free-memory-required``)
|
|
248
|
+
or both, each with the memory free now and needed. A resource counts as short when freeing
|
|
249
|
+
only the other one still plans nothing (roadmap decision 60)."""
|
|
250
|
+
gpu_only, ram_only = copy.deepcopy(facts), copy.deepcopy(facts)
|
|
251
|
+
gpu_only["gpus"] = copy.deepcopy(roomy.get("gpus") or [])
|
|
252
|
+
ram_only["ram"] = copy.deepcopy(roomy["ram"])
|
|
253
|
+
gpu_short = gpu_only != facts and not _plans(options, ram_only)
|
|
254
|
+
ram_short = ram_only != facts and not _plans(options, gpu_only)
|
|
255
|
+
if not gpu_short and not ram_short:
|
|
256
|
+
return [_free_memory_reason(facts, roomy, lang)]
|
|
257
|
+
summary = stack_review.summarize(plan, lang)
|
|
258
|
+
gib = budget.gib
|
|
259
|
+
reasons: list[Reason] = []
|
|
260
|
+
if gpu_short:
|
|
261
|
+
live = {g["index"]: g for g in facts.get("gpus") or []}
|
|
262
|
+
for index, vram in _vram_by_card(plan).items():
|
|
263
|
+
card = live.get(index)
|
|
264
|
+
required = vram + AGENT_VRAM_RESERVE_BYTES
|
|
265
|
+
if card is None or card["free_bytes"] >= required:
|
|
266
|
+
continue
|
|
267
|
+
reasons.append(
|
|
268
|
+
{
|
|
269
|
+
"code": "gpu-memory-required",
|
|
270
|
+
"message": text(
|
|
271
|
+
"gpu-memory-required",
|
|
272
|
+
lang,
|
|
273
|
+
index=index,
|
|
274
|
+
free=gib(card["free_bytes"]),
|
|
275
|
+
needed=gib(required),
|
|
276
|
+
),
|
|
277
|
+
"gpuIndex": index,
|
|
278
|
+
"freeBytes": card["free_bytes"],
|
|
279
|
+
"requiredBytes": required,
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
if ram_short or not reasons:
|
|
283
|
+
ram = facts["ram"]["available_bytes"]
|
|
284
|
+
reason = _free_memory_reason(facts, ram_only if gpu_short else roomy, lang)
|
|
285
|
+
reasons.append({**reason, "freeBytes": ram, "requiredBytes": summary["memoryBytes"]})
|
|
286
|
+
return reasons
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def _vram_by_card(plan: StackPlan) -> dict[int, int]:
|
|
290
|
+
"""GPU memory the plan's deployments reserve on each card; a split one counts on each."""
|
|
291
|
+
found: dict[int, int] = {}
|
|
292
|
+
for part in deployments(plan):
|
|
293
|
+
for gpu in decode(part["placement"].get("gpus") or [], list[stack_review.SelectedGPU]):
|
|
294
|
+
index = gpu["index"]
|
|
295
|
+
found[index] = found.get(index, 0) + int(str(part["launch"].get("vram_bytes") or 0))
|
|
296
|
+
return found
|
|
297
|
+
|
|
298
|
+
|
|
208
299
|
def _free_memory_reason(facts: HostFacts, roomy: HostFacts, lang: Lang = "zh") -> Reason:
|
|
209
300
|
"""Names the memory other programs hold now: each reading the capacity plan counted as freed."""
|
|
210
301
|
gib = budget.gib
|
|
@@ -342,11 +433,15 @@ INSPECT = (
|
|
|
342
433
|
)
|
|
343
434
|
INSPECT_REASONS = (
|
|
344
435
|
"unsupported-platform · facts-unavailable · plan-unavailable · gpu-sharing-required\n"
|
|
345
|
-
"(the last: a plan fits only beside known
|
|
346
|
-
"
|
|
347
|
-
"
|
|
348
|
-
"the
|
|
349
|
-
"
|
|
436
|
+
"(the last: a plan fits only beside other GPU work, its owner known or not; ask, then rerun "
|
|
437
|
+
"with --share-gpu, which plans by the free VRAM)\n"
|
|
438
|
+
"gpu-memory-required (stack.state is blocked-now, stack.basis is capacity: other programs "
|
|
439
|
+
"use the GPU memory the plan needs; close them and check again; gpuIndex, freeBytes and "
|
|
440
|
+
"requiredBytes give the card and its free and needed VRAM)\n"
|
|
441
|
+
"free-memory-required (the same for RAM, freeBytes and requiredBytes in RAM; stack.memory "
|
|
442
|
+
"gives the RAM free and needed). On a Mac whose hardware fits only once another inference "
|
|
443
|
+
"app on its GPU is quit, plan-unavailable (blocked-now) names that app instead of the "
|
|
444
|
+
"hardware"
|
|
350
445
|
)
|
|
351
446
|
BINDING = (
|
|
352
447
|
"Read-only handoff check of a stack that `stack apply` installed from --plan: the plan's "
|
|
@@ -358,7 +453,8 @@ BINDING = (
|
|
|
358
453
|
)
|
|
359
454
|
BINDING_REASONS = (
|
|
360
455
|
"plan-invalid · acceptance-unavailable · deployment-unavailable · gateway-ownership\n"
|
|
361
|
-
"gateway-unavailable · pi-model-unavailable · pi-config-changed · binding-unavailable"
|
|
456
|
+
"gateway-unavailable · pi-model-unavailable · pi-config-changed · binding-unavailable\n"
|
|
457
|
+
"pi-extensions-unavailable"
|
|
362
458
|
)
|
|
363
459
|
REVIEW = (
|
|
364
460
|
"Read-only: verify the saved plan's digest and project it for the user to approve. The "
|
|
@@ -410,8 +506,8 @@ def _inspect_parser(actions: argparse._SubParsersAction[argparse.ArgumentParser]
|
|
|
410
506
|
inspect.add_argument(
|
|
411
507
|
"--share-gpu",
|
|
412
508
|
action="store_true",
|
|
413
|
-
help="consent to plan
|
|
414
|
-
"stopped (without it
|
|
509
|
+
help="consent to plan beside other GPU work, its owner known or not, by the current "
|
|
510
|
+
"free VRAM; nothing is stopped (without it such GPUs are avoided)",
|
|
415
511
|
)
|
|
416
512
|
stack_hardware.add_arguments(inspect)
|
|
417
513
|
setup_text.add_argument(inspect)
|
|
@@ -36,6 +36,14 @@ 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-memory-required": (
|
|
40
|
+
"这台电脑的显卡可以运行本地模型,但其他程序目前占用了 GPU {index} 的显存"
|
|
41
|
+
"(空闲 {free},安装约需 {needed})。请关闭正在使用显卡的程序(游戏、视频、其他 AI 应用)"
|
|
42
|
+
"后重新检查;本工具不会停止任何进程。",
|
|
43
|
+
"This computer's GPU can run local models, but other programs are using GPU {index}'s "
|
|
44
|
+
"memory ({free} free; the install needs about {needed}). Close programs that use the "
|
|
45
|
+
"GPU (games, video, other AI apps) and check again; this tool stops no process.",
|
|
46
|
+
),
|
|
39
47
|
"free-memory-required": (
|
|
40
48
|
"这台电脑的硬件可以运行本地模型,但其他程序目前占用了所需的内存(当前 {held})。"
|
|
41
49
|
"安装前请关闭其他程序;安装时会按当时的空闲内存重新规划,不会停止任何进程。",
|
|
@@ -86,6 +94,11 @@ MESSAGES: dict[str, tuple[str, str]] = {
|
|
|
86
94
|
"检查期间 Pi 配置发生变化,请重新检查。",
|
|
87
95
|
"Pi's configuration changed during the check. Check again.",
|
|
88
96
|
),
|
|
97
|
+
"pi-extensions-unavailable": (
|
|
98
|
+
"Pi 无法加载扩展(0.1.0.dev39 之前安装的 Pi 缺少依赖),请重新运行 stack apply。",
|
|
99
|
+
"Pi cannot load extensions (a Pi installed before 0.1.0.dev39 lacks its dependencies). "
|
|
100
|
+
"Run stack apply again to replace it.",
|
|
101
|
+
),
|
|
89
102
|
"binding-unavailable": (
|
|
90
103
|
"Pi 配置或本机状态无法安全读取,请恢复已有安装后重试。",
|
|
91
104
|
"Pi's configuration or this computer's state cannot be read safely. Restore the "
|