@simplexai/localmodels-win32-x64 0.1.0-dev.102 → 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/NOTICE +126 -0
- package/README.md +10 -0
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +139 -121
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +3 -1
- package/modules/localmodels/catalog.json +435 -127
- package/modules/localmodels/catalog.py +7 -3
- package/modules/localmodels/catalog_recipes.py +3 -3
- package/modules/localmodels/cli_parser.py +7 -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/debug_stub_server.py +280 -7
- 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 +77 -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 +68 -0
- 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 +162 -75
- 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_common.py +12 -2
- 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 +460 -0
- package/modules/localmodels/sidecar_http.py +452 -0
- package/modules/localmodels/sidecar_state.py +516 -0
- package/modules/localmodels/speech_admission.py +33 -4
- package/modules/localmodels/speech_catalog.py +23 -0
- package/modules/localmodels/speech_cli.py +10 -2
- package/modules/localmodels/speech_jobs.py +120 -384
- package/modules/localmodels/speech_server.py +187 -77
- package/modules/localmodels/speech_state.py +90 -454
- package/modules/localmodels/speech_workers.py +51 -162
- package/modules/localmodels/stack.py +18 -0
- 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_down.py +19 -14
- 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 +32 -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_up.py +51 -1
- 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 +251 -3
- package/modules/localmodels/suite.py +137 -5
- package/modules/localmodels/tts-moss.txt +321 -0
- package/modules/localmodels/tts_admission.py +381 -0
- package/modules/localmodels/tts_backend_speechcpp.py +487 -0
- package/modules/localmodels/tts_catalog.py +279 -0
- package/modules/localmodels/tts_cli.py +352 -0
- package/modules/localmodels/tts_http.py +623 -0
- package/modules/localmodels/tts_jobs.py +526 -0
- package/modules/localmodels/tts_model.py +591 -0
- package/modules/localmodels/tts_moss_presets.json +1 -0
- package/modules/localmodels/tts_serve.py +451 -0
- package/modules/localmodels/tts_server.py +1 -1
- package/modules/localmodels/tts_sidecar.py +788 -0
- package/modules/localmodels/tts_state.py +400 -0
- package/modules/localmodels/tts_worker_kokoro.py +463 -0
- package/modules/localmodels/tts_worker_moss.py +748 -0
- package/modules/localmodels/tts_workers.py +696 -0
- 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.dev102.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/RECORD +132 -109
- 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.dev102.dist-info/METADATA +0 -9
- package/modules/simplex_localmodels-0.1.0.dev102.dist-info/licenses/NOTICE +0 -68
- /package/modules/{simplex_localmodels-0.1.0.dev102.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev102.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev102.dist-info → simplex_localmodels-0.1.0.dev104.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -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)
|