@simplexai/localmodels-linux-x64 0.1.0-dev.32.build.git9f03dd7a81cec1338df8eaf613ec9e3013365c9c → 0.1.0-dev.36
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 +141 -99
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +4 -0
- package/modules/localmodels/app.py +7 -2
- package/modules/localmodels/approval.py +4 -4
- package/modules/localmodels/bifrost_checks.py +121 -3
- package/modules/localmodels/bifrost_provider.py +53 -0
- package/modules/localmodels/bifrost_unit.py +32 -1
- package/modules/localmodels/budget.py +7 -1
- package/modules/localmodels/catalog.json +286 -12
- package/modules/localmodels/catalog.py +30 -29
- package/modules/localmodels/catalog_add.py +1 -0
- package/modules/localmodels/cli_parser.py +10 -2
- package/modules/localmodels/component.py +7 -1
- package/modules/localmodels/decode_calibration.json +6 -0
- package/modules/localmodels/decode_calibration.py +104 -0
- package/modules/localmodels/deploy.py +44 -7
- package/modules/localmodels/deploy_steps.py +10 -1
- package/modules/localmodels/engines-strata-0.1.49.2.json +31 -0
- package/modules/localmodels/engines-strata-0.1.59.1.json +31 -0
- package/modules/localmodels/engines.json +57 -1
- package/modules/localmodels/engines.py +6 -2
- package/modules/localmodels/estimator.py +21 -7
- package/modules/localmodels/frontend.py +4 -4
- package/modules/localmodels/gateway.py +14 -4
- package/modules/localmodels/gateway_app_bifrost.py +4 -3
- package/modules/localmodels/gateway_bifrost.py +70 -57
- package/modules/localmodels/gateway_probe.py +3 -4
- package/modules/localmodels/gguf.py +7 -0
- package/modules/localmodels/harness.py +24 -25
- package/modules/localmodels/harness_gateway.py +19 -10
- package/modules/localmodels/harness_probe.py +33 -6
- package/modules/localmodels/hosts.py +73 -9
- package/modules/localmodels/install.py +36 -6
- package/modules/localmodels/library_cli.py +179 -0
- package/modules/localmodels/library_convert.py +132 -0
- package/modules/localmodels/library_gateway.py +471 -0
- package/modules/localmodels/library_jobs.py +314 -0
- package/modules/localmodels/library_model.py +246 -0
- package/modules/localmodels/library_pricing.py +347 -0
- package/modules/localmodels/library_serve.py +348 -0
- package/modules/localmodels/library_state.py +373 -0
- package/modules/localmodels/library_status.py +349 -0
- package/modules/localmodels/llm_rank.py +77 -8
- package/modules/localmodels/memcalc.py +7 -30
- package/modules/localmodels/metal.py +26 -0
- package/modules/localmodels/metal_probe.py +11 -7
- package/modules/localmodels/plan_envelope.py +4 -1
- package/modules/localmodels/preparation.py +49 -0
- package/modules/localmodels/probe.py +8 -8
- package/modules/localmodels/process_identity.py +536 -9
- package/modules/localmodels/quant_formats.py +123 -0
- package/modules/localmodels/recommend.py +32 -3
- package/modules/localmodels/recommend_cli.py +8 -4
- package/modules/localmodels/records.py +1 -0
- package/modules/localmodels/remote_ops.py +104 -6
- package/modules/localmodels/remote_ops_download.py +17 -2
- package/modules/localmodels/remote_ops_prepare.py +425 -0
- package/modules/localmodels/remote_ops_remove.py +40 -7
- package/modules/localmodels/remote_ops_service.py +110 -8
- package/modules/localmodels/remote_ops_verify.py +15 -2
- package/modules/localmodels/runtime_auth.py +31 -1
- package/modules/localmodels/runtime_cli.py +3 -4
- package/modules/localmodels/runtime_io.py +50 -6
- package/modules/localmodels/service_autostart.py +45 -1
- package/modules/localmodels/service_control.py +13 -0
- package/modules/localmodels/service_deployment.py +12 -3
- package/modules/localmodels/service_jobs.py +33 -4
- package/modules/localmodels/service_probe.py +67 -13
- package/modules/localmodels/service_stop.py +152 -0
- package/modules/localmodels/service_worker.py +9 -1
- package/modules/localmodels/services_cli.py +50 -6
- package/modules/localmodels/setup_inspection.py +34 -25
- package/modules/localmodels/setup_text.py +118 -0
- package/modules/localmodels/sizecalc.py +625 -0
- package/modules/localmodels/sizecalc_cli.py +249 -0
- package/modules/localmodels/stack.py +69 -17
- package/modules/localmodels/stack_args.py +91 -19
- package/modules/localmodels/stack_auto.py +78 -0
- package/modules/localmodels/stack_binding.py +23 -35
- package/modules/localmodels/stack_card.py +195 -0
- package/modules/localmodels/stack_cleanup.py +379 -0
- package/modules/localmodels/stack_clients.py +4 -1
- package/modules/localmodels/stack_compose.py +173 -206
- package/modules/localmodels/stack_console.py +2 -0
- package/modules/localmodels/stack_decision.py +3 -2
- package/modules/localmodels/stack_down.py +189 -0
- package/modules/localmodels/stack_events.py +54 -0
- package/modules/localmodels/stack_hardware.py +30 -34
- package/modules/localmodels/stack_journal.py +29 -8
- package/modules/localmodels/stack_ledger.py +411 -0
- package/modules/localmodels/stack_lifecycle.py +162 -167
- package/modules/localmodels/stack_llm_ram.py +57 -5
- package/modules/localmodels/stack_memory.py +721 -0
- package/modules/localmodels/stack_picks.py +147 -0
- package/modules/localmodels/stack_plan.py +143 -25
- package/modules/localmodels/stack_ports.py +22 -0
- package/modules/localmodels/stack_preflight.py +699 -0
- package/modules/localmodels/stack_review.py +123 -5
- package/modules/localmodels/stack_rollback.py +2 -0
- package/modules/localmodels/stack_route.py +256 -0
- package/modules/localmodels/stack_run.py +11 -0
- package/modules/localmodels/stack_suite.py +107 -20
- package/modules/localmodels/stack_summary.py +65 -4
- package/modules/localmodels/stack_try.py +354 -0
- package/modules/localmodels/stack_try_client.py +194 -0
- package/modules/localmodels/stack_try_docs.py +139 -0
- package/modules/localmodels/stack_up.py +8 -1
- package/modules/localmodels/stack_update.py +29 -4
- package/modules/localmodels/stack_verify.py +3 -1
- package/modules/localmodels/stack_view.py +10 -11
- package/modules/localmodels/stack_view_apply.py +4 -2
- package/modules/localmodels/stack_view_events.py +2 -1
- package/modules/localmodels/stack_view_serve.py +3 -0
- package/modules/localmodels/stack_view_text.py +1 -1
- package/modules/localmodels/stack_view_words.py +4 -1
- package/modules/localmodels/stack_warm.py +574 -0
- package/modules/localmodels/stack_whatif.py +558 -0
- package/modules/localmodels/suite.py +48 -39
- package/modules/localmodels/tool_archive.py +40 -0
- package/modules/localmodels/tools.json +8 -0
- package/modules/localmodels/transport.py +1 -0
- package/modules/localmodels/vision.py +8 -1
- package/modules/localmodels/web/sizecalc/app.js +431 -0
- package/modules/localmodels/web/sizecalc/calc.js +269 -0
- package/modules/localmodels/web/sizecalc/page.html +362 -0
- package/modules/localmodels/web/view/ASSET-SOURCES.md +11 -0
- package/modules/localmodels/web/view/i18n.js +1 -1
- package/modules/localmodels/web/view/logo-claude.svg +3 -0
- package/modules/localmodels/web/view/logo-codex.png +0 -0
- package/modules/localmodels/web/view/logo-pi.svg +6 -0
- package/modules/localmodels/web/view/view.css +4 -0
- package/modules/localmodels/web/view/view.js +15 -6
- package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/METADATA +1 -1
- package/modules/simplex_localmodels-0.1.0.dev36.dist-info/RECORD +242 -0
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/simplex_localmodels-0.1.0.dev32.dist-info/RECORD +0 -200
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev36.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Bounded folder Q&A: UTF-8 text chunks and embeddings live only in this process.
|
|
2
|
+
|
|
3
|
+
No index, cache, prompt, file content or answer is written to disk. Hidden paths and symlinks
|
|
4
|
+
are excluded. Exceeding a bound refuses the folder instead of silently truncating it.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import math
|
|
11
|
+
import os
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from localmodels.stack_try_client import DemoError, Gateway
|
|
16
|
+
|
|
17
|
+
SUFFIXES = frozenset({".txt", ".md", ".rst", ".csv", ".json"})
|
|
18
|
+
MAX_FILES = 64
|
|
19
|
+
MAX_BYTES = 1 << 20
|
|
20
|
+
MAX_CHUNKS = 128
|
|
21
|
+
# A conservative UTF-8 byte bound leaves special-token room in the 2047-token embedding slot.
|
|
22
|
+
MAX_QUESTION_BYTES = 2000
|
|
23
|
+
CHUNK_CHARS = 1200
|
|
24
|
+
CHUNK_OVERLAP = 150
|
|
25
|
+
BATCH_SIZE = 16
|
|
26
|
+
TOP_CHUNKS = 4
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class Chunk:
|
|
31
|
+
source: str
|
|
32
|
+
text: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def chunks(folder: Path) -> list[Chunk]:
|
|
36
|
+
"""Read a bounded folder of documents without following links or hidden paths."""
|
|
37
|
+
if folder.is_symlink() or not folder.is_dir():
|
|
38
|
+
raise DemoError("Docs needs a readable folder, not a symlink; pass FOLDER again.")
|
|
39
|
+
found: list[Chunk] = []
|
|
40
|
+
files, total = 0, 0
|
|
41
|
+
|
|
42
|
+
def unreadable(error: OSError) -> None:
|
|
43
|
+
raise DemoError("A document directory cannot be read; choose a readable folder.")
|
|
44
|
+
|
|
45
|
+
for root, dirs, names in os.walk(folder, followlinks=False, onerror=unreadable):
|
|
46
|
+
dirs[:] = sorted(
|
|
47
|
+
d for d in dirs if not d.startswith(".") and not Path(root, d).is_symlink()
|
|
48
|
+
)
|
|
49
|
+
for name in sorted(names):
|
|
50
|
+
path = Path(root, name)
|
|
51
|
+
if name.startswith(".") or path.suffix.lower() not in SUFFIXES or path.is_symlink():
|
|
52
|
+
continue
|
|
53
|
+
if not path.is_file():
|
|
54
|
+
continue
|
|
55
|
+
files += 1
|
|
56
|
+
if files > MAX_FILES:
|
|
57
|
+
raise DemoError("Docs accepts at most 64 files; choose a smaller folder.")
|
|
58
|
+
with path.open("rb") as handle:
|
|
59
|
+
raw = handle.read(MAX_BYTES - total + 1)
|
|
60
|
+
total += len(raw)
|
|
61
|
+
if total > MAX_BYTES:
|
|
62
|
+
raise DemoError("Docs accepts at most 1 MiB of text; choose a smaller folder.")
|
|
63
|
+
try:
|
|
64
|
+
text = raw.decode("utf-8")
|
|
65
|
+
except UnicodeError:
|
|
66
|
+
raise DemoError(
|
|
67
|
+
"Docs requires UTF-8 text; convert the documents and retry."
|
|
68
|
+
) from None
|
|
69
|
+
if "\0" in text:
|
|
70
|
+
raise DemoError("Docs found binary data; choose a folder of UTF-8 documents.")
|
|
71
|
+
for offset in range(0, len(text), CHUNK_CHARS - CHUNK_OVERLAP):
|
|
72
|
+
piece = text[offset : offset + CHUNK_CHARS].strip()
|
|
73
|
+
if piece:
|
|
74
|
+
number = offset // (CHUNK_CHARS - CHUNK_OVERLAP) + 1
|
|
75
|
+
source = f"{path.relative_to(folder).as_posix()}#chunk-{number}"
|
|
76
|
+
found.append(Chunk(source, piece))
|
|
77
|
+
if len(found) > MAX_CHUNKS:
|
|
78
|
+
raise DemoError("Docs accepts at most 128 chunks; choose a smaller folder.")
|
|
79
|
+
if not found:
|
|
80
|
+
raise DemoError("No UTF-8 .txt, .md, .rst, .csv or .json documents in the folder.")
|
|
81
|
+
return found
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _vectors(value: object, count: int) -> list[list[float]]:
|
|
85
|
+
if not isinstance(value, list) or len(value) != count:
|
|
86
|
+
raise DemoError("The embedding service returned missing vectors; run stack verify.")
|
|
87
|
+
indexed: dict[int, list[float]] = {}
|
|
88
|
+
for row in value:
|
|
89
|
+
if not isinstance(row, dict):
|
|
90
|
+
raise DemoError("The embedding service returned invalid vectors; run stack verify.")
|
|
91
|
+
index, vector = row.get("index"), row.get("embedding")
|
|
92
|
+
if (
|
|
93
|
+
not isinstance(index, int)
|
|
94
|
+
or isinstance(index, bool)
|
|
95
|
+
or index < 0
|
|
96
|
+
or index >= count
|
|
97
|
+
or index in indexed
|
|
98
|
+
or not isinstance(vector, list)
|
|
99
|
+
or not vector
|
|
100
|
+
):
|
|
101
|
+
raise DemoError("The embedding service returned invalid vector indices.")
|
|
102
|
+
if any(
|
|
103
|
+
not isinstance(x, int | float) or isinstance(x, bool) or not math.isfinite(x)
|
|
104
|
+
for x in vector
|
|
105
|
+
):
|
|
106
|
+
raise DemoError("The embedding service returned invalid vector numbers.")
|
|
107
|
+
numbers = [float(x) for x in vector]
|
|
108
|
+
norm = math.hypot(*numbers)
|
|
109
|
+
if not norm or not math.isfinite(norm):
|
|
110
|
+
raise DemoError("The embedding service returned an empty or invalid vector.")
|
|
111
|
+
indexed[index] = [x / norm for x in numbers]
|
|
112
|
+
return [indexed[i] for i in range(count)]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def context(client: Gateway, model: str, folder: Path, question: str) -> str:
|
|
116
|
+
if len(question.encode("utf-8")) > MAX_QUESTION_BYTES:
|
|
117
|
+
raise DemoError(
|
|
118
|
+
"Docs questions must fit 2000 UTF-8 bytes to stay within the embedding input limit; "
|
|
119
|
+
"shorten the question and retry."
|
|
120
|
+
)
|
|
121
|
+
pieces = chunks(folder)
|
|
122
|
+
texts = [question, *(c.text for c in pieces)]
|
|
123
|
+
vectors: list[list[float]] = []
|
|
124
|
+
for offset in range(0, len(texts), BATCH_SIZE):
|
|
125
|
+
batch = texts[offset : offset + BATCH_SIZE]
|
|
126
|
+
response = client.post("/v1/embeddings", {"model": model, "input": batch})
|
|
127
|
+
vectors.extend(_vectors(response.get("data"), len(batch)))
|
|
128
|
+
query = vectors[0]
|
|
129
|
+
if any(len(v) != len(query) for v in vectors):
|
|
130
|
+
raise DemoError("The embedding service returned inconsistent vector dimensions.")
|
|
131
|
+
ranked = sorted(
|
|
132
|
+
zip(pieces, vectors[1:], strict=False),
|
|
133
|
+
key=lambda item: sum(q * v for q, v in zip(query, item[1], strict=False)),
|
|
134
|
+
reverse=True,
|
|
135
|
+
)
|
|
136
|
+
return "\n\n".join(
|
|
137
|
+
f"Source: {json.dumps(chunk.source, ensure_ascii=True)}\n{chunk.text}"
|
|
138
|
+
for chunk, _ in ranked[:TOP_CHUNKS]
|
|
139
|
+
)
|
|
@@ -61,6 +61,11 @@ class UpReport(_UpReportSince20261102):
|
|
|
61
61
|
notes: list[str]
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
def accepted() -> StackPlan | None:
|
|
65
|
+
"""The plan of the last ``stack apply``, if that apply passed."""
|
|
66
|
+
return _accepted()
|
|
67
|
+
|
|
68
|
+
|
|
64
69
|
def _accepted(plan_id: str | None = None) -> StackPlan | None:
|
|
65
70
|
"""The plan of the last stack apply (of ``plan_id`` when given) if that apply passed."""
|
|
66
71
|
for run, saved in reversed(hosts.stack_runs()):
|
|
@@ -105,10 +110,12 @@ def installed(
|
|
|
105
110
|
saved.pop("update", None) # an update plan installs what a plain one with its options would
|
|
106
111
|
saved.setdefault("search", True) # old saved plans enabled search by omission
|
|
107
112
|
wanted = dict(options)
|
|
108
|
-
for key in ("decision", "aux", "tts", "search"):
|
|
113
|
+
for key in ("decision", "aux", "tts", "search", "route"):
|
|
109
114
|
if key not in selected:
|
|
110
115
|
saved.pop(key, None)
|
|
111
116
|
wanted.pop(key, None)
|
|
117
|
+
if "llm_fast_port" not in wanted:
|
|
118
|
+
saved.pop("llm_fast_port", None)
|
|
112
119
|
if "aux" not in selected:
|
|
113
120
|
saved.pop("aux_tasks", None)
|
|
114
121
|
wanted.pop("aux_tasks", None)
|
|
@@ -32,6 +32,7 @@ from localmodels import (
|
|
|
32
32
|
deploy,
|
|
33
33
|
harness,
|
|
34
34
|
hosts,
|
|
35
|
+
metal,
|
|
35
36
|
reuse,
|
|
36
37
|
stack_compose,
|
|
37
38
|
stack_run,
|
|
@@ -96,6 +97,13 @@ def preserve_components(
|
|
|
96
97
|
Explicit CLI selections override inheritance and appear in the approved update.
|
|
97
98
|
"""
|
|
98
99
|
kept = dict(options)
|
|
100
|
+
if (
|
|
101
|
+
"route" not in selected
|
|
102
|
+
and "route" not in options
|
|
103
|
+
and base.get("llm_fast")
|
|
104
|
+
and base["options"].get("route")
|
|
105
|
+
):
|
|
106
|
+
kept["route"] = base["options"]["route"]
|
|
99
107
|
if "decision" not in selected and options["decision"] == "none":
|
|
100
108
|
if base["decision"] is not None:
|
|
101
109
|
kept["decision"] = base["options"]["decision"]
|
|
@@ -135,7 +143,8 @@ def held_ports(live: dict[str, Plan], running: Callable[[Plan], list[int]]) -> d
|
|
|
135
143
|
|
|
136
144
|
def reclaimed(facts: HostFacts, pids: set[int]) -> HostFacts:
|
|
137
145
|
"""``facts`` as if this tool's processes ``pids`` were stopped: they leave the compute process
|
|
138
|
-
list and the memory they hold goes back to their card. Another owner's process stays.
|
|
146
|
+
list and the memory they hold goes back to their card. Another owner's process stays. On a
|
|
147
|
+
Mac the card is the unified memory, so it goes back to the RAM available too."""
|
|
139
148
|
services = facts.get("services")
|
|
140
149
|
procs = services.get("compute_processes") if services else None
|
|
141
150
|
mine = [p for p in procs or [] if p["pid"] in pids and p["owned"] is True]
|
|
@@ -153,6 +162,12 @@ def reclaimed(facts: HostFacts, pids: set[int]) -> HostFacts:
|
|
|
153
162
|
back = freed.get(g["uuid"], 0)
|
|
154
163
|
g["free_bytes"] = min(g["total_bytes"], g["free_bytes"] + back)
|
|
155
164
|
g["used_bytes"] = max(0, g["used_bytes"] - back)
|
|
165
|
+
if (facts.get("metal") or {}).get("unified_memory") is True and (
|
|
166
|
+
back := freed.get(metal.METAL_UUID, 0)
|
|
167
|
+
):
|
|
168
|
+
seen["ram"]["available_bytes"] = min(
|
|
169
|
+
seen["ram"]["total_bytes"], seen["ram"]["available_bytes"] + back
|
|
170
|
+
)
|
|
156
171
|
return seen
|
|
157
172
|
|
|
158
173
|
|
|
@@ -209,8 +224,13 @@ def compose(
|
|
|
209
224
|
live = installed()
|
|
210
225
|
held = held_ports(live, running)
|
|
211
226
|
pids = {pid for found in held.values() for pid in found}
|
|
227
|
+
# reclaimed returns the same object when nothing of ours is running. Re-applying
|
|
228
|
+
# --unified-memory only after that copy, so assume does not subtract the same bytes twice.
|
|
229
|
+
priced = reclaimed(facts, pids)
|
|
230
|
+
if priced is not facts and (total := metal.assumed_total(priced)) is not None:
|
|
231
|
+
priced = metal.assume(priced, total)
|
|
212
232
|
plan = stack_compose.compose(
|
|
213
|
-
ports_freed(
|
|
233
|
+
ports_freed(priced, set(held)),
|
|
214
234
|
tools,
|
|
215
235
|
options,
|
|
216
236
|
resolver=resolver,
|
|
@@ -238,6 +258,8 @@ def compose(
|
|
|
238
258
|
|
|
239
259
|
def roles(plan: StackPlan) -> dict[str, Plan]:
|
|
240
260
|
found = {"llm": plan["llm"]}
|
|
261
|
+
if fast := plan.get("llm_fast"):
|
|
262
|
+
found["llm_fast"] = fast
|
|
241
263
|
if plan["decision"] is not None:
|
|
242
264
|
found["decision"] = plan["decision"]
|
|
243
265
|
if (front := plan.get("decision_front")) is not None:
|
|
@@ -275,6 +297,8 @@ def version(part: Plan) -> str:
|
|
|
275
297
|
def _keep(plan: StackPlan, role: str, part: Plan) -> None:
|
|
276
298
|
if role == "llm":
|
|
277
299
|
plan["llm"] = part
|
|
300
|
+
elif role == "llm_fast":
|
|
301
|
+
plan["llm_fast"] = part
|
|
278
302
|
elif role == "decision":
|
|
279
303
|
plan["decision"] = part
|
|
280
304
|
elif role == "decision_front":
|
|
@@ -494,7 +518,8 @@ def _under(path: str, base_dir: str) -> bool:
|
|
|
494
518
|
def replaced(plan: StackPlan) -> list[str]:
|
|
495
519
|
"""This install's stack deployments that a role of ``plan`` takes over under another name
|
|
496
520
|
(another model, port or quantization): installed by an earlier stack apply from the same
|
|
497
|
-
base directory, still recorded, and not part of ``plan``.
|
|
521
|
+
base directory, still recorded, and not part of ``plan``. An omitted fast LLM also retires,
|
|
522
|
+
so a fresh single-target plan cannot leave it running outside the gateway."""
|
|
498
523
|
live = installed()
|
|
499
524
|
if not live:
|
|
500
525
|
return []
|
|
@@ -510,7 +535,7 @@ def replaced(plan: StackPlan) -> list[str]:
|
|
|
510
535
|
name
|
|
511
536
|
for name, part in live.items()
|
|
512
537
|
if name not in names
|
|
513
|
-
and was.get(name) in now
|
|
538
|
+
and (was.get(name) in now or was.get(name) == "llm_fast")
|
|
514
539
|
and _under(part["service"]["deploy_dir"], plan["options"]["base_dir"])
|
|
515
540
|
)
|
|
516
541
|
|
|
@@ -40,6 +40,8 @@ def parts(plan: StackPlan) -> list[tuple[str, Plan]]:
|
|
|
40
40
|
"""(component, deployment) for every service the plan deployed, the decision server
|
|
41
41
|
before the front that answers for it."""
|
|
42
42
|
found = [("llm", plan["llm"])]
|
|
43
|
+
if fast := plan.get("llm_fast"):
|
|
44
|
+
found.append(("llm_fast", fast))
|
|
43
45
|
found += [("decision", p) for p in (plan["decision"], plan.get("decision_front")) if p]
|
|
44
46
|
found += [(p["endpoint"].get("contract", "aux"), p) for p in plan.get("aux", [])]
|
|
45
47
|
return found
|
|
@@ -150,7 +152,7 @@ def verify(plan: StackPlan, owned: hosts.Owned, do: Effects = REAL) -> list[Chec
|
|
|
150
152
|
checks.append(check)
|
|
151
153
|
ok["decision"] = check["ok"]
|
|
152
154
|
gw = plan["harness"]
|
|
153
|
-
if not ok.get("llm"):
|
|
155
|
+
if not ok.get("llm") or (plan.get("llm_fast") and not ok.get("llm_fast")):
|
|
154
156
|
checks.append(
|
|
155
157
|
{
|
|
156
158
|
"check": "gateway",
|
|
@@ -50,7 +50,7 @@ from localmodels.stack_view_words import say
|
|
|
50
50
|
SCHEMA = "localmodels.stack-view/v1"
|
|
51
51
|
GIB = 1 << 30
|
|
52
52
|
METRICS_BYTES = 256 * 1024 # a llama-server /metrics page is a few KiB
|
|
53
|
-
TASKS = ("llm", "decision", "embedding", "rerank", "stt", "tts")
|
|
53
|
+
TASKS = ("llm", "llm_fast", "decision", "embedding", "rerank", "stt", "tts")
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
class Figure(TypedDict):
|
|
@@ -73,7 +73,7 @@ class Fit(TypedDict):
|
|
|
73
73
|
|
|
74
74
|
id: str
|
|
75
75
|
quant: str
|
|
76
|
-
decode_tok_s: float # the planner's
|
|
76
|
+
decode_tok_s: float # the planner's calibrated decode estimate
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
class Gpu(TypedDict):
|
|
@@ -273,10 +273,7 @@ def _gpu_of(part: Plan) -> int | None:
|
|
|
273
273
|
|
|
274
274
|
|
|
275
275
|
def _decode_estimate(hw: Hardware | None, part: Plan) -> Figure:
|
|
276
|
-
"""The
|
|
277
|
-
(catalog.decode_estimate) at the card's spec bandwidth, priced as stack hardware prices
|
|
278
|
-
its fits. It does not ask whether the LLM would fit there again: a running stack leaves no
|
|
279
|
-
room for a second copy, and the ceiling is the same."""
|
|
276
|
+
"""The uncalibrated bandwidth bound, independent of fitted workload efficiency."""
|
|
280
277
|
gpu = _gpu_of(part)
|
|
281
278
|
card = next((c for c in hw["cards"] if c["index"] == gpu), None) if hw else None
|
|
282
279
|
entry = catalog_entry(part["model"]["id"])
|
|
@@ -297,7 +294,7 @@ def _decode_estimate(hw: Hardware | None, part: Plan) -> Figure:
|
|
|
297
294
|
platform=str(hw.get("platform") or ""),
|
|
298
295
|
gpu_bandwidth_gb_s=float(bandwidth) if isinstance(bandwidth, int | float) else None,
|
|
299
296
|
)
|
|
300
|
-
speed = cat.decode_estimate(entry, variant, budget)
|
|
297
|
+
speed = cat.decode_estimate(entry, variant, budget, calibrated=False)
|
|
301
298
|
key = f"decode.{speed.basis}"
|
|
302
299
|
basis = say(key) if key in _DECODE_EN else speed.basis
|
|
303
300
|
return _figure(speed.tok_s, "estimate", say("fig.bound", basis=basis))
|
|
@@ -337,7 +334,7 @@ def _perf(
|
|
|
337
334
|
"live",
|
|
338
335
|
say("fig.decode.live"),
|
|
339
336
|
)
|
|
340
|
-
if task
|
|
337
|
+
if task in ("llm", "llm_fast"):
|
|
341
338
|
perf["decode_bound"] = _decode_estimate(hw, part)
|
|
342
339
|
if perf["decode_tok_s"]["value"] is None:
|
|
343
340
|
perf["decode_tok_s"] = _figure(None, "none", say("fig.decode.none"))
|
|
@@ -377,9 +374,9 @@ def _device(part: Plan, gpu: int | None) -> str:
|
|
|
377
374
|
def _component(task: str, part: Plan, reading: Reading, ram: int) -> Component:
|
|
378
375
|
launch = part["launch"]
|
|
379
376
|
gpu = _gpu_of(part)
|
|
380
|
-
parts = sum(llm_parts(part).values()) if task
|
|
377
|
+
parts = sum(llm_parts(part).values()) if task in ("llm", "llm_fast") else 0
|
|
381
378
|
vram = (parts or _int(launch.get("vram_bytes"))) if gpu is not None else 0
|
|
382
|
-
if gpu is None and task
|
|
379
|
+
if gpu is None and task in ("llm", "llm_fast"):
|
|
383
380
|
ram = ram or parts # an LLM off the GPU holds its weights and KV in host memory
|
|
384
381
|
state, health = _state(reading["liveness"].get(part["name"]))
|
|
385
382
|
kv = launch.get("kv_types")
|
|
@@ -418,6 +415,8 @@ def _component(task: str, part: Plan, reading: Reading, ram: int) -> Component:
|
|
|
418
415
|
def parts_of(plan: StackPlan) -> list[tuple[str, Plan]]:
|
|
419
416
|
"""Each deployment a stack plan runs, by task: the LLM, the decision model, auxiliaries."""
|
|
420
417
|
found: list[tuple[str, Plan]] = [("llm", plan["llm"])]
|
|
418
|
+
if fast := plan.get("llm_fast"):
|
|
419
|
+
found.append(("llm_fast", fast))
|
|
421
420
|
if plan.get("decision"):
|
|
422
421
|
found.append(("decision", cast(Plan, plan["decision"])))
|
|
423
422
|
for aux in plan.get("aux", []):
|
|
@@ -712,7 +711,7 @@ def read_live(hw: Hardware | None = None) -> Reading:
|
|
|
712
711
|
live[task] = part # measured below: what it holds beside what the plan priced
|
|
713
712
|
if found := read_metrics(part):
|
|
714
713
|
counters[part["name"]] = found
|
|
715
|
-
if task
|
|
714
|
+
if task in ("llm", "llm_fast") and (ctx := stack_view_slots.read(part)) is not None:
|
|
716
715
|
slots[part["name"]] = ctx
|
|
717
716
|
magpie = (
|
|
718
717
|
plan["harness"]["gateway"]["addr"]
|
|
@@ -8,10 +8,11 @@ from typing import TypedDict, cast
|
|
|
8
8
|
|
|
9
9
|
from localmodels import stack_journal
|
|
10
10
|
from localmodels.records import Plan
|
|
11
|
+
from localmodels.stack_events import APPLY_ORDER as APPLY_ORDER
|
|
11
12
|
from localmodels.stack_plan import StackPlan
|
|
12
13
|
from localmodels.stack_view_words import say
|
|
13
14
|
|
|
14
|
-
ROLES = ("llm", "decision", "embedding", "rerank", "stt", "tts")
|
|
15
|
+
ROLES = ("llm", "llm_fast", "decision", "embedding", "rerank", "stt", "tts")
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class ApplyRow(TypedDict):
|
|
@@ -39,6 +40,8 @@ def _apply_details(plan: StackPlan) -> dict[str, str]:
|
|
|
39
40
|
"""What each component of ``plan`` installs, by the ids apply reports: models by id, the
|
|
40
41
|
gateway by kind and address. Never a path."""
|
|
41
42
|
found = {"llm": f"{plan['llm']['model']['id']} {plan['llm']['model']['quant']}"}
|
|
43
|
+
if fast := plan.get("llm_fast"):
|
|
44
|
+
found["llm_fast"] = f"{fast['model']['id']} {fast['model']['quant']}"
|
|
42
45
|
if plan.get("decision"):
|
|
43
46
|
found["decision"] = cast(Plan, plan["decision"])["model"]["id"]
|
|
44
47
|
for part in plan.get("aux", []):
|
|
@@ -87,5 +90,4 @@ def rows(live: stack_journal.Live | None, plan: StackPlan) -> Apply | None:
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
|
|
90
|
-
APPLY_ORDER = ("decision", "llm", "embedding", "rerank", "stt", "tts", "search", "gateway")
|
|
91
93
|
APPLY_STATES = {"waiting", "running", "ok", "failed", "skipped"}
|
|
@@ -25,7 +25,7 @@ import os
|
|
|
25
25
|
from typing import Any, TypedDict
|
|
26
26
|
|
|
27
27
|
from localmodels import bifrost_checks, gateway, harness, hosts
|
|
28
|
-
from localmodels.gateway_bifrost import owned_listener
|
|
28
|
+
from localmodels.gateway_bifrost import FAST_PROVIDER, owned_listener
|
|
29
29
|
from localmodels.stack_view_words import say
|
|
30
30
|
|
|
31
31
|
LIMIT = 40 # the last calls a page needs to animate and to average
|
|
@@ -78,6 +78,7 @@ def newest_first(events: list[Event]) -> list[Event]:
|
|
|
78
78
|
|
|
79
79
|
def _components() -> dict[str, str]:
|
|
80
80
|
found = {harness.LLM_PROVIDER: "llm", harness.DECISION_PROVIDER: "decision"}
|
|
81
|
+
found[FAST_PROVIDER] = "llm_fast"
|
|
81
82
|
found.update({provider: task for task, provider in gateway.AUX_PROVIDERS.items()})
|
|
82
83
|
return found
|
|
83
84
|
|
|
@@ -56,6 +56,9 @@ FILES = {
|
|
|
56
56
|
"nav.js": ("nav.js", "text/javascript; charset=utf-8"),
|
|
57
57
|
"fleet.js": ("fleet.js", "text/javascript; charset=utf-8"),
|
|
58
58
|
"icon.svg": ("icon.svg", "image/svg+xml"),
|
|
59
|
+
"logo-pi.svg": ("logo-pi.svg", "image/svg+xml"),
|
|
60
|
+
"logo-claude.svg": ("logo-claude.svg", "image/svg+xml"),
|
|
61
|
+
"logo-codex.png": ("logo-codex.png", "image/png"),
|
|
59
62
|
"manifest.webmanifest": ("manifest.webmanifest", "application/manifest+json"),
|
|
60
63
|
}
|
|
61
64
|
FORBIDDEN = b"stack view: this address needs the access key; open the LAN link printed at start.\n"
|
|
@@ -458,7 +458,7 @@ def _memory(view: StackView, paint: Paint, cells: int) -> list[str]:
|
|
|
458
458
|
lines += [head, f" {used}", *([] if aside else _map(gpu["segments"], paint, cells))]
|
|
459
459
|
if gpu["fits"]:
|
|
460
460
|
items = [
|
|
461
|
-
f"{f['id']} {f['quant']} (
|
|
461
|
+
f"{f['id']} {f['quant']} ({rate(f['decode_tok_s'])} tok/s)" for f in gpu["fits"]
|
|
462
462
|
]
|
|
463
463
|
lines += [paint(line, "muted") for line in _fits(items, cells)]
|
|
464
464
|
ram = view["ram"]
|
|
@@ -9,6 +9,9 @@ from __future__ import annotations
|
|
|
9
9
|
WORDS: dict[str, str] = {
|
|
10
10
|
# components: the role chip and what it does
|
|
11
11
|
"role.llm": "LLM",
|
|
12
|
+
"role.llm_fast": "Fast LLM",
|
|
13
|
+
"explain.llm_fast": "The fastest LLM handles easy turns; the primary LLM handles COMPLEX turns.",
|
|
14
|
+
"ram.llm_fast": "Fast LLM (host side)",
|
|
12
15
|
"role.decision": "Jev decision",
|
|
13
16
|
"role.embedding": "Embedding",
|
|
14
17
|
"role.rerank": "Reranker",
|
|
@@ -177,7 +180,7 @@ WORDS: dict[str, str] = {
|
|
|
177
180
|
"t.measured": "measured",
|
|
178
181
|
"t.demo": "demo",
|
|
179
182
|
"t.fits": (
|
|
180
|
-
"still fits now (at least 64K shared pool × 2 sessions; decode
|
|
183
|
+
"still fits now (at least 64K shared pool × 2 sessions; decode speeds are estimates): "
|
|
181
184
|
"{fits}"
|
|
182
185
|
),
|
|
183
186
|
"t.speed": "Speed",
|