@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
|
@@ -7,10 +7,11 @@ library_pricing, and the commands in library_jobs and library_serve.
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import datetime as dt
|
|
10
11
|
import json
|
|
11
12
|
import sys
|
|
12
13
|
from collections.abc import Mapping, Sequence
|
|
13
|
-
from typing import Literal, TypedDict
|
|
14
|
+
from typing import Literal, TypedDict, cast
|
|
14
15
|
|
|
15
16
|
STATUS_SCHEMA = "localmodels.library-status/v1"
|
|
16
17
|
EVENT_SCHEMA = "localmodels.library-event/v1"
|
|
@@ -19,6 +20,42 @@ CUSTOM_PROBE_SCHEMA = "localmodels.library-custom-probe/v1"
|
|
|
19
20
|
|
|
20
21
|
ModelState = Literal["absent", "downloading", "idle", "loading", "loaded", "failed"]
|
|
21
22
|
Engine = Literal["llama.cpp", "polystrata", "strata", "mlx"]
|
|
23
|
+
EngineDisplayName = Literal["llama.cpp", "PolyStrata", "Strata", "MLX"]
|
|
24
|
+
ENGINE_DISPLAY_NAMES: dict[Engine, EngineDisplayName] = {
|
|
25
|
+
"llama.cpp": "llama.cpp",
|
|
26
|
+
"polystrata": "PolyStrata",
|
|
27
|
+
"strata": "Strata",
|
|
28
|
+
"mlx": "MLX",
|
|
29
|
+
}
|
|
30
|
+
QuantMethod = Literal["gsq_rco", "unsloth_dynamic", "qat", "mlx", "standard"]
|
|
31
|
+
QUANT_METHODS = ("gsq_rco", "unsloth_dynamic", "qat", "mlx", "standard")
|
|
32
|
+
QuantFidelity = Literal[
|
|
33
|
+
"near_lossless", "high_fidelity_compact", "balanced", "compact", "ultra_compact"
|
|
34
|
+
]
|
|
35
|
+
OffloadMode = Literal["gpu_resident", "hybrid_gpu_ram", "unified", "cpu"]
|
|
36
|
+
OFFLOAD_MODES = ("gpu_resident", "hybrid_gpu_ram", "unified", "cpu")
|
|
37
|
+
RecommendationReason = Literal[
|
|
38
|
+
"polystrata_engine",
|
|
39
|
+
"high_fidelity_compact_quant",
|
|
40
|
+
"near_lossless_quant",
|
|
41
|
+
"hybrid_gpu_ram_offload",
|
|
42
|
+
"fits_low_vram",
|
|
43
|
+
"smaller_footprint",
|
|
44
|
+
"long_context",
|
|
45
|
+
"best_quality_for_hardware",
|
|
46
|
+
"prefix_cache",
|
|
47
|
+
]
|
|
48
|
+
RECOMMENDATION_REASONS = (
|
|
49
|
+
"polystrata_engine",
|
|
50
|
+
"high_fidelity_compact_quant",
|
|
51
|
+
"near_lossless_quant",
|
|
52
|
+
"hybrid_gpu_ram_offload",
|
|
53
|
+
"fits_low_vram",
|
|
54
|
+
"smaller_footprint",
|
|
55
|
+
"long_context",
|
|
56
|
+
"best_quality_for_hardware",
|
|
57
|
+
"prefix_cache",
|
|
58
|
+
)
|
|
22
59
|
Fit = Literal["gpu", "unified", "system", "none"]
|
|
23
60
|
Phase = Literal["download", "verify", "load", "warm", "smoke_test"]
|
|
24
61
|
MemoryPressure = Literal["normal", "warn", "critical"]
|
|
@@ -279,6 +316,24 @@ class Load(TypedDict):
|
|
|
279
316
|
total_steps: int
|
|
280
317
|
|
|
281
318
|
|
|
319
|
+
LOAD_BREAKDOWN_KEYS = (
|
|
320
|
+
"prepare_ms",
|
|
321
|
+
"engine_load_ms",
|
|
322
|
+
"touch_verify_ms",
|
|
323
|
+
"warm_ms",
|
|
324
|
+
"register_ms",
|
|
325
|
+
)
|
|
326
|
+
MAX_SAFE_COUNTER = 9007199254740991
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class LoadBreakdownMs(TypedDict, total=False):
|
|
330
|
+
prepare_ms: int
|
|
331
|
+
engine_load_ms: int
|
|
332
|
+
touch_verify_ms: int
|
|
333
|
+
warm_ms: int
|
|
334
|
+
register_ms: int
|
|
335
|
+
|
|
336
|
+
|
|
282
337
|
class _Endpoint(TypedDict):
|
|
283
338
|
base_url: str
|
|
284
339
|
gateway_model: str
|
|
@@ -362,6 +417,15 @@ class VerificationMeta(_VerificationMetaRequired, total=False):
|
|
|
362
417
|
failure: VerificationFailure
|
|
363
418
|
|
|
364
419
|
|
|
420
|
+
class BaselineComparison(TypedDict):
|
|
421
|
+
"""Savings and context delta relative to a larger sibling quantization in the same group."""
|
|
422
|
+
|
|
423
|
+
reference_quant: str
|
|
424
|
+
download_saved_bytes: int
|
|
425
|
+
memory_saved_bytes: int
|
|
426
|
+
context_delta_tokens: int
|
|
427
|
+
|
|
428
|
+
|
|
365
429
|
class _Row(TypedDict):
|
|
366
430
|
id: str
|
|
367
431
|
name: str
|
|
@@ -414,8 +478,27 @@ class Row(_Row, total=False):
|
|
|
414
478
|
custom: CustomRowMeta # present on custom hub models only
|
|
415
479
|
verification: VerificationMeta # present on custom hub models only
|
|
416
480
|
storage: Storage # on-disk file locations; absent when state is absent or no destinations exist
|
|
481
|
+
loaded_at: str | None # RFC3339 UTC timestamp when current load became ready (loaded only)
|
|
482
|
+
uptime_s: int | None # elapsed seconds since loaded_at, computed dynamically (loaded only)
|
|
483
|
+
load_duration_ms: int | None # total end-to-end duration of the load in ms (loaded only)
|
|
484
|
+
load_breakdown_ms: LoadBreakdownMs | None # per-phase load timing breakdown in ms (loaded only)
|
|
485
|
+
cold_load: bool | None # True/False when reliably determinable, else null (loaded only)
|
|
417
486
|
error: Problem # failed only
|
|
418
487
|
note: Note # idle only, when autoload was skipped
|
|
488
|
+
# Structured presentation metadata (all optional, additive since 2026-12-03).
|
|
489
|
+
group_id: str
|
|
490
|
+
display_name: str
|
|
491
|
+
suitability_rank: int
|
|
492
|
+
best_for_host: bool
|
|
493
|
+
quant_method: QuantMethod
|
|
494
|
+
bits_per_weight: float
|
|
495
|
+
quant_fidelity: QuantFidelity
|
|
496
|
+
engine_display_name: EngineDisplayName
|
|
497
|
+
offload_mode: OffloadMode
|
|
498
|
+
recommendation_reasons: list[RecommendationReason]
|
|
499
|
+
baseline_comparison: BaselineComparison
|
|
500
|
+
quality_score: int | None
|
|
501
|
+
estimated_tokens_per_second: float | None
|
|
419
502
|
|
|
420
503
|
|
|
421
504
|
class _DebugInfo(TypedDict):
|
|
@@ -727,6 +810,68 @@ def problem_from_error(error: LibraryError) -> Problem:
|
|
|
727
810
|
return sanitize_problem(raw)
|
|
728
811
|
|
|
729
812
|
|
|
813
|
+
def sanitize_load_breakdown(raw: object) -> LoadBreakdownMs | None:
|
|
814
|
+
"""Validate and copy a persisted ``LoadBreakdownMs`` dict for status and result rows."""
|
|
815
|
+
if not isinstance(raw, Mapping):
|
|
816
|
+
return None
|
|
817
|
+
out: dict[str, int] = {}
|
|
818
|
+
for key in LOAD_BREAKDOWN_KEYS:
|
|
819
|
+
val = raw.get(key)
|
|
820
|
+
if isinstance(val, int) and not isinstance(val, bool) and 0 <= val <= MAX_SAFE_COUNTER:
|
|
821
|
+
out[key] = val
|
|
822
|
+
return cast(LoadBreakdownMs, out) if out else None
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
def parse_rfc3339_utc(raw: object) -> dt.datetime | None:
|
|
826
|
+
"""Parse an RFC3339 timestamp with timezone offset into UTC, or None when invalid."""
|
|
827
|
+
if not isinstance(raw, str) or not raw.strip():
|
|
828
|
+
return None
|
|
829
|
+
text = raw.strip()
|
|
830
|
+
if text.endswith(("Z", "z")):
|
|
831
|
+
text = text[:-1] + "+00:00"
|
|
832
|
+
try:
|
|
833
|
+
parsed = dt.datetime.fromisoformat(text)
|
|
834
|
+
except ValueError:
|
|
835
|
+
return None
|
|
836
|
+
return parsed.astimezone(dt.timezone.utc) if parsed.tzinfo is not None else None
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
def apply_load_lifecycle(found: Row, record: Mapping[str, object], *, now_utc: dt.datetime) -> None:
|
|
840
|
+
"""Project persisted load timing & dynamic uptime onto a loaded ``Row``."""
|
|
841
|
+
raw_loaded_at = record.get("loaded_at")
|
|
842
|
+
parsed_loaded_at = parse_rfc3339_utc(raw_loaded_at)
|
|
843
|
+
raw_duration = record.get("load_duration_ms")
|
|
844
|
+
duration = (
|
|
845
|
+
raw_duration
|
|
846
|
+
if isinstance(raw_duration, int)
|
|
847
|
+
and not isinstance(raw_duration, bool)
|
|
848
|
+
and 0 <= raw_duration <= MAX_SAFE_COUNTER
|
|
849
|
+
else None
|
|
850
|
+
)
|
|
851
|
+
breakdown = sanitize_load_breakdown(record.get("load_breakdown_ms"))
|
|
852
|
+
raw_cold = record.get("cold_load")
|
|
853
|
+
cold: bool | None = raw_cold if isinstance(raw_cold, bool) else None
|
|
854
|
+
if not (
|
|
855
|
+
parsed_loaded_at is not None
|
|
856
|
+
or duration is not None
|
|
857
|
+
or breakdown is not None
|
|
858
|
+
or "cold_load" in record
|
|
859
|
+
or "loaded_at" in record
|
|
860
|
+
):
|
|
861
|
+
return
|
|
862
|
+
if parsed_loaded_at is not None and isinstance(raw_loaded_at, str):
|
|
863
|
+
found["loaded_at"] = raw_loaded_at
|
|
864
|
+
found["uptime_s"] = min(
|
|
865
|
+
MAX_SAFE_COUNTER, max(0, int((now_utc - parsed_loaded_at).total_seconds()))
|
|
866
|
+
)
|
|
867
|
+
else:
|
|
868
|
+
found["loaded_at"] = None
|
|
869
|
+
found["uptime_s"] = None
|
|
870
|
+
found["load_duration_ms"] = duration
|
|
871
|
+
found["load_breakdown_ms"] = breakdown
|
|
872
|
+
found["cold_load"] = cold
|
|
873
|
+
|
|
874
|
+
|
|
730
875
|
def sanitize_problem(raw: Mapping[str, object]) -> Problem:
|
|
731
876
|
"""Validate and copy a persisted ``Problem`` dict for ``library status``."""
|
|
732
877
|
out: Problem = {
|
|
@@ -8,33 +8,68 @@ fallback below validated models whenever a validated model fits (Decision 69).
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
+
from collections.abc import Iterable, Mapping
|
|
12
|
+
|
|
11
13
|
from localmodels import catalog as cat
|
|
12
|
-
from localmodels import llm_rank, metal
|
|
14
|
+
from localmodels import catalog_recipes, llm_rank, metal, suite
|
|
13
15
|
from localmodels.estimator import HardwareBudget
|
|
14
16
|
from localmodels.library_model import Row
|
|
15
17
|
from localmodels.library_pricing import Model
|
|
16
18
|
from localmodels.planning import budget, memory_pools
|
|
17
|
-
from localmodels.probe import HostFacts
|
|
19
|
+
from localmodels.probe import GPU, HostFacts
|
|
18
20
|
|
|
19
21
|
_ACTIONABLE_UNAVAILABLE = frozenset({"DRIVER_UPDATE_REQUIRED", "RUNTIME_DEPENDENCY_MISSING"})
|
|
20
22
|
_LONG_CONTEXT_FLOOR = 131_072
|
|
21
23
|
|
|
22
24
|
|
|
23
|
-
def
|
|
25
|
+
def ranked_quality(entry: cat.CatalogEntry) -> int:
|
|
26
|
+
"""Installed SimplexAI quality score, or 0 for editorial-only / unscored entries."""
|
|
27
|
+
if entry.quality <= 0:
|
|
28
|
+
return 0
|
|
29
|
+
if entry.quality_sources and not any(
|
|
30
|
+
s["type"] == "intelligence_score" for s in entry.quality_sources
|
|
31
|
+
):
|
|
32
|
+
return 0
|
|
33
|
+
return entry.quality
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _quality_bands(scores: Iterable[int]) -> dict[int, int]:
|
|
37
|
+
"""Group descending scores into greedy bands of width ``llm_rank.COIN_FLIP``."""
|
|
38
|
+
unique = sorted(set(scores), reverse=True)
|
|
39
|
+
bands: dict[int, int] = {}
|
|
40
|
+
band_idx = -1
|
|
41
|
+
anchor: int | None = None
|
|
42
|
+
for score in unique:
|
|
43
|
+
if anchor is None or anchor - score > llm_rank.COIN_FLIP:
|
|
44
|
+
band_idx += 1
|
|
45
|
+
anchor = score
|
|
46
|
+
bands[score] = band_idx
|
|
47
|
+
return bands
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _fidelity_rank(model: Model) -> int:
|
|
51
|
+
return catalog_recipes.fidelity_rank(model.entry.quant_fidelity, model.variant.quant)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _est_tok_s(
|
|
24
55
|
model: Model,
|
|
25
|
-
row_doc: Row,
|
|
26
56
|
hw: HardwareBudget | None,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
best_gpu: GPU | None,
|
|
58
|
+
poly_recipes: Mapping[str, suite.SuiteRecipe],
|
|
59
|
+
) -> float:
|
|
60
|
+
if model.entry.runtime == "strata-poly":
|
|
61
|
+
recipe = poly_recipes.get(model.entry.id)
|
|
62
|
+
if recipe is None:
|
|
63
|
+
return 0.0
|
|
64
|
+
est = suite.poly_decode_estimate(recipe, best_gpu)
|
|
65
|
+
return round(est.tok_s, 1) if est is not None else 0.0
|
|
66
|
+
return round(cat.decode_estimate(model.entry, model.variant, hw).tok_s, 1) if hw else 0.0
|
|
30
67
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
entry, variant = model.entry, model.variant
|
|
37
|
-
is_recommended = 0 if row_doc["recommended"] else 1
|
|
68
|
+
|
|
69
|
+
def _mac_bucket_tier(
|
|
70
|
+
model: Model, row_doc: Row, smartest_rungs: tuple[str, ...]
|
|
71
|
+
) -> tuple[int, int]:
|
|
72
|
+
entry = model.entry
|
|
38
73
|
if row_doc["state"] != "absent" or (
|
|
39
74
|
row_doc["fit"] != "none" and row_doc["availability"]["downloadable"]
|
|
40
75
|
):
|
|
@@ -43,37 +78,67 @@ def _mac_suitability_key(
|
|
|
43
78
|
avail_bucket = 1
|
|
44
79
|
else:
|
|
45
80
|
avail_bucket = 2
|
|
46
|
-
est_tok_s = round(cat.decode_estimate(entry, variant, hw).tok_s, 1) if hw else 0.0
|
|
47
81
|
if entry.id in llm_rank.MAC_LADDER_REPLACES:
|
|
48
82
|
tier = 4
|
|
83
|
+
elif entry.id in smartest_rungs:
|
|
84
|
+
tier = 1 if smartest_rungs.index(entry.id) == 0 else 3
|
|
85
|
+
elif entry.status == "validated" and ranked_quality(entry) >= llm_rank.MAC_DEFAULT_YIELD_SCORE:
|
|
86
|
+
tier = 0
|
|
87
|
+
else:
|
|
88
|
+
tier = 2
|
|
89
|
+
return avail_bucket, tier
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _mac_suitability_key(
|
|
93
|
+
model: Model,
|
|
94
|
+
row_doc: Row,
|
|
95
|
+
hw: HardwareBudget | None,
|
|
96
|
+
smartest_rungs: tuple[str, ...],
|
|
97
|
+
bands: Mapping[tuple[int, int], Mapping[int, int]],
|
|
98
|
+
) -> tuple[object, ...]:
|
|
99
|
+
"""Order Apple Silicon library rows by machine-tailored suitability.
|
|
100
|
+
|
|
101
|
+
Recommended comes first, then fitting/active models ranked from high-intelligence validated
|
|
102
|
+
models (>= yield score, grouped into ``COIN_FLIP`` bands) through the primary Mac ladder
|
|
103
|
+
rung (Ornith 1.5 9B), secondary validated/candidate models, fallback ladder rungs (Spark 4B),
|
|
104
|
+
and ladder-replaced legacy entries (Ling 3.0 tiny). Within equal quality bands, compact
|
|
105
|
+
variants win ties over larger ones. Models that do not fit this Mac follow from smallest
|
|
106
|
+
memory requirement up.
|
|
107
|
+
"""
|
|
108
|
+
entry, variant = model.entry, model.variant
|
|
109
|
+
is_recommended = 0 if row_doc["recommended"] else 1
|
|
110
|
+
avail_bucket, tier = _mac_bucket_tier(model, row_doc, smartest_rungs)
|
|
111
|
+
rq = ranked_quality(entry)
|
|
112
|
+
band = bands.get((avail_bucket, tier), {}).get(rq, 0)
|
|
113
|
+
fidelity = _fidelity_rank(model)
|
|
114
|
+
est_tok_s = round(cat.decode_estimate(entry, variant, hw).tok_s, 1) if hw else 0.0
|
|
115
|
+
if tier == 4:
|
|
49
116
|
rank_tuple: tuple[float, ...] = (
|
|
50
|
-
-
|
|
117
|
+
-rq,
|
|
51
118
|
-est_tok_s,
|
|
52
119
|
-row_doc["context_tokens"],
|
|
53
|
-
|
|
120
|
+
variant.size_bytes,
|
|
54
121
|
)
|
|
55
|
-
elif
|
|
122
|
+
elif tier in (1, 3):
|
|
56
123
|
rung_idx = smartest_rungs.index(entry.id)
|
|
57
|
-
tier = 1 if rung_idx == 0 else 3
|
|
58
124
|
rank_tuple = (
|
|
59
125
|
float(rung_idx),
|
|
60
126
|
-est_tok_s,
|
|
61
127
|
-row_doc["context_tokens"],
|
|
62
|
-
|
|
128
|
+
variant.size_bytes,
|
|
63
129
|
)
|
|
64
|
-
elif
|
|
65
|
-
tier = 0
|
|
130
|
+
elif tier == 0:
|
|
66
131
|
rank_tuple = (
|
|
67
|
-
|
|
132
|
+
float(band),
|
|
68
133
|
-est_tok_s,
|
|
69
134
|
-row_doc["context_tokens"],
|
|
70
|
-
|
|
135
|
+
variant.size_bytes,
|
|
71
136
|
)
|
|
72
137
|
else:
|
|
73
|
-
tier = 2
|
|
74
138
|
rank_tuple = (
|
|
75
|
-
|
|
76
|
-
|
|
139
|
+
float(band),
|
|
140
|
+
float(fidelity),
|
|
141
|
+
variant.size_bytes,
|
|
77
142
|
-est_tok_s,
|
|
78
143
|
-row_doc["context_tokens"],
|
|
79
144
|
)
|
|
@@ -108,36 +173,18 @@ def _best_cuda_budget(facts: HostFacts) -> HardwareBudget | None:
|
|
|
108
173
|
return budget.agent_budget(best, facts) or best.budget
|
|
109
174
|
|
|
110
175
|
|
|
111
|
-
def
|
|
176
|
+
def _best_visible_nvidia_gpu(facts: HostFacts) -> GPU | None:
|
|
112
177
|
shown_cards = memory_pools.visible(facts)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
default=0,
|
|
120
|
-
)
|
|
121
|
-
|
|
178
|
+
gpus = [
|
|
179
|
+
g
|
|
180
|
+
for g in facts.get("gpus") or []
|
|
181
|
+
if g.get("vendor") == "nvidia" and (shown_cards is None or g["index"] in shown_cards)
|
|
182
|
+
]
|
|
183
|
+
return max(gpus, key=lambda g: g["total_bytes"]) if gpus else None
|
|
122
184
|
|
|
123
|
-
def _desktop_suitability_key(
|
|
124
|
-
facts: HostFacts,
|
|
125
|
-
model: Model,
|
|
126
|
-
row_doc: Row,
|
|
127
|
-
hw: HardwareBudget | None,
|
|
128
|
-
max_gpu_bytes: int,
|
|
129
|
-
) -> tuple[object, ...]:
|
|
130
|
-
"""Order Linux and Windows library rows by suitability for this machine.
|
|
131
185
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
candidates (such as Ornith 1.5 9B) and then the Windows small-card fallback (Spark-X2.6 4B)
|
|
135
|
-
whenever stronger models fit. Unavailable rows surface actionable driver/runtime upgrades
|
|
136
|
-
(preferring variants whose VRAM floor fits this GPU) before memory/hardware-blocked rows
|
|
137
|
-
ordered from smallest shortfall up.
|
|
138
|
-
"""
|
|
139
|
-
entry, variant = model.entry, model.variant
|
|
140
|
-
is_recommended = 0 if row_doc["recommended"] else 1
|
|
186
|
+
def _desktop_bucket_tier(facts: HostFacts, model: Model, row_doc: Row) -> tuple[int, int]:
|
|
187
|
+
entry = model.entry
|
|
141
188
|
reason = row_doc["availability"].get("reason")
|
|
142
189
|
reason_code = reason["code"] if reason is not None else ""
|
|
143
190
|
if row_doc["state"] != "absent" or (
|
|
@@ -151,36 +198,80 @@ def _desktop_suitability_key(
|
|
|
151
198
|
else:
|
|
152
199
|
avail_bucket = 3
|
|
153
200
|
|
|
154
|
-
est_tok_s = round(cat.decode_estimate(entry, variant, hw).tok_s, 1) if hw else 0.0
|
|
155
201
|
if llm_rank.windows_fallback(entry, facts):
|
|
156
202
|
tier = 3
|
|
203
|
+
elif entry.status != "validated":
|
|
204
|
+
tier = 2
|
|
205
|
+
elif ranked_quality(entry) >= llm_rank.MAC_DEFAULT_YIELD_SCORE:
|
|
206
|
+
tier = 0
|
|
207
|
+
else:
|
|
208
|
+
tier = 1
|
|
209
|
+
return avail_bucket, tier
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def _desktop_suitability_key(
|
|
213
|
+
facts: HostFacts,
|
|
214
|
+
model: Model,
|
|
215
|
+
row_doc: Row,
|
|
216
|
+
hw: HardwareBudget | None,
|
|
217
|
+
best_gpu: GPU | None,
|
|
218
|
+
poly_recipes: Mapping[str, suite.SuiteRecipe],
|
|
219
|
+
bands: Mapping[tuple[int, int], Mapping[int, int]],
|
|
220
|
+
) -> tuple[object, ...]:
|
|
221
|
+
"""Order Linux and Windows library rows by suitability for this machine.
|
|
222
|
+
|
|
223
|
+
Recommended always comes first. Fitting/active rows follow in ``COIN_FLIP``-banded
|
|
224
|
+
intelligence, quantization-fidelity, ``prefer_over_llama``, context-tier, MoE efficiency and
|
|
225
|
+
compact-first footprint order, followed by optional library candidates (ranked by installed
|
|
226
|
+
quality score, fidelity and ``prefer_over_llama`` so high-scoring builds never drop below
|
|
227
|
+
score-0 or 2-bit models) and then the Windows small-card fallback (Spark-X2.6 4B) whenever
|
|
228
|
+
stronger models fit. Unavailable rows surface actionable driver/runtime upgrades (preferring
|
|
229
|
+
variants whose VRAM floor fits this GPU) before memory/hardware-blocked rows ordered from
|
|
230
|
+
smallest shortfall up.
|
|
231
|
+
"""
|
|
232
|
+
entry, variant = model.entry, model.variant
|
|
233
|
+
is_recommended = 0 if row_doc["recommended"] else 1
|
|
234
|
+
reason = row_doc["availability"].get("reason")
|
|
235
|
+
avail_bucket, tier = _desktop_bucket_tier(facts, model, row_doc)
|
|
236
|
+
rq = ranked_quality(entry)
|
|
237
|
+
band = bands.get((avail_bucket, tier), {}).get(rq, 0)
|
|
238
|
+
fidelity = _fidelity_rank(model)
|
|
239
|
+
prefer_poly = 0.0 if entry.prefer_over_llama else 1.0
|
|
240
|
+
est_tok_s = _est_tok_s(model, hw, best_gpu, poly_recipes)
|
|
241
|
+
max_gpu_bytes = best_gpu["total_bytes"] if best_gpu is not None else 0
|
|
242
|
+
|
|
243
|
+
if tier == 3:
|
|
157
244
|
rank_tuple: tuple[float, ...] = (
|
|
158
245
|
-row_doc["context_tokens"],
|
|
159
|
-
|
|
246
|
+
variant.size_bytes,
|
|
160
247
|
-est_tok_s,
|
|
161
248
|
)
|
|
162
|
-
elif
|
|
163
|
-
tier = 2
|
|
249
|
+
elif tier == 2:
|
|
164
250
|
rank_tuple = (
|
|
251
|
+
float(band),
|
|
252
|
+
float(fidelity),
|
|
253
|
+
prefer_poly,
|
|
254
|
+
variant.size_bytes,
|
|
165
255
|
-row_doc["context_tokens"],
|
|
166
|
-
-variant.size_bytes,
|
|
167
256
|
-est_tok_s,
|
|
168
257
|
)
|
|
169
|
-
elif
|
|
170
|
-
tier = 0
|
|
258
|
+
elif tier == 0:
|
|
171
259
|
rank_tuple = (
|
|
172
|
-
|
|
260
|
+
float(band),
|
|
261
|
+
float(fidelity),
|
|
262
|
+
prefer_poly,
|
|
173
263
|
0.0 if row_doc["context_tokens"] >= _LONG_CONTEXT_FLOOR else 1.0,
|
|
174
264
|
0.0 if entry.moe else 1.0,
|
|
175
|
-
|
|
265
|
+
variant.size_bytes,
|
|
176
266
|
-row_doc["context_tokens"],
|
|
177
267
|
-est_tok_s,
|
|
178
268
|
)
|
|
179
269
|
else:
|
|
180
|
-
tier = 1
|
|
181
270
|
rank_tuple = (
|
|
182
|
-
|
|
183
|
-
|
|
271
|
+
float(band),
|
|
272
|
+
float(fidelity),
|
|
273
|
+
prefer_poly,
|
|
274
|
+
variant.size_bytes,
|
|
184
275
|
-row_doc["context_tokens"],
|
|
185
276
|
-est_tok_s,
|
|
186
277
|
)
|
|
@@ -225,11 +316,26 @@ def order_rows(facts: HostFacts, models: list[Model], rows: list[Row]) -> list[R
|
|
|
225
316
|
hw = (budget.agent_budget(placement, facts) or placement.budget) if placement else None
|
|
226
317
|
ladder = llm_rank.mac_ladder(facts)
|
|
227
318
|
smartest_rungs = ladder.smartest if ladder is not None else ()
|
|
228
|
-
|
|
319
|
+
grouped: dict[tuple[int, int], list[int]] = {}
|
|
320
|
+
for model, row_doc in pairs:
|
|
321
|
+
key = _mac_bucket_tier(model, row_doc, smartest_rungs)
|
|
322
|
+
grouped.setdefault(key, []).append(ranked_quality(model.entry))
|
|
323
|
+
bands = {k: _quality_bands(v) for k, v in grouped.items()}
|
|
324
|
+
pairs.sort(
|
|
325
|
+
key=lambda pair: _mac_suitability_key(pair[0], pair[1], hw, smartest_rungs, bands)
|
|
326
|
+
)
|
|
229
327
|
return [row_doc for _, row_doc in pairs]
|
|
230
328
|
hw = _best_cuda_budget(facts)
|
|
231
|
-
|
|
329
|
+
best_gpu = _best_visible_nvidia_gpu(facts)
|
|
330
|
+
poly_recipes = {r["id"]: r for r in suite.recipes("llm") if r["runtime"] == "strata-poly"}
|
|
331
|
+
grouped_desktop: dict[tuple[int, int], list[int]] = {}
|
|
332
|
+
for model, row_doc in pairs:
|
|
333
|
+
key = _desktop_bucket_tier(facts, model, row_doc)
|
|
334
|
+
grouped_desktop.setdefault(key, []).append(ranked_quality(model.entry))
|
|
335
|
+
bands = {k: _quality_bands(v) for k, v in grouped_desktop.items()}
|
|
232
336
|
pairs.sort(
|
|
233
|
-
key=lambda pair: _desktop_suitability_key(
|
|
337
|
+
key=lambda pair: _desktop_suitability_key(
|
|
338
|
+
facts, pair[0], pair[1], hw, best_gpu, poly_recipes, bands
|
|
339
|
+
)
|
|
234
340
|
)
|
|
235
341
|
return [row_doc for _, row_doc in pairs]
|
|
@@ -87,9 +87,23 @@ def _validated_for(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
|
87
87
|
return key in scope or (key == "win32" and "linux" in scope)
|
|
88
88
|
|
|
89
89
|
|
|
90
|
+
def _candidate_for(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
91
|
+
# A candidate has no validated_on scope (it needs status validated), and Metal PolyStrata
|
|
92
|
+
# recipes are priced from their own validated KV geometry and overhead: until evidence
|
|
93
|
+
# promotes a candidate on Apple Silicon, list it on the CUDA platforms only.
|
|
94
|
+
return (
|
|
95
|
+
bool(recipe.get("library"))
|
|
96
|
+
and recipe.get("status") == "candidate"
|
|
97
|
+
and platform != "darwin"
|
|
98
|
+
and stack_suite.built_for(recipe, platform)
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
90
102
|
def eligible(recipe: suite.SuiteRecipe, platform: str) -> bool:
|
|
91
103
|
"""Whether ``recipe`` should be shown by ``library status`` on ``platform``."""
|
|
92
|
-
return is_library_recipe(recipe) and
|
|
104
|
+
return is_library_recipe(recipe) and (
|
|
105
|
+
_validated_for(recipe, platform) or _candidate_for(recipe, platform)
|
|
106
|
+
)
|
|
93
107
|
|
|
94
108
|
|
|
95
109
|
def in_library(recipe_id: str, facts: HostFacts) -> bool:
|
|
@@ -115,6 +129,7 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
|
|
|
115
129
|
path=f"{alias}.gguf" if i == 0 else str(f.get("local_name") or f["path"]),
|
|
116
130
|
size_bytes=int(f["size_bytes"]),
|
|
117
131
|
local=str(f.get("local_name") or "") or None,
|
|
132
|
+
repo=str(f.get("repo") or "") or None,
|
|
118
133
|
revision=str(f.get("revision") or recipe["revision"]),
|
|
119
134
|
sha256=str(f["sha256"]),
|
|
120
135
|
)
|
|
@@ -127,6 +142,7 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
|
|
|
127
142
|
path=str(vision_files[0]["path"]),
|
|
128
143
|
size_bytes=int(vision_files[0]["size_bytes"]),
|
|
129
144
|
local=str(vision_files[0].get("local_name") or "") or None,
|
|
145
|
+
repo=str(vision_files[0].get("repo") or "") or None,
|
|
130
146
|
revision=str(vision_files[0].get("revision") or recipe["revision"]),
|
|
131
147
|
sha256=str(vision_files[0]["sha256"]),
|
|
132
148
|
)
|
|
@@ -137,9 +153,22 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
|
|
|
137
153
|
quant=recipe["version"],
|
|
138
154
|
files=weight_files,
|
|
139
155
|
validated=recipe.get("status") == "validated",
|
|
156
|
+
embd_table_bytes=int(recipe.get("embd_table_bytes") or 0),
|
|
140
157
|
)
|
|
141
158
|
quality_doc = recipe.get("quality")
|
|
142
159
|
score = int(quality_doc["score"]) if isinstance(quality_doc, dict) else 0
|
|
160
|
+
raw_sources = quality_doc.get("sources") if isinstance(quality_doc, dict) else None
|
|
161
|
+
quality_sources: tuple[cat.QualitySource, ...] = tuple(
|
|
162
|
+
{
|
|
163
|
+
"type": str(s.get("type") or ""),
|
|
164
|
+
"ref": str(s.get("ref") or ""),
|
|
165
|
+
"date": str(s.get("date") or ""),
|
|
166
|
+
}
|
|
167
|
+
for s in (raw_sources if isinstance(raw_sources, list) else ())
|
|
168
|
+
if isinstance(s, dict)
|
|
169
|
+
)
|
|
170
|
+
raw_df = recipe.get("decode_fraction")
|
|
171
|
+
raw_bpw = recipe.get("bits_per_weight")
|
|
143
172
|
entry = cat.CatalogEntry(
|
|
144
173
|
id=recipe["id"],
|
|
145
174
|
display_name=recipe.get("display_name") or alias,
|
|
@@ -160,20 +189,27 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
|
|
|
160
189
|
moe=bool(recipe.get("moe", True)),
|
|
161
190
|
mmproj=mmproj,
|
|
162
191
|
quality=score,
|
|
163
|
-
decode_fraction=float(
|
|
192
|
+
decode_fraction=float(raw_df) if raw_df is not None else 1.0,
|
|
164
193
|
license=recipe.get("license") or "",
|
|
165
194
|
license_url=recipe.get("license_url") or "",
|
|
166
195
|
status=recipe.get("status") or "",
|
|
167
196
|
tasks=tuple(recipe.get("tasks") or ("llm",)),
|
|
168
197
|
evidence=tuple(recipe.get("evidence") or ()),
|
|
198
|
+
quality_sources=quality_sources,
|
|
169
199
|
validated_on=tuple(recipe.get("validated_on") or ()),
|
|
170
200
|
reasoning_efforts=tuple(recipe.get("reasoning_efforts") or ()),
|
|
201
|
+
library=bool(recipe.get("library", False)),
|
|
171
202
|
runtime="strata-poly",
|
|
172
203
|
engine=recipe.get("engine") or "",
|
|
173
204
|
family=recipe.get("family") or "",
|
|
174
205
|
publisher=recipe.get("publisher") or "",
|
|
175
206
|
parameters=recipe.get("parameters") or "",
|
|
176
207
|
active_parameters=recipe.get("active_parameters") or "",
|
|
208
|
+
base_model=str(recipe.get("base_model") or ""),
|
|
209
|
+
capabilities=tuple(recipe.get("capabilities") or ()),
|
|
210
|
+
quant_fidelity=str(recipe.get("quant_fidelity") or ""),
|
|
211
|
+
bits_per_weight=float(raw_bpw) if raw_bpw is not None else None,
|
|
212
|
+
prefer_over_llama=bool(recipe.get("prefer_over_llama", False)),
|
|
177
213
|
)
|
|
178
214
|
return entry, variant
|
|
179
215
|
|
|
@@ -207,12 +243,6 @@ def _gpu_for_pool(facts: HostFacts, pool: str) -> GPU:
|
|
|
207
243
|
return gpu
|
|
208
244
|
|
|
209
245
|
|
|
210
|
-
# Measured non-expert VRAM overhead (KV cache + compute buffers + CUDA context) for PolyStrata
|
|
211
|
-
# recipes when experts fit in VRAM: SP219 inkling-2-mini-q3-poly on 16 GB peaked at 14,498 MiB
|
|
212
|
-
# for 12.69 GiB of weights (~1.47 GiB overhead); 2 GiB keeps a conservative safety margin.
|
|
213
|
-
_VRAM_NON_EXPERT_BYTES = 2 << 30
|
|
214
|
-
|
|
215
|
-
|
|
216
246
|
def _ram_experts_bytes(recipe: suite.SuiteRecipe) -> int:
|
|
217
247
|
profile = recipe.get("profile")
|
|
218
248
|
raw_args = profile.get("args") if isinstance(profile, dict) else None
|
|
@@ -242,11 +272,12 @@ def _calibrate_host_ram(plan: Plan, recipe: suite.SuiteRecipe, gpu: GPU) -> None
|
|
|
242
272
|
recipe_base = int(recipe.get("memory_estimate_bytes") or 0)
|
|
243
273
|
if ram_experts <= 0 or recipe_base <= ram_experts:
|
|
244
274
|
return
|
|
245
|
-
weight_bytes =
|
|
275
|
+
weight_bytes = suite.poly_weight_bytes(recipe)
|
|
246
276
|
if weight_bytes <= 0:
|
|
247
277
|
return
|
|
248
|
-
|
|
249
|
-
|
|
278
|
+
gpu_weights = max(0, weight_bytes - int(recipe.get("embd_table_bytes") or 0))
|
|
279
|
+
vram_for_weights = max(0, gpu["free_bytes"] - suite.VRAM_NON_EXPERT_BYTES)
|
|
280
|
+
spilled = min(ram_experts, max(0, gpu_weights - vram_for_weights))
|
|
250
281
|
saved = ram_experts - spilled
|
|
251
282
|
if saved <= 0:
|
|
252
283
|
return
|