@simplexai/localmodels-win32-x64 0.1.0-dev.104 → 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/README.md +1 -1
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +80 -78
- 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 +454 -31
- package/modules/localmodels/catalog.py +11 -0
- package/modules/localmodels/catalog_recipes.py +61 -3
- package/modules/localmodels/cli_help.py +10 -0
- package/modules/localmodels/cli_parser.py +313 -230
- package/modules/localmodels/component.py +20 -2
- package/modules/localmodels/custom_probe.py +4 -2
- package/modules/localmodels/deploy.py +11 -1
- package/modules/localmodels/engine_adapters/suite_plan.py +21 -21
- package/modules/localmodels/host_sensors.py +25 -2
- package/modules/localmodels/hosts.py +26 -5
- 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_jobs.py +23 -4
- package/modules/localmodels/library_model.py +146 -1
- package/modules/localmodels/library_order.py +175 -69
- package/modules/localmodels/library_poly.py +42 -11
- package/modules/localmodels/library_presentation.py +485 -0
- package/modules/localmodels/library_pricing.py +3 -1
- package/modules/localmodels/library_serve.py +208 -3
- package/modules/localmodels/library_state.py +47 -10
- package/modules/localmodels/library_status.py +29 -16
- package/modules/localmodels/llm_rank.py +9 -3
- package/modules/localmodels/plan_envelope.py +11 -2
- package/modules/localmodels/probe.py +34 -7
- package/modules/localmodels/quant_formats.py +9 -2
- package/modules/localmodels/records.py +19 -2
- package/modules/localmodels/remote_ops_verify.py +91 -24
- package/modules/localmodels/runtime_index.py +303 -0
- package/modules/localmodels/setup_inspection.py +22 -3
- package/modules/localmodels/speech_cli.py +20 -14
- package/modules/localmodels/speech_serve.py +9 -2
- package/modules/localmodels/speech_server.py +3 -0
- package/modules/localmodels/stack_args.py +270 -139
- package/modules/localmodels/stack_auto.py +90 -5
- package/modules/localmodels/stack_cli.py +117 -116
- package/modules/localmodels/stack_compose.py +5 -1
- package/modules/localmodels/stack_debug.py +14 -4
- package/modules/localmodels/stack_down.py +2 -0
- package/modules/localmodels/stack_hardware.py +14 -12
- package/modules/localmodels/stack_mlx.py +8 -1
- package/modules/localmodels/stack_picks.py +19 -20
- package/modules/localmodels/stack_plan.py +3 -2
- package/modules/localmodels/stack_review.py +28 -7
- package/modules/localmodels/stack_suite.py +11 -9
- package/modules/localmodels/stack_up.py +2 -0
- package/modules/localmodels/stack_view.py +180 -35
- 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_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 +7 -0
- package/modules/localmodels/stack_whatif_html.py +9 -12
- package/modules/localmodels/suite.py +129 -2
- package/modules/localmodels/telemetry_math.py +458 -18
- package/modules/localmodels/transport.py +8 -1
- package/modules/localmodels/tts_cli.py +24 -20
- package/modules/localmodels/tts_serve.py +9 -2
- package/modules/localmodels/tts_sidecar.py +3 -0
- package/modules/localmodels/web/whatif/app.js +1 -1
- package/modules/localmodels/web/whatif/sim.js +8 -14
- package/modules/localmodels/win_probe.py +89 -16
- package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +76 -74
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/LICENSE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -45,8 +45,8 @@ from localmodels.library_model import (
|
|
|
45
45
|
from localmodels.planning import budget, memory_pools
|
|
46
46
|
from localmodels.probe import HostFacts
|
|
47
47
|
|
|
48
|
-
# The llama.cpp engine lock every custom GGUF model runs on.
|
|
49
|
-
CUSTOM_ENGINE_TAG = "
|
|
48
|
+
# The llama.cpp engine lock every custom GGUF model runs on (b12757+ supports inkling2_loop).
|
|
49
|
+
CUSTOM_ENGINE_TAG = "b12757-mix-ef2df21"
|
|
50
50
|
|
|
51
51
|
SWEET_SPOT_QUANTS: tuple[str, ...] = (
|
|
52
52
|
"Q4_K_M",
|
|
@@ -55,7 +55,9 @@ SWEET_SPOT_QUANTS: tuple[str, ...] = (
|
|
|
55
55
|
"IQ4_XS",
|
|
56
56
|
"Q4_K_S",
|
|
57
57
|
"Q5_K_M",
|
|
58
|
+
"GSQ-RCO-IQ3_S",
|
|
58
59
|
"Q4_0",
|
|
60
|
+
"IQ3_S",
|
|
59
61
|
"Q3_K_M",
|
|
60
62
|
"Q6_K",
|
|
61
63
|
"Q8_0",
|
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
import json
|
|
10
10
|
import os
|
|
11
11
|
import secrets
|
|
12
|
+
import time
|
|
12
13
|
from collections.abc import Callable
|
|
13
14
|
from dataclasses import dataclass, replace
|
|
14
15
|
|
|
@@ -355,7 +356,13 @@ def build_plan(
|
|
|
355
356
|
placement=llama_cpp.placement_doc(facts, placement, backend),
|
|
356
357
|
launch=llama_cpp.launch_doc(entry, variant, launch, extra, backend, agent),
|
|
357
358
|
service=service,
|
|
358
|
-
endpoint={
|
|
359
|
+
endpoint={
|
|
360
|
+
"model": variant.model_id,
|
|
361
|
+
"health_path": "/health",
|
|
362
|
+
"slots_path": "/slots",
|
|
363
|
+
"metrics_path": "/metrics",
|
|
364
|
+
"metrics_requires_auth": True,
|
|
365
|
+
},
|
|
359
366
|
warnings=warnings,
|
|
360
367
|
)
|
|
361
368
|
|
|
@@ -430,7 +437,9 @@ def execute(
|
|
|
430
437
|
def seen(event: dict[str, object], step: str = step) -> None:
|
|
431
438
|
on_event(step, _event(event))
|
|
432
439
|
|
|
440
|
+
step_started = time.monotonic()
|
|
433
441
|
last, result = executor.run_action(step, step_params(plan, step, api_key), on_event=seen)
|
|
442
|
+
step_ms = max(0, round((time.monotonic() - step_started) * 1000))
|
|
434
443
|
outcome = _event(last)
|
|
435
444
|
ok = result.returncode == 0 and outcome["event"] == "result"
|
|
436
445
|
record["steps"].append(
|
|
@@ -439,6 +448,7 @@ def execute(
|
|
|
439
448
|
"ok": ok,
|
|
440
449
|
"result": outcome,
|
|
441
450
|
"stderr": result.stderr[-2000:] if not ok else "",
|
|
451
|
+
"duration_ms": step_ms,
|
|
442
452
|
}
|
|
443
453
|
)
|
|
444
454
|
if not ok:
|
|
@@ -27,7 +27,7 @@ from localmodels.plan_envelope import (
|
|
|
27
27
|
verified_in_place,
|
|
28
28
|
)
|
|
29
29
|
from localmodels.probe import HostFacts
|
|
30
|
-
from localmodels.records import ModelSpec, Plan, ReleaseEngine, ReusableFile
|
|
30
|
+
from localmodels.records import ModelSpec, Plan, PlanEndpoint, ReleaseEngine, ReusableFile
|
|
31
31
|
from localmodels.suite import (
|
|
32
32
|
AUTH_PROXY,
|
|
33
33
|
NO_SWAP,
|
|
@@ -148,26 +148,11 @@ def _plan_files(
|
|
|
148
148
|
def _matching_card_args(
|
|
149
149
|
facts: HostFacts, r: SuiteRecipe, options: SuiteOptions
|
|
150
150
|
) -> list[suite.CardArgs]:
|
|
151
|
-
|
|
152
|
-
return []
|
|
153
|
-
# Under --gpu-memory the reserve also holds what the share leaves out of the real card
|
|
154
|
-
# (stack_gpu_memory.LEFT_OUT, stack_suite.poly_reserve_mib), so the room is counted on it.
|
|
155
|
-
left_out = int(cast("dict[str, int]", options.gpu).get("share_left_out_bytes", 0))
|
|
156
|
-
reserve = options.vram_reserve_mib << 20
|
|
157
|
-
room = options.gpu["total_bytes"] + left_out - reserve
|
|
158
|
-
free_room = options.gpu["free_bytes"] + left_out - reserve
|
|
159
|
-
return [
|
|
160
|
-
group
|
|
161
|
-
for group in r["card_args"]
|
|
162
|
-
if room >= group["at_least_bytes"]
|
|
163
|
-
and free_room >= group.get("at_least_free_bytes", 0)
|
|
164
|
-
and facts["platform"] in group.get("platforms", [facts["platform"]])
|
|
165
|
-
]
|
|
151
|
+
return suite.matched_card_args(facts, r, options.gpu, options.vram_reserve_mib)
|
|
166
152
|
|
|
167
153
|
|
|
168
154
|
def _effective_context(r: SuiteRecipe, matched: list[suite.CardArgs]) -> int:
|
|
169
|
-
|
|
170
|
-
return max((base, *(int(group.get("context") or 0) for group in matched)), default=base)
|
|
155
|
+
return suite.effective_context(r, matched)
|
|
171
156
|
|
|
172
157
|
|
|
173
158
|
def _set_flag(args: list[str], flag: str, value: str) -> list[str]:
|
|
@@ -212,6 +197,8 @@ def _profile_template(
|
|
|
212
197
|
profile_template["args"] = _set_flag(
|
|
213
198
|
cast("list[str]", profile_template["args"]), "--max-context", str(window)
|
|
214
199
|
)
|
|
200
|
+
if matched_card_args and any(group.get("parallel") for group in matched_card_args):
|
|
201
|
+
profile_template["parallel"] = suite.effective_parallel(r, matched_card_args)
|
|
215
202
|
adapter.finish_profile(profile_template, options, facts)
|
|
216
203
|
return profile_template
|
|
217
204
|
|
|
@@ -406,6 +393,19 @@ def build_plan(host_id: str, facts: HostFacts, r: SuiteRecipe, options: SuiteOpt
|
|
|
406
393
|
profile = _profile_template(facts, r, options, files, values, reader, matched_card_args, window)
|
|
407
394
|
values |= _parking_values(r, parking_mib)
|
|
408
395
|
added_mib = parking_mib + vision.strata_ram_mib(r.get("vision") or {}, reader)
|
|
396
|
+
argv = _argv(r, values, host_id, adapter.device_args(apple=apple, on_gpu=on_gpu))
|
|
397
|
+
env = _env(r, values, adapter.library_path(engine, on_gpu=on_gpu), apple)
|
|
398
|
+
has_metrics = r["runtime"] in ("strata", "strata-poly") or "--metrics" in argv
|
|
399
|
+
has_slots = "--slots" in argv
|
|
400
|
+
keyed = bool(r.get("auth_proxy")) or "--api-key-file" in argv or "STRATA_API_KEY" in env
|
|
401
|
+
endpoint: PlanEndpoint = {
|
|
402
|
+
"model": r.get("alias", r["id"]),
|
|
403
|
+
"contract": r.get("contract", "chat"),
|
|
404
|
+
"health_path": r.get("health_path") or "/health",
|
|
405
|
+
"slots_path": "/slots" if has_slots else None,
|
|
406
|
+
"metrics_path": "/metrics" if has_metrics else None,
|
|
407
|
+
"metrics_requires_auth": bool(has_metrics and keyed),
|
|
408
|
+
}
|
|
409
409
|
plan = plan_envelope(
|
|
410
410
|
host_id,
|
|
411
411
|
facts,
|
|
@@ -416,13 +416,13 @@ def build_plan(host_id: str, facts: HostFacts, r: SuiteRecipe, options: SuiteOpt
|
|
|
416
416
|
placement=_placement(options, on_gpu, int(values["threads"])),
|
|
417
417
|
launch=_launch(r, options, values, profile, reader, parking_mib, added_mib, window),
|
|
418
418
|
service={
|
|
419
|
-
"argv":
|
|
420
|
-
"env":
|
|
419
|
+
"argv": argv,
|
|
420
|
+
"env": env,
|
|
421
421
|
"limits": _limits(r, added_mib, adapter.extra_limits(facts)),
|
|
422
422
|
"slice": SLICE,
|
|
423
423
|
"slice_limits": {**options.slice_limits, **NO_SWAP},
|
|
424
424
|
},
|
|
425
|
-
endpoint=
|
|
425
|
+
endpoint=endpoint,
|
|
426
426
|
warnings=[],
|
|
427
427
|
)
|
|
428
428
|
if config := _config_files(r, where, values, profile):
|
|
@@ -25,6 +25,7 @@ from typing import Any, TypedDict
|
|
|
25
25
|
_PROC = Path("/proc")
|
|
26
26
|
_SECTOR_BYTES = 512
|
|
27
27
|
_BYTES_PER_MB = 1_000_000.0
|
|
28
|
+
_COLD_SAMPLE_S = 0.02
|
|
28
29
|
# Whole physical block devices on Linux (excludes partitions and loop/ram/dm to avoid double counts).
|
|
29
30
|
_WHOLE_DISK_RE = re.compile(r"^(?:nvme\d+n\d+|sd[a-z]+|vd[a-z]+|hd[a-z]+|xvd[a-z]+|mmcblk\d+)$")
|
|
30
31
|
_OOM_MARKERS = ("out of memory", "oom-kill", "oom_kill", "cudamalloc failed", "bad_alloc")
|
|
@@ -461,7 +462,7 @@ def _collect_linux(
|
|
|
461
462
|
|
|
462
463
|
# On a cold sample with no prior snapshot, take one tiny 20 ms delta so live CPU % is real.
|
|
463
464
|
if not isinstance(prev_cpu, dict) and curr_cpu:
|
|
464
|
-
time.sleep(
|
|
465
|
+
time.sleep(_COLD_SAMPLE_S)
|
|
465
466
|
now_mono = time.monotonic()
|
|
466
467
|
stat_text2 = _read_text(proc / "stat")
|
|
467
468
|
disk_text2 = _read_text(proc / "diskstats")
|
|
@@ -471,7 +472,7 @@ def _collect_linux(
|
|
|
471
472
|
if disk_text2 and curr_disk is not None:
|
|
472
473
|
prev_disk = curr_disk
|
|
473
474
|
curr_disk = parse_proc_diskstats(disk_text2)
|
|
474
|
-
prev_at = now_mono -
|
|
475
|
+
prev_at = now_mono - _COLD_SAMPLE_S
|
|
475
476
|
|
|
476
477
|
overall: float | None = None
|
|
477
478
|
per_core: list[CoreUsage] = []
|
|
@@ -530,6 +531,15 @@ def _collect_macos(
|
|
|
530
531
|
prev_disk = prev_state.get("disk")
|
|
531
532
|
prev_at = prev_state.get("at")
|
|
532
533
|
|
|
534
|
+
# On a cold sample with no prior snapshot, take one tiny 20 ms delta so live CPU % is real.
|
|
535
|
+
if not isinstance(prev_cpu, dict) and curr_cpu:
|
|
536
|
+
time.sleep(_COLD_SAMPLE_S)
|
|
537
|
+
now_mono = time.monotonic()
|
|
538
|
+
curr_cpu2 = _read_macos_cpu_ticks()
|
|
539
|
+
if curr_cpu2:
|
|
540
|
+
prev_cpu = curr_cpu
|
|
541
|
+
curr_cpu = curr_cpu2
|
|
542
|
+
|
|
533
543
|
overall, per_core = (
|
|
534
544
|
diff_cpu_samples(prev_cpu, curr_cpu)
|
|
535
545
|
if isinstance(prev_cpu, dict) and curr_cpu
|
|
@@ -577,6 +587,19 @@ def _collect_windows(
|
|
|
577
587
|
) -> tuple[CpuSensors, DiskSensors, MemoryPressure, dict[str, Any]]:
|
|
578
588
|
curr_times = _read_windows_system_times()
|
|
579
589
|
prev_times = prev_state.get("win_cpu")
|
|
590
|
+
|
|
591
|
+
# On a cold sample with no prior snapshot, take one tiny 20 ms delta so live CPU % is real.
|
|
592
|
+
if (
|
|
593
|
+
not (isinstance(prev_times, list | tuple) and len(prev_times) == 3)
|
|
594
|
+
and curr_times is not None
|
|
595
|
+
):
|
|
596
|
+
time.sleep(_COLD_SAMPLE_S)
|
|
597
|
+
now_mono = time.monotonic()
|
|
598
|
+
curr_times2 = _read_windows_system_times()
|
|
599
|
+
if curr_times2 is not None:
|
|
600
|
+
prev_times = curr_times
|
|
601
|
+
curr_times = curr_times2
|
|
602
|
+
|
|
580
603
|
overall: float | None = None
|
|
581
604
|
if isinstance(prev_times, list | tuple) and len(prev_times) == 3 and curr_times is not None:
|
|
582
605
|
overall = parse_windows_system_times(
|
|
@@ -7,9 +7,12 @@ keep the full plan and step results, never the API key; the key stays in a 0600
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import contextlib
|
|
10
11
|
import json
|
|
11
12
|
import os
|
|
12
13
|
import re
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
13
16
|
import threading
|
|
14
17
|
import time
|
|
15
18
|
from collections.abc import Callable, Iterator, Mapping
|
|
@@ -18,6 +21,7 @@ from pathlib import Path
|
|
|
18
21
|
from typing import Any, Literal, TypedDict, TypeVar
|
|
19
22
|
|
|
20
23
|
from localmodels import deployment_lifecycle as lifecycle
|
|
24
|
+
from localmodels import runtime_windows_acl
|
|
21
25
|
from localmodels.contracts import decode
|
|
22
26
|
from localmodels.probe import HostFacts
|
|
23
27
|
from localmodels.records import Device, FinishedRecord, Plan
|
|
@@ -41,11 +45,28 @@ def stacks_dir() -> Path:
|
|
|
41
45
|
|
|
42
46
|
def _write_private(path: Path, data: object) -> Path:
|
|
43
47
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
44
|
-
|
|
45
|
-
tmp
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
fd, tmp_name = tempfile.mkstemp(prefix=f".{path.name}.", suffix=".tmp", dir=path.parent)
|
|
49
|
+
tmp = Path(tmp_name)
|
|
50
|
+
closed = False
|
|
51
|
+
try:
|
|
52
|
+
if os.name != "nt":
|
|
53
|
+
os.chmod(
|
|
54
|
+
tmp, 0o600
|
|
55
|
+
) # owner-only before any content, so no interrupt leaves a readable copy
|
|
56
|
+
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
57
|
+
closed = True
|
|
58
|
+
handle.write(json.dumps(data, ensure_ascii=False, indent=1) + "\n")
|
|
59
|
+
if sys.platform == "win32":
|
|
60
|
+
runtime_windows_acl.rename_with_retry(tmp, path, replace=True)
|
|
61
|
+
else:
|
|
62
|
+
tmp.replace(path) # atomic: a kill mid-write never leaves a truncated record
|
|
63
|
+
except BaseException:
|
|
64
|
+
if not closed:
|
|
65
|
+
with contextlib.suppress(OSError):
|
|
66
|
+
os.close(fd)
|
|
67
|
+
with contextlib.suppress(OSError):
|
|
68
|
+
tmp.unlink(missing_ok=True)
|
|
69
|
+
raise
|
|
49
70
|
return path
|
|
50
71
|
|
|
51
72
|
|
|
@@ -12,19 +12,9 @@ import argparse
|
|
|
12
12
|
import json
|
|
13
13
|
import sys
|
|
14
14
|
from pathlib import Path
|
|
15
|
+
from typing import TYPE_CHECKING
|
|
15
16
|
|
|
16
|
-
from localmodels import
|
|
17
|
-
cli_help,
|
|
18
|
-
custom_hub,
|
|
19
|
-
custom_probe,
|
|
20
|
-
deploy,
|
|
21
|
-
library_custom,
|
|
22
|
-
library_jobs,
|
|
23
|
-
library_serve,
|
|
24
|
-
library_smoke,
|
|
25
|
-
library_status,
|
|
26
|
-
)
|
|
27
|
-
from localmodels.contracts import decode
|
|
17
|
+
from localmodels import cli_help
|
|
28
18
|
from localmodels.library_model import (
|
|
29
19
|
EXIT_FAILED,
|
|
30
20
|
LibraryError,
|
|
@@ -32,7 +22,9 @@ from localmodels.library_model import (
|
|
|
32
22
|
error_doc,
|
|
33
23
|
result_doc,
|
|
34
24
|
)
|
|
35
|
-
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
from localmodels.probe import HostFacts
|
|
36
28
|
|
|
37
29
|
DESCRIPTION = (
|
|
38
30
|
"Each validated chat model on its own: download it (then load it when its memory pool has "
|
|
@@ -55,7 +47,7 @@ FALLBACK = {
|
|
|
55
47
|
def _base(p: argparse.ArgumentParser) -> None:
|
|
56
48
|
p.add_argument(
|
|
57
49
|
"--base-dir",
|
|
58
|
-
default=
|
|
50
|
+
default=cli_help.DEFAULT_BASE_DIR,
|
|
59
51
|
metavar="DIR",
|
|
60
52
|
help="where weights, engines and deployments live (the v1 calls' --base-dir)",
|
|
61
53
|
)
|
|
@@ -70,12 +62,18 @@ def add_parser(sub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None
|
|
|
70
62
|
verbs = parser.add_subparsers(dest="library_command", required=True, metavar="COMMAND")
|
|
71
63
|
status = verbs.add_parser("status", help="every model, its fit, state and pool (JSON)")
|
|
72
64
|
_base(status)
|
|
73
|
-
status.
|
|
65
|
+
status_facts = status.add_mutually_exclusive_group()
|
|
66
|
+
status_facts.add_argument(
|
|
74
67
|
"--facts",
|
|
75
68
|
type=Path,
|
|
76
69
|
metavar="FILE",
|
|
77
70
|
help="price against saved host facts (probe JSON) instead of probing; read-only",
|
|
78
71
|
)
|
|
72
|
+
status_facts.add_argument(
|
|
73
|
+
"--cached-facts",
|
|
74
|
+
action="store_true",
|
|
75
|
+
help="reuse cached $LOCALMODELS_STATE/facts/local.json when present (falls back to live probe)",
|
|
76
|
+
)
|
|
79
77
|
status.add_argument("--json", action="store_true", help="accepted; the output is JSON")
|
|
80
78
|
cli_help.document(
|
|
81
79
|
status,
|
|
@@ -195,12 +193,18 @@ def add_parser(sub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None
|
|
|
195
193
|
help="read probe target (and optional token) as JSON from standard input",
|
|
196
194
|
)
|
|
197
195
|
_base(c_probe)
|
|
198
|
-
c_probe.
|
|
196
|
+
probe_facts = c_probe.add_mutually_exclusive_group()
|
|
197
|
+
probe_facts.add_argument(
|
|
199
198
|
"--facts",
|
|
200
199
|
type=Path,
|
|
201
200
|
metavar="FILE",
|
|
202
201
|
help="price variants against saved host facts (probe JSON) instead of probing; read-only",
|
|
203
202
|
)
|
|
203
|
+
probe_facts.add_argument(
|
|
204
|
+
"--cached-facts",
|
|
205
|
+
action="store_true",
|
|
206
|
+
help="reuse cached $LOCALMODELS_STATE/facts/local.json when present (falls back to live probe)",
|
|
207
|
+
)
|
|
204
208
|
c_probe.add_argument("--json", action="store_true", help="accepted; the output is JSON")
|
|
205
209
|
cli_help.document(
|
|
206
210
|
c_probe,
|
|
@@ -261,6 +265,10 @@ def _read_custom_stdin() -> dict[str, object]:
|
|
|
261
265
|
|
|
262
266
|
|
|
263
267
|
def _custom(args: argparse.Namespace) -> int:
|
|
268
|
+
from localmodels import custom_hub, custom_probe, library_custom, library_jobs
|
|
269
|
+
from localmodels.contracts import decode
|
|
270
|
+
from localmodels.probe import HostFacts
|
|
271
|
+
|
|
264
272
|
sub = args.custom_command
|
|
265
273
|
jsonl = sub == "download"
|
|
266
274
|
token: str | None = None
|
|
@@ -284,6 +292,8 @@ def _custom(args: argparse.Namespace) -> int:
|
|
|
284
292
|
raise LibraryError(
|
|
285
293
|
"INVALID_REPO_SPEC", f"invalid --facts file {args.facts}: {exc}"
|
|
286
294
|
) from None
|
|
295
|
+
elif getattr(args, "cached_facts", False):
|
|
296
|
+
facts = library_jobs.cached_or_probe()
|
|
287
297
|
doc = custom_probe.probe(payload, args.base_dir, facts=facts)
|
|
288
298
|
except LibraryError as exc:
|
|
289
299
|
safe = LibraryError(
|
|
@@ -308,9 +318,15 @@ def _custom(args: argparse.Namespace) -> int:
|
|
|
308
318
|
|
|
309
319
|
|
|
310
320
|
def _status(args: argparse.Namespace) -> int:
|
|
321
|
+
from localmodels import library_jobs, library_status
|
|
322
|
+
from localmodels.contracts import decode
|
|
323
|
+
from localmodels.probe import HostFacts
|
|
324
|
+
|
|
311
325
|
try:
|
|
312
326
|
if args.facts is not None:
|
|
313
327
|
facts = decode(json.loads(args.facts.read_text(encoding="utf-8")), HostFacts)
|
|
328
|
+
elif getattr(args, "cached_facts", False):
|
|
329
|
+
facts = library_jobs.cached_or_probe()
|
|
314
330
|
else:
|
|
315
331
|
facts = library_jobs.probe()
|
|
316
332
|
doc = library_status.build(library_status.Library.read(facts, args.base_dir))
|
|
@@ -327,6 +343,8 @@ def cli(args: argparse.Namespace) -> int:
|
|
|
327
343
|
return _status(args)
|
|
328
344
|
if verb == "custom":
|
|
329
345
|
return _custom(args)
|
|
346
|
+
from localmodels import library_jobs, library_serve, library_smoke
|
|
347
|
+
|
|
330
348
|
jsonl = verb in ("download", "load", "smoke-test")
|
|
331
349
|
try:
|
|
332
350
|
if verb == "download":
|
|
@@ -32,6 +32,7 @@ from localmodels import (
|
|
|
32
32
|
plan_envelope,
|
|
33
33
|
remote_ops,
|
|
34
34
|
remote_ops_download,
|
|
35
|
+
runtime_index,
|
|
35
36
|
)
|
|
36
37
|
from localmodels.gguf import GGUFHeader
|
|
37
38
|
from localmodels.library_model import (
|
|
@@ -442,7 +443,13 @@ def _build_download_plan(
|
|
|
442
443
|
placement={"id": placement_id, "label": pool_id, "pooled": False, "gpus": placement_gpus},
|
|
443
444
|
launch=launch,
|
|
444
445
|
service={"argv": argv, "env": {}, "autostart": False},
|
|
445
|
-
endpoint={
|
|
446
|
+
endpoint={
|
|
447
|
+
"model": model_alias,
|
|
448
|
+
"health_path": "/health",
|
|
449
|
+
"slots_path": None,
|
|
450
|
+
"metrics_path": None,
|
|
451
|
+
"metrics_requires_auth": False,
|
|
452
|
+
},
|
|
446
453
|
warnings=[],
|
|
447
454
|
)
|
|
448
455
|
|
|
@@ -866,3 +873,4 @@ def _commit_custom_record(
|
|
|
866
873
|
if stale:
|
|
867
874
|
library_jobs.delete_weights(stale, library_jobs.in_use(custom_model_id))
|
|
868
875
|
library_jobs.prune_empty_custom_dirs(stale, base_dir)
|
|
876
|
+
runtime_index.refresh()
|
|
@@ -10,12 +10,13 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
import os
|
|
12
12
|
import re
|
|
13
|
+
from collections.abc import Mapping
|
|
13
14
|
from pathlib import Path
|
|
14
15
|
|
|
15
16
|
from localmodels import catalog as cat
|
|
16
17
|
from localmodels import vision
|
|
17
18
|
from localmodels.library_model import PiSpec, display_name, split_id
|
|
18
|
-
from localmodels.library_state import Registration
|
|
19
|
+
from localmodels.library_state import Record, Registration
|
|
19
20
|
from localmodels.records import Plan
|
|
20
21
|
|
|
21
22
|
PROVIDER_PREFIX = "localmodels-lib-"
|
|
@@ -92,3 +93,42 @@ def pi_spec(
|
|
|
92
93
|
"default_effort": default_effort(levels),
|
|
93
94
|
"api_key_file": api_key_file(plan),
|
|
94
95
|
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def pi_spec_for_record(
|
|
99
|
+
record: Record,
|
|
100
|
+
*,
|
|
101
|
+
catalog_by_id: Mapping[str, cat.CatalogEntry] | None = None,
|
|
102
|
+
) -> PiSpec:
|
|
103
|
+
"""Build ``PiSpec`` directly from a saved library ``Record`` (curated, custom, or retired)."""
|
|
104
|
+
reg = record.get("registration")
|
|
105
|
+
api_name = (reg.get("api") if reg else None) or DEFAULT_API
|
|
106
|
+
plan = record["plan"]
|
|
107
|
+
model = record["id"]
|
|
108
|
+
entry = catalog_by_id.get(record["catalog_id"]) if catalog_by_id else None
|
|
109
|
+
if entry is not None:
|
|
110
|
+
return pi_spec(model, entry, plan, api=api_name)
|
|
111
|
+
raw_name = str(plan["model"]["display_name"])
|
|
112
|
+
efforts: list[str] = list(cat.EFFORT_LEVELS)
|
|
113
|
+
if isinstance(ce := record.get("catalog_entry"), Mapping):
|
|
114
|
+
if isinstance(ce_name := ce.get("display_name"), str) and ce_name:
|
|
115
|
+
raw_name = ce_name
|
|
116
|
+
raw_efforts = ce.get("reasoning_efforts")
|
|
117
|
+
if isinstance(raw_efforts, list) and all(isinstance(v, str) for v in raw_efforts):
|
|
118
|
+
efforts = list(raw_efforts) or list(cat.EFFORT_LEVELS)
|
|
119
|
+
served = str(plan["endpoint"]["model"])
|
|
120
|
+
pid = provider_id(model)
|
|
121
|
+
context = int(str(plan["launch"].get("window") or 0)) or DEFAULT_CONTEXT
|
|
122
|
+
return {
|
|
123
|
+
"provider": pid,
|
|
124
|
+
"model": served,
|
|
125
|
+
"pi_model": f"{pid}/{served}",
|
|
126
|
+
"name": display_name(raw_name, split_id(model)[1]),
|
|
127
|
+
"api": api_name,
|
|
128
|
+
"base_url": str(plan["endpoint"]["base_url"]),
|
|
129
|
+
"context_tokens": context,
|
|
130
|
+
"vision": vision.reads_pictures(plan["launch"]),
|
|
131
|
+
"efforts": efforts,
|
|
132
|
+
"default_effort": default_effort(efforts),
|
|
133
|
+
"api_key_file": api_key_file(plan),
|
|
134
|
+
}
|
|
@@ -36,6 +36,7 @@ from localmodels import (
|
|
|
36
36
|
remote_ops_download,
|
|
37
37
|
remote_ops_mirrors,
|
|
38
38
|
reuse,
|
|
39
|
+
runtime_index,
|
|
39
40
|
)
|
|
40
41
|
from localmodels.deploy_steps import Action
|
|
41
42
|
from localmodels.library_model import (
|
|
@@ -54,15 +55,31 @@ from localmodels.records import Plan, ReusableFile
|
|
|
54
55
|
from localmodels.transport import Executor
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
def
|
|
58
|
-
"""This computer's facts, an inference server's file-cached weights on a Mac out of the RAM
|
|
59
|
-
available (metal.foreign_cached_bytes; the library's own servers are not foreign)."""
|
|
60
|
-
facts = app.probe(hosts.LOCAL_ID)
|
|
58
|
+
def _adjust_foreign_ram(facts: HostFacts) -> HostFacts:
|
|
61
59
|
if foreign := metal.foreign_cached_bytes(facts):
|
|
62
60
|
facts["ram"]["available_bytes"] = max(0, facts["ram"]["available_bytes"] - foreign)
|
|
63
61
|
return facts
|
|
64
62
|
|
|
65
63
|
|
|
64
|
+
def probe() -> HostFacts:
|
|
65
|
+
"""This computer's facts, an inference server's file-cached weights on a Mac out of the RAM
|
|
66
|
+
available (metal.foreign_cached_bytes; the library's own servers are not foreign)."""
|
|
67
|
+
return _adjust_foreign_ram(app.probe(hosts.LOCAL_ID))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def cached_or_probe() -> HostFacts:
|
|
71
|
+
"""Reuse saved ``$LOCALMODELS_STATE/facts/local.json`` when present and valid; otherwise run
|
|
72
|
+
a live ``probe()`` (which also populates the cache). Debug simulate mode still answers via
|
|
73
|
+
``probe()`` so simulated profiles are not shadowed by stale real-host facts."""
|
|
74
|
+
from localmodels import debug_mode
|
|
75
|
+
|
|
76
|
+
if debug_mode.simulating() is None:
|
|
77
|
+
cached = hosts.load_facts(hosts.LOCAL_ID)
|
|
78
|
+
if cached is not None:
|
|
79
|
+
return _adjust_foreign_ram(cached)
|
|
80
|
+
return probe()
|
|
81
|
+
|
|
82
|
+
|
|
66
83
|
def executor() -> Executor:
|
|
67
84
|
return hosts.executor(hosts.get_device(hosts.LOCAL_ID))
|
|
68
85
|
|
|
@@ -639,6 +656,7 @@ def _fetch_and_commit(
|
|
|
639
656
|
# the record's, and no download job is left for a cancel to act on.
|
|
640
657
|
library_state.save(record)
|
|
641
658
|
library_state.clear_job(model.id)
|
|
659
|
+
runtime_index.refresh()
|
|
642
660
|
|
|
643
661
|
|
|
644
662
|
def download(
|
|
@@ -714,6 +732,7 @@ def download(
|
|
|
714
732
|
):
|
|
715
733
|
record_["note"] = {"code": NO_ROOM_TO_LOAD}
|
|
716
734
|
library_state.save(record_)
|
|
735
|
+
runtime_index.refresh()
|
|
717
736
|
return library_status.model_row(library_status.Library.read(probe(), base_dir), model.id)
|
|
718
737
|
|
|
719
738
|
|