@simplexai/localmodels-linux-x64 0.1.0-dev.37 → 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 +43 -42
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/bifrost_checks.py +9 -6
- package/modules/localmodels/bifrost_config.py +16 -1
- package/modules/localmodels/bifrost_datasheet.py +12 -2
- package/modules/localmodels/catalog.json +137 -2
- package/modules/localmodels/catalog.py +19 -1
- package/modules/localmodels/catalog_recipes.py +33 -2
- package/modules/localmodels/gateway_bifrost.py +11 -9
- package/modules/localmodels/gateway_cli.py +4 -2
- package/modules/localmodels/library_gateway.py +11 -0
- package/modules/localmodels/library_jobs.py +51 -3
- package/modules/localmodels/library_model.py +10 -0
- package/modules/localmodels/library_pricing.py +29 -22
- package/modules/localmodels/library_serve.py +5 -0
- package/modules/localmodels/library_state.py +9 -1
- package/modules/localmodels/library_status.py +30 -0
- package/modules/localmodels/llm_rank.py +83 -30
- package/modules/localmodels/process_identity.py +11 -0
- package/modules/localmodels/recommend.py +5 -2
- package/modules/localmodels/search_server.py +5 -1
- package/modules/localmodels/stack.py +31 -14
- package/modules/localmodels/stack_args.py +6 -3
- package/modules/localmodels/stack_cli.py +2 -0
- package/modules/localmodels/stack_compose.py +5 -5
- package/modules/localmodels/stack_hardware.py +4 -3
- package/modules/localmodels/stack_llm_ram.py +16 -6
- package/modules/localmodels/stack_picks.py +4 -4
- package/modules/localmodels/stack_progress.py +9 -1
- package/modules/localmodels/stack_run.py +29 -0
- package/modules/localmodels/stack_suite.py +10 -3
- package/modules/localmodels/stack_warm.py +45 -4
- package/modules/localmodels/tools.json +32 -18
- package/modules/localmodels/transport.py +38 -13
- package/modules/localmodels/windows_job.py +69 -0
- package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/RECORD +40 -39
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev37.dist-info → simplex_localmodels-0.1.0.dev38.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -15,7 +15,7 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
import json
|
|
17
17
|
from collections.abc import Sequence
|
|
18
|
-
from dataclasses import dataclass, field
|
|
18
|
+
from dataclasses import dataclass, field, replace
|
|
19
19
|
from pathlib import Path, PurePosixPath
|
|
20
20
|
|
|
21
21
|
from localmodels import decode_calibration, vision
|
|
@@ -128,6 +128,9 @@ class CatalogEntry:
|
|
|
128
128
|
full_layers: int
|
|
129
129
|
recurrent_layers: int
|
|
130
130
|
per_layer_f16: int # KV bytes/token per full-attention layer
|
|
131
|
+
# The agent posture's window never grows past this (0: no cap beyond the posture's target);
|
|
132
|
+
# the Mac small-memory ladder runs Spark-X2.6 at 64K shared by two slots (decision 57).
|
|
133
|
+
max_agent_window: int = 0
|
|
131
134
|
swa_layers: int = 0
|
|
132
135
|
swa_window: int = 0
|
|
133
136
|
moe: bool = False
|
|
@@ -166,6 +169,11 @@ class CatalogEntry:
|
|
|
166
169
|
validated_on: tuple[str, ...] = () # PLATFORMS its validating evidence ran on; empty: all
|
|
167
170
|
reasoning_efforts: tuple[str, ...] = () # levels the template accepts; empty: EFFORT_LEVELS
|
|
168
171
|
runtime: str = "llama.cpp"
|
|
172
|
+
# Model card (CardData): empty when the catalog does not state it.
|
|
173
|
+
family: str = ""
|
|
174
|
+
publisher: str = ""
|
|
175
|
+
parameters: str = ""
|
|
176
|
+
active_parameters: str = ""
|
|
169
177
|
|
|
170
178
|
@property
|
|
171
179
|
def mtp_capable(self) -> bool:
|
|
@@ -210,6 +218,11 @@ class CatalogEntry:
|
|
|
210
218
|
agent: AgentPosture | None = None,
|
|
211
219
|
) -> LaunchPlan:
|
|
212
220
|
if agent is not None:
|
|
221
|
+
if self.max_agent_window:
|
|
222
|
+
cap = self.max_agent_window
|
|
223
|
+
agent = replace(
|
|
224
|
+
agent, target=min(agent.target, cap), preferred=min(agent.preferred, cap)
|
|
225
|
+
)
|
|
213
226
|
profile = eager(self.profile(variant)) # the agent argv has no --lazy-mode
|
|
214
227
|
depth = self.mtp_draft_depth if self.agent_mtp and self.mtp_capable else 0
|
|
215
228
|
return vision.priced(self.mmproj, profile, budget, agent, mtp_depth=depth)
|
|
@@ -413,6 +426,7 @@ def load_catalog(value: object) -> tuple[CatalogEntry, ...]:
|
|
|
413
426
|
full_layers=m["full_layers"],
|
|
414
427
|
recurrent_layers=m["recurrent_layers"],
|
|
415
428
|
per_layer_f16=m["per_layer_f16"],
|
|
429
|
+
max_agent_window=m.get("max_agent_window", 0),
|
|
416
430
|
swa_layers=m.get("swa_layers", 0),
|
|
417
431
|
swa_window=m.get("swa_window", 0),
|
|
418
432
|
moe=m.get("moe", False),
|
|
@@ -443,6 +457,10 @@ def load_catalog(value: object) -> tuple[CatalogEntry, ...]:
|
|
|
443
457
|
validated_on=tuple(m.get("validated_on", [])),
|
|
444
458
|
reasoning_efforts=tuple(m.get("reasoning_efforts", [])),
|
|
445
459
|
runtime=m.get("runtime", "llama.cpp"),
|
|
460
|
+
family=m.get("family", ""),
|
|
461
|
+
publisher=m.get("publisher", ""),
|
|
462
|
+
parameters=m.get("parameters", ""),
|
|
463
|
+
active_parameters=m.get("active_parameters", ""),
|
|
446
464
|
)
|
|
447
465
|
)
|
|
448
466
|
return tuple(entries)
|
|
@@ -18,6 +18,9 @@ STATUSES = ("candidate", "validated", "deprecated")
|
|
|
18
18
|
PLATFORMS = ("linux", "darwin", "win32") # validated_on: Linux, Apple Silicon Macs, Windows
|
|
19
19
|
EFFORT_LEVELS = ("low", "medium", "high") # reasoning_effort values a gateway may send, in order
|
|
20
20
|
TASKS = tuple("llm vision decision embedding reranker stt tts search privacy-span".split())
|
|
21
|
+
# Model-card families Linger's LocalModelFamily knows (its contract); "other" for the rest.
|
|
22
|
+
FAMILIES = tuple("qwen gemma llama openai deepseek mistral phi glm kimi claude grok other".split())
|
|
23
|
+
SCALE = r"[1-9][0-9]*(\.[0-9]+)?[BM]" # a parameter scale as a model's name states it: 27B, 1.7B
|
|
21
24
|
# intelligence_score: the installed SimplexAI score (decisions 26, 33); make check keeps it equal
|
|
22
25
|
QUALITY_SOURCE_TYPES = ("editorial", "own_eval", "external_index", "kld", "intelligence_score")
|
|
23
26
|
|
|
@@ -88,8 +91,20 @@ class ProvenanceData(TypedDict, total=False):
|
|
|
88
91
|
base_license_url: str
|
|
89
92
|
|
|
90
93
|
|
|
91
|
-
class
|
|
94
|
+
class CardData(TypedDict, total=False):
|
|
95
|
+
"""Since 2026-11-17: what a model card shows, stated per entry, never guessed from a name.
|
|
96
|
+
``family`` is one of FAMILIES; ``parameters`` and ``active_parameters`` are display scales
|
|
97
|
+
such as 35B and 3B (an MoE's active slice), as the model's own name states them."""
|
|
98
|
+
|
|
99
|
+
family: str
|
|
100
|
+
publisher: str
|
|
101
|
+
parameters: str
|
|
102
|
+
active_parameters: str
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class OptionalModelData(ModelData, ProvenanceData, CardData, total=False):
|
|
92
106
|
runtime: str
|
|
107
|
+
max_agent_window: int # since 2026-11-16: the agent posture's window cap, tokens
|
|
93
108
|
swa_layers: int
|
|
94
109
|
swa_window: int
|
|
95
110
|
moe: bool
|
|
@@ -270,6 +285,22 @@ def _entry_problems(
|
|
|
270
285
|
return found
|
|
271
286
|
|
|
272
287
|
|
|
288
|
+
def _card_problems(model: OptionalModelData) -> list[str]:
|
|
289
|
+
found = []
|
|
290
|
+
if model.get("family") is not None and model.get("family") not in FAMILIES:
|
|
291
|
+
found.append(f"family is not one of {', '.join(FAMILIES)}")
|
|
292
|
+
publisher = model.get("publisher")
|
|
293
|
+
if publisher is not None and not (0 < len(publisher.strip()) <= 120):
|
|
294
|
+
found.append("publisher must be 1 to 120 characters")
|
|
295
|
+
for key in ("parameters", "active_parameters"):
|
|
296
|
+
value = cast(dict[str, object], model).get(key)
|
|
297
|
+
if value is not None and not re.fullmatch(SCALE, str(value)):
|
|
298
|
+
found.append(f"{key} is not a scale such as 27B or 1.7B")
|
|
299
|
+
if model.get("active_parameters") and not model.get("parameters"):
|
|
300
|
+
found.append("active_parameters needs parameters")
|
|
301
|
+
return found
|
|
302
|
+
|
|
303
|
+
|
|
273
304
|
def _pin_problems(model: OptionalModelData) -> list[str]:
|
|
274
305
|
"""A file pinned by content must name that content and the commit that holds it."""
|
|
275
306
|
assets = [f for v in model["variants"] for f in v["files"]]
|
|
@@ -303,7 +334,7 @@ def problems(value: object) -> list[str]:
|
|
|
303
334
|
issues.append("quality has no sources")
|
|
304
335
|
elif any(s["type"] not in QUALITY_SOURCE_TYPES for s in quality["sources"]):
|
|
305
336
|
issues.append("quality.sources[].type is unknown")
|
|
306
|
-
issues += _pin_problems(m)
|
|
337
|
+
issues += _pin_problems(m) + _card_problems(m)
|
|
307
338
|
found += [f"models.{m['id']}: {issue}" for issue in issues]
|
|
308
339
|
for c in doc.get("components", []):
|
|
309
340
|
issues = _entry_problems(c, c["task"], c["runtime"])
|
|
@@ -81,7 +81,8 @@ def plan_tools(
|
|
|
81
81
|
raise HarnessError("the tool lock has no Bifrost")
|
|
82
82
|
build = harness.tool_build(lock["bifrost"]["builds"], platform, arch, "Bifrost")
|
|
83
83
|
version = lock["bifrost"]["version"]
|
|
84
|
-
|
|
84
|
+
# Windows starts only a file named .exe; the npm package and the CDN name it bifrost-http.
|
|
85
|
+
binary = f"{tools_dir}/bifrost-{version}/bifrost-http" + (".exe" if platform == "win32" else "")
|
|
85
86
|
found = os.path.expanduser(binary)
|
|
86
87
|
if os.path.lexists(found) and harness.digest(found) != build["sha256"]:
|
|
87
88
|
raise HarnessError(f"{binary} is not the pinned Bifrost {version}; deal with it first")
|
|
@@ -95,7 +96,7 @@ def plan_tools(
|
|
|
95
96
|
addr = state.get("bifrost_addr") or harness.bifrost_addr()
|
|
96
97
|
listeners = set(state.get("bifrost_listeners", []))
|
|
97
98
|
ours = hosts.load_owned(tools_dir)["gateway"].get("bifrost")
|
|
98
|
-
if listeners - {
|
|
99
|
+
if listeners - {process_identity.current_uid()}:
|
|
99
100
|
raise HarnessError(
|
|
100
101
|
f"Bifrost address {addr} is held by another user's program; ask them to free it, or "
|
|
101
102
|
"set LOCALMODELS_BIFROST_ADDR=127.0.0.1:<free port> in this terminal and plan again"
|
|
@@ -260,7 +261,7 @@ def owned_listener(record: hosts.OwnedBifrost) -> bool:
|
|
|
260
261
|
]
|
|
261
262
|
return bool(
|
|
262
263
|
before
|
|
263
|
-
and before["uid"] ==
|
|
264
|
+
and before["uid"] == process_identity.current_uid()
|
|
264
265
|
and remote_ops_service.command_matches(pid, argv)
|
|
265
266
|
and remote_ops_service.listener_problem(harness_gateway.address_port(addr), [pid])
|
|
266
267
|
is None
|
|
@@ -371,17 +372,18 @@ def _start(record: hosts.OwnedBifrost, restart: bool) -> None:
|
|
|
371
372
|
_stop_serve(app) # ours: restarted, or an earlier instance that stopped answering
|
|
372
373
|
host, _, port = addr.rpartition(":")
|
|
373
374
|
env = {**os.environ, "NO_PROXY": "127.0.0.1,localhost", "no_proxy": "127.0.0.1,localhost"}
|
|
375
|
+
options: dict[str, Any] = {"cwd": app, "env": env, "stdin": subprocess.DEVNULL}
|
|
376
|
+
if os.name != "nt":
|
|
377
|
+
options["umask"] = 0o077 # its SQLite stores and log stay private
|
|
374
378
|
with (app / "bifrost.log").open("ab") as log:
|
|
375
|
-
|
|
379
|
+
# Its own session; on Windows also no console, out of the starting job (a scheduled
|
|
380
|
+
# task ends its job's processes), at normal priority, as every service this tool runs.
|
|
381
|
+
proc = process_identity.spawn_detached(
|
|
376
382
|
[record["binary"], "-app-dir", str(app), "-host", host, "-port", port]
|
|
377
383
|
+ ["-log-style", "json", "-log-level", "warn"],
|
|
378
|
-
cwd=app,
|
|
379
|
-
env=env,
|
|
380
|
-
stdin=subprocess.DEVNULL,
|
|
381
384
|
stdout=log,
|
|
382
385
|
stderr=log,
|
|
383
|
-
|
|
384
|
-
umask=0o077, # its SQLite stores and log stay private
|
|
386
|
+
**options,
|
|
385
387
|
)
|
|
386
388
|
try:
|
|
387
389
|
process_identity.save(app / "bifrost.pid", proc.pid)
|
|
@@ -86,8 +86,10 @@ def choose_kind(
|
|
|
86
86
|
if choice == "magpie":
|
|
87
87
|
return choice
|
|
88
88
|
platform, arch = runtime_cli._platform().split("-", 1)
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
# Windows keeps Magpie (decisions 32 and 48): its Bifrost build (since localmodels.6) serves
|
|
90
|
+
# the model library, whose own gateway is a different instance; this one is not verified there.
|
|
91
|
+
available = platform != "win32" and any(
|
|
92
|
+
b["platform"] == platform and b["arch"] == arch
|
|
91
93
|
for b in harness.load_lock()["bifrost"]["builds"]
|
|
92
94
|
)
|
|
93
95
|
if choice == "auto" and (not available or runtime is None):
|
|
@@ -23,6 +23,7 @@ from pathlib import Path
|
|
|
23
23
|
from typing import Any
|
|
24
24
|
|
|
25
25
|
from localmodels import (
|
|
26
|
+
bifrost_config,
|
|
26
27
|
bifrost_datasheet,
|
|
27
28
|
bifrost_models,
|
|
28
29
|
bifrost_unit,
|
|
@@ -39,6 +40,8 @@ from localmodels.probe import HostFacts
|
|
|
39
40
|
from localmodels.records import Plan
|
|
40
41
|
|
|
41
42
|
PROVIDER_PREFIX = "localmodels-lib-"
|
|
43
|
+
# Windows cannot delete the config store a running Bifrost holds open: stop it before a change.
|
|
44
|
+
STOP_BEFORE_CONFIG_CHANGE = os.name == "nt"
|
|
42
45
|
PI_PROVIDER = "localmodels-library"
|
|
43
46
|
|
|
44
47
|
|
|
@@ -149,6 +152,14 @@ def _apply(record: hosts.OwnedBifrost, config: dict[str, Any], sheet: dict[str,
|
|
|
149
152
|
and config kept, and the next load starts it again."""
|
|
150
153
|
app = Path(record["app_dir"])
|
|
151
154
|
params = {bifrost_datasheet.DATASHEET: sheet, bifrost_datasheet.PARAMETERS: {}}
|
|
155
|
+
if (
|
|
156
|
+
STOP_BEFORE_CONFIG_CHANGE
|
|
157
|
+
and record["how"] != "unit"
|
|
158
|
+
and bifrost_config.differs(app, config, params)
|
|
159
|
+
):
|
|
160
|
+
# A change drops the config store, which Windows cannot delete while Bifrost holds it
|
|
161
|
+
# open (WinError 32 on unload, homewin): stop it first; it restarts on the change.
|
|
162
|
+
gateway_bifrost._stop_serve(app)
|
|
152
163
|
changed = gateway_bifrost._write_config(app, config, params)
|
|
153
164
|
if not config.get("providers"):
|
|
154
165
|
_stop(record)
|
|
@@ -12,8 +12,10 @@ from __future__ import annotations
|
|
|
12
12
|
|
|
13
13
|
import os
|
|
14
14
|
import signal
|
|
15
|
+
import threading
|
|
15
16
|
import time
|
|
16
|
-
from collections.abc import Callable
|
|
17
|
+
from collections.abc import Callable, Iterator
|
|
18
|
+
from contextlib import contextmanager
|
|
17
19
|
from pathlib import Path
|
|
18
20
|
|
|
19
21
|
from localmodels import (
|
|
@@ -25,6 +27,7 @@ from localmodels import (
|
|
|
25
27
|
library_state,
|
|
26
28
|
library_status,
|
|
27
29
|
plan_envelope,
|
|
30
|
+
process_identity,
|
|
28
31
|
remote_ops_download,
|
|
29
32
|
)
|
|
30
33
|
from localmodels.deploy_steps import Action
|
|
@@ -61,6 +64,45 @@ def cancel_on_sigterm() -> None:
|
|
|
61
64
|
signal.signal(signal.SIGTERM, once)
|
|
62
65
|
|
|
63
66
|
|
|
67
|
+
WATCH_S = 0.2 # how often a Windows download looks for its cancel mark
|
|
68
|
+
CANCEL_BY_MARK = os.name == "nt" # Windows: no signal reaches a job; it watches its mark
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@contextmanager
|
|
72
|
+
def watch_cancel(job: Job) -> Iterator[None]:
|
|
73
|
+
"""Windows: a cancel cannot signal this process (another console process can only end it,
|
|
74
|
+
which would leave no CANCELLED line and no cleanup), so ``cancel`` marks the job and waits.
|
|
75
|
+
While the body runs, a thread looks for the mark and ends the download helper this process
|
|
76
|
+
runs, again until the body is over: the transfer then fails, the job sees its mark
|
|
77
|
+
(``_cancelled``) and ends as a cancel does on POSIX. POSIX gets SIGTERM instead."""
|
|
78
|
+
if not CANCEL_BY_MARK:
|
|
79
|
+
yield
|
|
80
|
+
return
|
|
81
|
+
done = threading.Event()
|
|
82
|
+
|
|
83
|
+
def watch() -> None:
|
|
84
|
+
while not done.wait(WATCH_S):
|
|
85
|
+
if library_state.cancelled(job):
|
|
86
|
+
try:
|
|
87
|
+
process_identity.stop_children(os.getpid())
|
|
88
|
+
except (OSError, RuntimeError, ValueError):
|
|
89
|
+
pass # the cancel ends the whole tree after its grace
|
|
90
|
+
|
|
91
|
+
thread = threading.Thread(target=watch, name="cancel-watch", daemon=True)
|
|
92
|
+
thread.start()
|
|
93
|
+
try:
|
|
94
|
+
yield
|
|
95
|
+
finally:
|
|
96
|
+
done.set()
|
|
97
|
+
thread.join(timeout=5)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _cancelled(job: Job) -> None:
|
|
101
|
+
"""Windows: a cancel marked this job; end it the way a cancel's SIGTERM ends it on POSIX."""
|
|
102
|
+
if CANCEL_BY_MARK and library_state.cancelled(job):
|
|
103
|
+
raise KeyboardInterrupt
|
|
104
|
+
|
|
105
|
+
|
|
64
106
|
def dests(plan: Plan) -> list[str]:
|
|
65
107
|
return [os.path.expanduser(f["dest"]) for f in plan["files"]]
|
|
66
108
|
|
|
@@ -190,6 +232,7 @@ def _shared(model: str, plan: Plan, handle: JobHandle, run: Executor, waiting: l
|
|
|
190
232
|
or claim and fetch one when its download ended without it."""
|
|
191
233
|
by_dest = {os.path.expanduser(f["dest"]): f for f in plan["files"]}
|
|
192
234
|
while waiting:
|
|
235
|
+
_cancelled(handle.job)
|
|
193
236
|
for dest in list(waiting):
|
|
194
237
|
if plan_envelope.verified_in_place(by_dest[dest]):
|
|
195
238
|
waiting.remove(dest)
|
|
@@ -256,8 +299,13 @@ def _fetch_and_commit(
|
|
|
256
299
|
"""Fetch the files this job claimed, wait for the ones another download claimed, then
|
|
257
300
|
record the model as this job, unless a cancel marked it."""
|
|
258
301
|
job = handle.job
|
|
259
|
-
|
|
260
|
-
|
|
302
|
+
try:
|
|
303
|
+
with watch_cancel(job):
|
|
304
|
+
fetch(model.id, plan, handle, executor(), set(mine))
|
|
305
|
+
_shared(model.id, plan, handle, executor(), [f for f in files if f not in mine])
|
|
306
|
+
except LibraryError:
|
|
307
|
+
_cancelled(job) # the failure is the helper a cancel ended (Windows)
|
|
308
|
+
raise
|
|
261
309
|
selector = library_gateway.pi_model(model.id, str(plan["endpoint"]["model"]))
|
|
262
310
|
record: Record = library_state.new_record(
|
|
263
311
|
model.id, model.entry.id, model.variant.quant, pool, plan, selector
|
|
@@ -169,6 +169,16 @@ class Row(_Row, total=False):
|
|
|
169
169
|
endpoint: Endpoint # loaded only
|
|
170
170
|
pi_model: str # every model not absent: <pi provider>/<pi model id> once it is loaded
|
|
171
171
|
tokens_per_second: float # the last measured warm speed; absent when unknown
|
|
172
|
+
# The model card (Linger's LocalModel fields): from the catalog, each absent when unknown.
|
|
173
|
+
family: str
|
|
174
|
+
publisher: str
|
|
175
|
+
architecture: str # dense | moe
|
|
176
|
+
parameters: str
|
|
177
|
+
active_parameters: str
|
|
178
|
+
capabilities: list[str]
|
|
179
|
+
license: str
|
|
180
|
+
source_url: str
|
|
181
|
+
prompt_tokens_per_second: float # the last load's measured prefill speed
|
|
172
182
|
error: Problem # failed only
|
|
173
183
|
note: Note # idle only, when autoload was skipped
|
|
174
184
|
|
|
@@ -63,11 +63,18 @@ def is_chat(entry: cat.CatalogEntry) -> bool:
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def shown(facts: HostFacts, catalog: Iterable[cat.CatalogEntry]) -> list[Model]:
|
|
66
|
-
"""The chat models validated for this platform,
|
|
66
|
+
"""The chat models validated for this platform, and the candidates ``stack --llm auto``
|
|
67
|
+
picks here too (the Mac small-memory ladder, the Windows NVIDIA fallback): one row per
|
|
68
|
+
variant. Ling-3.0-tiny, which the ladder replaces in automatic selection, stays listed."""
|
|
67
69
|
return [
|
|
68
70
|
Model(e, v)
|
|
69
71
|
for e in catalog
|
|
70
|
-
if is_chat(e)
|
|
72
|
+
if is_chat(e)
|
|
73
|
+
and (
|
|
74
|
+
cat.validated_here(e, facts["platform"])
|
|
75
|
+
or llm_rank.mac_rung(e, facts)
|
|
76
|
+
or llm_rank.windows_fallback(e, facts)
|
|
77
|
+
)
|
|
71
78
|
for v in e.variants
|
|
72
79
|
]
|
|
73
80
|
|
|
@@ -320,28 +327,28 @@ def download_reason(facts: HostFacts, priced: Priced, disk_free: int) -> Reason
|
|
|
320
327
|
return None
|
|
321
328
|
|
|
322
329
|
|
|
323
|
-
def
|
|
324
|
-
"""
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
index = (metal.device(facts) or {"index": 0})["index"]
|
|
329
|
-
from localmodels import stack
|
|
330
|
+
def smartest(facts: HostFacts) -> tuple[str, str] | None:
|
|
331
|
+
"""(catalog id, quant) of the smartest pick ``stack hardware`` shows for this computer with
|
|
332
|
+
its memory free (stack_picks, decision 45): what ``stack plan --llm auto`` installs on it,
|
|
333
|
+
the Mac ladder and the Windows fallback included. None when nothing fits automatically."""
|
|
334
|
+
from localmodels import stack
|
|
330
335
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
seen = capacity(facts)
|
|
337
|
+
seen["disk"] = facts["disk"] # Strata's fit still sees the real disk
|
|
338
|
+
if seen["ram"].get("pressure_level") is not None: # a Mac with its memory free: no pressure
|
|
339
|
+
seen["ram"]["pressure_level"] = 1
|
|
340
|
+
try:
|
|
341
|
+
view = stack_hardware.view(seen, stack.default_options(), posture())
|
|
342
|
+
except (KeyError, ValueError, TypeError, OSError):
|
|
343
|
+
return None
|
|
344
|
+
pick = next((p for p in view.get("picks") or [] if p["role"] == "smartest"), None)
|
|
345
|
+
return (pick["id"], pick["quant"]) if pick is not None else None
|
|
337
346
|
|
|
338
347
|
|
|
339
348
|
def recommend(facts: HostFacts, candidates: list[tuple[Model, str]]) -> str | None:
|
|
340
|
-
"""The one model to suggest
|
|
341
|
-
|
|
349
|
+
"""The one model to suggest: the CLI's smartest pick, when it is among the absent,
|
|
350
|
+
downloadable ``candidates``. None when it is already on disk, not a library model (a
|
|
351
|
+
Strata recipe) or nothing fits: never a runner-up in its place."""
|
|
352
|
+
if not candidates or (pick := smartest(facts)) is None:
|
|
342
353
|
return None
|
|
343
|
-
|
|
344
|
-
small_mac = llm_rank.mac_default(facts)
|
|
345
|
-
default = next((m.id for m, _ in candidates if m.entry.id == small_mac), None)
|
|
346
|
-
chosen, _ = llm_rank.choose(ranked, "smartest", default)
|
|
347
|
-
return chosen
|
|
354
|
+
return next((m.id for m, _ in candidates if (m.entry.id, m.variant.quant) == pick), None)
|
|
@@ -222,9 +222,14 @@ def _start(
|
|
|
222
222
|
progress(model.id, "load", len(steps), len(steps))
|
|
223
223
|
progress(model.id, "warm", 0, 2)
|
|
224
224
|
speed = stack_warm.warm_llm(plan)["decode_tok_s"]
|
|
225
|
+
prefill = stack_warm.prompt_speed(plan) # one more request; warm still counts two steps
|
|
225
226
|
progress(model.id, "warm", 2, 2)
|
|
226
227
|
if speed is not None:
|
|
227
228
|
record["tokens_per_second"] = float(speed)
|
|
229
|
+
if prefill is not None:
|
|
230
|
+
record["prompt_tokens_per_second"] = prefill
|
|
231
|
+
else: # the last load's measurement, or none
|
|
232
|
+
record.pop("prompt_tokens_per_second", None)
|
|
228
233
|
key = stack_verify.key(plan) or ""
|
|
229
234
|
member = stack_member(record)
|
|
230
235
|
record["registration"] = library_gateway.planned(model.id, plan, stack_provider=member)
|
|
@@ -60,6 +60,7 @@ class Record(_RecordRequired, total=False):
|
|
|
60
60
|
base_dir: str # where it was downloaded: its weights, engine and deployments live there
|
|
61
61
|
memory_bytes: int # the footprint priced at download (on the pool's whole capacity)
|
|
62
62
|
tokens_per_second: float
|
|
63
|
+
prompt_tokens_per_second: float
|
|
63
64
|
registration: Registration
|
|
64
65
|
error: Problem
|
|
65
66
|
note: Note
|
|
@@ -357,13 +358,20 @@ def receipt(model: str) -> process_identity.Identity | None:
|
|
|
357
358
|
def stop_process(saved: process_identity.Identity, grace: float = 20.0) -> str:
|
|
358
359
|
"""Stop exactly the process group ``saved`` names (SIGTERM, then SIGKILL), whatever job
|
|
359
360
|
file now sits at its path: "gone" when it had ended, "stopped" otherwise. RuntimeError
|
|
360
|
-
when it outlives SIGKILL.
|
|
361
|
+
when it outlives SIGKILL. Windows has no signal one console process can send another, so
|
|
362
|
+
there the job ends itself once it sees its cancel mark (``library_jobs.watch_cancel``): it
|
|
363
|
+
is given ``grace`` to, and only then its tree is ended by force."""
|
|
361
364
|
import signal
|
|
362
365
|
import time
|
|
363
366
|
|
|
364
367
|
if process_identity.inspect(saved["pid"]) != saved:
|
|
365
368
|
return "gone"
|
|
366
369
|
if os.name == "nt":
|
|
370
|
+
deadline = time.monotonic() + grace
|
|
371
|
+
while time.monotonic() < deadline:
|
|
372
|
+
if process_identity.inspect(saved["pid"]) != saved:
|
|
373
|
+
return "stopped"
|
|
374
|
+
time.sleep(0.1)
|
|
367
375
|
if process_identity.windows_stop_tree(saved["pid"], saved, grace):
|
|
368
376
|
return "stopped"
|
|
369
377
|
raise RuntimeError(f"process {saved['pid']} is still running")
|
|
@@ -5,8 +5,10 @@ probe's; the web formats them and infers nothing."""
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
7
|
import datetime as dt
|
|
8
|
+
import re
|
|
8
9
|
import urllib.request
|
|
9
10
|
from dataclasses import dataclass, field
|
|
11
|
+
from typing import cast
|
|
10
12
|
|
|
11
13
|
from localmodels import (
|
|
12
14
|
__version__,
|
|
@@ -162,6 +164,31 @@ def pi_model_of(model: Model, record: Record | None) -> str | None:
|
|
|
162
164
|
return library_gateway.pi_model(model.id, model.variant.model_id)
|
|
163
165
|
|
|
164
166
|
|
|
167
|
+
HUB_REPO = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*/[A-Za-z0-9][A-Za-z0-9._-]*")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def card(model: Model, vision_on: bool) -> Row:
|
|
171
|
+
"""The model card fields of a row, each only when the catalog states it: family,
|
|
172
|
+
publisher and parameter scales as written there, the architecture from its MoE flag, its
|
|
173
|
+
license, the Hugging Face page of the repository the weights come from, and vision when
|
|
174
|
+
this deployment reads images (its projector is pinned and priced). Nothing is guessed from
|
|
175
|
+
a name; Linger rejects a whole status document over one value outside its sets."""
|
|
176
|
+
entry = model.entry
|
|
177
|
+
found: dict[str, object] = {
|
|
178
|
+
"family": entry.family,
|
|
179
|
+
"publisher": entry.publisher.strip()[:120],
|
|
180
|
+
"architecture": "moe" if entry.moe else "dense",
|
|
181
|
+
"parameters": entry.parameters,
|
|
182
|
+
"active_parameters": entry.active_parameters if entry.moe else "",
|
|
183
|
+
"license": entry.license.strip()[:120],
|
|
184
|
+
}
|
|
185
|
+
if HUB_REPO.fullmatch(entry.repo):
|
|
186
|
+
found["source_url"] = f"https://huggingface.co/{entry.repo}"
|
|
187
|
+
if vision_on:
|
|
188
|
+
found["capabilities"] = ["vision"]
|
|
189
|
+
return cast(Row, {k: v for k, v in found.items() if v})
|
|
190
|
+
|
|
191
|
+
|
|
165
192
|
def row(lib: Library, model: Model) -> Row:
|
|
166
193
|
record = lib.records.get(model.id)
|
|
167
194
|
priced = lib.judge(model)
|
|
@@ -210,6 +237,7 @@ def row(lib: Library, model: Model) -> Row:
|
|
|
210
237
|
"total_bytes": job["total"],
|
|
211
238
|
"bytes_per_second": job["bytes_per_second"],
|
|
212
239
|
}
|
|
240
|
+
found.update(card(model, found["vision"]))
|
|
213
241
|
if state != "absent":
|
|
214
242
|
if (selector := pi_model_of(model, record)) is not None:
|
|
215
243
|
found["pi_model"] = selector
|
|
@@ -221,6 +249,8 @@ def row(lib: Library, model: Model) -> Row:
|
|
|
221
249
|
}
|
|
222
250
|
if (speed := record.get("tokens_per_second")) is not None:
|
|
223
251
|
found["tokens_per_second"] = round(speed, 1)
|
|
252
|
+
if (prefill := record.get("prompt_tokens_per_second")) is not None:
|
|
253
|
+
found["prompt_tokens_per_second"] = round(prefill, 1)
|
|
224
254
|
if state == "idle" and (note := record.get("note")):
|
|
225
255
|
found["note"] = note
|
|
226
256
|
if state == "failed" and problem is not None:
|