@simplexai/localmodels-linux-arm64 0.1.0-dev.103 → 0.1.0-dev.105
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/LICENSE +201 -0
- package/{modules/simplex_localmodels-0.1.0.dev103.dist-info/licenses/NOTICE → NOTICE} +42 -13
- package/README.md +10 -0
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +159 -158
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +204 -86
- package/modules/localmodels/apple_sensors.py +23 -0
- package/modules/localmodels/approval.py +25 -2
- package/modules/localmodels/catalog.json +584 -158
- package/modules/localmodels/catalog.py +18 -3
- package/modules/localmodels/catalog_recipes.py +64 -6
- package/modules/localmodels/cli_help.py +10 -0
- package/modules/localmodels/cli_parser.py +313 -230
- package/modules/localmodels/component.py +21 -3
- package/modules/localmodels/console.py +1 -1
- package/modules/localmodels/context_policy.py +6 -5
- package/modules/localmodels/custom_probe.py +4 -2
- package/modules/localmodels/debug_cli.py +0 -12
- package/modules/localmodels/debug_mode.py +0 -6
- package/modules/localmodels/decode_calibration.json +3 -4
- package/modules/localmodels/decode_calibration.py +5 -2
- package/modules/localmodels/deploy.py +11 -1
- package/modules/localmodels/deployment_lifecycle.py +1 -1
- package/modules/localmodels/download-mirrors.json +1 -1
- package/modules/localmodels/engine_adapters/base.py +11 -1
- package/modules/localmodels/engine_adapters/strata_poly.py +65 -3
- package/modules/localmodels/engine_adapters/suite_plan.py +61 -24
- package/modules/localmodels/engines-b11583.json +6 -26
- package/modules/localmodels/engines-b12588-mix-c0c3de8.json +3 -15
- package/modules/localmodels/engines-b12757-mix-ef2df21.json +3 -15
- package/modules/localmodels/engines-prism-b12178-03ec600.json +3 -15
- package/modules/localmodels/engines-speechcpp-v0.11.3.json +4 -20
- package/modules/localmodels/engines-strata-0.1.47.json +1 -5
- package/modules/localmodels/engines-strata-0.1.49.2.json +1 -5
- package/modules/localmodels/engines-strata-0.1.59.1.json +1 -5
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.1.json +6 -30
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.9.json +129 -0
- package/modules/localmodels/engines-whisper-b5454.json +6 -30
- package/modules/localmodels/engines.json +13 -61
- package/modules/localmodels/estimator.py +10 -5
- package/modules/localmodels/gpu_specs.py +1 -1
- package/modules/localmodels/host_sensors.py +25 -2
- package/modules/localmodels/hosts.py +38 -21
- package/modules/localmodels/kokoro-tts-0.6.1.txt +1 -1
- package/modules/localmodels/library_cli.py +34 -16
- package/modules/localmodels/library_custom.py +9 -1
- package/modules/localmodels/library_direct.py +41 -1
- package/modules/localmodels/library_elastic.py +135 -6
- package/modules/localmodels/library_jobs.py +23 -4
- package/modules/localmodels/library_kept.py +9 -1
- package/modules/localmodels/library_model.py +174 -2
- package/modules/localmodels/library_order.py +175 -69
- package/modules/localmodels/library_poly.py +150 -21
- package/modules/localmodels/library_presentation.py +485 -0
- package/modules/localmodels/library_pricing.py +15 -4
- package/modules/localmodels/library_serve.py +342 -70
- package/modules/localmodels/library_smoke.py +63 -5
- package/modules/localmodels/library_state.py +48 -10
- package/modules/localmodels/library_status.py +37 -17
- package/modules/localmodels/llm_rank.py +22 -11
- package/modules/localmodels/metal.py +1 -2
- package/modules/localmodels/plan_envelope.py +40 -13
- package/modules/localmodels/planning/budget.py +14 -12
- package/modules/localmodels/planning/memory_pools.py +7 -1
- package/modules/localmodels/privacy_acceptance.py +6 -5
- package/modules/localmodels/probe.py +34 -7
- package/modules/localmodels/py.typed +0 -0
- package/modules/localmodels/quant_formats.py +10 -3
- package/modules/localmodels/recommend_cli.py +1 -1
- package/modules/localmodels/records.py +19 -2
- package/modules/localmodels/remote_ops_launchd.py +8 -1
- package/modules/localmodels/remote_ops_verify.py +91 -24
- package/modules/localmodels/runtime_index.py +303 -0
- package/modules/localmodels/runtime_process.py +1 -1
- package/modules/localmodels/service_deployment.py +2 -4
- package/modules/localmodels/service_probe.py +59 -13
- package/modules/localmodels/setup_inspection.py +94 -73
- package/modules/localmodels/setup_text.py +7 -56
- package/modules/localmodels/sidecar_downloads.py +34 -0
- package/modules/localmodels/sidecar_http.py +61 -5
- package/modules/localmodels/sidecar_state.py +52 -2
- package/modules/localmodels/speech_admission.py +20 -4
- package/modules/localmodels/speech_catalog.py +23 -0
- package/modules/localmodels/speech_cli.py +30 -16
- package/modules/localmodels/speech_jobs.py +42 -17
- package/modules/localmodels/speech_serve.py +9 -2
- package/modules/localmodels/speech_server.py +185 -81
- package/modules/localmodels/speech_state.py +4 -1
- package/modules/localmodels/speech_workers.py +11 -0
- package/modules/localmodels/stack.py +1 -1
- package/modules/localmodels/stack_args.py +276 -145
- package/modules/localmodels/stack_auto.py +91 -6
- package/modules/localmodels/stack_aux_gpu.py +1 -1
- package/modules/localmodels/stack_cleanup.py +21 -18
- package/modules/localmodels/stack_cli.py +120 -115
- package/modules/localmodels/stack_compose.py +16 -5
- package/modules/localmodels/stack_debug.py +15 -6
- package/modules/localmodels/stack_decision.py +4 -4
- package/modules/localmodels/stack_doctor.py +2 -2
- package/modules/localmodels/stack_down.py +2 -0
- package/modules/localmodels/stack_events.py +1 -1
- package/modules/localmodels/stack_gpu_memory.py +1 -1
- package/modules/localmodels/stack_hardware.py +17 -15
- package/modules/localmodels/stack_mcp.py +1 -2
- package/modules/localmodels/stack_mlx.py +8 -1
- package/modules/localmodels/stack_picks.py +20 -21
- package/modules/localmodels/stack_plan.py +12 -11
- package/modules/localmodels/stack_ports.py +31 -4
- package/modules/localmodels/stack_review.py +28 -7
- package/modules/localmodels/stack_rollback.py +1 -1
- package/modules/localmodels/stack_run.py +1 -1
- package/modules/localmodels/stack_suite.py +72 -21
- package/modules/localmodels/stack_up.py +2 -0
- package/modules/localmodels/stack_view.py +180 -35
- package/modules/localmodels/stack_view_agent.py +1 -1
- package/modules/localmodels/stack_view_demo.py +2 -0
- package/modules/localmodels/stack_view_gpu.py +36 -2
- package/modules/localmodels/stack_view_schema.py +26 -3
- package/modules/localmodels/stack_view_serve.py +0 -2
- package/modules/localmodels/stack_view_slots.py +3 -1
- package/modules/localmodels/stack_view_telemetry.py +90 -4
- package/modules/localmodels/stack_view_tick.py +246 -40
- package/modules/localmodels/stack_view_words.py +9 -2
- package/modules/localmodels/stack_warm.py +2 -2
- package/modules/localmodels/stack_whatif.py +524 -41
- package/modules/localmodels/stack_whatif_html.py +900 -0
- package/modules/localmodels/startlux-decide-83fe6c7d.txt +2 -2
- package/modules/localmodels/{strata-poly-serve-0.2.20-poly.7.txt → strata-poly-serve-0.2.20-poly.9.txt} +1 -1
- package/modules/localmodels/strata_poly_server.py +114 -3
- package/modules/localmodels/suite.py +265 -6
- package/modules/localmodels/telemetry_math.py +458 -18
- package/modules/localmodels/transport.py +8 -1
- package/modules/localmodels/tts_admission.py +2 -17
- package/modules/localmodels/tts_catalog.py +29 -1
- package/modules/localmodels/tts_cli.py +45 -22
- package/modules/localmodels/tts_http.py +10 -4
- package/modules/localmodels/tts_jobs.py +49 -19
- package/modules/localmodels/tts_serve.py +9 -2
- package/modules/localmodels/tts_server.py +1 -1
- package/modules/localmodels/tts_sidecar.py +69 -28
- package/modules/localmodels/tts_state.py +7 -2
- package/modules/localmodels/vision.py +5 -3
- package/modules/localmodels/web/view/ASSET-SOURCES.md +4 -7
- package/modules/localmodels/web/view/view.css +0 -1
- package/modules/localmodels/web/view/view.js +2 -5
- package/modules/localmodels/web/whatif/app.js +730 -0
- package/modules/localmodels/web/whatif/page.html +1172 -0
- package/modules/localmodels/web/whatif/sim.js +297 -0
- package/modules/localmodels/win_probe.py +89 -16
- package/modules/localmodels/windows_job.py +179 -11
- package/modules/simplex_localmodels-0.1.0.dev105.dist-info/METADATA +14 -0
- package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +151 -145
- package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/LICENSE +201 -0
- package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/NOTICE +126 -0
- package/package.json +11 -2
- package/tool.json +1 -1
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.7.json +0 -94
- package/modules/localmodels/fixtures/stack-research-demo-plan.json +0 -1059
- package/modules/localmodels/stack_research.py +0 -716
- package/modules/localmodels/stack_research_demo.py +0 -125
- package/modules/localmodels/stack_research_plan.py +0 -146
- package/modules/localmodels/web/index.html +0 -2605
- package/modules/localmodels/web/sizecalc/app.js +0 -1306
- package/modules/localmodels/web/sizecalc/calc.js +0 -269
- package/modules/localmodels/web/sizecalc/page.html +0 -520
- package/modules/localmodels/web/view/logo-claude.svg +0 -3
- package/modules/localmodels/web/view/logo-codex.png +0 -0
- package/modules/simplex_localmodels-0.1.0.dev103.dist-info/METADATA +0 -9
- /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
"""Structured presentation metadata for ``library-status/v1`` rows and ``v1 PlanSummary``.
|
|
2
|
+
|
|
3
|
+
Keeps Linger free of regexes, hardcoded model-rank tables and bit-width heuristics: every
|
|
4
|
+
grouping slug, display title, quantization method/fidelity/BPW, engine display label, offload
|
|
5
|
+
mode, baseline savings comparison and recommendation reason comes directly from catalog and
|
|
6
|
+
planner truth.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from collections.abc import Mapping, Sequence
|
|
13
|
+
from typing import cast
|
|
14
|
+
|
|
15
|
+
from localmodels import catalog as cat
|
|
16
|
+
from localmodels import (
|
|
17
|
+
catalog_recipes,
|
|
18
|
+
library_order,
|
|
19
|
+
metal,
|
|
20
|
+
quant_formats,
|
|
21
|
+
suite,
|
|
22
|
+
)
|
|
23
|
+
from localmodels.estimator import HardwareBudget
|
|
24
|
+
from localmodels.library_model import (
|
|
25
|
+
ENGINE_DISPLAY_NAMES,
|
|
26
|
+
BaselineComparison,
|
|
27
|
+
Engine,
|
|
28
|
+
EngineDisplayName,
|
|
29
|
+
OffloadMode,
|
|
30
|
+
QuantFidelity,
|
|
31
|
+
QuantMethod,
|
|
32
|
+
RecommendationReason,
|
|
33
|
+
Row,
|
|
34
|
+
)
|
|
35
|
+
from localmodels.library_pricing import Model
|
|
36
|
+
from localmodels.planning import budget, memory_pools
|
|
37
|
+
from localmodels.probe import GPU, HostFacts
|
|
38
|
+
from localmodels.records import Plan
|
|
39
|
+
|
|
40
|
+
_SLUG_BAD_RE = re.compile(r"[^a-z0-9._-]+")
|
|
41
|
+
_LONG_CONTEXT_FLOOR = 131_072
|
|
42
|
+
_LOW_VRAM_CEILING_BYTES = 16 << 30
|
|
43
|
+
# Quant patterns treated as higher-precision reference baselines within a model group.
|
|
44
|
+
_Q4_REFERENCE_PRIORITY: tuple[str, ...] = (
|
|
45
|
+
"UD-Q4_K_XL",
|
|
46
|
+
"Q4_K_XL",
|
|
47
|
+
"UD-Q4_K_M",
|
|
48
|
+
"Q4_K_M",
|
|
49
|
+
"UD-IQ4_XS",
|
|
50
|
+
"IQ4_XS",
|
|
51
|
+
"Q4_0",
|
|
52
|
+
"QAD-Q4_0",
|
|
53
|
+
"Q5_K_M",
|
|
54
|
+
"Q8_0",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _slug(text: str) -> str:
|
|
59
|
+
cleaned = _SLUG_BAD_RE.sub("-", text.strip().lower()).strip("-._")
|
|
60
|
+
return cleaned or "model"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def clean_display_name(entry: cat.CatalogEntry, quant: str) -> str:
|
|
64
|
+
"""Clean base model title without trailing ``(<quant>)``."""
|
|
65
|
+
raw = (entry.display_name or entry.id).strip()
|
|
66
|
+
suffix = f" ({quant})"
|
|
67
|
+
if quant and raw.endswith(suffix) and len(raw) > len(suffix):
|
|
68
|
+
raw = raw[: -len(suffix)].strip()
|
|
69
|
+
return (raw or entry.id)[:120]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def group_id(entry: cat.CatalogEntry, quant: str) -> str:
|
|
73
|
+
"""Stable group identifier derived from catalog ``base_model`` (e.g. ``inkling-2-mini``).
|
|
74
|
+
|
|
75
|
+
Distinct branded fine-tunes that list an upstream ``base_model`` (such as
|
|
76
|
+
``underdog-saluki-27b`` or ``ternary-bonsai-2.5-27b``) keep their own group slug rather
|
|
77
|
+
than collapsing into the upstream base family.
|
|
78
|
+
"""
|
|
79
|
+
title_slug = _slug(clean_display_name(entry, quant))
|
|
80
|
+
if entry.base_model:
|
|
81
|
+
tail = entry.base_model.rsplit("/", 1)[-1]
|
|
82
|
+
base_slug = _slug(tail)
|
|
83
|
+
entry_lower = entry.id.lower()
|
|
84
|
+
short_stem = base_slug.split("-", 1)[1] if "-" in base_slug else ""
|
|
85
|
+
if (
|
|
86
|
+
title_slug == base_slug
|
|
87
|
+
or entry_lower.startswith(base_slug)
|
|
88
|
+
or (len(short_stem) >= 6 and entry_lower.startswith(short_stem))
|
|
89
|
+
):
|
|
90
|
+
return base_slug[:120]
|
|
91
|
+
return (title_slug or _slug(entry.id))[:120]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def quant_method(quant: str) -> QuantMethod:
|
|
95
|
+
"""Structured quantization method tag from the variant's canonical quant label."""
|
|
96
|
+
upper = quant.strip().upper()
|
|
97
|
+
if upper.startswith("GSQ-RCO-"):
|
|
98
|
+
return "gsq_rco"
|
|
99
|
+
if upper.startswith("UD-"):
|
|
100
|
+
return "unsloth_dynamic"
|
|
101
|
+
if upper.startswith(("QAD-", "QAT-")):
|
|
102
|
+
return "qat"
|
|
103
|
+
if upper.startswith("MLX-"):
|
|
104
|
+
return "mlx"
|
|
105
|
+
return "standard"
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def bits_per_weight(entry: cat.CatalogEntry, quant: str) -> float | None:
|
|
109
|
+
"""Catalog-declared or format-table average bits per weight; None when unknown."""
|
|
110
|
+
if entry.bits_per_weight is not None and entry.bits_per_weight > 0:
|
|
111
|
+
return round(float(entry.bits_per_weight), 2)
|
|
112
|
+
fmt = quant_formats.lookup(quant)
|
|
113
|
+
if fmt is not None and fmt.bits > 0:
|
|
114
|
+
return round(float(fmt.bits), 2)
|
|
115
|
+
return None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def quant_fidelity(entry: cat.CatalogEntry, quant: str) -> QuantFidelity:
|
|
119
|
+
"""Structured quantization fidelity tier for ``entry``/``quant``."""
|
|
120
|
+
return cast(QuantFidelity, catalog_recipes.infer_quant_fidelity(entry.quant_fidelity, quant))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def engine_display_name(engine: Engine) -> EngineDisplayName:
|
|
124
|
+
return ENGINE_DISPLAY_NAMES[engine]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _best_gpu(facts: HostFacts, pool: str) -> GPU | None:
|
|
128
|
+
shown = memory_pools.visible(facts)
|
|
129
|
+
gpus = [
|
|
130
|
+
g
|
|
131
|
+
for g in facts.get("gpus") or []
|
|
132
|
+
if g.get("vendor") == "nvidia" and (shown is None or g["index"] in shown)
|
|
133
|
+
]
|
|
134
|
+
if not gpus:
|
|
135
|
+
return None
|
|
136
|
+
if pool.startswith("gpu:"):
|
|
137
|
+
try:
|
|
138
|
+
idx = int(pool.split(":", 1)[1])
|
|
139
|
+
except ValueError:
|
|
140
|
+
idx = -1
|
|
141
|
+
for gpu in gpus:
|
|
142
|
+
if gpu["index"] == idx:
|
|
143
|
+
return gpu
|
|
144
|
+
return max(gpus, key=lambda g: g["total_bytes"])
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _host_budget(facts: HostFacts) -> HardwareBudget | None:
|
|
148
|
+
if metal.supported(facts):
|
|
149
|
+
placement = next(
|
|
150
|
+
(p for p in budget.placements(facts, planning=True) if p.backend == "metal"),
|
|
151
|
+
None,
|
|
152
|
+
)
|
|
153
|
+
return (budget.agent_budget(placement, facts) or placement.budget) if placement else None
|
|
154
|
+
shown = memory_pools.visible(facts)
|
|
155
|
+
cuda_placements = [
|
|
156
|
+
p
|
|
157
|
+
for p in budget.placements(facts, planning=True)
|
|
158
|
+
if not p.pooled
|
|
159
|
+
and p.backend == "cuda"
|
|
160
|
+
and (not p.gpu_indices or shown is None or all(idx in shown for idx in p.gpu_indices))
|
|
161
|
+
]
|
|
162
|
+
if not cuda_placements:
|
|
163
|
+
return None
|
|
164
|
+
best = max(cuda_placements, key=lambda p: p.budget.total_device_bytes)
|
|
165
|
+
return budget.agent_budget(best, facts) or best.budget
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def offload_mode(
|
|
169
|
+
facts: HostFacts,
|
|
170
|
+
row: Row,
|
|
171
|
+
model: Model,
|
|
172
|
+
plan: Plan | None,
|
|
173
|
+
poly_recipes: Mapping[str, suite.SuiteRecipe],
|
|
174
|
+
) -> OffloadMode:
|
|
175
|
+
"""How weights execute on this host: unified, CPU, full GPU-resident, or hybrid GPU+RAM."""
|
|
176
|
+
pool = row["pool"]
|
|
177
|
+
if (
|
|
178
|
+
pool == "unified"
|
|
179
|
+
or metal.supported(facts)
|
|
180
|
+
or memory_pools.cuda_uma_bytes(facts) is not None
|
|
181
|
+
):
|
|
182
|
+
return "unified"
|
|
183
|
+
if pool == "system" or (plan is not None and plan["placement"].get("id") == "cpu"):
|
|
184
|
+
return "cpu"
|
|
185
|
+
engine = row.get("engine") or "llama.cpp"
|
|
186
|
+
if engine == "strata":
|
|
187
|
+
return "hybrid_gpu_ram"
|
|
188
|
+
if engine == "polystrata":
|
|
189
|
+
recipe = poly_recipes.get(model.entry.id)
|
|
190
|
+
gpu = _best_gpu(facts, pool)
|
|
191
|
+
if recipe is not None and suite.poly_gpu_resident(recipe, gpu):
|
|
192
|
+
return "gpu_resident"
|
|
193
|
+
return "hybrid_gpu_ram"
|
|
194
|
+
if plan is not None and bool(plan["launch"].get("spilled")):
|
|
195
|
+
return "hybrid_gpu_ram"
|
|
196
|
+
return "gpu_resident"
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def estimated_tokens_per_second(
|
|
200
|
+
facts: HostFacts,
|
|
201
|
+
row: Row,
|
|
202
|
+
model: Model,
|
|
203
|
+
hw: HardwareBudget | None,
|
|
204
|
+
poly_recipes: Mapping[str, suite.SuiteRecipe],
|
|
205
|
+
) -> float | None:
|
|
206
|
+
"""Estimated single-stream decode speed on this host; None when offloaded or unknown."""
|
|
207
|
+
engine = row.get("engine") or "llama.cpp"
|
|
208
|
+
if engine == "strata":
|
|
209
|
+
return None
|
|
210
|
+
if engine == "polystrata":
|
|
211
|
+
recipe = poly_recipes.get(model.entry.id)
|
|
212
|
+
if recipe is None:
|
|
213
|
+
return None
|
|
214
|
+
est = suite.poly_decode_estimate(recipe, _best_gpu(facts, row["pool"]))
|
|
215
|
+
return round(est.tok_s, 1) if est is not None and est.tok_s > 0 else None
|
|
216
|
+
if hw is None:
|
|
217
|
+
return None
|
|
218
|
+
est = cat.decode_estimate(model.entry, model.variant, hw)
|
|
219
|
+
return round(est.tok_s, 1) if est.tok_s > 0 else None
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _has_low_vram_card(facts: HostFacts) -> bool:
|
|
223
|
+
if metal.supported(facts) or memory_pools.cuda_uma_bytes(facts) is not None:
|
|
224
|
+
return False
|
|
225
|
+
gpu = _best_gpu(facts, "")
|
|
226
|
+
return gpu is not None and gpu["total_bytes"] <= _LOW_VRAM_CEILING_BYTES
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _reasons(
|
|
230
|
+
*,
|
|
231
|
+
best_for_host: bool,
|
|
232
|
+
engine: Engine,
|
|
233
|
+
fidelity: QuantFidelity,
|
|
234
|
+
mode: OffloadMode,
|
|
235
|
+
fits_low_vram: bool,
|
|
236
|
+
smaller_footprint: bool,
|
|
237
|
+
context_tokens: int,
|
|
238
|
+
prefix_cache: bool,
|
|
239
|
+
) -> list[RecommendationReason]:
|
|
240
|
+
found: list[RecommendationReason] = []
|
|
241
|
+
if best_for_host:
|
|
242
|
+
found.append("best_quality_for_hardware")
|
|
243
|
+
if engine == "polystrata":
|
|
244
|
+
found.append("polystrata_engine")
|
|
245
|
+
if fidelity == "high_fidelity_compact":
|
|
246
|
+
found.append("high_fidelity_compact_quant")
|
|
247
|
+
elif fidelity == "near_lossless":
|
|
248
|
+
found.append("near_lossless_quant")
|
|
249
|
+
if mode == "hybrid_gpu_ram":
|
|
250
|
+
found.append("hybrid_gpu_ram_offload")
|
|
251
|
+
if fits_low_vram:
|
|
252
|
+
found.append("fits_low_vram")
|
|
253
|
+
if smaller_footprint:
|
|
254
|
+
found.append("smaller_footprint")
|
|
255
|
+
if context_tokens >= _LONG_CONTEXT_FLOOR:
|
|
256
|
+
found.append("long_context")
|
|
257
|
+
if prefix_cache:
|
|
258
|
+
found.append("prefix_cache")
|
|
259
|
+
return found
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def _poly_recipe_map() -> dict[str, suite.SuiteRecipe]:
|
|
263
|
+
return {r["id"]: r for r in suite.recipes("llm") if r["runtime"] == "strata-poly"}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def apply_row_meta(
|
|
267
|
+
facts: HostFacts,
|
|
268
|
+
row: Row,
|
|
269
|
+
model: Model,
|
|
270
|
+
plan: Plan | None,
|
|
271
|
+
*,
|
|
272
|
+
hw: HardwareBudget | None = None,
|
|
273
|
+
poly_recipes: Mapping[str, suite.SuiteRecipe] | None = None,
|
|
274
|
+
) -> None:
|
|
275
|
+
"""Attach intrinsic presentation metadata to one ``library-status/v1`` row."""
|
|
276
|
+
recipes = _poly_recipe_map() if poly_recipes is None else poly_recipes
|
|
277
|
+
host_hw = _host_budget(facts) if hw is None else hw
|
|
278
|
+
engine: Engine = row.get("engine") or "llama.cpp"
|
|
279
|
+
fidelity = quant_fidelity(model.entry, model.variant.quant)
|
|
280
|
+
mode = offload_mode(facts, row, model, plan, recipes)
|
|
281
|
+
rq = library_order.ranked_quality(model.entry)
|
|
282
|
+
|
|
283
|
+
row["group_id"] = group_id(model.entry, model.variant.quant)
|
|
284
|
+
row["display_name"] = clean_display_name(model.entry, model.variant.quant)
|
|
285
|
+
row["quant_method"] = quant_method(model.variant.quant)
|
|
286
|
+
if (bpw := bits_per_weight(model.entry, model.variant.quant)) is not None:
|
|
287
|
+
row["bits_per_weight"] = bpw
|
|
288
|
+
row["quant_fidelity"] = fidelity
|
|
289
|
+
row["engine_display_name"] = engine_display_name(engine)
|
|
290
|
+
row["offload_mode"] = mode
|
|
291
|
+
row["quality_score"] = rq if rq > 0 else None
|
|
292
|
+
row["estimated_tokens_per_second"] = estimated_tokens_per_second(
|
|
293
|
+
facts, row, model, host_hw, recipes
|
|
294
|
+
)
|
|
295
|
+
prefix_cache = engine == "polystrata" or (
|
|
296
|
+
plan is not None and int(str(plan["launch"].get("conversation_cache_mib") or 0)) > 0
|
|
297
|
+
)
|
|
298
|
+
reasons = _reasons(
|
|
299
|
+
best_for_host=False,
|
|
300
|
+
engine=engine,
|
|
301
|
+
fidelity=fidelity,
|
|
302
|
+
mode=mode,
|
|
303
|
+
fits_low_vram=_has_low_vram_card(facts) and row["fit"] != "none",
|
|
304
|
+
smaller_footprint=False,
|
|
305
|
+
context_tokens=row["context_tokens"],
|
|
306
|
+
prefix_cache=prefix_cache,
|
|
307
|
+
)
|
|
308
|
+
if reasons:
|
|
309
|
+
row["recommendation_reasons"] = reasons
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def _reference_row(rows: Sequence[Row], target: Row) -> Row | None:
|
|
313
|
+
"""Pick the larger Q4-class sibling in the same ``group_id`` for ``baseline_comparison``."""
|
|
314
|
+
target_dl = target["download_bytes"]
|
|
315
|
+
target_engine = target.get("engine")
|
|
316
|
+
candidates: list[tuple[int, int, int, Row]] = []
|
|
317
|
+
for sibling in rows:
|
|
318
|
+
if sibling["id"] == target["id"] or sibling["quant"] == target["quant"]:
|
|
319
|
+
continue
|
|
320
|
+
if sibling["download_bytes"] <= target_dl:
|
|
321
|
+
continue
|
|
322
|
+
upper = sibling["quant"].strip().upper()
|
|
323
|
+
if upper not in _Q4_REFERENCE_PRIORITY:
|
|
324
|
+
continue
|
|
325
|
+
same_engine = 0 if sibling.get("engine") == target_engine else 1
|
|
326
|
+
priority = _Q4_REFERENCE_PRIORITY.index(upper)
|
|
327
|
+
candidates.append((same_engine, priority, -sibling["download_bytes"], sibling))
|
|
328
|
+
if not candidates:
|
|
329
|
+
return None
|
|
330
|
+
candidates.sort(key=lambda item: (item[0], item[1], item[2]))
|
|
331
|
+
return candidates[0][3]
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def enrich_status_rows(
|
|
335
|
+
facts: HostFacts,
|
|
336
|
+
ordered_rows: list[Row],
|
|
337
|
+
best_id: str | None,
|
|
338
|
+
) -> None:
|
|
339
|
+
"""Populate cross-row host-relative metadata after ``library_order.order_rows``."""
|
|
340
|
+
low_vram_host = _has_low_vram_card(facts)
|
|
341
|
+
by_group: dict[str, list[Row]] = {}
|
|
342
|
+
for row in ordered_rows:
|
|
343
|
+
gid = row.get("group_id") or _slug(row["id"])
|
|
344
|
+
by_group.setdefault(gid, []).append(row)
|
|
345
|
+
|
|
346
|
+
group_counters: dict[str, int] = {}
|
|
347
|
+
for row in ordered_rows:
|
|
348
|
+
gid = row.get("group_id") or _slug(row["id"])
|
|
349
|
+
rank = group_counters.get(gid, 0) + 1
|
|
350
|
+
group_counters[gid] = rank
|
|
351
|
+
row["suitability_rank"] = rank
|
|
352
|
+
is_best = best_id is not None and row["id"] == best_id
|
|
353
|
+
row["best_for_host"] = is_best
|
|
354
|
+
|
|
355
|
+
ref = _reference_row(by_group[gid], row)
|
|
356
|
+
has_smaller = False
|
|
357
|
+
if ref is not None:
|
|
358
|
+
saved_dl = ref["download_bytes"] - row["download_bytes"]
|
|
359
|
+
if saved_dl > 0:
|
|
360
|
+
comparison: BaselineComparison = {
|
|
361
|
+
"reference_quant": ref["quant"],
|
|
362
|
+
"download_saved_bytes": saved_dl,
|
|
363
|
+
"memory_saved_bytes": max(0, ref["memory_bytes"] - row["memory_bytes"]),
|
|
364
|
+
"context_delta_tokens": row["context_tokens"] - ref["context_tokens"],
|
|
365
|
+
}
|
|
366
|
+
row["baseline_comparison"] = comparison
|
|
367
|
+
has_smaller = True
|
|
368
|
+
|
|
369
|
+
engine: Engine = row.get("engine") or "llama.cpp"
|
|
370
|
+
fidelity: QuantFidelity = row.get("quant_fidelity") or "balanced"
|
|
371
|
+
mode: OffloadMode = row.get("offload_mode") or "gpu_resident"
|
|
372
|
+
existing = set(row.get("recommendation_reasons") or ())
|
|
373
|
+
reasons = _reasons(
|
|
374
|
+
best_for_host=is_best,
|
|
375
|
+
engine=engine,
|
|
376
|
+
fidelity=fidelity,
|
|
377
|
+
mode=mode,
|
|
378
|
+
fits_low_vram=low_vram_host and row["fit"] != "none",
|
|
379
|
+
smaller_footprint=has_smaller,
|
|
380
|
+
context_tokens=row["context_tokens"],
|
|
381
|
+
prefix_cache="prefix_cache" in existing or engine == "polystrata",
|
|
382
|
+
)
|
|
383
|
+
if reasons:
|
|
384
|
+
row["recommendation_reasons"] = reasons
|
|
385
|
+
else:
|
|
386
|
+
row.pop("recommendation_reasons", None)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def plan_presentation(
|
|
390
|
+
plan: Plan,
|
|
391
|
+
*,
|
|
392
|
+
context_window: int,
|
|
393
|
+
gpus: Sequence[Mapping[str, object]],
|
|
394
|
+
unified: bool,
|
|
395
|
+
) -> dict[str, object]:
|
|
396
|
+
"""Additive presentation fields for v1 ``PlanSummary`` (``stack_review.summarize``)."""
|
|
397
|
+
model = plan["model"]
|
|
398
|
+
model_id = str(model.get("id") or "")
|
|
399
|
+
quant = str(model.get("quant") or "")
|
|
400
|
+
engine_doc: Mapping[str, object] = plan.get("engine") or {}
|
|
401
|
+
build = str(engine_doc.get("build") or "")
|
|
402
|
+
backend = str(engine_doc.get("backend") or "")
|
|
403
|
+
if build.startswith("strata-poly") or str(
|
|
404
|
+
plan["launch"].get("frontend_requirements") or ""
|
|
405
|
+
).startswith("strata-poly"):
|
|
406
|
+
engine: Engine = "polystrata"
|
|
407
|
+
elif build.startswith("strata"):
|
|
408
|
+
engine = "strata"
|
|
409
|
+
elif backend == "mlx" or build.startswith("mlx"):
|
|
410
|
+
engine = "mlx"
|
|
411
|
+
else:
|
|
412
|
+
engine = "llama.cpp"
|
|
413
|
+
|
|
414
|
+
explicit_fidelity = ""
|
|
415
|
+
recipe: suite.SuiteRecipe | None = None
|
|
416
|
+
if engine in ("polystrata", "strata"):
|
|
417
|
+
recipe = next((r for r in suite.recipes("llm") if r["id"] == model_id), None)
|
|
418
|
+
if recipe is not None:
|
|
419
|
+
explicit_fidelity = str(recipe.get("quant_fidelity") or "")
|
|
420
|
+
else:
|
|
421
|
+
entry = cat.find_entry(model_id)
|
|
422
|
+
if entry is not None:
|
|
423
|
+
explicit_fidelity = entry.quant_fidelity
|
|
424
|
+
|
|
425
|
+
fidelity = cast(QuantFidelity, catalog_recipes.infer_quant_fidelity(explicit_fidelity, quant))
|
|
426
|
+
mode: OffloadMode
|
|
427
|
+
if unified:
|
|
428
|
+
mode = "unified"
|
|
429
|
+
elif plan["placement"].get("id") == "cpu":
|
|
430
|
+
mode = "cpu"
|
|
431
|
+
elif engine == "strata":
|
|
432
|
+
mode = "hybrid_gpu_ram"
|
|
433
|
+
elif engine == "polystrata":
|
|
434
|
+
first_total = gpus[0].get("totalBytes") if gpus else None
|
|
435
|
+
if isinstance(first_total, int) and first_total > 0 and recipe is not None:
|
|
436
|
+
synth_gpu = cast(
|
|
437
|
+
GPU,
|
|
438
|
+
{
|
|
439
|
+
"index": 0,
|
|
440
|
+
"uuid": "",
|
|
441
|
+
"name": "",
|
|
442
|
+
"total_bytes": first_total,
|
|
443
|
+
"free_bytes": first_total,
|
|
444
|
+
"used_bytes": 0,
|
|
445
|
+
"vendor": "nvidia",
|
|
446
|
+
},
|
|
447
|
+
)
|
|
448
|
+
mode = (
|
|
449
|
+
"gpu_resident" if suite.poly_gpu_resident(recipe, synth_gpu) else "hybrid_gpu_ram"
|
|
450
|
+
)
|
|
451
|
+
else:
|
|
452
|
+
mode = "hybrid_gpu_ram"
|
|
453
|
+
elif bool(plan["launch"].get("spilled")):
|
|
454
|
+
mode = "hybrid_gpu_ram"
|
|
455
|
+
else:
|
|
456
|
+
mode = "gpu_resident"
|
|
457
|
+
|
|
458
|
+
low_vram = not unified and any(
|
|
459
|
+
isinstance(tb := g.get("totalBytes"), int)
|
|
460
|
+
and not isinstance(tb, bool)
|
|
461
|
+
and 0 < tb <= _LOW_VRAM_CEILING_BYTES
|
|
462
|
+
for g in gpus
|
|
463
|
+
)
|
|
464
|
+
prefix_cache = (
|
|
465
|
+
engine == "polystrata" or int(str(plan["launch"].get("conversation_cache_mib") or 0)) > 0
|
|
466
|
+
)
|
|
467
|
+
reasons = _reasons(
|
|
468
|
+
best_for_host=False,
|
|
469
|
+
engine=engine,
|
|
470
|
+
fidelity=fidelity,
|
|
471
|
+
mode=mode,
|
|
472
|
+
fits_low_vram=low_vram,
|
|
473
|
+
smaller_footprint=False,
|
|
474
|
+
context_tokens=context_window,
|
|
475
|
+
prefix_cache=prefix_cache,
|
|
476
|
+
)
|
|
477
|
+
out: dict[str, object] = {
|
|
478
|
+
"engine": engine,
|
|
479
|
+
"quant_fidelity": fidelity,
|
|
480
|
+
}
|
|
481
|
+
if quant:
|
|
482
|
+
out["quant"] = quant
|
|
483
|
+
if reasons:
|
|
484
|
+
out["recommendation_reasons"] = reasons
|
|
485
|
+
return out
|
|
@@ -136,7 +136,9 @@ class LiveMemoryUnavailable(plan_envelope.PlanError):
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
def host_ram_bytes(plan: Plan, catalog: tuple[cat.CatalogEntry, ...]) -> int:
|
|
139
|
-
"""Host RAM held by one discrete-GPU model (llama.cpp or PolyStrata)."""
|
|
139
|
+
"""Host RAM held by one discrete-GPU model (llama.cpp or PolyStrata); 0 on unified pools."""
|
|
140
|
+
if memory_pools.pool_of(plan) == "unified":
|
|
141
|
+
return 0
|
|
140
142
|
if library_poly.is_poly_plan(plan):
|
|
141
143
|
return suite.bounded_ram(plan)
|
|
142
144
|
min_cache_bytes = (
|
|
@@ -542,7 +544,9 @@ def smartest(facts: HostFacts, base_dir: str = deploy.DEFAULT_BASE_DIR) -> tuple
|
|
|
542
544
|
if (shown_cards := memory_pools.visible(facts)) is not None:
|
|
543
545
|
seen["gpus"] = [g for g in seen.get("gpus") or [] if g["index"] in shown_cards]
|
|
544
546
|
try:
|
|
545
|
-
|
|
547
|
+
opts = default_options()
|
|
548
|
+
opts["base_dir"] = base_dir
|
|
549
|
+
view = stack_hardware.view(seen, opts, posture())
|
|
546
550
|
except (KeyError, ValueError, TypeError, OSError):
|
|
547
551
|
return None
|
|
548
552
|
pick = next(
|
|
@@ -589,12 +593,19 @@ def floor_metadata(
|
|
|
589
593
|
if model.entry.runtime == "strata-poly":
|
|
590
594
|
recipe = suite.recipe(model.entry.id)
|
|
591
595
|
window = int(recipe.get("context") or model.entry.n_ctx_train)
|
|
592
|
-
|
|
596
|
+
metal_unified = metal.supported(facts)
|
|
597
|
+
active = model.entry.agent_posture(
|
|
598
|
+
context_policy.posture_for(posture(), "metal" if metal_unified else "cuda")
|
|
599
|
+
)
|
|
593
600
|
vision_on = bool(recipe.get("vision")) and active.vision != "off"
|
|
594
601
|
download = sum(
|
|
595
602
|
int(f["size_bytes"]) for f in recipe["files"] if vision_on or not f.get("vision")
|
|
596
603
|
)
|
|
597
|
-
floor_bytes =
|
|
604
|
+
floor_bytes = (
|
|
605
|
+
library_poly.unified_floor_bytes(recipe, active)
|
|
606
|
+
if metal_unified
|
|
607
|
+
else int(recipe.get("min_vram_free_bytes") or recipe.get("vram_bytes") or 0)
|
|
608
|
+
)
|
|
598
609
|
effective_shortfall = 0 if memory_kind == "ram" else shortfall_bytes
|
|
599
610
|
return max(effective_shortfall, floor_bytes), window, vision_on, download
|
|
600
611
|
metal_unified = metal.supported(facts)
|