@simplexai/localmodels-linux-x64 0.1.0-dev.36 → 0.1.0-dev.38
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 +132 -110
- package/kit.py +1 -0
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +9 -3
- package/modules/localmodels/bifrost_checks.py +9 -6
- package/modules/localmodels/bifrost_config.py +203 -0
- package/modules/localmodels/bifrost_datasheet.py +12 -2
- package/modules/localmodels/budget.py +13 -2
- package/modules/localmodels/catalog.json +137 -2
- package/modules/localmodels/catalog.py +70 -321
- package/modules/localmodels/catalog_add.py +2 -8
- package/modules/localmodels/catalog_recipes.py +352 -0
- package/modules/localmodels/cli_parser.py +4 -1
- package/modules/localmodels/console.py +5 -4
- package/modules/localmodels/contracts.py +13 -3
- package/modules/localmodels/debug_cli.py +158 -0
- package/modules/localmodels/debug_mode.py +727 -0
- package/modules/localmodels/debug_stub_server.py +192 -0
- package/modules/localmodels/decode_calibration.json +1 -1
- package/modules/localmodels/decode_calibration.py +34 -17
- package/modules/localmodels/gateway.py +21 -155
- package/modules/localmodels/gateway_accept.py +201 -0
- package/modules/localmodels/gateway_bifrost.py +30 -193
- package/modules/localmodels/gateway_cli.py +15 -6
- package/modules/localmodels/gateway_foundations.py +2 -4
- package/modules/localmodels/gateway_probe.py +0 -1
- package/modules/localmodels/gateway_server.py +2 -3
- package/modules/localmodels/gpu_specs.py +12 -0
- package/modules/localmodels/guard.py +2 -7
- package/modules/localmodels/harness.py +16 -129
- package/modules/localmodels/harness_cleanup.py +135 -0
- package/modules/localmodels/harness_gateway.py +16 -14
- package/modules/localmodels/harness_probe.py +12 -4
- package/modules/localmodels/hosts.py +25 -2
- package/modules/localmodels/http_local.py +59 -0
- package/modules/localmodels/install.py +23 -8
- package/modules/localmodels/library_gateway.py +20 -9
- package/modules/localmodels/library_jobs.py +125 -28
- package/modules/localmodels/library_model.py +10 -0
- package/modules/localmodels/library_pricing.py +29 -22
- package/modules/localmodels/library_serve.py +17 -1
- package/modules/localmodels/library_state.py +15 -2
- package/modules/localmodels/library_status.py +30 -0
- package/modules/localmodels/llm_rank.py +185 -39
- package/modules/localmodels/probe.py +108 -174
- package/modules/localmodels/process_identity.py +120 -154
- package/modules/localmodels/process_windows.py +86 -0
- package/modules/localmodels/recommend.py +6 -3
- package/modules/localmodels/recommend_cli.py +14 -6
- package/modules/localmodels/remote_ops.py +65 -0
- package/modules/localmodels/remote_ops_service.py +14 -2
- package/modules/localmodels/runtime_args.py +10 -3
- package/modules/localmodels/runtime_auth.py +5 -9
- package/modules/localmodels/runtime_cli.py +128 -129
- package/modules/localmodels/runtime_discovery.py +84 -0
- package/modules/localmodels/runtime_install.py +101 -0
- package/modules/localmodels/runtime_releases.py +302 -0
- package/modules/localmodels/search_server.py +5 -1
- package/modules/localmodels/service_stop.py +8 -108
- package/modules/localmodels/service_upgrade.py +394 -63
- package/modules/localmodels/services_cli.py +24 -14
- package/modules/localmodels/setup_inspection.py +97 -9
- package/modules/localmodels/setup_text.py +7 -0
- package/modules/localmodels/sizecalc.py +0 -1
- package/modules/localmodels/stack.py +45 -235
- package/modules/localmodels/stack_arena.py +732 -0
- package/modules/localmodels/stack_args.py +21 -12
- package/modules/localmodels/stack_auto.py +384 -3
- package/modules/localmodels/stack_aux_gpu.py +4 -3
- package/modules/localmodels/stack_capacity.py +138 -0
- package/modules/localmodels/stack_cleanup.py +9 -4
- package/modules/localmodels/stack_cli.py +288 -0
- package/modules/localmodels/stack_compose.py +63 -30
- package/modules/localmodels/stack_console.py +9 -6
- package/modules/localmodels/stack_hardware.py +95 -265
- package/modules/localmodels/stack_hardware_text.py +263 -0
- package/modules/localmodels/stack_journal.py +3 -9
- package/modules/localmodels/stack_ledger.py +48 -18
- package/modules/localmodels/stack_lifecycle.py +33 -312
- package/modules/localmodels/stack_llm_ram.py +16 -6
- package/modules/localmodels/stack_mcp.py +729 -0
- package/modules/localmodels/stack_memory.py +0 -2
- package/modules/localmodels/stack_picks.py +62 -15
- package/modules/localmodels/stack_plan.py +19 -1
- package/modules/localmodels/stack_preflight.py +11 -19
- package/modules/localmodels/stack_progress.py +9 -1
- package/modules/localmodels/stack_remove.py +373 -0
- package/modules/localmodels/stack_route.py +101 -17
- package/modules/localmodels/stack_run.py +29 -0
- package/modules/localmodels/stack_suite.py +21 -10
- package/modules/localmodels/stack_summary.py +14 -0
- package/modules/localmodels/stack_try.py +238 -24
- package/modules/localmodels/stack_try_client.py +53 -15
- package/modules/localmodels/stack_try_docs.py +2 -2
- package/modules/localmodels/stack_view.py +24 -171
- package/modules/localmodels/stack_view_access.py +114 -1
- package/modules/localmodels/stack_view_agent.py +3 -13
- package/modules/localmodels/stack_view_hub.py +9 -10
- package/modules/localmodels/stack_view_llm.py +1 -1
- package/modules/localmodels/stack_view_sandbox.py +2 -2
- package/modules/localmodels/stack_view_schema.py +183 -0
- package/modules/localmodels/stack_view_serve.py +7 -1
- package/modules/localmodels/stack_view_service.py +1 -2
- package/modules/localmodels/stack_view_text.py +13 -9
- package/modules/localmodels/stack_warm.py +48 -4
- package/modules/localmodels/stack_warm_store.py +517 -0
- package/modules/localmodels/tools.json +32 -18
- package/modules/localmodels/transport.py +38 -13
- package/modules/localmodels/tui.py +28 -4
- package/modules/localmodels/tui_dialogs.py +136 -0
- package/modules/localmodels/tui_modals.py +279 -0
- package/modules/localmodels/tui_screen.py +113 -154
- package/modules/localmodels/tui_views.py +134 -203
- package/modules/localmodels/web/index.html +510 -101
- package/modules/localmodels/web/sizecalc/app.js +363 -10
- package/modules/localmodels/web/sizecalc/page.html +27 -3
- package/modules/localmodels/web/view/fleet.html +11 -2
- package/modules/localmodels/web/view/fleet.js +191 -17
- package/modules/localmodels/web/view/i18n.js +3 -2
- package/modules/localmodels/web/view/index.html +1 -1
- package/modules/localmodels/web/view/nav.js +22 -3
- package/modules/localmodels/web/view/view.css +63 -18
- package/modules/localmodels/web/view/view.js +169 -32
- package/modules/localmodels/windows_job.py +69 -0
- package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/RECORD +128 -106
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/localmodels/engines-strata-0.1.49.1.json +0 -31
- /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev36.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
"""Read-only hardware readings, card budgets and
|
|
2
|
-
|
|
3
|
-
``stack plan`` uses the same card budgets, plus whole-stack RAM and disk checks for Strata.
|
|
4
|
-
A Mac shares unified memory; ``--unified-memory`` prices it as a smaller Mac.
|
|
5
|
-
Only probe readings are measurements. ``snapshot`` preserves them without binding approval.
|
|
6
|
-
"""
|
|
1
|
+
"""Read-only hardware readings, shared card budgets and llama.cpp capacity references."""
|
|
7
2
|
|
|
8
3
|
from __future__ import annotations
|
|
9
4
|
|
|
@@ -13,20 +8,47 @@ from collections.abc import Callable
|
|
|
13
8
|
from typing import Any, cast
|
|
14
9
|
|
|
15
10
|
from localmodels import catalog as cat
|
|
16
|
-
from localmodels import
|
|
11
|
+
from localmodels import (
|
|
12
|
+
catalog_recipes,
|
|
13
|
+
component,
|
|
14
|
+
context_policy,
|
|
15
|
+
gpu_specs,
|
|
16
|
+
llm_rank,
|
|
17
|
+
metal,
|
|
18
|
+
stack_capacity,
|
|
19
|
+
stack_warm_store,
|
|
20
|
+
suite,
|
|
21
|
+
)
|
|
17
22
|
from localmodels.budget import gib, holders, host_ram, placements, sharing_cards, unknown_services
|
|
18
23
|
from localmodels.context_policy import AGENT, AgentPosture, cache_floor_bytes, posture_for
|
|
19
24
|
from localmodels.estimator import (
|
|
20
|
-
AGENT_DISPLAY_RESERVE_BYTES,
|
|
21
25
|
AGENT_VRAM_RESERVE_BYTES,
|
|
22
|
-
AGENT_VRAM_SAFETY_BYTES,
|
|
23
26
|
METAL_VRAM_RESERVE_BYTES,
|
|
24
27
|
HardwareBudget,
|
|
25
28
|
)
|
|
26
29
|
from localmodels.probe import GPU, HostFacts
|
|
27
30
|
from localmodels.records import Plan
|
|
28
|
-
from localmodels.
|
|
29
|
-
|
|
31
|
+
from localmodels.stack_hardware_text import (
|
|
32
|
+
agent_label as agent_label,
|
|
33
|
+
)
|
|
34
|
+
from localmodels.stack_hardware_text import (
|
|
35
|
+
lines as lines,
|
|
36
|
+
)
|
|
37
|
+
from localmodels.stack_hardware_text import (
|
|
38
|
+
on_metal as on_metal,
|
|
39
|
+
)
|
|
40
|
+
from localmodels.stack_hardware_text import (
|
|
41
|
+
plan_card as plan_card,
|
|
42
|
+
)
|
|
43
|
+
from localmodels.stack_hardware_text import (
|
|
44
|
+
plan_lines as plan_lines,
|
|
45
|
+
)
|
|
46
|
+
from localmodels.stack_hardware_text import (
|
|
47
|
+
reboot_line as reboot_line,
|
|
48
|
+
)
|
|
49
|
+
from localmodels.stack_hardware_text import (
|
|
50
|
+
slow_warning as slow_warning,
|
|
51
|
+
)
|
|
30
52
|
from localmodels.stack_picks import picks
|
|
31
53
|
from localmodels.stack_plan import (
|
|
32
54
|
Card,
|
|
@@ -35,6 +57,7 @@ from localmodels.stack_plan import (
|
|
|
35
57
|
LlmFit,
|
|
36
58
|
StackError,
|
|
37
59
|
StackOptions,
|
|
60
|
+
default_options,
|
|
38
61
|
platform_error,
|
|
39
62
|
)
|
|
40
63
|
|
|
@@ -42,8 +65,6 @@ GIB = 1 << 30
|
|
|
42
65
|
TIERS_GIB = (8, 12, 16, 24, 32, 48, 96) # research/2026-10-24-vram-tier-stacks
|
|
43
66
|
_NOMINAL_SLACK = 1.1 # a 24 GB card reports 22.5–24 GiB; an 80 GB one is not a 96 GB card
|
|
44
67
|
_FIRST_TIER_RAM = 60 * GIB # 64 GB of RAM reads about 62 GiB
|
|
45
|
-
_MAC = "--unified-memory SIZE prices it as a smaller Mac" # the next step's option hint
|
|
46
|
-
_CARDS = "with several cards, --gpu N picks the card for the LLM and the decision model"
|
|
47
68
|
# ``--unified-memory`` when the option is not given: a front-end that runs this tool (the Simplex
|
|
48
69
|
# installer) passes its environment through, so the same ceiling reaches every plan it makes.
|
|
49
70
|
UNIFIED_MEMORY_ENV = "LOCALMODELS_UNIFIED_MEMORY"
|
|
@@ -63,8 +84,7 @@ def add_arguments(parser: argparse._ActionsContainer) -> None:
|
|
|
63
84
|
|
|
64
85
|
|
|
65
86
|
def with_platform_options(options: StackOptions, args: argparse.Namespace) -> StackOptions:
|
|
66
|
-
"""
|
|
67
|
-
them keep their ids; a front-end without the options (the TUI) passes them through."""
|
|
87
|
+
"""Add explicit platform options; fronts without them preserve the existing plan options."""
|
|
68
88
|
if profile := getattr(args, "profile", None):
|
|
69
89
|
options["profile"] = profile
|
|
70
90
|
if getattr(args, "unified_memory", None):
|
|
@@ -90,8 +110,7 @@ def assumed(facts: HostFacts, unified_memory: str | None) -> HostFacts:
|
|
|
90
110
|
|
|
91
111
|
|
|
92
112
|
def decision_reserve(card_budget_bytes: int, options: StackOptions) -> int:
|
|
93
|
-
"""
|
|
94
|
-
holds back before testing a candidate. 0 when the decision is disabled or nothing fits."""
|
|
113
|
+
"""Smallest decision reserve kept before auto selection; 0 if disabled or none fits."""
|
|
95
114
|
if str(options["decision"]) == "none" or card_budget_bytes <= 0:
|
|
96
115
|
return 0
|
|
97
116
|
recipes = cat.decision_components()
|
|
@@ -107,12 +126,7 @@ def decision_reserve(card_budget_bytes: int, options: StackOptions) -> int:
|
|
|
107
126
|
|
|
108
127
|
|
|
109
128
|
def cards(facts: HostFacts, gpu: int | None = None, *, share_gpu: bool = False) -> list[int]:
|
|
110
|
-
"""
|
|
111
|
-
Cards running foreign services are not candidates: choosing one would read as consent to
|
|
112
|
-
share. ``gpu`` (``--gpu``) narrows them to that card, conflicts included: the plan then
|
|
113
|
-
asks for ``--share-gpu`` like any named placement. A Mac has one card, its Metal GPU,
|
|
114
|
-
which another inference server on it does not take away: there is no other card to prefer,
|
|
115
|
-
and the plan asks for ``--share-gpu`` instead."""
|
|
129
|
+
"""Single-card choices by free memory; foreign GPU work needs explicit sharing."""
|
|
116
130
|
if share_gpu and unknown_services(facts):
|
|
117
131
|
raise StackError(
|
|
118
132
|
"GPU service owners unknown; explicit sharing cannot skip the unknown-service check"
|
|
@@ -130,6 +144,8 @@ def cards(facts: HostFacts, gpu: int | None = None, *, share_gpu: bool = False)
|
|
|
130
144
|
raise StackError(
|
|
131
145
|
f"no placeable GPU {gpu} here (usable cards: {found}; MIG-mode cards excluded)"
|
|
132
146
|
)
|
|
147
|
+
if share_gpu and gpu not in {g["index"] for g in sharing_cards(facts, 0)}:
|
|
148
|
+
raise StackError("GPU process owners unknown; cannot share this GPU")
|
|
133
149
|
return [gpu]
|
|
134
150
|
allowed = {g["index"] for g in sharing_cards(facts, 0)} if share_gpu else set()
|
|
135
151
|
free = [
|
|
@@ -143,8 +159,7 @@ def cards(facts: HostFacts, gpu: int | None = None, *, share_gpu: bool = False)
|
|
|
143
159
|
def check_shared_start(
|
|
144
160
|
part: Plan, facts: HostFacts, *, options: StackOptions | None = None, shared: bool = True
|
|
145
161
|
) -> None:
|
|
146
|
-
"""Recheck
|
|
147
|
-
discovery section read; an unshared ``stack up`` only who uses the GPUs."""
|
|
162
|
+
"""Recheck free VRAM and ownership before starting; sharing needs all discovery sections."""
|
|
148
163
|
from localmodels import budget, hosts, stack_lifecycle
|
|
149
164
|
|
|
150
165
|
services = facts.get("services")
|
|
@@ -170,6 +185,8 @@ def check_shared_start(
|
|
|
170
185
|
raise StackError("the GPU-sharing model has no VRAM budget or no approved GPU placement")
|
|
171
186
|
for target in assigned:
|
|
172
187
|
card = next((g for g in facts.get("gpus") or [] if g["uuid"] == target["uuid"]), None)
|
|
188
|
+
if shared and card and card["index"] not in {g["index"] for g in sharing_cards(facts, 0)}:
|
|
189
|
+
raise StackError("GPU process owners unknown; cannot start a shared model")
|
|
173
190
|
reserve = (
|
|
174
191
|
decision_reserve(component.auto_budget(card["total_bytes"]), options)
|
|
175
192
|
if card and options
|
|
@@ -208,26 +225,8 @@ def device(facts: HostFacts, index: int) -> GPU:
|
|
|
208
225
|
return next(g for g in facts.get("gpus") or [] if g["index"] == index)
|
|
209
226
|
|
|
210
227
|
|
|
211
|
-
def on_metal(part: Plan | None) -> bool:
|
|
212
|
-
"""The part runs on a Mac's Metal GPU."""
|
|
213
|
-
return part is not None and metal.on_device(part["placement"])
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def plan_card(part: Plan | None, facts: HostFacts) -> int | None:
|
|
217
|
-
"""Resolve the running service's CUDA UUID to its current host index (0 on a Mac)."""
|
|
218
|
-
if part is None:
|
|
219
|
-
return None
|
|
220
|
-
if on_metal(part):
|
|
221
|
-
return 0
|
|
222
|
-
devices = part["service"].get("env", {}).get("CUDA_VISIBLE_DEVICES")
|
|
223
|
-
if not isinstance(devices, str) or not devices or "," in devices:
|
|
224
|
-
return None
|
|
225
|
-
return next((g["index"] for g in facts.get("gpus") or [] if g["uuid"] == devices), None)
|
|
226
|
-
|
|
227
|
-
|
|
228
228
|
def held_elsewhere(name: str, part: Plan, gpu: int | None, facts: HostFacts) -> None:
|
|
229
|
-
"""Refuse reusing a running deployment
|
|
230
|
-
keeping it would silently drop the operator's choice."""
|
|
229
|
+
"""Refuse reusing a running deployment on another card than ``--gpu`` names."""
|
|
231
230
|
card = plan_card(part, facts)
|
|
232
231
|
placed = part["placement"].get("gpus")
|
|
233
232
|
had_gpu_binding = bool(placed) or bool(
|
|
@@ -277,8 +276,7 @@ def llm_budget(
|
|
|
277
276
|
entry: cat.CatalogEntry | None = None,
|
|
278
277
|
posture: AgentPosture = AGENT,
|
|
279
278
|
) -> tuple[HardwareBudget, int]:
|
|
280
|
-
"""Live
|
|
281
|
-
On a Mac also reserve embeddings and the cache floor; carry bandwidth for speed estimates."""
|
|
279
|
+
"""Live LLM budget and decision reserve, including safety, display and Metal host costs."""
|
|
282
280
|
gpu = device(facts, index)
|
|
283
281
|
on_mac = gpu["uuid"] == metal.METAL_UUID
|
|
284
282
|
reserve = decision_reserve(component.auto_budget(gpu["total_bytes"]), options)
|
|
@@ -293,7 +291,7 @@ def llm_budget(
|
|
|
293
291
|
usable = free - (METAL_VRAM_RESERVE_BYTES if on_mac else AGENT_VRAM_RESERVE_BYTES) - reserve
|
|
294
292
|
budget = HardwareBudget(
|
|
295
293
|
usable_vram_bytes=max(0, usable),
|
|
296
|
-
total_device_bytes=
|
|
294
|
+
total_device_bytes=gpu["total_bytes"],
|
|
297
295
|
ram_available_bytes=0,
|
|
298
296
|
uma=on_mac,
|
|
299
297
|
gpu_name=gpu["name"],
|
|
@@ -307,9 +305,16 @@ def llm_fits(
|
|
|
307
305
|
facts: HostFacts, index: int, options: StackOptions, posture: AgentPosture
|
|
308
306
|
) -> list[LlmFit]:
|
|
309
307
|
"""Automatic candidates priced with their own embeddings and cache."""
|
|
308
|
+
from localmodels import stack_auto
|
|
309
|
+
|
|
310
310
|
if device(facts, index)["uuid"] == metal.METAL_UUID:
|
|
311
311
|
posture = posture_for(posture, "metal")
|
|
312
|
-
|
|
312
|
+
merged: StackOptions = {**default_options(), **options}
|
|
313
|
+
capped = stack_auto.maybe_capped(facts, merged)
|
|
314
|
+
if capped is None:
|
|
315
|
+
return []
|
|
316
|
+
facts = capped
|
|
317
|
+
found: list[tuple[tuple[int, float], LlmFit]] = []
|
|
313
318
|
for entry in (
|
|
314
319
|
e
|
|
315
320
|
for e in cat.load_catalog_file()
|
|
@@ -317,18 +322,33 @@ def llm_fits(
|
|
|
317
322
|
):
|
|
318
323
|
variant = entry.variants[-1]
|
|
319
324
|
budget, _ = llm_budget(facts, index, options, entry=entry, posture=posture)
|
|
320
|
-
|
|
325
|
+
fits = (
|
|
326
|
+
llm_rank.automatic_fit(entry, facts, budget, posture, options)
|
|
327
|
+
if budget.uma
|
|
328
|
+
else stack_auto.llama_ram_fits(facts, merged, entry, index, posture, budget=budget)
|
|
329
|
+
)
|
|
330
|
+
if fits:
|
|
321
331
|
speed = cat.decode_estimate(entry, variant, budget)
|
|
332
|
+
unscored = llm_rank.windows_fallback(entry, facts) or llm_rank.mac_rung(entry, facts)
|
|
322
333
|
fit: LlmFit = {
|
|
323
334
|
"id": entry.id,
|
|
324
335
|
"quant": variant.quant,
|
|
325
|
-
"quality": 0 if
|
|
336
|
+
"quality": 0 if unscored else entry.quality,
|
|
326
337
|
"decode_tok_s": round(speed.tok_s, 1),
|
|
327
338
|
"decode_basis": speed.basis,
|
|
328
339
|
}
|
|
340
|
+
stack_warm_store.apply_fit_measurement(facts, index, fit)
|
|
329
341
|
if llm_rank.windows_fallback(entry, facts):
|
|
330
342
|
fit["candidate_fallback"] = True
|
|
331
|
-
|
|
343
|
+
tok_s = float(fit["decode_tok_s"]) if fit["decode_tok_s"] is not None else -1.0
|
|
344
|
+
found.append((((0 if unscored else entry.quality), tok_s), fit))
|
|
345
|
+
|
|
346
|
+
llama_score = max(
|
|
347
|
+
(f["quality"] for _, f in found if not f.get("candidate_fallback")), default=-1
|
|
348
|
+
)
|
|
349
|
+
for fit in stack_auto.card_fits(facts, index, options, llama_score):
|
|
350
|
+
stack_warm_store.apply_fit_measurement(facts, index, fit)
|
|
351
|
+
found.append(((fit["quality"], -1.0), fit))
|
|
332
352
|
found = [row for row in found if not row[1].get("candidate_fallback")] or found
|
|
333
353
|
default_id = llm_rank.listed_default(facts, [(f["id"], f["quality"]) for _, f in found])
|
|
334
354
|
return [
|
|
@@ -414,7 +434,7 @@ def _card(
|
|
|
414
434
|
budget, reserve = llm_budget(facts, g["index"], options)
|
|
415
435
|
gen, width = g.get("pcie_gen"), g.get("pcie_width")
|
|
416
436
|
on_mac = g["uuid"] == metal.METAL_UUID
|
|
417
|
-
|
|
437
|
+
shown: Card = {
|
|
418
438
|
"index": g["index"],
|
|
419
439
|
"uuid": g["uuid"],
|
|
420
440
|
"name": g["name"],
|
|
@@ -438,11 +458,30 @@ def _card(
|
|
|
438
458
|
if posture is not None and not mig
|
|
439
459
|
else [],
|
|
440
460
|
}
|
|
461
|
+
if posture is not None and not mig and not on_mac:
|
|
462
|
+
shown["capacity"] = stack_capacity.rows(facts, g["index"], options, posture)
|
|
463
|
+
return shown
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
def _set_linux_note(facts: HostFacts, notes: list[str], cards: list[Card]) -> None:
|
|
467
|
+
strata_ids = {
|
|
468
|
+
c["id"] for c in catalog_recipes.components() if c["runtime"] in ("strata", "strata-poly")
|
|
469
|
+
}
|
|
470
|
+
if facts["platform"] == "linux" and any(
|
|
471
|
+
f["decode_tok_s"] is None or f["id"] in strata_ids for c in cards for f in c["llm"]
|
|
472
|
+
):
|
|
473
|
+
notes[0] = (
|
|
474
|
+
"per-card LLM lists include validated Strata/PolyStrata recipes whose "
|
|
475
|
+
"whole-stack RAM and disk fit"
|
|
476
|
+
)
|
|
441
477
|
|
|
442
478
|
|
|
443
479
|
def view(facts: HostFacts, options: StackOptions, posture: AgentPosture | None) -> Hardware:
|
|
444
480
|
"""The hardware as ``stack`` prices it; ``posture`` None leaves the LLM lists empty."""
|
|
481
|
+
from localmodels import stack_auto
|
|
482
|
+
|
|
445
483
|
facts, pressure_notes = metal.pressured(facts)
|
|
484
|
+
facts = stack_auto.maybe_capped(facts, {**default_options(), **options}) or facts
|
|
446
485
|
total, available = host_ram(facts)
|
|
447
486
|
os_info = facts.get("os") or {}
|
|
448
487
|
driver = (facts.get("nvidia") or {}).get("driver_version")
|
|
@@ -470,6 +509,8 @@ def view(facts: HostFacts, options: StackOptions, posture: AgentPosture | None)
|
|
|
470
509
|
if options.get("profile") != "macos-mlx-preview" and (error := metal.problem(facts)):
|
|
471
510
|
notes.append(error)
|
|
472
511
|
notes += pressure_notes
|
|
512
|
+
if facts["platform"] == "win32" and facts.get("gpus"):
|
|
513
|
+
notes.append(stack_capacity.WDDM_NOTE)
|
|
473
514
|
mac = metal.device(facts)
|
|
474
515
|
if mac is not None:
|
|
475
516
|
notes.append(
|
|
@@ -525,222 +566,11 @@ def view(facts: HostFacts, options: StackOptions, posture: AgentPosture | None)
|
|
|
525
566
|
if manager := facts.get("service_manager"):
|
|
526
567
|
seen["service_manager"] = manager
|
|
527
568
|
if posture is not None:
|
|
528
|
-
|
|
569
|
+
_set_linux_note(facts, notes, seen["cards"])
|
|
570
|
+
seen["picks"] = picks(seen["cards"], llm_rank.mac_ladder(facts))
|
|
529
571
|
return seen
|
|
530
572
|
|
|
531
573
|
|
|
532
574
|
def snapshot(facts: HostFacts, options: StackOptions) -> Hardware:
|
|
533
575
|
"""The copy a stack plan keeps: the readings it was priced against, without LLM lists."""
|
|
534
576
|
return view(facts, options, None)
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
def _card_head(c: Card) -> str:
|
|
538
|
-
arch = c["architecture"] or ""
|
|
539
|
-
if c["compute_capability"]:
|
|
540
|
-
arch = f"{arch} (compute capability {c['compute_capability']})".lstrip()
|
|
541
|
-
traits = [
|
|
542
|
-
t
|
|
543
|
-
for t in (
|
|
544
|
-
arch,
|
|
545
|
-
f"PCIe {c['pcie']}" if c["pcie"] else "",
|
|
546
|
-
{True: "display attached", False: "no display", None: ""}[c["display_active"]],
|
|
547
|
-
"MIG on" if c["mig"] else "",
|
|
548
|
-
)
|
|
549
|
-
if t
|
|
550
|
-
]
|
|
551
|
-
return f"GPU {c['index']} {c['name']}" + "".join(f" · {t}" for t in traits)
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
def lines(hw: Hardware, command: str) -> list[str]:
|
|
555
|
-
"""What ``stack hardware`` prints."""
|
|
556
|
-
out = [
|
|
557
|
-
f"Hardware of {hw['hostname']} (collected {console.local_time(hw['collected_at'])} local time; "
|
|
558
|
-
f"{hw['system'] or 'system unknown'})"
|
|
559
|
-
]
|
|
560
|
-
if not hw["cards"]:
|
|
561
|
-
out.append(
|
|
562
|
-
" GPU Apple Silicon Metal working set unknown"
|
|
563
|
-
if hw.get("platform") == "darwin" and hw.get("arch") == "arm64"
|
|
564
|
-
else " GPU no NVIDIA GPU found"
|
|
565
|
-
)
|
|
566
|
-
for c in hw["cards"]:
|
|
567
|
-
reserved = f", driver reserved {gib(c['reserved_bytes'])}" if c["reserved_bytes"] else ""
|
|
568
|
-
on_mac = c.get("uuid") == metal.METAL_UUID
|
|
569
|
-
out += [
|
|
570
|
-
f" {_card_head(c)}",
|
|
571
|
-
f" Metal working-set limit {gib(c['total_bytes'])}; the memory available "
|
|
572
|
-
f"now can give the GPU {gib(c['free_bytes'])}"
|
|
573
|
-
if on_mac
|
|
574
|
-
else f" VRAM {gib(c['total_bytes'])}: used {gib(c['used_bytes'])}, "
|
|
575
|
-
f"free {gib(c['free_bytes'])}{reserved}",
|
|
576
|
-
]
|
|
577
|
-
if c["mig"]:
|
|
578
|
-
out.append(
|
|
579
|
-
" in MIG mode CUDA sees only the instances; this tool places nothing "
|
|
580
|
-
"on this card"
|
|
581
|
-
)
|
|
582
|
-
continue
|
|
583
|
-
out.append(
|
|
584
|
-
f" LLM may use {gib(c['llm_bytes'])} (free less a "
|
|
585
|
-
f"{AGENT_VRAM_SAFETY_BYTES >> 20} MiB safety margin and a "
|
|
586
|
-
f"{AGENT_DISPLAY_RESERVE_BYTES >> 20} MiB display reserve"
|
|
587
|
-
+ (", kept even with no display attached" if c["display_active"] is False else "")
|
|
588
|
-
+ (
|
|
589
|
-
f", less the smallest decision reserve {gib(c['decision_reserve_bytes'])}"
|
|
590
|
-
if c["decision_reserve_bytes"]
|
|
591
|
-
else ""
|
|
592
|
-
)
|
|
593
|
-
+ ")"
|
|
594
|
-
)
|
|
595
|
-
out.append(
|
|
596
|
-
f" spec memory bandwidth {c['bandwidth_gb_s']:g} GB/s "
|
|
597
|
-
"(vendor spec, not measured)"
|
|
598
|
-
if c["bandwidth_gb_s"]
|
|
599
|
-
else " memory bandwidth: speed is estimated from "
|
|
600
|
-
f"{cat.DECODE_BASES['uma-class']} (not measured)"
|
|
601
|
-
if on_mac
|
|
602
|
-
else " memory bandwidth: the model is not in the spec table; speed is "
|
|
603
|
-
f"estimated from {cat.DECODE_BASES['discrete-class']}"
|
|
604
|
-
)
|
|
605
|
-
if c["display_active"]:
|
|
606
|
-
out.append(
|
|
607
|
-
" a display is attached: the desktop takes VRAM that changes at any "
|
|
608
|
-
"time; the plan prices what is free now"
|
|
609
|
-
)
|
|
610
|
-
if c["held_by"]:
|
|
611
|
-
out.append(" held by: " + "; ".join(c["held_by"]))
|
|
612
|
-
fits = [fit_label(f) for f in c["llm"][:3]]
|
|
613
|
-
shown = f"top 3 of {len(c['llm'])}" if len(c["llm"]) > 3 else f"{len(fits)} in all"
|
|
614
|
-
out.append(
|
|
615
|
-
f" llama.cpp LLMs that fit (agent posture, automatic eligibility, {shown}): "
|
|
616
|
-
+ ", ".join(fits)
|
|
617
|
-
if fits
|
|
618
|
-
else " LLMs that fit: no validated LLM fits this card in the agent posture"
|
|
619
|
-
)
|
|
620
|
-
if fits and not c["auto"]:
|
|
621
|
-
out.append(
|
|
622
|
-
" another inference service runs on the Metal GPU; once sharing with "
|
|
623
|
-
"it is confirmed, add --share-gpu to stack plan"
|
|
624
|
-
if on_mac
|
|
625
|
-
else " other programs' services run on this card, so --llm auto skips "
|
|
626
|
-
f"it; when sharing is confirmed, use --gpu {c['index']} --share-gpu"
|
|
627
|
-
)
|
|
628
|
-
slow = [f for f in c["llm"][:1] if f["decode_tok_s"] < cat.PLEASANT_FLOOR_TOK_S]
|
|
629
|
-
if slow:
|
|
630
|
-
out.append(
|
|
631
|
-
" note: the first choice's estimated decode is below the "
|
|
632
|
-
f"pleasant floor of {cat.PLEASANT_FLOOR_TOK_S:g} tok/s"
|
|
633
|
-
)
|
|
634
|
-
out.append(
|
|
635
|
-
f" RAM {gib(hw['ram_total_bytes'])}, available {gib(hw['ram_available_bytes'])}"
|
|
636
|
-
)
|
|
637
|
-
free = hw["disk_free_bytes"]
|
|
638
|
-
out.append(
|
|
639
|
-
f" disk {hw['disk_path']}: {gib(free) if free is not None else 'unknown'} free"
|
|
640
|
-
)
|
|
641
|
-
out.append(f" tier {hw['tier']}")
|
|
642
|
-
refused = platform_error(hw.get("platform", "linux"), arch=hw.get("arch"))
|
|
643
|
-
out += pick_lines(hw.get("picks") or [], None if refused else command)
|
|
644
|
-
out += [f" note {n}" for n in hw["notes"]]
|
|
645
|
-
mac = any(c.get("uuid") == metal.METAL_UUID for c in hw["cards"])
|
|
646
|
-
out.append(
|
|
647
|
-
"Planning is not possible now: fix the probe or resource problem first, then check the "
|
|
648
|
-
"hardware again."
|
|
649
|
-
if hw.get("planning_problem")
|
|
650
|
-
else "This platform can check its hardware; run the full suite on a supported Linux host "
|
|
651
|
-
"or an Apple Silicon Mac."
|
|
652
|
-
if platform_error(hw.get("platform", "linux"), arch=hw.get("arch"))
|
|
653
|
-
else f"Next: {command} install (plan, confirm once, install and verify), or {command} "
|
|
654
|
-
f"stack plan to only see and save the plan ({_MAC if mac else _CARDS})"
|
|
655
|
-
)
|
|
656
|
-
return out
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
def plan_lines(hw: Hardware, llm: Plan, *, decision: bool = True) -> list[str]:
|
|
660
|
-
"""The hardware lines a stack plan summary opens with; the LLM's card is marked, and named
|
|
661
|
-
as the decision model's too when the plan has one (it only ever shares the LLM's card)."""
|
|
662
|
-
devices = llm["service"].get("env", {}).get("CUDA_VISIBLE_DEVICES")
|
|
663
|
-
llm_uuid = devices if isinstance(devices, str) and devices and "," not in devices else None
|
|
664
|
-
if on_metal(llm):
|
|
665
|
-
llm_uuid = metal.METAL_UUID
|
|
666
|
-
out = []
|
|
667
|
-
for c in hw["cards"]:
|
|
668
|
-
bandwidth = f", spec bandwidth {c['bandwidth_gb_s']:g} GB/s" if c["bandwidth_gb_s"] else ""
|
|
669
|
-
here = llm_uuid is not None and c.get("uuid") == llm_uuid
|
|
670
|
-
mark = (" (LLM and decision)" if decision else " (LLM)") if here else ""
|
|
671
|
-
if c.get("uuid") == metal.METAL_UUID:
|
|
672
|
-
out.append(
|
|
673
|
-
f" hardware GPU 0 {c['name']}{mark}: Metal working-set limit "
|
|
674
|
-
f"{gib(c['total_bytes'])}, {gib(c['free_bytes'])} for the GPU when planned "
|
|
675
|
-
"(unified memory)"
|
|
676
|
-
)
|
|
677
|
-
continue
|
|
678
|
-
out.append(
|
|
679
|
-
f" hardware GPU {c['index']} {c['name']}{mark}: VRAM {gib(c['total_bytes'])}, "
|
|
680
|
-
f"free when planned {gib(c['free_bytes'])}{bandwidth}"
|
|
681
|
-
)
|
|
682
|
-
out.append(
|
|
683
|
-
f" hardware RAM {gib(hw['ram_total_bytes'])}, available when planned "
|
|
684
|
-
f"{gib(hw['ram_available_bytes'])}; {hw['tier']}"
|
|
685
|
-
)
|
|
686
|
-
return out
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
def reboot_line(hw: Hardware | None, llm: Plan, command: str) -> str:
|
|
690
|
-
"""What a reboot does to the planned services, and the one command that changes it."""
|
|
691
|
-
kind = llm["service"]["kind"]
|
|
692
|
-
if kind == "systemd-user":
|
|
693
|
-
manager = hw.get("service_manager") if hw else None
|
|
694
|
-
if manager and manager["linger"]:
|
|
695
|
-
return (
|
|
696
|
-
" reboot the services start at boot (systemd --user, linger on); nothing to "
|
|
697
|
-
f"run; {command} stack up checks them and starts any that are missing"
|
|
698
|
-
)
|
|
699
|
-
return " reboot the services start when you log in (systemd --user)" + (
|
|
700
|
-
"; linger is off, so they do not start at boot until someone logs in. To start "
|
|
701
|
-
"them at boot, run once: loginctl enable-linger"
|
|
702
|
-
if manager
|
|
703
|
-
else ""
|
|
704
|
-
)
|
|
705
|
-
if kind == "launchd-user":
|
|
706
|
-
return (
|
|
707
|
-
" reboot the launchd jobs belong to the current login session; after a reboot "
|
|
708
|
-
f"run {command} stack up to start them"
|
|
709
|
-
)
|
|
710
|
-
return (
|
|
711
|
-
" reboot the services run under nohup and do not come back after a reboot; run "
|
|
712
|
-
f"{command} stack up to start them, without reinstalling"
|
|
713
|
-
)
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
def slow_warning(facts: HostFacts, llm: Plan) -> list[str]:
|
|
717
|
-
"""A note when the stack's LLM, priced at its card's spec bandwidth, decodes below the
|
|
718
|
-
pleasant floor; silent where the card model has no published figure."""
|
|
719
|
-
model, index = llm["model"], plan_card(llm, facts)
|
|
720
|
-
gpu = next((g for g in facts.get("gpus") or [] if g["index"] == index), None)
|
|
721
|
-
entry = next((e for e in cat.load_catalog_file() if e.id == model.get("id")), None)
|
|
722
|
-
variant = (
|
|
723
|
-
next((v for v in entry.variants if v.quant == model.get("quant")), None) if entry else None
|
|
724
|
-
)
|
|
725
|
-
bandwidth = gpu_specs.bandwidth_gb_s(gpu["name"]) if gpu else None
|
|
726
|
-
if entry is None or variant is None or gpu is None or bandwidth is None:
|
|
727
|
-
return []
|
|
728
|
-
budget = HardwareBudget(0, 0, 0, gpu_bandwidth_gb_s=bandwidth)
|
|
729
|
-
tok_s = cat.decode_estimate(entry, variant, budget).tok_s
|
|
730
|
-
if tok_s >= cat.PLEASANT_FLOOR_TOK_S:
|
|
731
|
-
return []
|
|
732
|
-
return [
|
|
733
|
-
f"LLM: at the {gpu['name']} spec memory bandwidth of {bandwidth:g} GB/s, single-stream "
|
|
734
|
-
f"decode is about {tok_s:.0f} tok/s (estimate), below the pleasant floor of "
|
|
735
|
-
f"{cat.PLEASANT_FLOOR_TOK_S:g} tok/s; --llm can pick a smaller model"
|
|
736
|
-
]
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
def agent_label(llm: Plan) -> str:
|
|
740
|
-
"""The concurrency and KV types an agent-posture LLM launches with; empty otherwise."""
|
|
741
|
-
launch = llm["launch"]
|
|
742
|
-
if launch.get("posture") != "agent":
|
|
743
|
-
return ""
|
|
744
|
-
kv = launch.get("kv_types")
|
|
745
|
-
pair = [str(t) for t in kv] if isinstance(kv, list) else ["q8_0", "q8_0"]
|
|
746
|
-
return f"{launch.get('slots')} parallel sessions sharing the KV ({'/'.join(pair)}), "
|