@simplexai/localmodels-darwin-arm64 0.1.0-dev.45 → 0.1.0-dev.48
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 +38 -36
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/catalog.json +150 -0
- package/modules/localmodels/catalog.py +20 -5
- package/modules/localmodels/catalog_recipes.py +8 -0
- package/modules/localmodels/context_policy.py +32 -9
- package/modules/localmodels/deploy.py +20 -14
- package/modules/localmodels/engines-b12588-mix-c0c3de8.json +98 -0
- package/modules/localmodels/engines.py +28 -2
- package/modules/localmodels/estimator.py +12 -3
- package/modules/localmodels/gateway_bifrost.py +95 -22
- package/modules/localmodels/gguf.py +6 -2
- package/modules/localmodels/harness_probe.py +60 -13
- package/modules/localmodels/library_pricing.py +6 -4
- package/modules/localmodels/library_state.py +6 -4
- package/modules/localmodels/probe.py +38 -11
- package/modules/localmodels/process_identity.py +47 -33
- package/modules/localmodels/process_identity_linux.py +135 -0
- package/modules/localmodels/process_windows.py +150 -1
- package/modules/localmodels/runtime_windows_acl.py +100 -0
- package/modules/localmodels/service_probe.py +26 -20
- package/modules/localmodels/setup_inspection.py +132 -36
- package/modules/localmodels/setup_text.py +17 -3
- package/modules/localmodels/stack_binding.py +117 -12
- package/modules/localmodels/stack_lifecycle.py +7 -4
- package/modules/localmodels/stack_view_llm.py +1 -1
- package/modules/localmodels/stack_view_sandbox.py +3 -1
- package/modules/localmodels/stack_warm.py +18 -7
- package/modules/localmodels/strata_poly_server.py +4 -2
- package/modules/localmodels/transport.py +7 -1
- package/modules/{simplex_localmodels-0.1.0.dev45.dist-info → simplex_localmodels-0.1.0.dev48.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev45.dist-info → simplex_localmodels-0.1.0.dev48.dist-info}/RECORD +35 -33
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev45.dist-info → simplex_localmodels-0.1.0.dev48.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev45.dist-info → simplex_localmodels-0.1.0.dev48.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev45.dist-info → simplex_localmodels-0.1.0.dev48.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev45.dist-info → simplex_localmodels-0.1.0.dev48.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -299,7 +299,7 @@ def _choose_agent_placement(
|
|
|
299
299
|
live = agent_budget(placement, facts, host_bytes=host_side)
|
|
300
300
|
if live is None:
|
|
301
301
|
continue
|
|
302
|
-
agent = posture_for(options.agent, placement.backend)
|
|
302
|
+
agent = entry.agent_posture(posture_for(options.agent, placement.backend))
|
|
303
303
|
planned = entry.launch_plan(variant, live, agent=agent)
|
|
304
304
|
if isinstance(planned.decision, PhysicsRefusal) or planned.decision.spilled:
|
|
305
305
|
if isinstance(planned.decision, PhysicsRefusal) and (
|
|
@@ -371,6 +371,7 @@ def _choose_placement(
|
|
|
371
371
|
live,
|
|
372
372
|
mtp_capable=entry.mtp_capable,
|
|
373
373
|
fixed_overhead=RUNTIME_OVERHEAD_BYTES + entry.companion_bytes,
|
|
374
|
+
ubatch=entry.ubatch,
|
|
374
375
|
)
|
|
375
376
|
fallbacks.append((now.decision.spill_bytes, placement, now))
|
|
376
377
|
if not fallbacks:
|
|
@@ -437,8 +438,10 @@ def build_plan(
|
|
|
437
438
|
where = deployment(entry.id, options.port, base, options.bind, hosts.deployment_dirs(host_id))
|
|
438
439
|
model_path = f"{models_dir}/{files[0]['local_name']}"
|
|
439
440
|
if options.agent is not None:
|
|
440
|
-
|
|
441
|
+
agent_eff = entry.agent_posture(posture_for(options.agent, placement.backend))
|
|
442
|
+
args = agent_launch_args(decision, agent_eff)
|
|
441
443
|
else:
|
|
444
|
+
agent_eff = None
|
|
442
445
|
args = launch_args(
|
|
443
446
|
as_loaded(entry.profile(variant), placement.budget),
|
|
444
447
|
decision,
|
|
@@ -446,6 +449,7 @@ def build_plan(
|
|
|
446
449
|
mtp_draft_depth=entry.mtp_draft_depth,
|
|
447
450
|
uma=placement.budget.uma,
|
|
448
451
|
mtp_prefill=launch.mtp_prefill,
|
|
452
|
+
ubatch=entry.ubatch,
|
|
449
453
|
)
|
|
450
454
|
argv = [
|
|
451
455
|
options.engine_path or "",
|
|
@@ -564,15 +568,13 @@ def build_plan(
|
|
|
564
568
|
**(
|
|
565
569
|
{
|
|
566
570
|
"unified_bytes": agent_unified_bytes(
|
|
567
|
-
eager(entry.profile(variant)),
|
|
568
|
-
decision,
|
|
569
|
-
posture_for(options.agent, placement.backend),
|
|
571
|
+
eager(entry.profile(variant)), decision, agent_eff
|
|
570
572
|
),
|
|
571
573
|
"cache_floor_bytes": cache_floor_bytes(
|
|
572
|
-
|
|
574
|
+
agent_eff, eager(entry.profile(variant))
|
|
573
575
|
),
|
|
574
576
|
}
|
|
575
|
-
if
|
|
577
|
+
if agent_eff is not None and placement.backend == "metal"
|
|
576
578
|
else {}
|
|
577
579
|
),
|
|
578
580
|
},
|
|
@@ -634,11 +636,12 @@ def _engine_plan(
|
|
|
634
636
|
warnings: list[str],
|
|
635
637
|
argv: list[str],
|
|
636
638
|
) -> ReleaseEngine:
|
|
639
|
+
required = entry.min_engine or entry.engine
|
|
637
640
|
if options.engine_path:
|
|
638
641
|
known = next((e for e in facts["engines"] if e["path"] == options.engine_path), None)
|
|
639
642
|
tag = known["build"] if known else None
|
|
640
643
|
if cat.engine_too_old(entry, tag):
|
|
641
|
-
raise PlanError(f"{entry.display_name} needs llama.cpp {
|
|
644
|
+
raise PlanError(f"{entry.display_name} needs llama.cpp {required} or newer")
|
|
642
645
|
if not tag:
|
|
643
646
|
warnings.append("reused engine has no comparable release; model support unconfirmed")
|
|
644
647
|
engine: ReleaseEngine = {"source": "existing", "binary": options.engine_path, "build": tag}
|
|
@@ -646,7 +649,7 @@ def _engine_plan(
|
|
|
646
649
|
host_engine(
|
|
647
650
|
{**facts, "engines": [known] if known else []},
|
|
648
651
|
argv,
|
|
649
|
-
|
|
652
|
+
required or None,
|
|
650
653
|
False,
|
|
651
654
|
EngineUnavailableError(
|
|
652
655
|
"CPU deployment must confirm every reused-engine launch option; "
|
|
@@ -656,18 +659,21 @@ def _engine_plan(
|
|
|
656
659
|
)
|
|
657
660
|
else:
|
|
658
661
|
try:
|
|
659
|
-
|
|
660
|
-
if
|
|
661
|
-
|
|
662
|
+
lock_tag = entry.engine or None
|
|
663
|
+
if lock_tag is None:
|
|
664
|
+
build = select_engine_build(facts, backend)
|
|
665
|
+
lock_tag = entry.min_engine if cat.engine_too_old(entry, build["tag"]) else None
|
|
666
|
+
if lock_tag is not None:
|
|
667
|
+
lock = engine_lock_path(lock_tag)
|
|
662
668
|
if not lock.is_file():
|
|
663
669
|
raise PlanError(
|
|
664
|
-
f"{entry.display_name} needs llama.cpp {
|
|
670
|
+
f"{entry.display_name} needs llama.cpp {lock_tag}; "
|
|
665
671
|
"no pinned engine lock is available"
|
|
666
672
|
)
|
|
667
673
|
build = select_engine_build(facts, backend, lock)
|
|
668
674
|
engine = release_engine(build, options.base_dir)
|
|
669
675
|
except EngineUnavailableError as exc:
|
|
670
|
-
engine = host_engine(facts, argv,
|
|
676
|
+
engine = host_engine(facts, argv, required or None, False, exc, warnings)
|
|
671
677
|
if backend == "cpu" and engine["source"] == "existing":
|
|
672
678
|
if entry.mmproj is not None or entry.mtp_capable:
|
|
673
679
|
raise PlanError("CPU: reused engine vision/draft placement unknown; use pinned engine")
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "localmodels.engine-lock/v1",
|
|
3
|
+
"tag": "b12588-mix-c0c3de8",
|
|
4
|
+
"commit": "883286076efe5b85fddb31d9cc7035a6b698ba9b",
|
|
5
|
+
"source": "https://github.com/unslothai/llama.cpp/releases/tag/b12588-mix-c0c3de8",
|
|
6
|
+
"note": "Release asset digests from the GitHub release API and llama-prebuilt-sha256.json (unslothai/llama.cpp, upstream llama.cpp b12588, read 2026-11-21). Required for Inkling 2 Mini (inkling2 / inkling2_loop architecture, unsupported in b11370). Linux x64 CUDA 12 portable (CUDA 12.8, SM 70-120, Ubuntu 22.04) and Linux x64 CPU archives unpack flat with ./llama-server and import up to GLIBC_2.34 plus libgomp.so.1 (verified via ELF .gnu.version_r and dynamic NEEDED); note libggml-cuda.so links libcudart.so.12/libcublas.so.12/libcublasLt.so.12 dynamically and this release ships no separate cudart archive, so CUDA 13 portable is intentionally omitted here (cuda12-portable covers SM 70-120 across CUDA 12.8+ and 13.x drivers without requiring CUDA 13 runtime libraries). Windows x64 CUDA 12 portable and CPU zips unpack flat with llama-server.exe; macOS arm64 Metal tarball unpacks with a single top directory stripped by remote_ops.unpack.",
|
|
7
|
+
"builds": [
|
|
8
|
+
{
|
|
9
|
+
"platform": "linux",
|
|
10
|
+
"arch": "x64",
|
|
11
|
+
"backend": "cuda",
|
|
12
|
+
"min_cuda": "12.8",
|
|
13
|
+
"min_glibc": "2.34",
|
|
14
|
+
"host_libraries": {
|
|
15
|
+
"libgomp.so.1": "libgomp1"
|
|
16
|
+
},
|
|
17
|
+
"assets": [
|
|
18
|
+
{
|
|
19
|
+
"name": "app-b12588-mix-c0c3de8-linux-x64-cuda12-portable.tar.gz",
|
|
20
|
+
"url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/app-b12588-mix-c0c3de8-linux-x64-cuda12-portable.tar.gz",
|
|
21
|
+
"sha256": "4c30d5e3b3d7242cf3f214977c09a0d06102c71a713c256749909dcafa9f5980",
|
|
22
|
+
"size_bytes": 471778328
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"platform": "linux",
|
|
28
|
+
"arch": "x64",
|
|
29
|
+
"backend": "cpu",
|
|
30
|
+
"min_glibc": "2.34",
|
|
31
|
+
"host_libraries": {
|
|
32
|
+
"libgomp.so.1": "libgomp1"
|
|
33
|
+
},
|
|
34
|
+
"assets": [
|
|
35
|
+
{
|
|
36
|
+
"name": "app-b12588-mix-c0c3de8-linux-x64-cpu.tar.gz",
|
|
37
|
+
"url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/app-b12588-mix-c0c3de8-linux-x64-cpu.tar.gz",
|
|
38
|
+
"sha256": "511b22366fa879213eb7f91016d629cdfe0054537f1c3cf46346017d968e7947",
|
|
39
|
+
"size_bytes": 19091181,
|
|
40
|
+
"npm_copy": {
|
|
41
|
+
"package": "@simplexai/engine-app-b12588-mix-c0c3de8-linux-x64-cpu",
|
|
42
|
+
"version": "0.0.0-sha256-511b22366fa87921"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"platform": "darwin",
|
|
49
|
+
"arch": "arm64",
|
|
50
|
+
"backend": "metal",
|
|
51
|
+
"assets": [
|
|
52
|
+
{
|
|
53
|
+
"name": "llama-b12588-mix-c0c3de8-bin-macos-arm64.tar.gz",
|
|
54
|
+
"url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/llama-b12588-mix-c0c3de8-bin-macos-arm64.tar.gz",
|
|
55
|
+
"sha256": "229def18e27ed740ec4f3a6508f084b25630e08d8a87ada40b00622fc496ceb8",
|
|
56
|
+
"size_bytes": 13114900,
|
|
57
|
+
"npm_copy": {
|
|
58
|
+
"package": "@simplexai/engine-llama-b12588-mix-c0c3de8-bin-macos-arm64",
|
|
59
|
+
"version": "0.0.0-sha256-229def18e27ed740"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"platform": "win32",
|
|
66
|
+
"arch": "x64",
|
|
67
|
+
"backend": "cuda",
|
|
68
|
+
"min_cuda": "12.8",
|
|
69
|
+
"binary": "llama-server.exe",
|
|
70
|
+
"assets": [
|
|
71
|
+
{
|
|
72
|
+
"name": "app-b12588-mix-c0c3de8-windows-x64-cuda12-portable.zip",
|
|
73
|
+
"url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/app-b12588-mix-c0c3de8-windows-x64-cuda12-portable.zip",
|
|
74
|
+
"sha256": "3e7ebce596952a550a49e6f27560f6c26a5b6ba341bbea632fbcfeb43ae7d901",
|
|
75
|
+
"size_bytes": 467643864
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"platform": "win32",
|
|
81
|
+
"arch": "x64",
|
|
82
|
+
"backend": "cpu",
|
|
83
|
+
"binary": "llama-server.exe",
|
|
84
|
+
"assets": [
|
|
85
|
+
{
|
|
86
|
+
"name": "app-b12588-mix-c0c3de8-windows-x64-cpu.zip",
|
|
87
|
+
"url": "https://github.com/unslothai/llama.cpp/releases/download/b12588-mix-c0c3de8/app-b12588-mix-c0c3de8-windows-x64-cpu.zip",
|
|
88
|
+
"sha256": "d80f6d21cd9a4c0a953ff3a381391b8f6f5166ba094efa72054e87a9bba1f9ab",
|
|
89
|
+
"size_bytes": 21367159,
|
|
90
|
+
"npm_copy": {
|
|
91
|
+
"package": "@simplexai/engine-app-b12588-mix-c0c3de8-windows-x64-cpu",
|
|
92
|
+
"version": "0.0.0-sha256-d80f6d21cd9a4c0a"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
@@ -33,6 +33,23 @@ class EngineUnavailableError(PlanError):
|
|
|
33
33
|
"""No pinned release build runs on this host; an engine already there may still."""
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
class CudaDriverError(PlanError):
|
|
37
|
+
"""The host's NVIDIA driver supports too old a CUDA version, or none could be detected."""
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
message: str,
|
|
42
|
+
*,
|
|
43
|
+
required_cuda: str,
|
|
44
|
+
detected_cuda: str = "",
|
|
45
|
+
driver_version: str = "",
|
|
46
|
+
) -> None:
|
|
47
|
+
super().__init__(message)
|
|
48
|
+
self.required_cuda = required_cuda
|
|
49
|
+
self.detected_cuda = detected_cuda
|
|
50
|
+
self.driver_version = driver_version
|
|
51
|
+
|
|
52
|
+
|
|
36
53
|
def _version(text: str | None) -> tuple[int, ...]:
|
|
37
54
|
return tuple(int(x) for x in re.findall(r"\d+", text or "")[:2])
|
|
38
55
|
|
|
@@ -106,18 +123,27 @@ def select_engine_build(
|
|
|
106
123
|
"host; this tool does not install system packages"
|
|
107
124
|
)
|
|
108
125
|
if not builds:
|
|
109
|
-
detail = ""
|
|
110
126
|
if backend == "cuda" and platform_builds:
|
|
111
127
|
oldest = min((b["min_cuda"] for b in platform_builds), key=_cuda_tuple)
|
|
128
|
+
driver_version = ((facts.get("nvidia") or {}).get("driver_version") or "").strip()
|
|
112
129
|
if driver == (0, 0):
|
|
113
130
|
detail = f" (could not detect the driver's CUDA version; requires CUDA >= {oldest})"
|
|
131
|
+
detected = ""
|
|
114
132
|
else:
|
|
115
133
|
detail = (
|
|
116
134
|
f" (the driver supports CUDA {driver_cuda}, "
|
|
117
135
|
f"older than the required CUDA >= {oldest})"
|
|
118
136
|
)
|
|
137
|
+
detected = driver_cuda
|
|
138
|
+
raise CudaDriverError(
|
|
139
|
+
f"no {lock['tag']} prebuilt engine for {platform}/{facts.get('arch')}/{backend}"
|
|
140
|
+
f"{detail}",
|
|
141
|
+
required_cuda=oldest,
|
|
142
|
+
detected_cuda=detected,
|
|
143
|
+
driver_version=driver_version,
|
|
144
|
+
)
|
|
119
145
|
raise PlanError(
|
|
120
|
-
f"no {lock['tag']} prebuilt engine for {platform}/{facts.get('arch')}/{backend}
|
|
146
|
+
f"no {lock['tag']} prebuilt engine for {platform}/{facts.get('arch')}/{backend}"
|
|
121
147
|
)
|
|
122
148
|
return {"tag": lock["tag"], "commit": lock["commit"], **builds[0]}
|
|
123
149
|
|
|
@@ -65,7 +65,14 @@ _AGENT_BASE_BY_N_EMBD = (
|
|
|
65
65
|
# unless an architecture was measured to grow faster. qwen35moe (Qwen3.6-35B-A3B, VP3 at
|
|
66
66
|
# -ub 512, no MTP): the buffer rose 768.5 MiB from a 128K to a 384K window, 6.0 B each; the
|
|
67
67
|
# 128K point then sits 205 MiB under this price, which keeps the estimate above both.
|
|
68
|
-
|
|
68
|
+
# inkling2 (Inkling-2-Mini looped MoE, b12588-mix-c0c3de8 CUDA vram-phase1-2.csv + Mac Metal -lv 4):
|
|
69
|
+
# its compute buffer has both a ubatch-scaled term (92 B/tok/ub) and a window-linear term
|
|
70
|
+
# (11,264 B/tok below), matching 128K/-ub 128 (3,297 MiB vs 3,276 MiB Metal / 3,211 MiB CUDA;
|
|
71
|
+
# UD-Q4_K_M + GPU mmproj = 21.97 GiB), 128K/-ub 256 (4,769 MiB vs 4,748 MiB CUDA / 4,714 MiB
|
|
72
|
+
# Metal; UD-Q4_K_M + GPU mmproj = 23.41 GiB vs 24,024 MiB CUDA peak, exceeding the 23,552 MiB
|
|
73
|
+
# 24 GB gate), and 200K/-ub 256 (7,058 MiB vs 7,211 MiB CUDA).
|
|
74
|
+
_AGENT_WINDOW_COMPUTE_BYTES = {"qwen35moe": 6, "inkling2": 92}
|
|
75
|
+
_AGENT_WINDOW_LINEAR_COMPUTE_BYTES = {"inkling2": 11264}
|
|
69
76
|
# Launch budget = the card's live free memory minus this safety reserve: VP1's headless-card
|
|
70
77
|
# driver retention plus slack for allocator variation (06 §1.1); replaces the max(2 GiB, 9%)
|
|
71
78
|
# capacity margin the generic path keeps.
|
|
@@ -103,7 +110,7 @@ _KV_DTYPE_BYTES_PER_ELEM = {"f16": 2.0, "q8_0": 34 / 32, "q4_0": 18 / 32}
|
|
|
103
110
|
# measured on b11370 with the router's unified KV (every slot sees the full window), device plus
|
|
104
111
|
# host buffers, target and MTP head contexts alike (39.5 + 6.1 B; 5.9 GiB per context at 256K and
|
|
105
112
|
# -ub 512, ~23 GiB at -ub 2048).
|
|
106
|
-
_WINDOW_COMPUTE_BYTES = {"qwen4exp": 46}
|
|
113
|
+
_WINDOW_COMPUTE_BYTES = {"qwen4exp": 46, "inkling2": 180}
|
|
107
114
|
|
|
108
115
|
|
|
109
116
|
class LayerKind(Enum):
|
|
@@ -471,6 +478,7 @@ def agent_footprint_parts(
|
|
|
471
478
|
"""``agent_footprint_bytes`` split into its FOOTPRINT_PARTS, for a view that shows where
|
|
472
479
|
the card's memory goes; the parts sum to exactly that footprint."""
|
|
473
480
|
per_window_token = _AGENT_WINDOW_COMPUTE_BYTES.get(profile.architecture, _F16_BYTES_PER_ELEM)
|
|
481
|
+
linear_per_window_token = _AGENT_WINDOW_LINEAR_COMPUTE_BYTES.get(profile.architecture, 0)
|
|
474
482
|
host_side = 0 if profile.tied_embeddings else profile.embd_table_bytes
|
|
475
483
|
# Without MTP the nextn block is never loaded; with it, it is, and the draft context too.
|
|
476
484
|
weights_gpu = max(
|
|
@@ -481,7 +489,8 @@ def agent_footprint_parts(
|
|
|
481
489
|
"kv": kv_pool_bytes(profile, window, kv_types),
|
|
482
490
|
"state": recurrent_state_bytes(profile, slots=slots),
|
|
483
491
|
"compute": int(
|
|
484
|
-
_agent_compute_base_bytes(profile.n_embd)
|
|
492
|
+
_agent_compute_base_bytes(profile.n_embd)
|
|
493
|
+
+ window * (linear_per_window_token + ubatch * per_window_token)
|
|
485
494
|
),
|
|
486
495
|
"draft": mtp_draft_bytes(profile, window, slots=slots) if mtp else 0,
|
|
487
496
|
"process": AGENT_PROCESS_OVERHEAD_BYTES,
|
|
@@ -7,6 +7,7 @@ import os
|
|
|
7
7
|
import secrets
|
|
8
8
|
import shutil
|
|
9
9
|
import subprocess
|
|
10
|
+
import sys
|
|
10
11
|
import time
|
|
11
12
|
import urllib.error
|
|
12
13
|
import urllib.parse
|
|
@@ -238,6 +239,23 @@ def opener() -> urllib.request.OpenerDirector:
|
|
|
238
239
|
return http_local.no_proxy_opener()
|
|
239
240
|
|
|
240
241
|
|
|
242
|
+
def _argv(record: hosts.OwnedBifrost) -> list[str]:
|
|
243
|
+
host, _, port = record["addr"].rpartition(":")
|
|
244
|
+
return [
|
|
245
|
+
record["binary"],
|
|
246
|
+
"-app-dir",
|
|
247
|
+
str(Path(record["app_dir"])),
|
|
248
|
+
"-host",
|
|
249
|
+
host,
|
|
250
|
+
"-port",
|
|
251
|
+
port,
|
|
252
|
+
"-log-style",
|
|
253
|
+
"json",
|
|
254
|
+
"-log-level",
|
|
255
|
+
"warn",
|
|
256
|
+
]
|
|
257
|
+
|
|
258
|
+
|
|
241
259
|
def owned_listener(record: hosts.OwnedBifrost) -> bool:
|
|
242
260
|
"""Prove this existing receipt's exact process and listener before sending requests."""
|
|
243
261
|
try:
|
|
@@ -260,24 +278,10 @@ def owned_listener(record: hosts.OwnedBifrost) -> bool:
|
|
|
260
278
|
if pid <= 1:
|
|
261
279
|
return False
|
|
262
280
|
before = process_identity.inspect(pid)
|
|
263
|
-
host, _, port = addr.rpartition(":")
|
|
264
|
-
argv = [
|
|
265
|
-
record["binary"],
|
|
266
|
-
"-app-dir",
|
|
267
|
-
str(app),
|
|
268
|
-
"-host",
|
|
269
|
-
host,
|
|
270
|
-
"-port",
|
|
271
|
-
port,
|
|
272
|
-
"-log-style",
|
|
273
|
-
"json",
|
|
274
|
-
"-log-level",
|
|
275
|
-
"warn",
|
|
276
|
-
]
|
|
277
281
|
return bool(
|
|
278
282
|
before
|
|
279
283
|
and before["uid"] == process_identity.current_uid()
|
|
280
|
-
and remote_ops_service.command_matches(pid,
|
|
284
|
+
and remote_ops_service.command_matches(pid, _argv(record))
|
|
281
285
|
and remote_ops_service.listener_problem(harness_gateway.address_port(addr), [pid])
|
|
282
286
|
is None
|
|
283
287
|
and process_identity.inspect(pid) == before
|
|
@@ -323,9 +327,18 @@ def healthy(addr: str, timeout: float = 5) -> bool:
|
|
|
323
327
|
|
|
324
328
|
def _await(addr: str, timeout: float = HEALTH_TIMEOUT_S, *, record: hosts.OwnedBifrost) -> None:
|
|
325
329
|
deadline = time.monotonic() + timeout
|
|
330
|
+
pid_file = Path(record["app_dir"]) / "bifrost.pid"
|
|
326
331
|
while time.monotonic() < deadline:
|
|
327
332
|
if _healthy_owned(record):
|
|
328
333
|
return
|
|
334
|
+
if (
|
|
335
|
+
record["how"] != "unit"
|
|
336
|
+
and os.path.lexists(pid_file)
|
|
337
|
+
and process_identity.status(pid_file)[0] == "inactive"
|
|
338
|
+
):
|
|
339
|
+
raise HarnessError(
|
|
340
|
+
f"Bifrost {addr} exited before becoming ready; see {APP_DIR}/bifrost.log"
|
|
341
|
+
)
|
|
329
342
|
time.sleep(1)
|
|
330
343
|
raise HarnessError(f"Bifrost {addr} not ready in {int(timeout)} s; see {APP_DIR}/bifrost.log")
|
|
331
344
|
|
|
@@ -384,8 +397,7 @@ def _start(record: hosts.OwnedBifrost, restart: bool) -> None:
|
|
|
384
397
|
return
|
|
385
398
|
if not restart and _healthy_owned(record):
|
|
386
399
|
return
|
|
387
|
-
|
|
388
|
-
host, _, port = addr.rpartition(":")
|
|
400
|
+
_stop_owned_serve(record) # ours: restarted, or an earlier instance that stopped answering
|
|
389
401
|
env = {**os.environ, "NO_PROXY": "127.0.0.1,localhost", "no_proxy": "127.0.0.1,localhost"}
|
|
390
402
|
options: dict[str, Any] = {"cwd": app, "env": env, "stdin": subprocess.DEVNULL}
|
|
391
403
|
if os.name != "nt":
|
|
@@ -394,8 +406,7 @@ def _start(record: hosts.OwnedBifrost, restart: bool) -> None:
|
|
|
394
406
|
# Its own session; on Windows also no console, out of the starting job (a scheduled
|
|
395
407
|
# task ends its job's processes), at normal priority, as every service this tool runs.
|
|
396
408
|
proc = process_identity.spawn_detached(
|
|
397
|
-
|
|
398
|
-
+ ["-log-style", "json", "-log-level", "warn"],
|
|
409
|
+
_argv(record),
|
|
399
410
|
stdout=log,
|
|
400
411
|
stderr=log,
|
|
401
412
|
**options,
|
|
@@ -409,12 +420,74 @@ def _start(record: hosts.OwnedBifrost, restart: bool) -> None:
|
|
|
409
420
|
raise HarnessError(f"cannot record Bifrost process identity ({exc}); stopped it") from None
|
|
410
421
|
|
|
411
422
|
|
|
423
|
+
def _orphaned_serve_pid(
|
|
424
|
+
record: hosts.OwnedBifrost,
|
|
425
|
+
) -> tuple[int, process_identity.Identity] | None:
|
|
426
|
+
"""Find a live Bifrost whose receipt was lost (for example deleted after an earlier
|
|
427
|
+
``lstart`` drift), proven to belong to ``record`` by exclusive port ownership, UID, PGID,
|
|
428
|
+
and exact command line including ``app_dir``."""
|
|
429
|
+
if record["how"] == "unit" or sys.platform == "win32":
|
|
430
|
+
return None
|
|
431
|
+
try:
|
|
432
|
+
port = harness_gateway.address_port(record["addr"])
|
|
433
|
+
owners = harness_probe.loopback_listener_pids(port)
|
|
434
|
+
if not owners or len(owners) != 1:
|
|
435
|
+
return None
|
|
436
|
+
pid = next(iter(owners))
|
|
437
|
+
before = process_identity.inspect(pid)
|
|
438
|
+
if (
|
|
439
|
+
before is None
|
|
440
|
+
or before["uid"] != process_identity.current_uid()
|
|
441
|
+
or before["pgid"] != pid
|
|
442
|
+
or not remote_ops_service.command_matches(pid, _argv(record))
|
|
443
|
+
or remote_ops_service.listener_problem(port, [pid]) is not None
|
|
444
|
+
or process_identity.inspect(pid) != before
|
|
445
|
+
):
|
|
446
|
+
return None
|
|
447
|
+
return pid, before
|
|
448
|
+
except (OSError, ValueError, RuntimeError, subprocess.SubprocessError):
|
|
449
|
+
return None
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def _stop_orphaned_serve(record: hosts.OwnedBifrost) -> None:
|
|
453
|
+
orphan = _orphaned_serve_pid(record)
|
|
454
|
+
if orphan is None:
|
|
455
|
+
return
|
|
456
|
+
pid, before = orphan
|
|
457
|
+
app = Path(record["app_dir"])
|
|
458
|
+
pid_file = app / "bifrost.pid"
|
|
459
|
+
try:
|
|
460
|
+
process_identity.save(pid_file, pid)
|
|
461
|
+
if process_identity.inspect(pid) != before:
|
|
462
|
+
for path in (pid_file, Path(f"{pid_file}.identity.json")):
|
|
463
|
+
path.unlink(missing_ok=True)
|
|
464
|
+
return
|
|
465
|
+
except (OSError, RuntimeError, subprocess.SubprocessError):
|
|
466
|
+
return
|
|
467
|
+
try:
|
|
468
|
+
process_identity.stop(pid_file)
|
|
469
|
+
except RuntimeError as exc:
|
|
470
|
+
raise HarnessError(f"Bifrost {exc}; process and config kept, rerun once resolved") from None
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def _stop_owned_serve(record: hosts.OwnedBifrost) -> None:
|
|
474
|
+
app = Path(record["app_dir"])
|
|
475
|
+
_stop_serve(app)
|
|
476
|
+
if not os.path.lexists(app / "bifrost.pid"):
|
|
477
|
+
_stop_orphaned_serve(record)
|
|
478
|
+
|
|
479
|
+
|
|
412
480
|
def _stop_serve(app: Path) -> None:
|
|
413
481
|
"""Only the process group the identity receipt proves is ours; anything else is kept."""
|
|
414
482
|
try:
|
|
415
|
-
process_identity.stop(app / "bifrost.pid")
|
|
483
|
+
outcome = process_identity.stop(app / "bifrost.pid")
|
|
416
484
|
except RuntimeError as exc:
|
|
417
485
|
raise HarnessError(f"Bifrost {exc}; process and config kept, rerun once resolved") from None
|
|
486
|
+
if outcome == "none":
|
|
487
|
+
with contextlib.suppress(OSError, ValueError):
|
|
488
|
+
record = hosts.load_owned()["gateway"].get("bifrost")
|
|
489
|
+
if record and Path(record["app_dir"]) == app:
|
|
490
|
+
_stop_orphaned_serve(record)
|
|
418
491
|
|
|
419
492
|
|
|
420
493
|
def pause(record: hosts.OwnedBifrost) -> str:
|
|
@@ -435,7 +508,7 @@ def _retire(record: hosts.OwnedBifrost) -> None:
|
|
|
435
508
|
if _systemctl("stop", f"{name}.service").returncode != 0:
|
|
436
509
|
raise HarnessError(f"systemctl --user stop {name} failed; the earlier Bifrost kept")
|
|
437
510
|
return
|
|
438
|
-
|
|
511
|
+
_stop_owned_serve(record)
|
|
439
512
|
|
|
440
513
|
|
|
441
514
|
def ensure(plan: ToolPlan) -> str:
|
|
@@ -564,7 +637,7 @@ def stop(tools_dir: str = hosts.TOOLS_DIR) -> Check:
|
|
|
564
637
|
return {"check": "bifrost", "ok": False, "detail": str(exc)}
|
|
565
638
|
else:
|
|
566
639
|
try:
|
|
567
|
-
|
|
640
|
+
_stop_owned_serve(record)
|
|
568
641
|
except HarnessError as exc:
|
|
569
642
|
return {"check": "bifrost", "ok": False, "detail": str(exc)}
|
|
570
643
|
for name in ("config.json", *bifrost_datasheet.FILES, *STORE, "admin-password"):
|
|
@@ -86,9 +86,13 @@ _GGML_TYPE_SIZES = {
|
|
|
86
86
|
29: (56, 256),
|
|
87
87
|
30: (2, 1),
|
|
88
88
|
39: (17, 32), # MXFP4 — 32 elements per 17-byte block (gpt-oss family)
|
|
89
|
-
#
|
|
90
|
-
#
|
|
89
|
+
# b12588 ggml-common.h: NVFP4 (QK_NVFP4=64, 4 E4M3 sub-block scales + 32 packed bytes),
|
|
90
|
+
# Q1_0 (QK1_0=128, fp16 scale + 16 packed bytes), Q2_0 (QK2_0=64, 18 bytes = 9/32),
|
|
91
|
+
# F8_E4M3 (1 byte per element). Inkling-2-Mini GGUFs use NVFP4 tensors.
|
|
92
|
+
40: (36, 64),
|
|
93
|
+
41: (18, 128),
|
|
91
94
|
42: (9, 32),
|
|
95
|
+
43: (1, 1),
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
# GGUF metadata value types -> struct format; STRING (8) and ARRAY (9) are variable-length.
|
|
@@ -110,7 +110,60 @@ def listener_uids(addr: str, tables: tuple[str, ...] | None = None) -> set[int]:
|
|
|
110
110
|
return uids
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
_PROC = "/proc"
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _linux_socket_owner_pids(
|
|
117
|
+
inodes: set[str], proc: str = _PROC, *, uid: int | None = None
|
|
118
|
+
) -> set[int]:
|
|
119
|
+
owners: set[int] = set()
|
|
120
|
+
for pid in (p for p in _listdir(proc) if p.isdigit()):
|
|
121
|
+
if uid is not None:
|
|
122
|
+
try:
|
|
123
|
+
if Path(proc, pid).stat().st_uid != uid:
|
|
124
|
+
continue
|
|
125
|
+
except OSError:
|
|
126
|
+
continue
|
|
127
|
+
for fd in _listdir(f"{proc}/{pid}/fd"):
|
|
128
|
+
try:
|
|
129
|
+
target = Path(proc, pid, "fd", fd).readlink()
|
|
130
|
+
except OSError:
|
|
131
|
+
continue
|
|
132
|
+
if str(target).removeprefix("socket:[").removesuffix("]") in inodes:
|
|
133
|
+
owners.add(int(pid))
|
|
134
|
+
break
|
|
135
|
+
return owners
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def loopback_listener_pids(port: int, proc: str = _PROC) -> set[int] | None:
|
|
139
|
+
"""PIDs of processes listening on TCP ``port`` (this user's on Linux), or None when unknown."""
|
|
140
|
+
if sys.platform == "win32":
|
|
141
|
+
from localmodels import process_identity
|
|
142
|
+
|
|
143
|
+
return process_identity.listener_pids(port)
|
|
144
|
+
if sys.platform == "darwin":
|
|
145
|
+
from localmodels.harness import run_tool
|
|
146
|
+
|
|
147
|
+
out = run_tool(
|
|
148
|
+
["/usr/sbin/lsof", "-wnP", f"-iTCP:{port}", "-sTCP:LISTEN", "-Fp"], timeout=10
|
|
149
|
+
)
|
|
150
|
+
lines = out.stdout.splitlines()
|
|
151
|
+
if out.returncode not in (0, 1) or any(not ln[1:].isdecimal() for ln in lines):
|
|
152
|
+
return None
|
|
153
|
+
return {int(ln[1:]) for ln in lines if ln[:1] == "p"}
|
|
154
|
+
if not sys.platform.startswith("linux"):
|
|
155
|
+
return None
|
|
156
|
+
from localmodels import remote_ops_service
|
|
157
|
+
|
|
158
|
+
inodes = remote_ops_service.loopback_listener_inodes(port)
|
|
159
|
+
if inodes is None:
|
|
160
|
+
return None
|
|
161
|
+
if not inodes:
|
|
162
|
+
return set()
|
|
163
|
+
return _linux_socket_owner_pids(inodes, proc, uid=os.getuid())
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def port_holder(port: int, proc: str = _PROC) -> str | None:
|
|
114
167
|
"""Who listens on ``port``, for a refusal the operator can act on: "name (pid N)" for this
|
|
115
168
|
user's own process, "a process of user uid N" for another user's, None when /proc shows no
|
|
116
169
|
listener or cannot be read (Linux only; the caller then says nothing more)."""
|
|
@@ -126,18 +179,12 @@ def port_holder(port: int, proc: str = "/proc") -> str | None:
|
|
|
126
179
|
inodes[f[9]] = int(f[7])
|
|
127
180
|
if not inodes:
|
|
128
181
|
return None
|
|
129
|
-
for pid in (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if str(target).removeprefix("socket:[").removesuffix("]") in inodes:
|
|
136
|
-
try:
|
|
137
|
-
name = Path(proc, pid, "comm").read_text(encoding="utf-8").strip()
|
|
138
|
-
except OSError:
|
|
139
|
-
name = "?"
|
|
140
|
-
return f"{name} (pid {pid})"
|
|
182
|
+
for pid in sorted(_linux_socket_owner_pids(set(inodes), proc)):
|
|
183
|
+
try:
|
|
184
|
+
name = Path(proc, str(pid), "comm").read_text(encoding="utf-8").strip()
|
|
185
|
+
except OSError:
|
|
186
|
+
name = "?"
|
|
187
|
+
return f"{name} (pid {pid})"
|
|
141
188
|
uid = next(iter(inodes.values()))
|
|
142
189
|
return f"a process of user uid {uid}"
|
|
143
190
|
|
|
@@ -82,9 +82,10 @@ def is_chat(entry: cat.CatalogEntry) -> bool:
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def shown(facts: HostFacts, catalog: Iterable[cat.CatalogEntry]) -> list[Model]:
|
|
85
|
-
"""The chat models validated for this platform, and the candidates
|
|
86
|
-
picks here too (the Mac small-memory ladder, the Windows NVIDIA
|
|
87
|
-
variant. Ling-3.0-tiny, which the ladder replaces in automatic
|
|
85
|
+
"""The chat models validated for this platform, library-listed candidates, and the candidates
|
|
86
|
+
``stack --llm auto`` picks here too (the Mac small-memory ladder, the Windows NVIDIA
|
|
87
|
+
fallback): one row per variant. Ling-3.0-tiny, which the ladder replaces in automatic
|
|
88
|
+
selection, stays listed."""
|
|
88
89
|
return [
|
|
89
90
|
Model(e, v)
|
|
90
91
|
for e in catalog
|
|
@@ -93,6 +94,7 @@ def shown(facts: HostFacts, catalog: Iterable[cat.CatalogEntry]) -> list[Model]:
|
|
|
93
94
|
cat.validated_here(e, facts["platform"])
|
|
94
95
|
or llm_rank.mac_rung(e, facts)
|
|
95
96
|
or llm_rank.windows_fallback(e, facts)
|
|
97
|
+
or (e.library and e.status == "candidate")
|
|
96
98
|
)
|
|
97
99
|
for v in e.variants
|
|
98
100
|
]
|
|
@@ -371,7 +373,7 @@ def _min_pool_need(model: Model, pool: str, exc: deploy.AgentMemoryError) -> int
|
|
|
371
373
|
return exc.needed_bytes + AGENT_VRAM_RESERVE_BYTES
|
|
372
374
|
if pool == "unified":
|
|
373
375
|
profile = model.entry.profile(model.variant)
|
|
374
|
-
mac_posture = context_policy.posture_for(posture(), "metal")
|
|
376
|
+
mac_posture = model.entry.agent_posture(context_policy.posture_for(posture(), "metal"))
|
|
375
377
|
host_side = context_policy.cache_floor_bytes(
|
|
376
378
|
mac_posture, profile
|
|
377
379
|
) + context_policy.metal_host_bytes(profile, mac_posture)
|
|
@@ -395,15 +395,17 @@ def stop_process(saved: process_identity.Identity, grace: float = 20.0) -> str:
|
|
|
395
395
|
import signal
|
|
396
396
|
import time
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
current = process_identity.inspect(saved["pid"])
|
|
399
|
+
if not process_identity.matches(current, saved):
|
|
399
400
|
return "gone"
|
|
401
|
+
assert current is not None
|
|
400
402
|
if os.name == "nt":
|
|
401
403
|
deadline = time.monotonic() + grace
|
|
402
404
|
while time.monotonic() < deadline:
|
|
403
|
-
if process_identity.inspect(saved["pid"]) !=
|
|
405
|
+
if process_identity.inspect(saved["pid"]) != current:
|
|
404
406
|
return "stopped"
|
|
405
407
|
time.sleep(0.1)
|
|
406
|
-
if process_identity.windows_stop_tree(saved["pid"],
|
|
408
|
+
if process_identity.windows_stop_tree(saved["pid"], current, grace):
|
|
407
409
|
return "stopped"
|
|
408
410
|
raise RuntimeError(f"process {saved['pid']} is still running")
|
|
409
411
|
for sig in (signal.SIGTERM, signal.SIGKILL):
|
|
@@ -411,7 +413,7 @@ def stop_process(saved: process_identity.Identity, grace: float = 20.0) -> str:
|
|
|
411
413
|
os.killpg(saved["pgid"], sig)
|
|
412
414
|
deadline = time.monotonic() + grace
|
|
413
415
|
while time.monotonic() < deadline:
|
|
414
|
-
if process_identity.inspect(saved["pid"]) !=
|
|
416
|
+
if process_identity.inspect(saved["pid"]) != current:
|
|
415
417
|
return "stopped"
|
|
416
418
|
time.sleep(0.1)
|
|
417
419
|
raise RuntimeError(f"process group {saved['pgid']} is still running after SIGKILL")
|