@simplexai/localmodels-linux-x64 0.1.0-dev.49 → 0.1.0-dev.51
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 +65 -59
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/catalog.json +2395 -9
- package/modules/localmodels/deploy.py +29 -134
- package/modules/localmodels/download-mirrors.json +47 -0
- package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +79 -0
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.1.json +132 -0
- package/modules/localmodels/gateway.py +23 -6
- package/modules/localmodels/gateway_bifrost.py +6 -2
- package/modules/localmodels/harness.py +8 -2
- package/modules/localmodels/harness_gateway.py +78 -17
- package/modules/localmodels/harness_probe.py +43 -23
- package/modules/localmodels/hosts.py +52 -5
- package/modules/localmodels/library_floor.py +76 -0
- package/modules/localmodels/library_gateway.py +17 -1
- package/modules/localmodels/library_jobs.py +38 -6
- package/modules/localmodels/library_model.py +5 -0
- package/modules/localmodels/library_poly.py +273 -0
- package/modules/localmodels/library_pricing.py +24 -35
- package/modules/localmodels/library_serve.py +7 -0
- package/modules/localmodels/library_state.py +16 -0
- package/modules/localmodels/library_status.py +114 -29
- package/modules/localmodels/llm_rank.py +14 -0
- package/modules/localmodels/magpie_windows.py +312 -0
- package/modules/localmodels/plan_envelope.py +234 -3
- package/modules/localmodels/probe.py +1 -1
- package/modules/localmodels/process_identity.py +19 -9
- package/modules/localmodels/process_identity_darwin.py +155 -0
- package/modules/localmodels/remote_ops.py +11 -0
- package/modules/localmodels/remote_ops_download.py +30 -5
- package/modules/localmodels/remote_ops_service.py +11 -13
- package/modules/localmodels/reuse.py +13 -6
- package/modules/localmodels/runtime_cli.py +8 -8
- package/modules/localmodels/runtime_install.py +25 -1
- package/modules/localmodels/runtime_io.py +32 -18
- package/modules/localmodels/setup_inspection.py +83 -79
- package/modules/localmodels/setup_inspection_harness.py +147 -0
- package/modules/localmodels/setup_text.py +12 -0
- package/modules/localmodels/setup_upgrade.py +11 -1
- package/modules/localmodels/stack.py +3 -1
- package/modules/localmodels/stack_auto.py +6 -2
- package/modules/localmodels/stack_cli.py +39 -0
- package/modules/localmodels/stack_clients.py +1 -1
- package/modules/localmodels/stack_compose.py +12 -43
- package/modules/localmodels/stack_down.py +25 -16
- package/modules/localmodels/stack_hardware.py +12 -1
- package/modules/localmodels/stack_picks.py +28 -13
- package/modules/localmodels/stack_plan.py +55 -3
- package/modules/localmodels/stack_remove.py +3 -1
- package/modules/localmodels/stack_suite.py +80 -20
- package/modules/localmodels/strata-poly-serve-0.2.19-poly.1.txt +428 -0
- package/modules/localmodels/{strata-poly-serve-0.1.45-poly.9.txt → strata-poly-serve-0.2.20-poly.1.txt} +2 -2
- package/modules/localmodels/strata_poly_server.py +33 -2
- package/modules/localmodels/suite.py +45 -4
- package/modules/localmodels/tool_archive.py +4 -0
- package/modules/localmodels/vision.py +4 -2
- package/modules/localmodels/win_probe.py +24 -7
- package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev51.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev51.dist-info}/RECORD +62 -56
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/localmodels/engines-strata-poly-0.1.45-poly.9.json +0 -75
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev51.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev51.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev51.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev49.dist-info → simplex_localmodels-0.1.0.dev51.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -48,7 +48,7 @@ from localmodels import stack_gpu_memory as gpu_memory
|
|
|
48
48
|
from localmodels import stack_hardware as hardware
|
|
49
49
|
from localmodels import stack_llm_ram as llm_ram
|
|
50
50
|
from localmodels.approval import digest
|
|
51
|
-
from localmodels.budget import gib, host_ram
|
|
51
|
+
from localmodels.budget import gib, host_ram
|
|
52
52
|
from localmodels.context_policy import AGENT, AgentPosture, posture_for, window_k
|
|
53
53
|
from localmodels.plan_envelope import PlanError, require_free_port, utc_now
|
|
54
54
|
from localmodels.probe import HostFacts
|
|
@@ -63,6 +63,7 @@ from localmodels.stack_plan import (
|
|
|
63
63
|
command,
|
|
64
64
|
download_budget,
|
|
65
65
|
is_redeploy,
|
|
66
|
+
no_fit_reason,
|
|
66
67
|
own_name,
|
|
67
68
|
platform_error,
|
|
68
69
|
ram_floor,
|
|
@@ -360,53 +361,17 @@ def _choose_llm(
|
|
|
360
361
|
" (with the smallest decision reserve)" if options.get("decision", "none") != "none" else ""
|
|
361
362
|
)
|
|
362
363
|
avail = (reclaimed_ram() if callable(reclaimed_ram) else reclaimed_ram) if vram_fit else 0
|
|
363
|
-
reason =
|
|
364
|
+
reason, cause_code = no_fit_reason(facts, cards, mac, vram_fit=vram_fit, reclaimed_ram=avail)
|
|
364
365
|
raise StackError(
|
|
365
366
|
stack_capacity.no_default_reason(facts, options, posture)
|
|
366
367
|
+ f"no verified LLM fits {where} in the agent posture "
|
|
367
368
|
f"({window_k(posture.floor)} floor){reserve}{reason}; "
|
|
368
369
|
"name a catalog model with --llm (other candidates are not ranked automatically), "
|
|
369
|
-
f"see each card with {command()} stack hardware"
|
|
370
|
+
f"see each card with {command()} stack hardware",
|
|
371
|
+
cause_code=cause_code,
|
|
370
372
|
)
|
|
371
373
|
|
|
372
374
|
|
|
373
|
-
def _no_fit_reason(
|
|
374
|
-
facts: HostFacts,
|
|
375
|
-
cards: list[int],
|
|
376
|
-
mac: bool,
|
|
377
|
-
*,
|
|
378
|
-
vram_fit: bool = False,
|
|
379
|
-
reclaimed_ram: int = 0,
|
|
380
|
-
) -> str:
|
|
381
|
-
gpus = {g["index"]: g for g in facts.get("gpus") or []}
|
|
382
|
-
if mac or not gpus:
|
|
383
|
-
return ""
|
|
384
|
-
if not cards:
|
|
385
|
-
eligible = [
|
|
386
|
-
p
|
|
387
|
-
for p in placements(facts)
|
|
388
|
-
if not p.pooled and not p.budget.uma and len(p.gpu_indices) == 1
|
|
389
|
-
]
|
|
390
|
-
if not eligible:
|
|
391
|
-
return ": no supported single-card GPU placement"
|
|
392
|
-
if not all(p.conflicts for p in eligible):
|
|
393
|
-
return ": no GPU meets automatic selection requirements; check GPU service discovery"
|
|
394
|
-
free = ", ".join(
|
|
395
|
-
f"GPU {p.gpu_indices[0]} {gib(gpus[p.gpu_indices[0]]['free_bytes'])} free"
|
|
396
|
-
for p in eligible
|
|
397
|
-
)
|
|
398
|
-
return (
|
|
399
|
-
f": every placeable card has other GPU work ({free}), and --llm auto skips "
|
|
400
|
-
"such cards; plan again once they end, or, if sharing is fine and that card has "
|
|
401
|
-
"room, use --gpu N --share-gpu"
|
|
402
|
-
)
|
|
403
|
-
if vram_fit:
|
|
404
|
-
avail = gib(host_ram(facts, reclaimed_bytes=reclaimed_ram)[1])
|
|
405
|
-
return f": not enough available RAM ({avail} available)"
|
|
406
|
-
best = gpus[cards[0]]
|
|
407
|
-
return f": the roomiest GPU {cards[0]} has only {gib(best['free_bytes'])} free"
|
|
408
|
-
|
|
409
|
-
|
|
410
375
|
def _foundation_reserve(facts: HostFacts, options: StackOptions, aux: list[Plan]) -> int:
|
|
411
376
|
"""The RAM the named foundations hold back before the LLM is chosen: on unified memory only,
|
|
412
377
|
where they share the pool with the LLM and its cache; a CPU auxiliary beside an NVIDIA card
|
|
@@ -452,7 +417,10 @@ def _gpu_conflicts(llm: Plan, facts: HostFacts, share_gpu: bool) -> list[str]:
|
|
|
452
417
|
"""Another program holding or serving on the LLM's card needs the operator's consent."""
|
|
453
418
|
busy = approval.busy_gpus(llm, facts)
|
|
454
419
|
if busy and not share_gpu:
|
|
455
|
-
raise StackError(
|
|
420
|
+
raise StackError(
|
|
421
|
+
"; ".join(busy) + "; if sharing is fine, plan again with --share-gpu",
|
|
422
|
+
cause_code="GPU_CONFLICT",
|
|
423
|
+
)
|
|
456
424
|
return [f"sharing per --share-gpu: {b}" for b in busy]
|
|
457
425
|
|
|
458
426
|
|
|
@@ -543,7 +511,7 @@ def _llama_parts(
|
|
|
543
511
|
resource_template=options.get("defer_services", False),
|
|
544
512
|
)
|
|
545
513
|
except PlanError as exc:
|
|
546
|
-
raise StackError(str(exc)) from None
|
|
514
|
+
raise StackError(str(exc), cause_code=getattr(exc, "cause_code", None)) from None
|
|
547
515
|
llm = choice["llm"] or llm
|
|
548
516
|
served = choice["front"] or choice["plan"]
|
|
549
517
|
if served is not None and not options.get("defer_services"):
|
|
@@ -609,7 +577,8 @@ def ram_budget(parts: Parts) -> dict[str, int]:
|
|
|
609
577
|
f", short about {gib(ram_needed - available)}; primary window is unchanged"
|
|
610
578
|
if fast is not None
|
|
611
579
|
else ""
|
|
612
|
-
)
|
|
580
|
+
),
|
|
581
|
+
cause_code="MEMORY_INSUFFICIENT",
|
|
613
582
|
)
|
|
614
583
|
return ram_parts
|
|
615
584
|
|
|
@@ -57,16 +57,24 @@ def _bifrost(record: hosts.OwnedBifrost) -> str:
|
|
|
57
57
|
return f"failed: {exc}"
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def _magpie(doc: hosts.Owned, plan: StackPlan, notes: list[str]) -> str:
|
|
60
|
+
def _magpie(doc: hosts.Owned, plan: StackPlan | None, notes: list[str]) -> str:
|
|
61
61
|
started = doc["gateway"]["started"]
|
|
62
|
+
owned_magpie = doc["gateway"].get("magpie")
|
|
62
63
|
if started == "daemon":
|
|
63
64
|
notes.append("the global magpie.service is not proven to be this tool's; left running")
|
|
64
65
|
return "kept: global magpie.service"
|
|
65
|
-
if started != "serve":
|
|
66
|
+
if started != "serve" and owned_magpie is None:
|
|
66
67
|
return "none"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if owned_magpie is not None:
|
|
69
|
+
tools_dir = owned_magpie["tools_dir"]
|
|
70
|
+
target = harness_gateway.owned_magpie_target(owned_magpie)
|
|
71
|
+
magpie = owned_magpie["binary"] or gateway.magpie_binary(doc)
|
|
72
|
+
elif plan is not None:
|
|
73
|
+
tools_dir = plan["harness"]["tools_dir"]
|
|
74
|
+
target = harness_gateway.magpie_target(tools_dir) or plan["harness"]
|
|
75
|
+
magpie = gateway.magpie_binary(doc)
|
|
76
|
+
else:
|
|
77
|
+
return "failed: saved stack plan unavailable; gateway left untouched"
|
|
70
78
|
if magpie is None:
|
|
71
79
|
return "failed: the Magpie binary this tool installed is missing"
|
|
72
80
|
check = gateway.stop_gateway(magpie, "serve", tools_dir, plan=target, forget=False)
|
|
@@ -76,21 +84,22 @@ def _magpie(doc: hosts.Owned, plan: StackPlan, notes: list[str]) -> str:
|
|
|
76
84
|
|
|
77
85
|
|
|
78
86
|
def _gateway(plan: StackPlan | None, notes: list[str]) -> tuple[str, str]:
|
|
79
|
-
"""Stop the gateway this tool started. Bifrost's own record
|
|
80
|
-
|
|
81
|
-
uninstall, GitHub linger#178). A Magpie
|
|
82
|
-
directory and is left untouched without it."""
|
|
87
|
+
"""Stop the gateway this tool started. Bifrost's own record and a recorded private Magpie
|
|
88
|
+
instance each prove themselves ours even without a saved stack plan (Linger's quit and
|
|
89
|
+
uninstall, GitHub linger#178 / WHI-887). A legacy Magpie manifest without an instance record
|
|
90
|
+
still needs the saved plan's tools directory and is left untouched without it."""
|
|
83
91
|
doc = hosts.load_owned(plan["harness"]["tools_dir"] if plan else hosts.TOOLS_DIR)
|
|
84
92
|
record = doc["gateway"].get("bifrost")
|
|
85
93
|
results: list[tuple[str, str]] = []
|
|
86
94
|
if record:
|
|
87
95
|
results.append((_bifrost(record), "Bifrost"))
|
|
88
|
-
if doc["gateway"]["started"]:
|
|
89
|
-
|
|
90
|
-
(_magpie(doc, plan, notes), "Magpie")
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
if doc["gateway"]["started"] or doc["gateway"].get("magpie"):
|
|
97
|
+
if plan is not None or doc["gateway"].get("magpie") is not None:
|
|
98
|
+
results.append((_magpie(doc, plan, notes), "Magpie"))
|
|
99
|
+
else:
|
|
100
|
+
results.append(
|
|
101
|
+
("failed: saved stack plan unavailable; gateway left untouched", "unknown")
|
|
102
|
+
)
|
|
94
103
|
for prefix in ("failed", "stopped", "kept", "not-running"):
|
|
95
104
|
found = next((r for r in results if r[0].startswith(prefix)), None)
|
|
96
105
|
if found:
|
|
@@ -120,7 +129,7 @@ def _down(out: Out) -> DownReport:
|
|
|
120
129
|
records = [r for r in hosts.records(hosts.LOCAL_ID) if r["plan"]["name"] in members]
|
|
121
130
|
notes: list[str] = []
|
|
122
131
|
# The gateway first: it routes to the services, as up starts it after them.
|
|
123
|
-
gate, kind = _gateway(_latest()
|
|
132
|
+
gate, kind = _gateway(_latest(), notes)
|
|
124
133
|
if gate in ("stopped", "not-running") and _library_loaded():
|
|
125
134
|
notes.append(
|
|
126
135
|
"models the library loaded keep running without the gateway; unload them "
|
|
@@ -354,9 +354,20 @@ def llm_fits(
|
|
|
354
354
|
llama_score = max(
|
|
355
355
|
(f["quality"] for _, f in found if not f.get("candidate_fallback")), default=-1
|
|
356
356
|
)
|
|
357
|
+
preferred_strata = {
|
|
358
|
+
c["id"]
|
|
359
|
+
for c in catalog_recipes.components()
|
|
360
|
+
if c["runtime"] in ("strata", "strata-poly") and c.get("prefer_over_llama")
|
|
361
|
+
}
|
|
362
|
+
strata_vram = {
|
|
363
|
+
c["id"]: int(str(c.get("vram_bytes") or 0))
|
|
364
|
+
for c in catalog_recipes.components()
|
|
365
|
+
if c["runtime"] in ("strata", "strata-poly")
|
|
366
|
+
}
|
|
357
367
|
for fit in stack_auto.card_fits(facts, index, options, llama_score):
|
|
358
368
|
_apply_fit_measurement(facts, index, fit)
|
|
359
|
-
|
|
369
|
+
tie = (1e9 if fit["id"] in preferred_strata else -1e9) + strata_vram.get(fit["id"], 0) / GIB
|
|
370
|
+
found.append(((fit["quality"], tie), fit))
|
|
360
371
|
found = [row for row in found if not row[1].get("candidate_fallback")] or found
|
|
361
372
|
default_id = llm_rank.listed_default(facts, [(f["id"], f["quality"]) for _, f in found])
|
|
362
373
|
return [
|
|
@@ -70,8 +70,17 @@ def picks(cards: Sequence[CardFits], ladder: llm_rank.MacLadder | None = None) -
|
|
|
70
70
|
found.setdefault(
|
|
71
71
|
fit["id"], {**fit, "role": "", "card": card["index"], "shared": not free}
|
|
72
72
|
)
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
components = catalog_recipes.components()
|
|
74
|
+
strata_ids = {c["id"] for c in components if c["runtime"] in ("strata", "strata-poly")}
|
|
75
|
+
preferred_strata = {
|
|
76
|
+
c["id"]
|
|
77
|
+
for c in components
|
|
78
|
+
if c["runtime"] in ("strata", "strata-poly") and c.get("prefer_over_llama")
|
|
79
|
+
}
|
|
80
|
+
strata_vram = {
|
|
81
|
+
c["id"]: int(str(c.get("vram_bytes") or 0))
|
|
82
|
+
for c in components
|
|
83
|
+
if c["runtime"] in ("strata", "strata-poly")
|
|
75
84
|
}
|
|
76
85
|
llama_scores = [
|
|
77
86
|
p["quality"]
|
|
@@ -80,25 +89,31 @@ def picks(cards: Sequence[CardFits], ladder: llm_rank.MacLadder | None = None) -
|
|
|
80
89
|
and p["id"] not in strata_ids
|
|
81
90
|
and not p.get("candidate_fallback")
|
|
82
91
|
]
|
|
83
|
-
|
|
92
|
+
best_llama = max(llama_scores, default=-1)
|
|
84
93
|
eligible = [
|
|
85
94
|
p
|
|
86
95
|
for p in found.values()
|
|
87
|
-
if (p["decode_tok_s"] is not None and p["id"] not in strata_ids)
|
|
96
|
+
if (p["decode_tok_s"] is not None and p["id"] not in strata_ids)
|
|
97
|
+
or p["quality"]
|
|
98
|
+
>= llm_rank.strata_recipe_bar(best_llama, {}, prefer_over_llama=p["id"] in preferred_strata)
|
|
88
99
|
]
|
|
89
100
|
if not eligible:
|
|
90
101
|
return []
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
p["id"],
|
|
95
|
-
p["
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
]
|
|
102
|
+
|
|
103
|
+
def _smart_tie(p: Pick) -> float:
|
|
104
|
+
if p["id"] in strata_ids:
|
|
105
|
+
gib_rank = strata_vram.get(p["id"], 0) / (1 << 30)
|
|
106
|
+
return (1e9 if p["id"] in preferred_strata else -1e9) + gib_rank
|
|
107
|
+
return -1.0 if p["decode_tok_s"] is None else p["decode_tok_s"]
|
|
108
|
+
|
|
109
|
+
ranked = [((p["quality"], _smart_tie(p)), p["id"], p["card"]) for p in eligible]
|
|
99
110
|
fallback_ids = {p["id"] for p in eligible if p.get("candidate_fallback")}
|
|
100
111
|
smartest = found[llm_rank.choose(ranked, "smartest", ladder, fallback_ids=fallback_ids)[0]]
|
|
101
|
-
llama_ranked = [
|
|
112
|
+
llama_ranked = [
|
|
113
|
+
((p["quality"], float(p["decode_tok_s"])), p["id"], p["card"])
|
|
114
|
+
for p in eligible
|
|
115
|
+
if p["id"] not in strata_ids and p["decode_tok_s"] is not None
|
|
116
|
+
]
|
|
102
117
|
fastest = (
|
|
103
118
|
found[llm_rank.choose(llama_ranked, "fastest", ladder, fallback_ids=fallback_ids)[0]]
|
|
104
119
|
if llama_ranked
|
|
@@ -15,7 +15,7 @@ from typing import Literal, TypedDict, cast
|
|
|
15
15
|
from localmodels import approval, deploy, gateway, harness, hosts, preparation, reuse, vision
|
|
16
16
|
from localmodels.budget import HARNESS_RAM as HARNESS_RAM
|
|
17
17
|
from localmodels.budget import RAM_FLOOR as RAM_FLOOR
|
|
18
|
-
from localmodels.budget import gib
|
|
18
|
+
from localmodels.budget import gib, host_ram, placements
|
|
19
19
|
from localmodels.gateway_bifrost import FAST_PROVIDER
|
|
20
20
|
from localmodels.plan_envelope import PlanError, resolved_name
|
|
21
21
|
from localmodels.plan_envelope import verified_in_place as verified_in_place
|
|
@@ -49,6 +49,10 @@ def ram_floor(metal: bool) -> int:
|
|
|
49
49
|
class StackError(RuntimeError):
|
|
50
50
|
"""The stack cannot be planned or applied as asked; the message says why."""
|
|
51
51
|
|
|
52
|
+
def __init__(self, message: str, *, cause_code: str | None = None) -> None:
|
|
53
|
+
super().__init__(message)
|
|
54
|
+
self.cause_code = cause_code
|
|
55
|
+
|
|
52
56
|
|
|
53
57
|
class StackGuardError(StackError):
|
|
54
58
|
"""An approval guard with structured, separately sanitized public diagnostics."""
|
|
@@ -61,7 +65,7 @@ class StackGuardError(StackError):
|
|
|
61
65
|
changed_fields: tuple[str, ...] = (),
|
|
62
66
|
public_message: str = "",
|
|
63
67
|
) -> None:
|
|
64
|
-
super().__init__(message)
|
|
68
|
+
super().__init__(message, cause_code=cause_code)
|
|
65
69
|
self.cause_code = cause_code
|
|
66
70
|
self.changed_fields = changed_fields
|
|
67
71
|
# A literal, path-free sentence the machine result may carry; never the message itself.
|
|
@@ -618,7 +622,8 @@ def download_budget(
|
|
|
618
622
|
if free is not None and disk_needed > free:
|
|
619
623
|
raise StackError(
|
|
620
624
|
f"not enough disk space: the stack needs about {gib(disk_needed)}, "
|
|
621
|
-
f"{facts['disk']['path']} has only {gib(free)} free"
|
|
625
|
+
f"{facts['disk']['path']} has only {gib(free)} free",
|
|
626
|
+
cause_code="DISK_INSUFFICIENT",
|
|
622
627
|
)
|
|
623
628
|
return {
|
|
624
629
|
"disk_free_bytes": free,
|
|
@@ -650,3 +655,50 @@ def engine_line(part: Plan) -> str:
|
|
|
650
655
|
f" engine {release['build']} ({release['commit'][:8]}), {release['backend']}"
|
|
651
656
|
+ "".join(f", {n}" for n in needs if n)
|
|
652
657
|
)
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def no_fit_reason(
|
|
661
|
+
facts: HostFacts,
|
|
662
|
+
cards: list[int],
|
|
663
|
+
mac: bool,
|
|
664
|
+
*,
|
|
665
|
+
vram_fit: bool = False,
|
|
666
|
+
reclaimed_ram: int = 0,
|
|
667
|
+
) -> tuple[str, str | None]:
|
|
668
|
+
"""Explain why no verified auto LLM fit and classify the refusal for structured callers."""
|
|
669
|
+
gpus = {g["index"]: g for g in facts.get("gpus") or []}
|
|
670
|
+
if mac:
|
|
671
|
+
return "", "MEMORY_INSUFFICIENT"
|
|
672
|
+
if not gpus:
|
|
673
|
+
return "", None
|
|
674
|
+
if not cards:
|
|
675
|
+
eligible = [
|
|
676
|
+
p
|
|
677
|
+
for p in placements(facts)
|
|
678
|
+
if not p.pooled and not p.budget.uma and len(p.gpu_indices) == 1
|
|
679
|
+
]
|
|
680
|
+
if not eligible:
|
|
681
|
+
return ": no supported single-card GPU placement", None
|
|
682
|
+
if not all(p.conflicts for p in eligible):
|
|
683
|
+
return (
|
|
684
|
+
": no GPU meets automatic selection requirements; check GPU service discovery",
|
|
685
|
+
None,
|
|
686
|
+
)
|
|
687
|
+
free = ", ".join(
|
|
688
|
+
f"GPU {p.gpu_indices[0]} {gib(gpus[p.gpu_indices[0]]['free_bytes'])} free"
|
|
689
|
+
for p in eligible
|
|
690
|
+
)
|
|
691
|
+
return (
|
|
692
|
+
f": every placeable card has other GPU work ({free}), and --llm auto skips "
|
|
693
|
+
"such cards; plan again once they end, or, if sharing is fine and that card has "
|
|
694
|
+
"room, use --gpu N --share-gpu",
|
|
695
|
+
"GPU_CONFLICT",
|
|
696
|
+
)
|
|
697
|
+
if vram_fit:
|
|
698
|
+
avail = gib(host_ram(facts, reclaimed_bytes=reclaimed_ram)[1])
|
|
699
|
+
return f": not enough available RAM ({avail} available)", "MEMORY_INSUFFICIENT"
|
|
700
|
+
best = gpus[cards[0]]
|
|
701
|
+
return (
|
|
702
|
+
f": the roomiest GPU {cards[0]} has only {gib(best['free_bytes'])} free",
|
|
703
|
+
"MEMORY_INSUFFICIENT",
|
|
704
|
+
)
|
|
@@ -201,10 +201,12 @@ def remove_tools(
|
|
|
201
201
|
checks: list[gateway.Check] = []
|
|
202
202
|
notes: list[str] = []
|
|
203
203
|
started = doc["gateway"]["started"]
|
|
204
|
-
ours = next((t for t in doc["tools"] if Path(t["path"]).name
|
|
204
|
+
ours = next((t for t in doc["tools"] if Path(t["path"]).name in ("magpie", "magpie.exe")), None)
|
|
205
205
|
drift = harness.changed(ours) if ours and os.path.lexists(ours["path"]) else None
|
|
206
206
|
if started and magpie and ours and drift:
|
|
207
207
|
hosts.own_gateway(hosts.TOOLS_DIR, "started", None)
|
|
208
|
+
if doc["gateway"].get("magpie") is not None:
|
|
209
|
+
hosts.own_magpie(hosts.TOOLS_DIR, None)
|
|
208
210
|
notes.append(
|
|
209
211
|
f"- gateway ({started}) kept: {ours['path']} {drift}; it may serve other providers"
|
|
210
212
|
)
|
|
@@ -9,16 +9,16 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
import argparse
|
|
11
11
|
import json
|
|
12
|
-
from collections.abc import Callable
|
|
12
|
+
from collections.abc import Callable, Mapping
|
|
13
13
|
from dataclasses import replace
|
|
14
14
|
|
|
15
15
|
from localmodels import catalog as cat
|
|
16
|
-
from localmodels import cli_help, hosts, metal, stack_ports, suite, vision
|
|
16
|
+
from localmodels import cli_help, hosts, llm_rank, metal, stack_ports, suite, vision
|
|
17
17
|
from localmodels import stack_decision as decide
|
|
18
18
|
from localmodels import stack_gpu_memory as gpu_memory
|
|
19
19
|
from localmodels import stack_hardware as hardware
|
|
20
20
|
from localmodels import stack_llm_ram as llm_ram
|
|
21
|
-
from localmodels.budget import gib, holders, host_ram, idle_cards, sharing_cards
|
|
21
|
+
from localmodels.budget import busy_cards, gib, holders, host_ram, idle_cards, sharing_cards
|
|
22
22
|
from localmodels.context_policy import AgentPosture
|
|
23
23
|
from localmodels.engines import engine_lock_path
|
|
24
24
|
from localmodels.plan_envelope import PlanError
|
|
@@ -160,9 +160,9 @@ def poly_reserve_mib(recipe: suite.SuiteRecipe, gpu: GPU, beside_mib: int) -> in
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
def auto_strata_wanted(facts: HostFacts, options: StackOptions) -> bool:
|
|
163
|
-
"""Whether ``--llm auto`` also weighs Strata recipes: on Linux and Windows (
|
|
164
|
-
|
|
165
|
-
auto_strata_candidates), and not for ``--prefer concurrent``, because a Strata recipe whose
|
|
163
|
+
"""Whether ``--llm auto`` also weighs Strata recipes: on Linux and Windows (a Mac runs a
|
|
164
|
+
strata-poly recipe that ``--llm`` names, and none is validated there; on Windows only
|
|
165
|
+
recipes whose engine has a Windows build, see auto_strata_candidates), and not for ``--prefer concurrent``, because a Strata recipe whose
|
|
166
166
|
experts stay in RAM gains nothing from a second request (GY1), nor under ``--context``: a
|
|
167
167
|
Strata recipe fixes its own window."""
|
|
168
168
|
return (
|
|
@@ -179,21 +179,42 @@ def built_for(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
|
179
179
|
return any(b["platform"] == platform for b in lock["builds"])
|
|
180
180
|
|
|
181
181
|
|
|
182
|
-
def auto_strata_candidates(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
def auto_strata_candidates(
|
|
183
|
+
facts: HostFacts,
|
|
184
|
+
at_least: int,
|
|
185
|
+
*,
|
|
186
|
+
llama_score: int | None = None,
|
|
187
|
+
options: Mapping[str, object] | None = None,
|
|
188
|
+
) -> list[suite.SuiteRecipe]:
|
|
189
|
+
"""Validated Strata LLM recipes eligible against the llama.cpp pick, best first, on a
|
|
190
|
+
computer with the RAM they are recommended for and an engine build for its platform."""
|
|
186
191
|
total = facts["ram"]["total_bytes"]
|
|
192
|
+
opts = options or {}
|
|
193
|
+
|
|
194
|
+
def _bar(r: suite.SuiteRecipe) -> int:
|
|
195
|
+
if llama_score is None:
|
|
196
|
+
return at_least
|
|
197
|
+
return llm_rank.strata_recipe_bar(
|
|
198
|
+
llama_score, opts, prefer_over_llama=bool(r.get("prefer_over_llama"))
|
|
199
|
+
)
|
|
200
|
+
|
|
187
201
|
found = [
|
|
188
202
|
r
|
|
189
203
|
for r in strata_recipes()
|
|
190
204
|
if r.get("status") == "validated"
|
|
191
205
|
and "quality" in r
|
|
192
|
-
and r["quality"]["score"] >=
|
|
206
|
+
and r["quality"]["score"] >= _bar(r)
|
|
193
207
|
and total >= r.get("min_ram_total_bytes", 0)
|
|
194
208
|
and built_for(r, facts["platform"])
|
|
195
209
|
]
|
|
196
|
-
return sorted(
|
|
210
|
+
return sorted(
|
|
211
|
+
found,
|
|
212
|
+
key=lambda r: (
|
|
213
|
+
-r["quality"]["score"],
|
|
214
|
+
-int(bool(r.get("prefer_over_llama"))),
|
|
215
|
+
-r.get("vram_bytes", 0),
|
|
216
|
+
),
|
|
217
|
+
)
|
|
197
218
|
|
|
198
219
|
|
|
199
220
|
def strata_recipe(facts: HostFacts, requested: str) -> tuple[suite.SuiteRecipe | None, list[str]]:
|
|
@@ -209,6 +230,23 @@ def strata_recipe(facts: HostFacts, requested: str) -> tuple[suite.SuiteRecipe |
|
|
|
209
230
|
]
|
|
210
231
|
|
|
211
232
|
|
|
233
|
+
METAL_BESIDE_BYTES = 12 << 30
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def unified_bytes(recipe: suite.SuiteRecipe) -> int:
|
|
237
|
+
"""What a strata-poly LLM holds on a Mac, where every expert stays in unified memory: its
|
|
238
|
+
files and METAL_BESIDE_BYTES (PS219, M5 Ultra, prompts up to 58K tokens: the engine held 1.4
|
|
239
|
+
to 4.4 GiB beside them; --conversation-cache-mib auto parks up to 8 GiB more)."""
|
|
240
|
+
return sum(f["size_bytes"] for f in recipe["files"] if not f.get("vision")) + METAL_BESIDE_BYTES
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _on_unified_memory(llm: Plan, recipe: suite.SuiteRecipe) -> Plan:
|
|
244
|
+
"""The plan on a Mac: priced whole and once (``launch.unified_bytes``), no cgroup ceiling."""
|
|
245
|
+
added = int(str(llm["launch"]["memory_estimate_bytes"])) - recipe["memory_estimate_bytes"]
|
|
246
|
+
llm["launch"]["unified_bytes"] = unified_bytes(recipe) + added
|
|
247
|
+
return suite.unbounded(llm)
|
|
248
|
+
|
|
249
|
+
|
|
212
250
|
def _suite_gpu(
|
|
213
251
|
facts: HostFacts,
|
|
214
252
|
llm: suite.SuiteRecipe,
|
|
@@ -234,6 +272,17 @@ def _suite_gpu(
|
|
|
234
272
|
)
|
|
235
273
|
if found is not None:
|
|
236
274
|
return found
|
|
275
|
+
mac = metal.device(facts) if llm["runtime"] == "strata-poly" else None # Strata is CUDA only
|
|
276
|
+
if mac is not None: # one Metal GPU on unified memory
|
|
277
|
+
if gpu not in (None, 0):
|
|
278
|
+
raise StackError(f"this computer has one Metal GPU (GPU 0), no GPU {gpu}")
|
|
279
|
+
busy = busy_cards(facts, [mac["uuid"]])
|
|
280
|
+
if busy and not share_gpu:
|
|
281
|
+
raise StackError("; ".join(busy) + "; if sharing is fine, plan again with --share-gpu")
|
|
282
|
+
if mac["free_bytes"] < need:
|
|
283
|
+
free = gib(mac["free_bytes"])
|
|
284
|
+
raise StackError(f"{llm['id']} needs {gib(need)} of unified memory, {free} is free")
|
|
285
|
+
return mac
|
|
237
286
|
candidates = sharing_cards(facts, need) if share_gpu else idle_cards(facts, need)
|
|
238
287
|
cards = [g for g in candidates if gpu is None or g["index"] == gpu]
|
|
239
288
|
if not cards:
|
|
@@ -275,7 +324,8 @@ def strata_parts(
|
|
|
275
324
|
except PlanError as exc:
|
|
276
325
|
raise StackError(f"{exc}; cannot share a card with {llm_recipe['id']}") from None
|
|
277
326
|
vram = pick.tier["vram_bytes"] if pick else 0
|
|
278
|
-
|
|
327
|
+
unified = metal.supported(facts) and llm_recipe["runtime"] == "strata-poly"
|
|
328
|
+
need = unified_bytes(llm_recipe) if unified else int(llm_recipe.get("vram_bytes", 0))
|
|
279
329
|
gpu = _suite_gpu(
|
|
280
330
|
facts, llm_recipe, need, running_llm, options.get("gpu"), share_gpu=options["share_gpu"]
|
|
281
331
|
)
|
|
@@ -315,7 +365,9 @@ def strata_parts(
|
|
|
315
365
|
reasoning_budget=int(options.get("reasoning_budget") or 0),
|
|
316
366
|
)
|
|
317
367
|
llm = running_llm or suite.build_plan(hosts.LOCAL_ID, facts, llm_recipe, opts)
|
|
318
|
-
if not running_llm and
|
|
368
|
+
if not running_llm and unified:
|
|
369
|
+
llm = _on_unified_memory(llm, llm_recipe)
|
|
370
|
+
elif not running_llm and facts["platform"] == "win32":
|
|
319
371
|
llm = suite.unbounded(llm) # no cgroups: priced by the recipe's estimate
|
|
320
372
|
if running_llm:
|
|
321
373
|
warnings.append(
|
|
@@ -338,7 +390,12 @@ def strata_parts(
|
|
|
338
390
|
|
|
339
391
|
ceiling = suite.size_bytes(options["suite_memory"])
|
|
340
392
|
available = host_ram(facts, reclaimed_bytes=owned_ram())[1]
|
|
341
|
-
|
|
393
|
+
floor = ram_floor(unified)
|
|
394
|
+
|
|
395
|
+
def held(plan: Plan) -> int:
|
|
396
|
+
return int(str(plan["launch"]["unified_bytes"])) if unified else bounded_ram(plan)
|
|
397
|
+
|
|
398
|
+
used = held(llm) + decide.host_ram(choice) + HARNESS_RAM
|
|
342
399
|
aux = fit_aux(
|
|
343
400
|
aux_plans(facts, options, listening, previous, warnings, approved=approved),
|
|
344
401
|
used,
|
|
@@ -346,21 +403,24 @@ def strata_parts(
|
|
|
346
403
|
ceiling,
|
|
347
404
|
available,
|
|
348
405
|
warnings,
|
|
406
|
+
floor=floor,
|
|
349
407
|
)
|
|
350
|
-
room = min(ceiling, available -
|
|
408
|
+
room = min(ceiling, available - floor) - used - sum(bounded_ram(p) for p in aux)
|
|
351
409
|
llm = _decide_parking(
|
|
352
410
|
llm, llm_recipe, facts, opts, options, running_llm is not None, room, warnings
|
|
353
411
|
)
|
|
354
|
-
|
|
412
|
+
if unified and "unified_bytes" not in llm["launch"]: # parking planned the LLM again
|
|
413
|
+
llm = _on_unified_memory(llm, llm_recipe)
|
|
414
|
+
whole = held(llm) + decide.host_ram(choice) + sum(map(bounded_ram, aux)) + HARNESS_RAM
|
|
355
415
|
if whole > ceiling:
|
|
356
416
|
raise StackError(
|
|
357
417
|
f"the whole-stack estimate {gib(whole)} exceeds --suite-memory {options['suite_memory']}"
|
|
358
418
|
)
|
|
359
|
-
if options["llm"] == "auto" and not running_llm and whole +
|
|
419
|
+
if options["llm"] == "auto" and not running_llm and whole + floor > available:
|
|
360
420
|
# stack_compose.assemble would refuse this plan outright; refusing here lets auto move
|
|
361
421
|
# on to a smaller recipe or to llama.cpp.
|
|
362
422
|
raise StackError(
|
|
363
|
-
f"its stack needs about {gib(whole +
|
|
423
|
+
f"its stack needs about {gib(whole + floor)} of RAM, {gib(available)} is available"
|
|
364
424
|
)
|
|
365
425
|
vram_needed = need + vram
|
|
366
426
|
if vram_needed > gpu["total_bytes"]:
|
|
@@ -371,7 +431,7 @@ def strata_parts(
|
|
|
371
431
|
return {
|
|
372
432
|
"llm": llm,
|
|
373
433
|
"llm_running": running_llm is not None,
|
|
374
|
-
"llm_ram":
|
|
434
|
+
"llm_ram": held(llm),
|
|
375
435
|
"decision": choice,
|
|
376
436
|
"aux": aux,
|
|
377
437
|
"ram_available": available,
|