@simplexai/localmodels-win32-x64 0.1.0-dev.57 → 0.1.0-dev.59
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 +66 -64
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/app.py +1 -1
- package/modules/localmodels/bifrost_admin.py +53 -8
- package/modules/localmodels/bifrost_config.py +103 -4
- package/modules/localmodels/bifrost_log.py +166 -0
- package/modules/localmodels/budget.py +161 -1
- package/modules/localmodels/catalog.json +55 -32
- package/modules/localmodels/catalog.py +5 -2
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.5.json +94 -0
- package/modules/localmodels/frontend.py +26 -21
- package/modules/localmodels/gateway_bifrost.py +30 -6
- package/modules/localmodels/gpu_specs.py +38 -13
- package/modules/localmodels/hosts.py +99 -12
- package/modules/localmodels/library_cli.py +8 -1
- package/modules/localmodels/library_convert.py +34 -0
- package/modules/localmodels/library_elastic.py +747 -0
- package/modules/localmodels/library_gateway.py +101 -10
- package/modules/localmodels/library_jobs.py +16 -7
- package/modules/localmodels/library_model.py +101 -4
- package/modules/localmodels/library_pricing.py +41 -39
- package/modules/localmodels/library_serve.py +322 -58
- package/modules/localmodels/library_state.py +35 -1
- package/modules/localmodels/library_status.py +113 -6
- package/modules/localmodels/llm_rank.py +16 -5
- package/modules/localmodels/metal.py +141 -0
- package/modules/localmodels/metal_probe.py +167 -0
- package/modules/localmodels/plan_envelope.py +4 -1
- package/modules/localmodels/probe.py +2 -2
- package/modules/localmodels/process_identity_linux.py +39 -0
- package/modules/localmodels/recommend.py +6 -1
- package/modules/localmodels/remote_ops.py +4 -3
- package/modules/localmodels/remote_ops_download.py +37 -24
- package/modules/localmodels/remote_ops_mirrors.py +43 -2
- package/modules/localmodels/remote_ops_service.py +93 -36
- package/modules/localmodels/runtime_auth.py +4 -1
- package/modules/localmodels/service_wiring.py +238 -12
- package/modules/localmodels/setup_inspection.py +47 -70
- package/modules/localmodels/setup_inspection_harness.py +159 -15
- package/modules/localmodels/setup_text.py +14 -0
- package/modules/localmodels/setup_upgrade.py +1 -1
- package/modules/localmodels/source_byok.py +6 -2
- package/modules/localmodels/source_byok_probe.py +6 -1
- package/modules/localmodels/stack.py +9 -1
- package/modules/localmodels/stack_binding.py +3 -35
- package/modules/localmodels/stack_cleanup.py +4 -0
- package/modules/localmodels/stack_compose.py +24 -3
- package/modules/localmodels/stack_hardware.py +3 -1
- package/modules/localmodels/stack_lifecycle.py +24 -1
- package/modules/localmodels/stack_picks.py +16 -2
- package/modules/localmodels/stack_plan.py +6 -2
- package/modules/localmodels/stack_ports.py +2 -0
- package/modules/localmodels/stack_remove.py +10 -1
- package/modules/localmodels/stack_up.py +33 -7
- package/modules/localmodels/stack_update.py +3 -1
- package/modules/localmodels/{strata-poly-serve-0.2.19-poly.1.txt → strata-poly-serve-0.2.20-poly.5.txt} +1 -1
- package/modules/localmodels/suite.py +43 -27
- package/modules/localmodels/transport.py +13 -2
- package/modules/{simplex_localmodels-0.1.0.dev57.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev57.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/RECORD +63 -61
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +0 -79
- /package/modules/{simplex_localmodels-0.1.0.dev57.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev57.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev57.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev57.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "localmodels.engine-lock/v1",
|
|
3
|
+
"tag": "strata-poly-0.2.20-poly.5",
|
|
4
|
+
"commit": "v0.2.20-poly.5",
|
|
5
|
+
"source": "https://github.com/simplexai-labs/PolyStrata/releases/tag/v0.2.20-poly.5",
|
|
6
|
+
"note": "PolyStrata 0.2.20-poly.5 (MIT, commit d62dfacbe, strata-poly engine 0.1.66) for CUDA 13 NVIDIA Linux and Windows recipes (Inkling 2 Mini). Adds fused CUDA decode/verify kernels, q5_k default --attn-requant fixing tool-call JSON token drops on small cards (#318), vram_ahead() staging race fix, OOM recovery during CUDA graph capture (#301), and strata_pin prefix pinning (#343). Linux: strata-poly and strata-vision from the release archive with NVIDIA CUDA 13.0.3 runtime libraries (libcublas, libcublasLt, libcudart) reused from 0.1.45-poly.9 under NVIDIA's licence; needs NVIDIA driver for CUDA 13.0 (580 or newer), glibc 2.34, and libstdc++ 12. Windows: strata-poly.exe and strata-vision.exe (CUDA 13.0) paired with NVIDIA's cuBLAS 13.0.2.14 wheel (nvidia/cu13/bin/x86_64 on lib_dirs). On both platforms the tag archive supplies PolyStrata's Python server and tokenizer tools under terminal/ (terminal/serve/, terminal/tools/, terminal/strata_control/, terminal/strata_cli/, and LICENSE).",
|
|
7
|
+
"builds": [
|
|
8
|
+
{
|
|
9
|
+
"platform": "linux",
|
|
10
|
+
"arch": "x64",
|
|
11
|
+
"backend": "cuda",
|
|
12
|
+
"min_cuda": "13.0",
|
|
13
|
+
"min_glibc": "2.34",
|
|
14
|
+
"binary": "strata-poly",
|
|
15
|
+
"assets": [
|
|
16
|
+
{
|
|
17
|
+
"name": "strata-poly-linux-x64-cuda13-f05645dc3b8f77a0.tar.gz",
|
|
18
|
+
"url": "https://github.com/simplexai-labs/PolyStrata/releases/download/v0.2.20-poly.5/strata-poly-linux-x64-cuda13-f05645dc3b8f77a0.tar.gz",
|
|
19
|
+
"sha256": "780bf3d2314dae06e9f42d459e7dfe2a2e476a0459a766fc8ac2410932df98bc",
|
|
20
|
+
"size_bytes": 81212258,
|
|
21
|
+
"npm_copy": {
|
|
22
|
+
"package": "@simplexai/engine-strata-poly-linux-x64-cuda13-f05645dc3b8f77a0",
|
|
23
|
+
"version": "0.0.0-sha256-780bf3d2314dae06"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "polystrata-0.2.20-poly.5-source.tar.gz",
|
|
28
|
+
"url": "https://github.com/simplexai-labs/PolyStrata/archive/refs/tags/v0.2.20-poly.5.tar.gz",
|
|
29
|
+
"sha256": "96e53351aae2de1b369da7d0ff3e44e31de1e4fc81ec19804f8f38130af1559a",
|
|
30
|
+
"size_bytes": 50429019,
|
|
31
|
+
"members": [
|
|
32
|
+
"terminal/serve/",
|
|
33
|
+
"terminal/tools/",
|
|
34
|
+
"terminal/strata_control/",
|
|
35
|
+
"terminal/strata_cli/",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"npm_copy": {
|
|
39
|
+
"package": "@simplexai/engine-polystrata-0.2.20-poly.5-source",
|
|
40
|
+
"version": "0.0.0-sha256-96e53351aae2de1b"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "cudart-strata-poly-linux-x64-cuda13.0.3.tar.gz",
|
|
45
|
+
"url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/strata-poly/0.1.45-poly.9/cudart-strata-poly-linux-x64-cuda13.0.3.tar.gz",
|
|
46
|
+
"sha256": "189c3a9fb5fd5f87331ffcedf03d5469c2a9c91f46379299ee6ea277364f05d2",
|
|
47
|
+
"size_bytes": 422462968
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"platform": "win32",
|
|
53
|
+
"arch": "x64",
|
|
54
|
+
"backend": "cuda",
|
|
55
|
+
"min_cuda": "13.0",
|
|
56
|
+
"binary": "strata-poly.exe",
|
|
57
|
+
"assets": [
|
|
58
|
+
{
|
|
59
|
+
"name": "strata-poly-windows-x64-adf95bbb55348db7.zip",
|
|
60
|
+
"url": "https://github.com/simplexai-labs/PolyStrata/releases/download/v0.2.20-poly.5/strata-poly-windows-x64-adf95bbb55348db7.zip",
|
|
61
|
+
"sha256": "e019563d6945737b75228b6e04d5cde5a33730c7ebfbd791a0d8f368688f5724",
|
|
62
|
+
"size_bytes": 81166456,
|
|
63
|
+
"npm_copy": {
|
|
64
|
+
"package": "@simplexai/engine-strata-poly-windows-x64-adf95bbb55348db7",
|
|
65
|
+
"version": "0.0.0-sha256-e019563d6945737b"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "polystrata-0.2.20-poly.5-source.tar.gz",
|
|
70
|
+
"url": "https://github.com/simplexai-labs/PolyStrata/archive/refs/tags/v0.2.20-poly.5.tar.gz",
|
|
71
|
+
"sha256": "96e53351aae2de1b369da7d0ff3e44e31de1e4fc81ec19804f8f38130af1559a",
|
|
72
|
+
"size_bytes": 50429019,
|
|
73
|
+
"members": [
|
|
74
|
+
"terminal/serve/",
|
|
75
|
+
"terminal/tools/",
|
|
76
|
+
"terminal/strata_control/",
|
|
77
|
+
"terminal/strata_cli/",
|
|
78
|
+
"LICENSE"
|
|
79
|
+
],
|
|
80
|
+
"npm_copy": {
|
|
81
|
+
"package": "@simplexai/engine-polystrata-0.2.20-poly.5-source",
|
|
82
|
+
"version": "0.0.0-sha256-96e53351aae2de1b"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "nvidia_cublas-13.0.2.14-py3-none-win_amd64.whl",
|
|
87
|
+
"url": "https://files.pythonhosted.org/packages/f3/91/bda39230b7a4c102bb724c21b50823efc63544490a885fea0b604911c0ab/nvidia_cublas-13.0.2.14-py3-none-win_amd64.whl",
|
|
88
|
+
"sha256": "5f7a90456b1392db60e28719547ba6e00696bfa81304b6887cf287f9edf2c1d7",
|
|
89
|
+
"size_bytes": 401887280
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
@@ -94,28 +94,33 @@ def install(
|
|
|
94
94
|
_own(venv)
|
|
95
95
|
return f"keeping the installed Python environment {venv.name}"
|
|
96
96
|
source = requirements_path(requirements)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
97
|
+
lock_key = hashlib.sha256(str(venv.resolve()).encode("utf-8")).hexdigest()[:16]
|
|
98
|
+
with hosts.file_lock(hosts.stacks_dir() / f".frontend-{lock_key}.lock"):
|
|
99
|
+
if ready(base_dir, requirements):
|
|
100
|
+
_own(venv)
|
|
101
|
+
return f"keeping the installed Python environment {venv.name}"
|
|
102
|
+
if venv.is_symlink():
|
|
103
|
+
raise FrontendError(f"{venv} is a symbolic link; refusing to write")
|
|
104
|
+
if venv.exists():
|
|
105
|
+
shutil.rmtree(venv)
|
|
106
|
+
venv.parent.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
log(f"creating Python environment {venv}")
|
|
108
|
+
python = venv_python(str(venv))
|
|
109
|
+
steps = [
|
|
110
|
+
[interpreter or sys.executable, "-m", "venv", "--without-pip", str(venv)],
|
|
111
|
+
_installer(python, source),
|
|
112
|
+
]
|
|
113
|
+
env = region.pip_environment() # hash-locked; in cn a China index unless pip has its own
|
|
114
|
+
for command in steps:
|
|
115
|
+
result = subprocess.run(
|
|
116
|
+
command, capture_output=True, text=True, timeout=1200, check=False, env=env
|
|
116
117
|
)
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
if result.returncode:
|
|
119
|
+
raise FrontendError(
|
|
120
|
+
f"{' '.join(command[:4])} failed: {(result.stderr or result.stdout).strip()[-400:]}"
|
|
121
|
+
)
|
|
122
|
+
(venv / MARKER).write_text(_digest(source) + "\n")
|
|
123
|
+
_own(venv)
|
|
119
124
|
return f"installed Python environment {venv}"
|
|
120
125
|
|
|
121
126
|
|
|
@@ -19,6 +19,7 @@ from typing import Any
|
|
|
19
19
|
|
|
20
20
|
from localmodels import (
|
|
21
21
|
bifrost_datasheet,
|
|
22
|
+
bifrost_log,
|
|
22
23
|
bifrost_unit,
|
|
23
24
|
gateway_home,
|
|
24
25
|
gateway_keys,
|
|
@@ -42,6 +43,7 @@ from localmodels.bifrost_config import differs as _config_differs
|
|
|
42
43
|
from localmodels.bifrost_config import read_config as read_config
|
|
43
44
|
from localmodels.bifrost_config import render as render
|
|
44
45
|
from localmodels.bifrost_config import render_config as render_config
|
|
46
|
+
from localmodels.bifrost_config import sanitize_governance as sanitize_governance
|
|
45
47
|
from localmodels.bifrost_config import write_config as write_config
|
|
46
48
|
from localmodels.bifrost_provider import origin as origin
|
|
47
49
|
from localmodels.bifrost_unit import unit, unit_file, unit_for
|
|
@@ -333,9 +335,16 @@ def healthy(addr: str, timeout: float = 5) -> bool:
|
|
|
333
335
|
return False
|
|
334
336
|
|
|
335
337
|
|
|
336
|
-
def _await(
|
|
338
|
+
def _await(
|
|
339
|
+
addr: str,
|
|
340
|
+
timeout: float = HEALTH_TIMEOUT_S,
|
|
341
|
+
*,
|
|
342
|
+
record: hosts.OwnedBifrost,
|
|
343
|
+
log_offset: int = 0,
|
|
344
|
+
) -> None:
|
|
337
345
|
deadline = time.monotonic() + timeout
|
|
338
|
-
|
|
346
|
+
app = Path(record["app_dir"])
|
|
347
|
+
pid_file = app / "bifrost.pid"
|
|
339
348
|
while time.monotonic() < deadline:
|
|
340
349
|
if _healthy_owned(record):
|
|
341
350
|
return
|
|
@@ -344,6 +353,12 @@ def _await(addr: str, timeout: float = HEALTH_TIMEOUT_S, *, record: hosts.OwnedB
|
|
|
344
353
|
and os.path.lexists(pid_file)
|
|
345
354
|
and process_identity.status(pid_file)[0] == "inactive"
|
|
346
355
|
):
|
|
356
|
+
summary = bifrost_log.startup_failure_summary(app, log_offset, app_label=APP_DIR)
|
|
357
|
+
if summary:
|
|
358
|
+
raise HarnessError(
|
|
359
|
+
f"Bifrost {addr} exited before becoming ready ({summary}); "
|
|
360
|
+
f"see {APP_DIR}/bifrost.log"
|
|
361
|
+
)
|
|
347
362
|
raise HarnessError(
|
|
348
363
|
f"Bifrost {addr} exited before becoming ready; see {APP_DIR}/bifrost.log"
|
|
349
364
|
)
|
|
@@ -546,9 +561,17 @@ def revive(plan: HarnessPlan) -> str:
|
|
|
546
561
|
return "reused"
|
|
547
562
|
if not record:
|
|
548
563
|
raise HarnessError("the ownership manifest has no record of this tool's Bifrost gateway")
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
564
|
+
app = Path(record["app_dir"])
|
|
565
|
+
config = read_config(app)
|
|
566
|
+
sanitized = bool(config and sanitize_governance(config))
|
|
567
|
+
if sanitized:
|
|
568
|
+
if STOP_BEFORE_CONFIG_CHANGE and record["how"] != "unit":
|
|
569
|
+
_stop_owned_serve(record)
|
|
570
|
+
_write_config(app, config)
|
|
571
|
+
log_offset = bifrost_log.log_size(app)
|
|
572
|
+
_start(record, restart=sanitized)
|
|
573
|
+
_await(addr, record=record, log_offset=log_offset)
|
|
574
|
+
_seal(app)
|
|
552
575
|
return "started"
|
|
553
576
|
|
|
554
577
|
|
|
@@ -604,8 +627,9 @@ def wire(
|
|
|
604
627
|
_stop_owned_serve(record)
|
|
605
628
|
changed = _write_config(app, config, sheets)
|
|
606
629
|
if changed or not _healthy_owned(record):
|
|
630
|
+
log_offset = bifrost_log.log_size(app)
|
|
607
631
|
_start(record, restart=changed)
|
|
608
|
-
_await(record["addr"], record=record)
|
|
632
|
+
_await(record["addr"], record=record, log_offset=log_offset)
|
|
609
633
|
_seal(app)
|
|
610
634
|
done = [f"provider {pid}" for pid in config["providers"]]
|
|
611
635
|
default = gw.get("llm_fast") or gw["llm"]
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
"""What a
|
|
2
|
-
bandwidth
|
|
1
|
+
"""What a GPU or Apple Silicon SoC model name and compute capability say about it: the
|
|
2
|
+
architecture, and the memory bandwidth the vendor publishes for that model.
|
|
3
3
|
|
|
4
|
-
Decode reads the resident weights once per token, so
|
|
5
|
-
|
|
6
|
-
vendor spec-sheet figures, not measurements of any host, and only names that pin one
|
|
7
|
-
configuration:
|
|
8
|
-
RTX 3060 Ti and RTX 4070 in GDDR6 and GDDR6X)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
Decode reads the resident weights once per token, so memory bandwidth bounds decode speed; two
|
|
5
|
+
devices with the same capacity but different memory buses do not decode alike (product.md). The
|
|
6
|
+
table holds vendor spec-sheet figures, not measurements of any host, and only names that pin one
|
|
7
|
+
memory configuration: NVIDIA parts sold with two memory setups (RTX 3060 8/12 GB, RTX 3080
|
|
8
|
+
10/12 GB, RTX 3060 Ti and RTX 4070 in GDDR6 and GDDR6X), laptop NVIDIA parts, and Apple Silicon
|
|
9
|
+
Max chips sold with two bus widths (M3 Max 300/400 GB/s, M4 Max 410/546 GB/s, M5 Max 460/614 GB/s)
|
|
10
|
+
are left out unless a known host fact (such as Apple M6's 16 GB vs 24/32 GB memory tier)
|
|
11
|
+
disambiguates them, so unlisted names keep their class constant. On qwen3.8-27b UD-Q4_K_M without
|
|
12
|
+
speculation the repository measured 43–47.6 tok/s on an RTX 4090 D and 14.8 tok/s on an L4
|
|
13
|
+
(catalog/model-matrix/pending/llm.qwen.json): a ratio of 3.2 against 3.4 between their spec
|
|
14
|
+
bandwidths, where the old single 1000 GB/s class constant priced both alike.
|
|
13
15
|
"""
|
|
14
16
|
|
|
15
17
|
from __future__ import annotations
|
|
@@ -56,7 +58,27 @@ _BANDWIDTH_GB_S: tuple[tuple[str, float], ...] = (
|
|
|
56
58
|
(r"h200", 4800.0),
|
|
57
59
|
(r"t4", 320.0),
|
|
58
60
|
(r"v100 (sxm2|pcie) (16|32)gb", 900.0),
|
|
61
|
+
# Apple Silicon unified memory bandwidth (vendor published specs).
|
|
62
|
+
# Omitted: M3 Max (300/400 GB/s), M4 Max (410/546 GB/s), M5 Max (460/614 GB/s) vary by core
|
|
63
|
+
# tier; base M6 varies by RAM capacity and is resolved when total_bytes is provided.
|
|
64
|
+
(r"apple m1", 68.25),
|
|
65
|
+
(r"apple m1 pro", 200.0),
|
|
66
|
+
(r"apple m1 max", 400.0),
|
|
67
|
+
(r"apple m1 ultra", 800.0),
|
|
68
|
+
(r"apple m2", 100.0),
|
|
69
|
+
(r"apple m2 pro", 200.0),
|
|
70
|
+
(r"apple m2 max", 400.0),
|
|
71
|
+
(r"apple m2 ultra", 800.0),
|
|
72
|
+
(r"apple m3", 100.0),
|
|
73
|
+
(r"apple m3 pro", 150.0),
|
|
74
|
+
(r"apple m3 ultra", 819.0),
|
|
75
|
+
(r"apple m4", 120.0),
|
|
76
|
+
(r"apple m4 pro", 273.0),
|
|
77
|
+
(r"apple m5", 153.0),
|
|
78
|
+
(r"apple m5 pro", 307.0),
|
|
79
|
+
(r"apple m5 ultra", 1200.0),
|
|
59
80
|
)
|
|
81
|
+
_GIB = 1 << 30
|
|
60
82
|
_DROPPED = re.compile(r"\b(nvidia|geforce|tesla|quadro)\b")
|
|
61
83
|
|
|
62
84
|
# Compute capability major (and minor where one major spans two) → architecture.
|
|
@@ -89,9 +111,12 @@ def device_class(name: str) -> str:
|
|
|
89
111
|
return key
|
|
90
112
|
|
|
91
113
|
|
|
92
|
-
def bandwidth_gb_s(name: str) -> float | None:
|
|
93
|
-
"""The published memory bandwidth of the
|
|
114
|
+
def bandwidth_gb_s(name: str, *, total_bytes: int | None = None) -> float | None:
|
|
115
|
+
"""The published memory bandwidth of the GPU or Apple Silicon SoC ``name``; None: not listed."""
|
|
94
116
|
key = normalized(name)
|
|
117
|
+
if key == "apple m6" and total_bytes is not None and total_bytes > 0:
|
|
118
|
+
# Base Apple M6 ships with 153 GB/s at 16 GB and 170 GB/s at 24/32 GB.
|
|
119
|
+
return 153.0 if total_bytes <= 16 * _GIB else 170.0
|
|
95
120
|
return next((bw for pattern, bw in _BANDWIDTH_GB_S if re.fullmatch(pattern, key)), None)
|
|
96
121
|
|
|
97
122
|
|
|
@@ -249,14 +249,33 @@ def load_facts(dev_id: str) -> HostFacts | None:
|
|
|
249
249
|
return _read(state_dir() / "facts" / f"{dev_id}.json", None, lambda v: decode(v, HostFacts))
|
|
250
250
|
|
|
251
251
|
|
|
252
|
+
def _same_place(a: str, b: str) -> bool:
|
|
253
|
+
def norm(path: str) -> str:
|
|
254
|
+
return os.path.normcase(os.path.realpath(os.path.expanduser(path)))
|
|
255
|
+
|
|
256
|
+
return norm(a) == norm(b)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _record_touched_service(record: FinishedRecord) -> bool:
|
|
260
|
+
"""True when a deployment succeeded or got far enough that it may have installed or started
|
|
261
|
+
service files on this computer. A deploy that failed before ``install`` succeeded (for
|
|
262
|
+
example, refused on a port or unit conflict) created no owned service."""
|
|
263
|
+
if record["ok"]:
|
|
264
|
+
return True
|
|
265
|
+
steps = record.get("steps") or []
|
|
266
|
+
if not steps:
|
|
267
|
+
return True
|
|
268
|
+
return any(step["step"] in ("install", "start", "verify") and step["ok"] for step in steps)
|
|
269
|
+
|
|
270
|
+
|
|
252
271
|
def save_record(dev_id: str, record: FinishedRecord) -> Path:
|
|
253
|
-
"""Keep the record; a deployment on this computer also enters the owned manifest
|
|
254
|
-
|
|
272
|
+
"""Keep the record; a deployment on this computer also enters the owned manifest when it
|
|
273
|
+
succeeded or installed service files, without overwriting another live deployment."""
|
|
255
274
|
plan = record["plan"]
|
|
256
275
|
path = state_dir() / "deployments" / dev_id / f"{plan['name']}.json"
|
|
257
276
|
_write(path, record)
|
|
258
|
-
if dev_id == LOCAL_ID:
|
|
259
|
-
own_deployment(plan)
|
|
277
|
+
if dev_id == LOCAL_ID and _record_touched_service(record):
|
|
278
|
+
own_deployment(plan, ok=record["ok"])
|
|
260
279
|
return path
|
|
261
280
|
|
|
262
281
|
|
|
@@ -272,8 +291,20 @@ def records(dev_id: str) -> list[FinishedRecord]:
|
|
|
272
291
|
|
|
273
292
|
|
|
274
293
|
def deployment_dirs(dev_id: str) -> dict[str, str]:
|
|
275
|
-
"""Each recorded deployment's name and directory: which names are already in use, and where.
|
|
276
|
-
|
|
294
|
+
"""Each recorded deployment's name and directory: which names are already in use, and where.
|
|
295
|
+
On this computer the shared owned manifest is included too so independent controllers with
|
|
296
|
+
separate state directories do not collide on one deployment name."""
|
|
297
|
+
taken = {r["plan"]["name"]: r["plan"]["service"]["deploy_dir"] for r in records(dev_id)}
|
|
298
|
+
if dev_id == LOCAL_ID and owned_path().is_file():
|
|
299
|
+
try:
|
|
300
|
+
for name, entry in load_owned()["deployments"].items():
|
|
301
|
+
if entry["removed"] or entry.get("failed"):
|
|
302
|
+
continue
|
|
303
|
+
if name not in taken or not _same_place(taken[name], entry["deploy_dir"]):
|
|
304
|
+
taken[name] = entry["deploy_dir"]
|
|
305
|
+
except (OSError, ValueError):
|
|
306
|
+
pass
|
|
307
|
+
return taken
|
|
277
308
|
|
|
278
309
|
|
|
279
310
|
def record(dev_id: str, name: str) -> FinishedRecord:
|
|
@@ -287,22 +318,33 @@ def record(dev_id: str, name: str) -> FinishedRecord:
|
|
|
287
318
|
return hit
|
|
288
319
|
|
|
289
320
|
|
|
290
|
-
def delete_record(
|
|
321
|
+
def delete_record(
|
|
322
|
+
dev_id: str, name: str, *, purged: bool = False, deploy_dir: str | None = None
|
|
323
|
+
) -> None:
|
|
291
324
|
"""Forget a removed deployment. On this computer the owned manifest keeps it as removed, its
|
|
292
|
-
files and log left for a purge, or drops it when ``purged
|
|
325
|
+
files and log left for a purge, or drops it when ``purged`` — only when the manifest entry
|
|
326
|
+
belongs to this deployment's directory, never another controller's."""
|
|
293
327
|
path = state_dir() / "deployments" / dev_id / f"{name}.json"
|
|
328
|
+
recorded_dir = deploy_dir
|
|
329
|
+
if recorded_dir is None and path.is_file():
|
|
330
|
+
existing = _read(path, None, lambda v: decode(v, FinishedRecord))
|
|
331
|
+
if existing is not None:
|
|
332
|
+
recorded_dir = existing["plan"]["service"]["deploy_dir"]
|
|
294
333
|
if path.exists():
|
|
295
334
|
path.unlink()
|
|
296
335
|
if dev_id != LOCAL_ID:
|
|
297
336
|
return
|
|
298
337
|
|
|
299
338
|
def change(doc: Owned) -> None:
|
|
300
|
-
|
|
339
|
+
entry = doc["deployments"].get(name)
|
|
340
|
+
if entry is None:
|
|
341
|
+
return
|
|
342
|
+
if recorded_dir is not None and not _same_place(entry["deploy_dir"], recorded_dir):
|
|
301
343
|
return
|
|
302
344
|
if purged:
|
|
303
345
|
del doc["deployments"][name]
|
|
304
346
|
else:
|
|
305
|
-
|
|
347
|
+
entry["removed"] = True
|
|
306
348
|
|
|
307
349
|
if owned_path().is_file():
|
|
308
350
|
update_owned(change)
|
|
@@ -316,6 +358,9 @@ OWNED_SCHEMA = "localmodels.owned/v1"
|
|
|
316
358
|
|
|
317
359
|
class _OwnedPreparation(TypedDict, total=False):
|
|
318
360
|
preparation_dir: str
|
|
361
|
+
failed: (
|
|
362
|
+
bool # True when recorded from a failed/interrupted deploy; never blocks a verified owner
|
|
363
|
+
)
|
|
319
364
|
|
|
320
365
|
|
|
321
366
|
class OwnedDeployment(_OwnedPreparation):
|
|
@@ -609,13 +654,55 @@ def owned_entry(plan: Plan) -> OwnedDeployment:
|
|
|
609
654
|
return entry
|
|
610
655
|
|
|
611
656
|
|
|
612
|
-
def
|
|
613
|
-
"""
|
|
657
|
+
def port_owned_elsewhere(port: int, deploy_dir: str, tools_dir: str | Path = TOOLS_DIR) -> bool:
|
|
658
|
+
"""True when the shared owned manifest records another live verified deployment on ``port``."""
|
|
659
|
+
if not owned_path(tools_dir).is_file():
|
|
660
|
+
return False
|
|
661
|
+
try:
|
|
662
|
+
entries = load_owned(tools_dir)["deployments"].values()
|
|
663
|
+
except (OSError, ValueError):
|
|
664
|
+
return False
|
|
665
|
+
return any(
|
|
666
|
+
not entry["removed"]
|
|
667
|
+
and not entry.get("failed")
|
|
668
|
+
and entry["port"] == port
|
|
669
|
+
and not _same_place(entry["deploy_dir"], deploy_dir)
|
|
670
|
+
for entry in entries
|
|
671
|
+
)
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
def own_deployment(plan: Plan, tools_dir: str | Path = TOOLS_DIR, *, ok: bool = True) -> bool:
|
|
675
|
+
"""Record a deployment on this computer (``owned_entry``). Never overwrites a live verified
|
|
676
|
+
manifest entry belonging to another directory, never claims a unit owned by another live
|
|
677
|
+
verified deployment, and on failure never registers a competing owner on a port another live
|
|
678
|
+
deployment holds."""
|
|
614
679
|
entry = owned_entry(plan)
|
|
680
|
+
if not ok:
|
|
681
|
+
entry["failed"] = True
|
|
682
|
+
recorded = False
|
|
615
683
|
|
|
616
684
|
def add(doc: Owned) -> None:
|
|
685
|
+
nonlocal recorded
|
|
686
|
+
existing = doc["deployments"].get(plan["name"])
|
|
687
|
+
if existing is not None and not _same_place(existing["deploy_dir"], entry["deploy_dir"]):
|
|
688
|
+
existing_live = not existing["removed"] and not existing.get("failed")
|
|
689
|
+
if existing_live or not ok:
|
|
690
|
+
return
|
|
691
|
+
for other in doc["deployments"].values():
|
|
692
|
+
if (
|
|
693
|
+
other["removed"]
|
|
694
|
+
or other.get("failed")
|
|
695
|
+
or _same_place(other["deploy_dir"], entry["deploy_dir"])
|
|
696
|
+
):
|
|
697
|
+
continue
|
|
698
|
+
if other["service"] == entry["service"]:
|
|
699
|
+
return
|
|
700
|
+
if not ok and other["port"] == entry["port"]:
|
|
701
|
+
return
|
|
617
702
|
doc["deployments"][plan["name"]] = entry
|
|
618
703
|
if entry["slice"]:
|
|
619
704
|
doc["slices"] = sorted({*doc["slices"], entry["slice"]})
|
|
705
|
+
recorded = True
|
|
620
706
|
|
|
621
707
|
update_owned(add, tools_dir)
|
|
708
|
+
return recorded
|
|
@@ -96,6 +96,13 @@ def add_parser(sub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None
|
|
|
96
96
|
metavar="MODEL",
|
|
97
97
|
help="unload this model first (repeatable); refused before any unload without room",
|
|
98
98
|
)
|
|
99
|
+
load.add_argument(
|
|
100
|
+
"--force",
|
|
101
|
+
"--allow-overcommit",
|
|
102
|
+
dest="force",
|
|
103
|
+
action="store_true",
|
|
104
|
+
help="load at the compact floor posture even when live memory is below headroom guards (still refuses critical OS memory pressure)",
|
|
105
|
+
)
|
|
99
106
|
load.add_argument("--jsonl", action="store_true", help="accepted; output is JSONL")
|
|
100
107
|
cli_help.document(
|
|
101
108
|
load,
|
|
@@ -158,7 +165,7 @@ def cli(args: argparse.Namespace) -> int:
|
|
|
158
165
|
load=lambda m, b, u: library_serve.load(m, b, u),
|
|
159
166
|
)
|
|
160
167
|
elif verb == "load":
|
|
161
|
-
row = library_serve.load(args.model, args.base_dir, args.unload)
|
|
168
|
+
row = library_serve.load(args.model, args.base_dir, args.unload, force=args.force)
|
|
162
169
|
elif verb == "unload":
|
|
163
170
|
row = library_serve.unload(args.model, args.base_dir)
|
|
164
171
|
elif verb == "remove":
|
|
@@ -142,6 +142,38 @@ def _planned_stack_llms(plan: StackPlan | None) -> dict[str, str]:
|
|
|
142
142
|
return found
|
|
143
143
|
|
|
144
144
|
|
|
145
|
+
def adopted_components(plan: StackPlan) -> set[str]:
|
|
146
|
+
"""The plan's LLM components the library adopted: from then on the
|
|
147
|
+
library loads, unloads, wires and may remove them, so their deployments, gateway route and
|
|
148
|
+
pi selection are no longer the stack's to check. The conversion marker names them, and
|
|
149
|
+
stays when ``library remove`` deletes the model's record; a converted record (an earlier
|
|
150
|
+
one may lack ``stack_provider``: the main LLM's) names them too. Read only; it never
|
|
151
|
+
converts."""
|
|
152
|
+
from localmodels import stack_verify
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
marker = json.loads((library_state.root() / MARKER).read_text("utf-8"))
|
|
156
|
+
except (OSError, ValueError):
|
|
157
|
+
return set()
|
|
158
|
+
if not isinstance(marker, dict) or marker.get("plan_id") != plan["plan_id"]:
|
|
159
|
+
return set()
|
|
160
|
+
ids = set(marker.get("adopted") or [])
|
|
161
|
+
providers = {
|
|
162
|
+
r.get("stack_provider") or harness.LLM_PROVIDER
|
|
163
|
+
for r in library_state.records()
|
|
164
|
+
if r.get("converted")
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
component
|
|
168
|
+
for component, part in stack_verify.parts(plan)
|
|
169
|
+
if component in STACK_LLMS
|
|
170
|
+
and (
|
|
171
|
+
library_id(part["model"]["id"], part["model"]["quant"]) in ids
|
|
172
|
+
or STACK_LLMS[component] in providers
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
145
177
|
def _active_stack_llms(plan: StackPlan | None) -> dict[str, tuple[str, Plan]]:
|
|
146
178
|
"""Accepted stack LLM deployments still present and ok on disk: ``library_id -> (provider, plan)``."""
|
|
147
179
|
if plan is None:
|
|
@@ -299,6 +331,8 @@ def _adopt_record(model: str, provider: str, deployed: Plan, base_dir: str | Non
|
|
|
299
331
|
record["quant"] = spec["quant"]
|
|
300
332
|
record["pool"] = pool
|
|
301
333
|
record["plan"] = deployed
|
|
334
|
+
record.pop("baseline_plan", None)
|
|
335
|
+
record.pop("load_posture", None)
|
|
302
336
|
record["pi_model"] = gateway_bifrost.PI_MODEL
|
|
303
337
|
record["state"] = "loaded"
|
|
304
338
|
record["converted"] = True
|