@simplexai/localmodels-darwin-x64 0.1.0-dev.103 → 0.1.0-dev.104
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 +126 -127
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/catalog.json +130 -127
- package/modules/localmodels/catalog.py +7 -3
- package/modules/localmodels/catalog_recipes.py +3 -3
- package/modules/localmodels/cli_parser.py +3 -3
- package/modules/localmodels/component.py +1 -1
- package/modules/localmodels/console.py +1 -1
- package/modules/localmodels/context_policy.py +6 -5
- 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/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 +57 -20
- 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/hosts.py +12 -16
- package/modules/localmodels/kokoro-tts-0.6.1.txt +1 -1
- package/modules/localmodels/library_elastic.py +135 -6
- package/modules/localmodels/library_kept.py +9 -1
- package/modules/localmodels/library_model.py +28 -1
- package/modules/localmodels/library_poly.py +109 -11
- package/modules/localmodels/library_pricing.py +12 -3
- package/modules/localmodels/library_serve.py +134 -67
- package/modules/localmodels/library_smoke.py +63 -5
- package/modules/localmodels/library_state.py +3 -2
- package/modules/localmodels/library_status.py +8 -1
- package/modules/localmodels/llm_rank.py +13 -8
- package/modules/localmodels/metal.py +1 -2
- package/modules/localmodels/plan_envelope.py +29 -11
- 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/py.typed +0 -0
- package/modules/localmodels/quant_formats.py +1 -1
- package/modules/localmodels/recommend_cli.py +1 -1
- package/modules/localmodels/remote_ops_launchd.py +8 -1
- 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 +72 -70
- 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 +10 -2
- package/modules/localmodels/speech_jobs.py +42 -17
- package/modules/localmodels/speech_server.py +182 -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 +6 -6
- package/modules/localmodels/stack_auto.py +1 -1
- package/modules/localmodels/stack_aux_gpu.py +1 -1
- package/modules/localmodels/stack_cleanup.py +21 -18
- package/modules/localmodels/stack_cli.py +6 -2
- package/modules/localmodels/stack_compose.py +11 -4
- package/modules/localmodels/stack_debug.py +1 -2
- package/modules/localmodels/stack_decision.py +4 -4
- package/modules/localmodels/stack_doctor.py +2 -2
- package/modules/localmodels/stack_events.py +1 -1
- package/modules/localmodels/stack_gpu_memory.py +1 -1
- package/modules/localmodels/stack_hardware.py +3 -3
- package/modules/localmodels/stack_mcp.py +1 -2
- package/modules/localmodels/stack_picks.py +1 -1
- package/modules/localmodels/stack_plan.py +9 -9
- package/modules/localmodels/stack_ports.py +31 -4
- package/modules/localmodels/stack_rollback.py +1 -1
- package/modules/localmodels/stack_run.py +1 -1
- package/modules/localmodels/stack_suite.py +61 -12
- package/modules/localmodels/stack_view_agent.py +1 -1
- package/modules/localmodels/stack_view_serve.py +0 -2
- package/modules/localmodels/stack_view_words.py +2 -2
- package/modules/localmodels/stack_warm.py +2 -2
- package/modules/localmodels/stack_whatif.py +524 -41
- package/modules/localmodels/stack_whatif_html.py +903 -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 +137 -5
- package/modules/localmodels/tts_admission.py +2 -17
- package/modules/localmodels/tts_catalog.py +29 -1
- package/modules/localmodels/tts_cli.py +23 -4
- package/modules/localmodels/tts_http.py +10 -4
- package/modules/localmodels/tts_jobs.py +49 -19
- package/modules/localmodels/tts_server.py +1 -1
- package/modules/localmodels/tts_sidecar.py +66 -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 +303 -0
- package/modules/localmodels/windows_job.py +179 -11
- package/modules/simplex_localmodels-0.1.0.dev104.dist-info/METADATA +14 -0
- package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/RECORD +118 -114
- package/modules/simplex_localmodels-0.1.0.dev104.dist-info/licenses/LICENSE +201 -0
- package/modules/simplex_localmodels-0.1.0.dev104.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.dev104.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -12,6 +12,7 @@ from __future__ import annotations
|
|
|
12
12
|
from dataclasses import dataclass, field, replace
|
|
13
13
|
from enum import Enum
|
|
14
14
|
from itertools import pairwise
|
|
15
|
+
from typing import Literal
|
|
15
16
|
|
|
16
17
|
from localmodels.gguf import GGUFHeader
|
|
17
18
|
|
|
@@ -46,7 +47,7 @@ def _expand_swa_period(period: int, n_layer: int, dense_first: bool) -> list[int
|
|
|
46
47
|
# right order; unknown SSM shapes must never underestimate.
|
|
47
48
|
_RECURRENT_STATE_PER_LAYER = 4 << 20
|
|
48
49
|
|
|
49
|
-
# Agent posture constants, calibrated on
|
|
50
|
+
# Agent posture constants, calibrated on reference 24 GB CUDA measurements.
|
|
50
51
|
# A llama-server process's fixed cost beside weights/KV/state at -np 2 --kv-unified: measured
|
|
51
52
|
# 410–444 MiB across the four cases; 448 rounds up so the estimate never undercuts reality.
|
|
52
53
|
AGENT_PROCESS_OVERHEAD_BYTES = 448 << 20
|
|
@@ -171,7 +172,7 @@ class ModelProfile:
|
|
|
171
172
|
window_compute_per_token: int = 0
|
|
172
173
|
# MLA: llama.cpp keeps one K tensor of the latent per layer and no V tensor
|
|
173
174
|
# (llama-kv-cache.cpp: has_v = !is_mla), so the layers' f16 bytes are all K and -ctv does
|
|
174
|
-
# not apply.
|
|
175
|
+
# not apply.
|
|
175
176
|
kv_k_only: bool = False
|
|
176
177
|
|
|
177
178
|
@property
|
|
@@ -188,6 +189,10 @@ class ModelProfile:
|
|
|
188
189
|
return sum(1 for kind, _ in self.layers if kind == LayerKind.RECURRENT)
|
|
189
190
|
|
|
190
191
|
|
|
192
|
+
# The device a placement runs on; engine_adapters.llama_cpp.backend_for keys its hooks on it.
|
|
193
|
+
Backend = Literal["cuda", "metal", "cpu"]
|
|
194
|
+
|
|
195
|
+
|
|
191
196
|
@dataclass
|
|
192
197
|
class HardwareBudget:
|
|
193
198
|
"""Memory the physics check may budget against. Discrete cards may trust the device query;
|
|
@@ -392,7 +397,7 @@ def recurrent_state_bytes(profile: ModelProfile, *, slots: int = 1) -> int:
|
|
|
392
397
|
|
|
393
398
|
|
|
394
399
|
# MTP speculation in the agent posture, measured on llama.cpp b11583 at 128K x 2, -ub 512
|
|
395
|
-
# (
|
|
400
|
+
# (27B MTP and 35B-A3B reference measurements). The draft context
|
|
396
401
|
# keeps f16 KV for one attention layer per window token (27B: 512 MiB = 4096 B x 131072; A3B:
|
|
397
402
|
# 256 MiB = 2048 B x 131072); the recurrent state triples (27B 299 -> 898, A3B 188 -> 565 MiB);
|
|
398
403
|
# and the draft context has its own compute buffer of about 200 MiB (27B 196, A3B 168).
|
|
@@ -457,7 +462,7 @@ def kv_pool_bytes(
|
|
|
457
462
|
"""KV cache bytes of a ``window``-token pool at the given K/V dtypes. Full layers hold
|
|
458
463
|
``window`` tokens; SWA layers follow llama.cpp's ``llama-kv-cache-iswa.cpp`` sizing
|
|
459
464
|
``GGML_PAD(min(size_base, swa_window * (unified ? slots : 1) + ubatch), 256)`` per stream
|
|
460
|
-
|
|
465
|
+
."""
|
|
461
466
|
scale = _kv_dtype_scale(profile, kv_types)
|
|
462
467
|
swa_tokens = _swa_kv_tokens(
|
|
463
468
|
window, profile.swa_window, slots=slots, ubatch=ubatch, unified=unified
|
|
@@ -481,7 +486,7 @@ def session_state_bytes(profile: ModelProfile, window: int, kv_types: tuple[str,
|
|
|
481
486
|
|
|
482
487
|
|
|
483
488
|
# A CUDA llama-server with every layer on the card holds host RAM besides its --cache-ram.
|
|
484
|
-
# Measured on b11370 r3 (
|
|
489
|
+
# Measured on b11370 r3 (16 GB reference GPU, Qwen3.8 27B UD-IQ3_S,
|
|
485
490
|
# 64K x 2): anon idles at 880 MiB after the warmup request in all seven phases, at --cache-ram 2048
|
|
486
491
|
# and 8192 alike (samples-gpu.txt); V3L's Spark 4B and MiniCPM5 2B idle at about 820 MiB.
|
|
487
492
|
LLAMA_HOST_BASE_BYTES = 880 << 20
|
|
@@ -10,7 +10,7 @@ Max chips sold with two bus widths (M3 Max 300/400 GB/s, M4 Max 410/546 GB/s, M5
|
|
|
10
10
|
are left out unless a known host fact (such as Apple M6's 16 GB vs 24/32 GB memory tier)
|
|
11
11
|
disambiguates them, so unlisted names keep their class constant. On qwen3.8-27b UD-Q4_K_M without
|
|
12
12
|
speculation the repository measured 43–47.6 tok/s on an RTX 4090 D and 14.8 tok/s on an L4
|
|
13
|
-
(
|
|
13
|
+
(measured across reference discrete GPUs): a ratio of 3.2 against 3.4 between their spec
|
|
14
14
|
bandwidths, where the old single 1000 GB/s class constant priced both alike.
|
|
15
15
|
"""
|
|
16
16
|
|
|
@@ -540,7 +540,7 @@ def update_owned(change: Callable[[Owned], None], tools_dir: str | Path = TOOLS_
|
|
|
540
540
|
`owned.lock` is permanent, even when the manifest becomes empty. Unlinking it after the
|
|
541
541
|
flock is released splits the lock domain: a writer that already opened the old inode and
|
|
542
542
|
a writer that recreates the pathname would both hold an "exclusive" lock and one archive
|
|
543
|
-
entry would be lost
|
|
543
|
+
entry would be lost. Nothing removes the tools directory itself."""
|
|
544
544
|
if os.name == "nt":
|
|
545
545
|
return _update_owned_windows(change, tools_dir)
|
|
546
546
|
import fcntl
|
|
@@ -591,18 +591,6 @@ def own_gateway(
|
|
|
591
591
|
update_owned(change, tools_dir)
|
|
592
592
|
|
|
593
593
|
|
|
594
|
-
def own_magpie(tools_dir: str | Path, record: OwnedMagpie | None) -> None:
|
|
595
|
-
"""Record or clear the private ``magpie serve`` instance launched by this tool."""
|
|
596
|
-
|
|
597
|
-
def change(doc: Owned) -> None:
|
|
598
|
-
if record is None:
|
|
599
|
-
doc["gateway"].pop("magpie", None)
|
|
600
|
-
else:
|
|
601
|
-
doc["gateway"]["magpie"] = record
|
|
602
|
-
|
|
603
|
-
update_owned(change, tools_dir)
|
|
604
|
-
|
|
605
|
-
|
|
606
594
|
def forget_search(tools_dir: str | Path, field: Literal["search", "search_you"]) -> None:
|
|
607
595
|
"""Forget a Magpie search API this tool added for the web search service it used to run."""
|
|
608
596
|
|
|
@@ -661,17 +649,25 @@ def port_owned_elsewhere(port: int, deploy_dir: str, tools_dir: str | Path = TOO
|
|
|
661
649
|
)
|
|
662
650
|
|
|
663
651
|
|
|
664
|
-
def own_deployment(
|
|
652
|
+
def own_deployment(
|
|
653
|
+
plan: Plan, tools_dir: str | Path = TOOLS_DIR, *, ok: bool = True, adopt: bool = False
|
|
654
|
+
) -> bool:
|
|
665
655
|
"""Record a deployment on this computer (``owned_entry``). Never overwrites a live verified
|
|
666
656
|
manifest entry belonging to another directory, never claims a unit owned by another live
|
|
667
657
|
verified deployment, and on failure never registers a competing owner on a port another live
|
|
668
|
-
deployment holds.
|
|
658
|
+
deployment holds.
|
|
659
|
+
|
|
660
|
+
``adopt`` (an uninstall taking a deployment its manifest does not list) only adds a missing
|
|
661
|
+
entry, never replacing one written meanwhile, and records a failed deploy even on a port a
|
|
662
|
+
live deployment holds: FAILED never blocks that owner, and the uninstall can remove it."""
|
|
669
663
|
entry = owned_entry(plan)
|
|
670
664
|
recorded = False
|
|
671
665
|
|
|
672
666
|
def add(doc: Owned) -> None:
|
|
673
667
|
nonlocal recorded
|
|
674
668
|
existing = doc["deployments"].get(plan["name"])
|
|
669
|
+
if adopt and existing is not None:
|
|
670
|
+
return
|
|
675
671
|
if existing is not None and not lifecycle.same_dir(
|
|
676
672
|
existing["deploy_dir"], entry["deploy_dir"]
|
|
677
673
|
):
|
|
@@ -684,7 +680,7 @@ def own_deployment(plan: Plan, tools_dir: str | Path = TOOLS_DIR, *, ok: bool =
|
|
|
684
680
|
continue
|
|
685
681
|
if other["service"] == entry["service"]:
|
|
686
682
|
return
|
|
687
|
-
if not ok and other["port"] == entry["port"]:
|
|
683
|
+
if not ok and not adopt and other["port"] == entry["port"]:
|
|
688
684
|
return
|
|
689
685
|
event = lifecycle.Event.DEPLOYED if ok else lifecycle.Event.DEPLOY_FAILED
|
|
690
686
|
lifecycle.advance(doc["deployments"], plan["name"], event, entry)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# kokoro-onnx 0.6.1 (thewh1teagle/kokoro-onnx, MIT) with misaki 0.9.4's Chinese G2P (hexgrad/misaki,
|
|
2
2
|
# Apache-2.0) on onnxruntime 1.23.2 for the Kokoro-82M TTS service (localmodels/tts_server.py). The
|
|
3
|
-
# versions are those of the venv measured on
|
|
3
|
+
# versions are those of the venv measured on a reference Linux host (Python 3.10.12),
|
|
4
4
|
# without its Piper voices. Installed by localmodels/frontend.py with --require-hashes --no-deps.
|
|
5
5
|
# Regenerate with
|
|
6
6
|
# uv pip compile --universal --python-version 3.10 --generate-hashes --no-header --no-annotate
|
|
@@ -24,6 +24,7 @@ from localmodels import (
|
|
|
24
24
|
library_pricing,
|
|
25
25
|
metal,
|
|
26
26
|
plan_envelope,
|
|
27
|
+
suite,
|
|
27
28
|
vision,
|
|
28
29
|
)
|
|
29
30
|
from localmodels.context_policy import AgentPosture
|
|
@@ -240,15 +241,19 @@ def _floor_need_bytes(
|
|
|
240
241
|
|
|
241
242
|
def minimum_memory_bytes(facts: HostFacts, model: Model, pool: str) -> int | None:
|
|
242
243
|
"""Estimated footprint at the lowest elastic posture rung (floor ctx x 1 slot, compact KV)."""
|
|
243
|
-
if (
|
|
244
|
-
not pool
|
|
245
|
-
or pool == "system"
|
|
246
|
-
or model.entry.runtime != "llama.cpp"
|
|
247
|
-
or library_kept.retired(model.entry)
|
|
248
|
-
):
|
|
244
|
+
if not pool or pool == "system" or library_kept.retired(model.entry):
|
|
249
245
|
return None
|
|
250
246
|
if pool not in memory_pools.pools(facts):
|
|
251
247
|
return None
|
|
248
|
+
if model.entry.runtime == "strata-poly":
|
|
249
|
+
if pool == "unified" and metal.supported(facts):
|
|
250
|
+
return library_poly.unified_floor_bytes(
|
|
251
|
+
suite.recipe(model.entry.id),
|
|
252
|
+
context_policy.posture_for(library_pricing.posture(), "metal"),
|
|
253
|
+
)
|
|
254
|
+
return None
|
|
255
|
+
if model.entry.runtime != "llama.cpp":
|
|
256
|
+
return None
|
|
252
257
|
backend: budget.Backend = "metal" if pool == "unified" and metal.supported(facts) else "cuda"
|
|
253
258
|
ladder = elastic_posture_ladder(
|
|
254
259
|
library_pricing.posture(),
|
|
@@ -536,6 +541,120 @@ def load_posture(model: Model, base_dir: str) -> AgentPosture:
|
|
|
536
541
|
return replace(posture, draft="off")
|
|
537
542
|
|
|
538
543
|
|
|
544
|
+
def _price_poly_unified(
|
|
545
|
+
facts: HostFacts,
|
|
546
|
+
model: Model,
|
|
547
|
+
base_dir: str,
|
|
548
|
+
port: int,
|
|
549
|
+
adm: budget.AdmissionBudget,
|
|
550
|
+
*,
|
|
551
|
+
allow_overcommit: bool,
|
|
552
|
+
force: bool,
|
|
553
|
+
) -> ElasticPlan:
|
|
554
|
+
"""Dual-tier Metal admission for a ``strata-poly`` recipe on Apple Silicon unified memory."""
|
|
555
|
+
mac_posture = context_policy.posture_for(library_pricing.posture(), "metal")
|
|
556
|
+
if problem := metal.problem(facts):
|
|
557
|
+
floor_need = library_poly.unified_floor_bytes(suite.recipe(model.entry.id), mac_posture)
|
|
558
|
+
if metal.is_critical_pressure(facts):
|
|
559
|
+
raise ElasticRoomError(
|
|
560
|
+
problem,
|
|
561
|
+
pool="unified",
|
|
562
|
+
need_bytes=floor_need,
|
|
563
|
+
free_bytes=0,
|
|
564
|
+
memory="unified memory",
|
|
565
|
+
wired_headroom_bytes=0,
|
|
566
|
+
soft_available_bytes=0,
|
|
567
|
+
pressure_level=adm.pressure_level,
|
|
568
|
+
can_force=False,
|
|
569
|
+
)
|
|
570
|
+
raise LiveMemoryUnavailable(problem)
|
|
571
|
+
plan, needed, wired = library_poly.build_unified_plan(
|
|
572
|
+
facts, model.entry.id, base_dir, port, mac_posture
|
|
573
|
+
)
|
|
574
|
+
eff = _plan_posture(plan)
|
|
575
|
+
working_set = metal.working_set_bytes(facts)
|
|
576
|
+
pool_cap = memory_pools.pool_total(facts, "unified")
|
|
577
|
+
tier1_limit = min(working_set, pool_cap, adm.soft_budget_bytes)
|
|
578
|
+
if (
|
|
579
|
+
needed <= tier1_limit
|
|
580
|
+
and wired <= adm.hard_ceiling_bytes
|
|
581
|
+
and needed <= adm.physical_limit_bytes
|
|
582
|
+
):
|
|
583
|
+
return ElasticPlan(plan, 0, (), eff, eff, False, None, None, False, adm)
|
|
584
|
+
if (
|
|
585
|
+
allow_overcommit
|
|
586
|
+
and adm.allows_soft_overcommit
|
|
587
|
+
and not adm.critical_pressure
|
|
588
|
+
and adm.pressure_level != metal.PRESSURE_WARN
|
|
589
|
+
and wired <= adm.hard_ceiling_bytes
|
|
590
|
+
and needed <= min(working_set, pool_cap, adm.physical_limit_bytes)
|
|
591
|
+
):
|
|
592
|
+
warning: MemoryPressureWarning = {
|
|
593
|
+
"level": "soft",
|
|
594
|
+
"pool": "unified",
|
|
595
|
+
"free_bytes": adm.soft_budget_bytes,
|
|
596
|
+
"budget_bytes": adm.hard_ceiling_bytes,
|
|
597
|
+
}
|
|
598
|
+
return ElasticPlan(
|
|
599
|
+
plan=plan,
|
|
600
|
+
rung_index=0,
|
|
601
|
+
ladder=(),
|
|
602
|
+
requested_posture=eff,
|
|
603
|
+
effective_posture=eff,
|
|
604
|
+
degraded=True,
|
|
605
|
+
degradation_reason="above_soft_budget",
|
|
606
|
+
memory_pressure_warning=warning,
|
|
607
|
+
forced=False,
|
|
608
|
+
admission=adm,
|
|
609
|
+
)
|
|
610
|
+
if force and _force_within_hard_limits(adm, needed, wired):
|
|
611
|
+
forced_warning: MemoryPressureWarning = {
|
|
612
|
+
"level": "high",
|
|
613
|
+
"pool": "unified",
|
|
614
|
+
"free_bytes": min(adm.soft_budget_bytes, adm.hard_ceiling_bytes),
|
|
615
|
+
"budget_bytes": adm.physical_limit_bytes,
|
|
616
|
+
}
|
|
617
|
+
return ElasticPlan(
|
|
618
|
+
plan=plan,
|
|
619
|
+
rung_index=0,
|
|
620
|
+
ladder=(),
|
|
621
|
+
requested_posture=eff,
|
|
622
|
+
effective_posture=eff,
|
|
623
|
+
degraded=True,
|
|
624
|
+
degradation_reason="forced_overcommit",
|
|
625
|
+
memory_pressure_warning=forced_warning,
|
|
626
|
+
forced=True,
|
|
627
|
+
admission=adm,
|
|
628
|
+
)
|
|
629
|
+
can_force = not force and _force_within_hard_limits(adm, needed, wired)
|
|
630
|
+
wired_blocked = wired > adm.hard_ceiling_bytes
|
|
631
|
+
phys_blocked = needed > adm.physical_limit_bytes
|
|
632
|
+
ws_blocked = needed > working_set
|
|
633
|
+
soft_blocked = not wired_blocked and not phys_blocked and not ws_blocked
|
|
634
|
+
report_need = wired if wired_blocked else needed
|
|
635
|
+
if wired_blocked:
|
|
636
|
+
report_free = adm.hard_ceiling_bytes
|
|
637
|
+
elif phys_blocked:
|
|
638
|
+
report_free = adm.physical_limit_bytes
|
|
639
|
+
elif ws_blocked:
|
|
640
|
+
report_free = working_set
|
|
641
|
+
else:
|
|
642
|
+
report_free = adm.soft_budget_bytes
|
|
643
|
+
ceiling_label = "soft budget" if soft_blocked else "hard ceiling"
|
|
644
|
+
raise ElasticRoomError(
|
|
645
|
+
f"{model.id} does not fit unified now (needs {report_need} bytes, {ceiling_label} "
|
|
646
|
+
f"{report_free} bytes)",
|
|
647
|
+
pool="unified",
|
|
648
|
+
need_bytes=report_need,
|
|
649
|
+
free_bytes=report_free,
|
|
650
|
+
memory="unified memory",
|
|
651
|
+
wired_headroom_bytes=adm.wired_headroom_bytes,
|
|
652
|
+
soft_available_bytes=adm.soft_budget_bytes,
|
|
653
|
+
pressure_level=adm.pressure_level,
|
|
654
|
+
can_force=can_force,
|
|
655
|
+
)
|
|
656
|
+
|
|
657
|
+
|
|
539
658
|
def price_elastic(
|
|
540
659
|
facts: HostFacts,
|
|
541
660
|
model: Model,
|
|
@@ -563,6 +682,16 @@ def price_elastic(
|
|
|
563
682
|
if adm is None:
|
|
564
683
|
raise plan_envelope.PlanError(f"this computer has no pool {pool}")
|
|
565
684
|
if model.entry.runtime == "strata-poly":
|
|
685
|
+
if pool == "unified" and metal.supported(facts):
|
|
686
|
+
return _price_poly_unified(
|
|
687
|
+
facts,
|
|
688
|
+
model,
|
|
689
|
+
base_dir,
|
|
690
|
+
port,
|
|
691
|
+
adm,
|
|
692
|
+
allow_overcommit=allow_overcommit,
|
|
693
|
+
force=force,
|
|
694
|
+
)
|
|
566
695
|
poly_plan = library_poly.price(
|
|
567
696
|
facts,
|
|
568
697
|
model.entry.id,
|
|
@@ -60,11 +60,19 @@ def _named(entry: cat.CatalogEntry, catalog: Iterable[cat.CatalogEntry]) -> cat.
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def _runtime(record: Record) -> str:
|
|
63
|
-
|
|
63
|
+
plan = record["plan"]
|
|
64
|
+
build = str(plan["engine"].get("build") or "")
|
|
64
65
|
if build.startswith("strata-poly"):
|
|
65
66
|
return "strata-poly"
|
|
66
67
|
if build.startswith("strata"):
|
|
67
68
|
return "strata"
|
|
69
|
+
launch_runtime = str(plan["launch"].get("runtime") or "")
|
|
70
|
+
custom = record.get("custom")
|
|
71
|
+
custom_fmt = custom.get("format") if custom is not None else None
|
|
72
|
+
if launch_runtime == "mlx-lm" or build.startswith("mlx") or custom_fmt == "mlx":
|
|
73
|
+
return "mlx-lm"
|
|
74
|
+
if launch_runtime and launch_runtime != "llama.cpp":
|
|
75
|
+
return launch_runtime
|
|
68
76
|
return "llama.cpp"
|
|
69
77
|
|
|
70
78
|
|
|
@@ -9,7 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
import json
|
|
11
11
|
import sys
|
|
12
|
-
from collections.abc import Mapping
|
|
12
|
+
from collections.abc import Mapping, Sequence
|
|
13
13
|
from typing import Literal, TypedDict
|
|
14
14
|
|
|
15
15
|
STATUS_SCHEMA = "localmodels.library-status/v1"
|
|
@@ -626,12 +626,39 @@ def library_id(catalog_id: str, quant: str) -> str:
|
|
|
626
626
|
return f"{catalog_id}:{quant}"
|
|
627
627
|
|
|
628
628
|
|
|
629
|
+
_ENGINE_NAME_SUFFIX = {
|
|
630
|
+
"polystrata": "PolyStrata",
|
|
631
|
+
"strata": "Strata",
|
|
632
|
+
"mlx": "MLX",
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
|
|
629
636
|
def display_name(model: str, quant: str) -> str:
|
|
630
637
|
"""What a person reads: the model's name and its variant, so no two rows share one (two
|
|
631
638
|
catalog ids can share a display name, and one id has a row per variant)."""
|
|
632
639
|
return f"{model} ({quant})"
|
|
633
640
|
|
|
634
641
|
|
|
642
|
+
def disambiguate_row_names(rows: Sequence[Row]) -> None:
|
|
643
|
+
"""Guard ``library-v2.schema.json`` row ``name`` uniqueness across engines: if two rows share
|
|
644
|
+
the same ``(display_name, quant)`` under different engines, append an engine suffix to every
|
|
645
|
+
non-``llama.cpp`` row in that collision group."""
|
|
646
|
+
groups: dict[str, list[Row]] = {}
|
|
647
|
+
for row in rows:
|
|
648
|
+
groups.setdefault(row["name"], []).append(row)
|
|
649
|
+
for group in groups.values():
|
|
650
|
+
if len(group) < 2:
|
|
651
|
+
continue
|
|
652
|
+
engines = {row.get("engine", "llama.cpp") for row in group}
|
|
653
|
+
if len(engines) < 2:
|
|
654
|
+
continue
|
|
655
|
+
for row in group:
|
|
656
|
+
engine = row.get("engine", "llama.cpp")
|
|
657
|
+
if engine != "llama.cpp":
|
|
658
|
+
suffix = _ENGINE_NAME_SUFFIX.get(engine, str(engine))
|
|
659
|
+
row["name"] = f"{row['name']} · {suffix}"
|
|
660
|
+
|
|
661
|
+
|
|
635
662
|
def split_id(value: str) -> tuple[str, str]:
|
|
636
663
|
"""(catalog id, quant); a bare catalog id has an empty quant (its last variant)."""
|
|
637
664
|
catalog_id, _, quant = value.partition(":")
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Validated ``strata-poly`` chat recipes that declare model-card metadata (``display_name``,
|
|
4
4
|
``description``, ``family``, ``publisher``, ``parameters``) join ``localmodels library`` on
|
|
5
|
-
supported
|
|
6
|
-
``suite_plan.build_plan`` so CUDA 13 driver checks, glibc checks,
|
|
7
|
-
RAM ceilings stay
|
|
5
|
+
supported Apple Silicon Metal Macs and NVIDIA Linux/Windows hosts alongside ``llama.cpp`` models.
|
|
6
|
+
Pricing runs ``suite_plan.build_plan`` so CUDA 13 driver checks, glibc checks, Metal unified
|
|
7
|
+
memory sizing, vision reader placement and host RAM ceilings stay consistent with ``stack plan``.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
@@ -15,6 +15,7 @@ from localmodels import (
|
|
|
15
15
|
deploy,
|
|
16
16
|
engines,
|
|
17
17
|
hosts,
|
|
18
|
+
metal,
|
|
18
19
|
plan_envelope,
|
|
19
20
|
stack_suite,
|
|
20
21
|
suite,
|
|
@@ -24,10 +25,14 @@ from localmodels.context_policy import AgentPosture
|
|
|
24
25
|
from localmodels.engine_adapters import suite_plan
|
|
25
26
|
from localmodels.estimator import PhysicsRefusal
|
|
26
27
|
from localmodels.library_model import Reason, split_id
|
|
27
|
-
from localmodels.planning import budget
|
|
28
|
+
from localmodels.planning import budget, memory_pools
|
|
28
29
|
from localmodels.probe import GPU, HostFacts
|
|
29
30
|
from localmodels.records import Plan
|
|
30
31
|
|
|
32
|
+
# On macOS, recommendedMaxWorkingSetSize already reserves OS headroom, so keep PolyStrata's
|
|
33
|
+
# --vram-reserve-mib modest rather than charging discrete-GPU display margins (1280 MiB) twice.
|
|
34
|
+
METAL_POLY_RESERVE_MIB = 512
|
|
35
|
+
|
|
31
36
|
|
|
32
37
|
def strata_ids() -> set[str]:
|
|
33
38
|
"""Every catalog component id of a Strata/PolyStrata runtime."""
|
|
@@ -72,13 +77,14 @@ def is_library_recipe(recipe: suite.SuiteRecipe) -> bool:
|
|
|
72
77
|
|
|
73
78
|
|
|
74
79
|
def _validated_for(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
75
|
-
if
|
|
80
|
+
key = "linux" if platform.startswith("linux") else platform
|
|
81
|
+
if recipe.get("status") != "validated" or not stack_suite.built_for(recipe, key):
|
|
76
82
|
return False
|
|
77
83
|
scope = recipe.get("validated_on")
|
|
78
84
|
if not scope:
|
|
79
85
|
return True
|
|
80
86
|
# Decision 48: Linux CUDA evidence also validates native Windows x64 CUDA builds.
|
|
81
|
-
return
|
|
87
|
+
return key in scope or (key == "win32" and "linux" in scope)
|
|
82
88
|
|
|
83
89
|
|
|
84
90
|
def eligible(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
@@ -140,13 +146,21 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
|
|
|
140
146
|
description=recipe.get("description") or "",
|
|
141
147
|
repo=recipe["repo"],
|
|
142
148
|
variants=(variant,),
|
|
143
|
-
n_ctx_train=
|
|
144
|
-
|
|
149
|
+
n_ctx_train=max(
|
|
150
|
+
[
|
|
151
|
+
int(recipe.get("context") or 65536),
|
|
152
|
+
*(int(g.get("context") or 0) for g in recipe.get("card_args") or ()),
|
|
153
|
+
]
|
|
154
|
+
),
|
|
155
|
+
full_layers=int(recipe.get("full_layers") or 0),
|
|
145
156
|
recurrent_layers=0,
|
|
146
|
-
per_layer_f16=0,
|
|
157
|
+
per_layer_f16=int(recipe.get("per_layer_f16") or 0),
|
|
158
|
+
swa_layers=int(recipe.get("swa_layers") or 0),
|
|
159
|
+
swa_window=int(recipe.get("swa_window") or 0),
|
|
147
160
|
moe=bool(recipe.get("moe", True)),
|
|
148
161
|
mmproj=mmproj,
|
|
149
162
|
quality=score,
|
|
163
|
+
decode_fraction=float(recipe.get("decode_fraction") or 1.0),
|
|
150
164
|
license=recipe.get("license") or "",
|
|
151
165
|
license_url=recipe.get("license_url") or "",
|
|
152
166
|
status=recipe.get("status") or "",
|
|
@@ -250,6 +264,88 @@ def _calibrate_host_ram(plan: Plan, recipe: suite.SuiteRecipe, gpu: GPU) -> None
|
|
|
250
264
|
limits["MemoryMax"] = f"{(new_max + (1 << 20) - 1) >> 20}M"
|
|
251
265
|
|
|
252
266
|
|
|
267
|
+
def unified_floor_bytes(recipe: suite.SuiteRecipe, posture: AgentPosture) -> int:
|
|
268
|
+
"""Compositional Apple Silicon unified-memory estimate for ``recipe`` at its base context."""
|
|
269
|
+
reader = vision.strata_mode(posture.vision, 0, bool(recipe.get("vision")), unified=True)
|
|
270
|
+
total, _ = suite.poly_unified_footprint(recipe, vision_reader=reader)
|
|
271
|
+
return total
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def build_unified_plan(
|
|
275
|
+
facts: HostFacts,
|
|
276
|
+
recipe_id: str,
|
|
277
|
+
base_dir: str,
|
|
278
|
+
port: int,
|
|
279
|
+
posture: AgentPosture,
|
|
280
|
+
) -> tuple[Plan, int, int]:
|
|
281
|
+
"""Build an Apple Silicon Metal ``strata-poly`` plan and return ``(plan, unified_bytes, wired_bytes)``."""
|
|
282
|
+
gpu = metal.device(facts)
|
|
283
|
+
if gpu is None:
|
|
284
|
+
raise plan_envelope.PlanError("this computer has no Metal GPU for unified memory")
|
|
285
|
+
recipe = suite.recipe(recipe_id)
|
|
286
|
+
if not stack_suite.built_for(recipe, facts["platform"]):
|
|
287
|
+
raise plan_envelope.PlanError(f"{recipe_id} has no engine build for {facts['platform']}")
|
|
288
|
+
spec = recipe.get("vision") or {}
|
|
289
|
+
reader = vision.strata_mode(posture.vision, gpu["total_bytes"], bool(spec), unified=True)
|
|
290
|
+
raw_reserve = int(recipe.get("vram_reserve_mib") or METAL_POLY_RESERVE_MIB)
|
|
291
|
+
reserve = min(raw_reserve, METAL_POLY_RESERVE_MIB)
|
|
292
|
+
opts = suite.SuiteOptions(
|
|
293
|
+
base_dir=base_dir,
|
|
294
|
+
hf_endpoint=deploy.hf_endpoint(),
|
|
295
|
+
gpu=gpu,
|
|
296
|
+
port=port,
|
|
297
|
+
vram_reserve_mib=reserve,
|
|
298
|
+
vision_reader=reader,
|
|
299
|
+
)
|
|
300
|
+
plan = suite.unbounded(suite_plan.build_plan(hosts.LOCAL_ID, facts, recipe, opts))
|
|
301
|
+
window = int(str(plan["launch"].get("window") or 0))
|
|
302
|
+
slots = int(str(plan["launch"].get("slots") or 1))
|
|
303
|
+
kv_fmt = suite.plan_kv_format(plan, recipe)
|
|
304
|
+
needed, wired = suite.poly_unified_footprint(
|
|
305
|
+
recipe, window=window, slots=slots, kv_fmt=kv_fmt, vision_reader=reader
|
|
306
|
+
)
|
|
307
|
+
plan["launch"]["unified_bytes"] = needed
|
|
308
|
+
plan["launch"]["vram_bytes"] = wired
|
|
309
|
+
plan["launch"].pop("min_vram_free_bytes", None)
|
|
310
|
+
return plan, needed, wired
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def _price_unified(
|
|
314
|
+
facts: HostFacts,
|
|
315
|
+
recipe_id: str,
|
|
316
|
+
base_dir: str,
|
|
317
|
+
port: int,
|
|
318
|
+
posture: AgentPosture,
|
|
319
|
+
*,
|
|
320
|
+
require_live: bool = False,
|
|
321
|
+
) -> Plan:
|
|
322
|
+
if require_live and (problem := metal.problem(facts)):
|
|
323
|
+
raise plan_envelope.PlanError(problem)
|
|
324
|
+
plan, needed, wired = build_unified_plan(facts, recipe_id, base_dir, port, posture)
|
|
325
|
+
working_set = metal.working_set_bytes(facts)
|
|
326
|
+
pool_cap = memory_pools.pool_total(facts, "unified")
|
|
327
|
+
adm = budget.admission_budget(facts, "unified")
|
|
328
|
+
limit = (
|
|
329
|
+
min(working_set, pool_cap, adm.soft_budget_bytes)
|
|
330
|
+
if adm is not None
|
|
331
|
+
else min(working_set, pool_cap)
|
|
332
|
+
)
|
|
333
|
+
if needed > limit:
|
|
334
|
+
msg = (
|
|
335
|
+
f"{recipe_id} needs {needed} bytes of unified memory, exceeding {limit} bytes available"
|
|
336
|
+
)
|
|
337
|
+
raise deploy.AgentMemoryError(msg, PhysicsRefusal(needed, limit, msg), "unified memory")
|
|
338
|
+
if require_live and adm is not None and wired > adm.hard_ceiling_bytes:
|
|
339
|
+
msg = (
|
|
340
|
+
f"{recipe_id} needs {wired} bytes of wired Metal memory, "
|
|
341
|
+
f"exceeding {adm.hard_ceiling_bytes} bytes headroom"
|
|
342
|
+
)
|
|
343
|
+
raise deploy.AgentMemoryError(
|
|
344
|
+
msg, PhysicsRefusal(wired, adm.hard_ceiling_bytes, msg), "unified memory"
|
|
345
|
+
)
|
|
346
|
+
return plan
|
|
347
|
+
|
|
348
|
+
|
|
253
349
|
def price(
|
|
254
350
|
facts: HostFacts,
|
|
255
351
|
recipe_id: str,
|
|
@@ -260,10 +356,12 @@ def price(
|
|
|
260
356
|
*,
|
|
261
357
|
require_live: bool = False,
|
|
262
358
|
) -> Plan:
|
|
263
|
-
"""Price one ``strata-poly`` library model on discrete
|
|
359
|
+
"""Price one ``strata-poly`` library model on discrete NVIDIA or Apple Silicon unified pool."""
|
|
360
|
+
if pool == "unified" and metal.supported(facts):
|
|
361
|
+
return _price_unified(facts, recipe_id, base_dir, port, posture, require_live=require_live)
|
|
264
362
|
if facts["platform"] not in ("linux", "win32"):
|
|
265
363
|
raise plan_envelope.PlanError(
|
|
266
|
-
"PolyStrata recipes run on
|
|
364
|
+
"PolyStrata recipes run on Apple Silicon Metal and Linux/Windows NVIDIA GPUs only"
|
|
267
365
|
)
|
|
268
366
|
gpu = _gpu_for_pool(facts, pool)
|
|
269
367
|
recipe = suite.recipe(recipe_id)
|
|
@@ -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 = (
|
|
@@ -589,12 +591,19 @@ def floor_metadata(
|
|
|
589
591
|
if model.entry.runtime == "strata-poly":
|
|
590
592
|
recipe = suite.recipe(model.entry.id)
|
|
591
593
|
window = int(recipe.get("context") or model.entry.n_ctx_train)
|
|
592
|
-
|
|
594
|
+
metal_unified = metal.supported(facts)
|
|
595
|
+
active = model.entry.agent_posture(
|
|
596
|
+
context_policy.posture_for(posture(), "metal" if metal_unified else "cuda")
|
|
597
|
+
)
|
|
593
598
|
vision_on = bool(recipe.get("vision")) and active.vision != "off"
|
|
594
599
|
download = sum(
|
|
595
600
|
int(f["size_bytes"]) for f in recipe["files"] if vision_on or not f.get("vision")
|
|
596
601
|
)
|
|
597
|
-
floor_bytes =
|
|
602
|
+
floor_bytes = (
|
|
603
|
+
library_poly.unified_floor_bytes(recipe, active)
|
|
604
|
+
if metal_unified
|
|
605
|
+
else int(recipe.get("min_vram_free_bytes") or recipe.get("vram_bytes") or 0)
|
|
606
|
+
)
|
|
598
607
|
effective_shortfall = 0 if memory_kind == "ram" else shortfall_bytes
|
|
599
608
|
return max(effective_shortfall, floor_bytes), window, vision_on, download
|
|
600
609
|
metal_unified = metal.supported(facts)
|