@simplexai/localmodels-darwin-x64 0.1.0-dev.58 → 0.1.0-dev.60

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.
Files changed (113) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +105 -98
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +104 -43
  5. package/modules/localmodels/app.py +1 -1
  6. package/modules/localmodels/apple_sensors.py +431 -0
  7. package/modules/localmodels/bifrost_admin.py +83 -8
  8. package/modules/localmodels/bifrost_checks.py +2 -2
  9. package/modules/localmodels/bifrost_config.py +235 -13
  10. package/modules/localmodels/bifrost_log.py +166 -0
  11. package/modules/localmodels/bifrost_models.py +1 -1
  12. package/modules/localmodels/budget.py +1 -1
  13. package/modules/localmodels/catalog.json +192 -77
  14. package/modules/localmodels/catalog.py +20 -3
  15. package/modules/localmodels/catalog_add.py +42 -11
  16. package/modules/localmodels/custom_hub.py +983 -0
  17. package/modules/localmodels/custom_hub_http.py +579 -0
  18. package/modules/localmodels/custom_probe.py +451 -0
  19. package/modules/localmodels/deploy.py +27 -5
  20. package/modules/localmodels/deploy_steps.py +5 -0
  21. package/modules/localmodels/download-mirrors.json +8 -0
  22. package/modules/localmodels/engines-prism-b12178-03ec600.json +131 -0
  23. package/modules/localmodels/engines-strata-poly-0.2.20-poly.6.json +94 -0
  24. package/modules/localmodels/engines.py +38 -8
  25. package/modules/localmodels/estimator.py +60 -7
  26. package/modules/localmodels/frontend.py +26 -21
  27. package/modules/localmodels/gateway.py +48 -3
  28. package/modules/localmodels/gateway_app_bifrost.py +4 -4
  29. package/modules/localmodels/gateway_bifrost.py +128 -21
  30. package/modules/localmodels/gguf.py +6 -0
  31. package/modules/localmodels/host_sensors.py +704 -0
  32. package/modules/localmodels/hosts.py +99 -12
  33. package/modules/localmodels/library_cli.py +181 -3
  34. package/modules/localmodels/library_convert.py +34 -0
  35. package/modules/localmodels/library_custom.py +831 -0
  36. package/modules/localmodels/library_elastic.py +182 -127
  37. package/modules/localmodels/library_gateway.py +193 -40
  38. package/modules/localmodels/library_jobs.py +92 -18
  39. package/modules/localmodels/library_kept.py +50 -6
  40. package/modules/localmodels/library_model.py +254 -2
  41. package/modules/localmodels/library_pricing.py +97 -8
  42. package/modules/localmodels/library_serve.py +196 -66
  43. package/modules/localmodels/library_smoke.py +315 -0
  44. package/modules/localmodels/library_state.py +81 -2
  45. package/modules/localmodels/library_status.py +144 -8
  46. package/modules/localmodels/metal.py +1 -1
  47. package/modules/localmodels/metal_probe.py +4 -4
  48. package/modules/localmodels/nvml_ctypes.py +431 -0
  49. package/modules/localmodels/plan_envelope.py +18 -7
  50. package/modules/localmodels/process_identity_linux.py +39 -0
  51. package/modules/localmodels/records.py +1 -0
  52. package/modules/localmodels/remote_ops.py +57 -8
  53. package/modules/localmodels/remote_ops_download.py +205 -53
  54. package/modules/localmodels/remote_ops_mirrors.py +43 -2
  55. package/modules/localmodels/remote_ops_ranges.py +2 -5
  56. package/modules/localmodels/remote_ops_service.py +95 -37
  57. package/modules/localmodels/remote_ops_verify.py +22 -5
  58. package/modules/localmodels/runtime-lock.json +19 -19
  59. package/modules/localmodels/runtime_auth.py +4 -1
  60. package/modules/localmodels/service_control.py +32 -1
  61. package/modules/localmodels/service_wiring.py +237 -12
  62. package/modules/localmodels/service_worker.py +6 -2
  63. package/modules/localmodels/services_cli.py +35 -27
  64. package/modules/localmodels/setup_inspection.py +47 -70
  65. package/modules/localmodels/setup_inspection_harness.py +159 -15
  66. package/modules/localmodels/setup_text.py +14 -0
  67. package/modules/localmodels/setup_upgrade.py +1 -1
  68. package/modules/localmodels/source_byok.py +9 -7
  69. package/modules/localmodels/source_byok_probe.py +6 -1
  70. package/modules/localmodels/stack.py +9 -1
  71. package/modules/localmodels/stack_binding.py +3 -35
  72. package/modules/localmodels/stack_cleanup.py +4 -0
  73. package/modules/localmodels/stack_compose.py +18 -2
  74. package/modules/localmodels/stack_lifecycle.py +26 -3
  75. package/modules/localmodels/stack_memory.py +1 -0
  76. package/modules/localmodels/stack_plan.py +6 -2
  77. package/modules/localmodels/stack_ports.py +2 -0
  78. package/modules/localmodels/stack_remove.py +10 -1
  79. package/modules/localmodels/stack_up.py +33 -7
  80. package/modules/localmodels/stack_update.py +3 -1
  81. package/modules/localmodels/stack_view.py +77 -53
  82. package/modules/localmodels/stack_view_demo.py +36 -5
  83. package/modules/localmodels/stack_view_events.py +147 -12
  84. package/modules/localmodels/stack_view_gpu.py +97 -17
  85. package/modules/localmodels/stack_view_llm.py +15 -0
  86. package/modules/localmodels/stack_view_measure.py +4 -1
  87. package/modules/localmodels/stack_view_schema.py +54 -8
  88. package/modules/localmodels/stack_view_serve.py +40 -3
  89. package/modules/localmodels/stack_view_slots.py +89 -10
  90. package/modules/localmodels/stack_view_telemetry.py +163 -0
  91. package/modules/localmodels/stack_view_text.py +5 -2
  92. package/modules/localmodels/stack_view_tick.py +658 -0
  93. package/modules/localmodels/stack_view_words.py +4 -0
  94. package/modules/localmodels/{strata-poly-serve-0.2.19-poly.1.txt → strata-poly-serve-0.2.20-poly.6.txt} +1 -1
  95. package/modules/localmodels/suite.py +45 -27
  96. package/modules/localmodels/telemetry_math.py +538 -0
  97. package/modules/localmodels/transport.py +13 -2
  98. package/modules/localmodels/web/view/view.js +1 -1
  99. package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/METADATA +1 -1
  100. package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/RECORD +102 -95
  101. package/package.json +1 -1
  102. package/tool.json +1 -1
  103. package/modules/localmodels/bifrost_datasheet.py +0 -53
  104. package/modules/localmodels/bifrost_provider.py +0 -88
  105. package/modules/localmodels/bifrost_unit.py +0 -99
  106. package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +0 -79
  107. package/modules/localmodels/gateway_switch.py +0 -51
  108. package/modules/localmodels/library_floor.py +0 -78
  109. package/modules/localmodels/service_stop.py +0 -52
  110. /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/WHEEL +0 -0
  111. /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/entry_points.txt +0 -0
  112. /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/licenses/NOTICE +0 -0
  113. /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev60.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -0,0 +1,451 @@
1
+ """Orchestration for read-only ``localmodels library custom search`` and ``custom probe``.
2
+
3
+ Zero state mutation: reads host facts, disk space, and installed library records read-only,
4
+ delegates hub I/O to ``custom_hub``, prices GGUF headers via ``estimator`` when Range reads
5
+ succeed, and falls back to the transparent ``1.2x + 0.8 GB`` estimate when headers are unavailable.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import platform as py_platform
11
+ import sys
12
+ from collections.abc import Mapping, Sequence
13
+ from dataclasses import replace
14
+ from typing import cast
15
+
16
+ from localmodels import (
17
+ budget,
18
+ custom_hub,
19
+ estimator,
20
+ library_elastic,
21
+ library_jobs,
22
+ library_pricing,
23
+ library_state,
24
+ library_status,
25
+ )
26
+ from localmodels.gguf import GGUFHeader
27
+ from localmodels.library_model import (
28
+ CUSTOM_PROBE_SCHEMA,
29
+ CUSTOM_SEARCH_SCHEMA,
30
+ CustomFormatFilter,
31
+ CustomGgufMeta,
32
+ CustomMmprojCandidate,
33
+ CustomProbeDoc,
34
+ CustomProbeHost,
35
+ CustomProbeReadyDoc,
36
+ CustomQuantVariant,
37
+ CustomSearchDoc,
38
+ CustomSearchHub,
39
+ CustomVariantFile,
40
+ LibraryError,
41
+ MemoryEstimateBasis,
42
+ MemoryStatus,
43
+ )
44
+ from localmodels.probe import HostFacts
45
+
46
+ SWEET_SPOT_QUANTS: tuple[str, ...] = (
47
+ "Q4_K_M",
48
+ "UD-Q4_K_XL",
49
+ "UD-Q4_K_M",
50
+ "IQ4_XS",
51
+ "Q4_K_S",
52
+ "Q5_K_M",
53
+ "Q4_0",
54
+ "Q3_K_M",
55
+ "Q6_K",
56
+ "Q8_0",
57
+ )
58
+ ROUGH_OVERHEAD_BYTES = 800_000_000
59
+ ROUGH_WEIGHT_MULTIPLIER = 1.2
60
+ DISK_HEADROOM_MULTIPLIER = 1.1
61
+ PROBE_UBATCH = 512
62
+
63
+
64
+ def _host_platform_arch(facts: HostFacts | None) -> tuple[str, str]:
65
+ if facts is not None:
66
+ plat = library_status.platform_name(facts)
67
+ raw_arch = str(facts.get("arch") or "")
68
+ return plat, library_status.ARCH.get(raw_arch, raw_arch or "x86_64")
69
+ raw_plat = sys.platform
70
+ plat = (
71
+ "linux" if raw_plat.startswith("linux") else "windows" if raw_plat == "win32" else raw_plat
72
+ )
73
+ machine = py_platform.machine().lower()
74
+ return plat, library_status.ARCH.get(machine, machine or "x86_64")
75
+
76
+
77
+ def rough_memory_bytes(weights_bytes: int, mmproj_bytes: int) -> int:
78
+ """Transparent fallback memory estimate when GGUF header metadata is unavailable."""
79
+ return int((weights_bytes + mmproj_bytes) * ROUGH_WEIGHT_MULTIPLIER) + ROUGH_OVERHEAD_BYTES
80
+
81
+
82
+ def physics_memory_bytes(header: GGUFHeader, weights_bytes: int, mmproj_bytes: int) -> int:
83
+ """Physics-priced memory estimate from a GGUF header at the elastic floor posture."""
84
+ profile = estimator.eager(estimator.profile_from_gguf(header))
85
+ variant_profile = replace(profile, weights_bytes=weights_bytes)
86
+ n_ctx = variant_profile.n_ctx_train
87
+ window = (
88
+ min(library_elastic.ELASTIC_FLOOR_WINDOW, n_ctx)
89
+ if n_ctx > 0
90
+ else library_elastic.ELASTIC_FLOOR_WINDOW
91
+ )
92
+ core = estimator.agent_footprint_bytes(
93
+ variant_profile,
94
+ window,
95
+ slots=1,
96
+ kv_types=("q8_0", "q8_0"),
97
+ ubatch=PROBE_UBATCH,
98
+ mtp=False,
99
+ )
100
+ return max(core + mmproj_bytes, weights_bytes + mmproj_bytes)
101
+
102
+
103
+ def _memory_status(
104
+ estimated_bytes: int, soft_budget_bytes: int, hard_ceiling_bytes: int
105
+ ) -> MemoryStatus:
106
+ if estimated_bytes <= soft_budget_bytes:
107
+ return "comfortable"
108
+ if estimated_bytes <= hard_ceiling_bytes:
109
+ return "tight"
110
+ return "exceeds"
111
+
112
+
113
+ def _select_target_pool(facts: HostFacts) -> tuple[str, int, int, int]:
114
+ """Return ``(pool_id, total_bytes, soft_budget_bytes, hard_ceiling_bytes)``."""
115
+ pool_map = library_pricing.pools(facts)
116
+ preferred = [p for p in pool_map if p != "system"]
117
+ if preferred:
118
+ target = max(
119
+ preferred,
120
+ key=lambda p: (
121
+ library_pricing.pool_free(facts, p),
122
+ library_pricing.pool_total(facts, p),
123
+ ),
124
+ )
125
+ else:
126
+ target = "system"
127
+ total = library_pricing.pool_total(facts, target)
128
+ adm = budget.admission_budget(facts, target)
129
+ if adm is None:
130
+ return target, total, 0, 0
131
+ return target, total, adm.soft_budget_bytes, adm.hard_ceiling_bytes
132
+
133
+
134
+ def _select_sweet_spot(
135
+ variants: Sequence[custom_hub.GgufVariantGroup],
136
+ estimates: Mapping[str, int],
137
+ ceiling_bytes: int,
138
+ ) -> str:
139
+ """Pick the highest-priority quant fitting ``ceiling_bytes``, else largest fitting / smallest."""
140
+ by_quant = {v.quant.upper(): v for v in variants}
141
+ for wanted in SWEET_SPOT_QUANTS:
142
+ cand = by_quant.get(wanted.upper())
143
+ if cand is not None and estimates[cand.variant_id] <= ceiling_bytes:
144
+ return cand.variant_id
145
+ fitting = [v for v in variants if estimates[v.variant_id] <= ceiling_bytes]
146
+ if fitting:
147
+ return max(fitting, key=lambda v: (v.weights_bytes, v.variant_id.lower())).variant_id
148
+ return min(variants, key=lambda v: (v.weights_bytes, v.variant_id.lower())).variant_id
149
+
150
+
151
+ def _match_preselected(
152
+ variants: Sequence[custom_hub.GgufVariantGroup],
153
+ spec: custom_hub.ParsedRepoSpec,
154
+ recommended_id: str,
155
+ ) -> str:
156
+ if spec.file_name:
157
+ target = spec.file_name.strip().lstrip("/").lower()
158
+ for v in variants:
159
+ if any(f.path.lower() == target for f in v.files):
160
+ return v.variant_id
161
+ target_base = target.rsplit("/", 1)[-1]
162
+ for v in variants:
163
+ if any(f.path.lower().rsplit("/", 1)[-1] == target_base for f in v.files):
164
+ return v.variant_id
165
+ if spec.quant_hint:
166
+ hint = spec.quant_hint.strip().lower()
167
+ for v in variants:
168
+ if hint in (v.variant_id.lower(), v.quant.lower(), v.stem.lower()):
169
+ return v.variant_id
170
+ return recommended_id
171
+
172
+
173
+ def _gguf_meta_dict(header: GGUFHeader) -> CustomGgufMeta:
174
+ return {
175
+ "architecture": header.architecture or "unknown",
176
+ "n_ctx_train": header.n_ctx_train,
177
+ "n_layer": header.n_layer,
178
+ "moe": header.expert_count > 0,
179
+ "has_chat_template": "tokenizer.chat_template" in header.metadata,
180
+ }
181
+
182
+
183
+ def _optional_str(payload: Mapping[str, object], key: str) -> str | None:
184
+ raw = payload.get(key)
185
+ if raw is None:
186
+ return None
187
+ if not isinstance(raw, str):
188
+ raise LibraryError("INVALID_REPO_SPEC", f"{key} must be a string")
189
+ return raw.strip() or None
190
+
191
+
192
+ def search(
193
+ payload: Mapping[str, object],
194
+ base_dir: str | None = None,
195
+ *,
196
+ facts: HostFacts | None = None,
197
+ ) -> CustomSearchDoc:
198
+ """Execute read-only ``library custom search`` from a stdin JSON payload."""
199
+ _ = base_dir
200
+ raw_hub = str(payload.get("hub") or "all").strip().lower()
201
+ if raw_hub not in ("all", "huggingface", "modelscope"):
202
+ raise LibraryError("INVALID_REPO_SPEC", f"invalid hub {raw_hub!r}")
203
+ raw_query = payload.get("query", "")
204
+ if not isinstance(raw_query, str):
205
+ raise LibraryError("INVALID_REPO_SPEC", "query must be a string")
206
+ raw_format = str(payload.get("format") or "compatible").strip().lower()
207
+ if raw_format not in ("compatible", "gguf", "mlx", "all"):
208
+ raise LibraryError("INVALID_REPO_SPEC", f"invalid format {raw_format!r}")
209
+ raw_limit = payload.get("limit", 20)
210
+ if isinstance(raw_limit, bool) or not isinstance(raw_limit, int) or raw_limit < 1:
211
+ raise LibraryError("INVALID_REPO_SPEC", "limit must be a positive integer")
212
+ limit = min(raw_limit, 50)
213
+ token = _optional_str(payload, "token")
214
+
215
+ plat, arch = _host_platform_arch(facts)
216
+ supported = list(custom_hub.SUPPORTED_FORMATS)
217
+ hub_val = cast(CustomSearchHub, raw_hub)
218
+ fmt_val = cast(CustomFormatFilter, raw_format)
219
+ results, warnings = custom_hub.search_hubs(
220
+ hub=hub_val,
221
+ query=raw_query,
222
+ format_filter=fmt_val,
223
+ limit=limit,
224
+ token=token,
225
+ supported_formats=supported,
226
+ )
227
+ return {
228
+ "schema": CUSTOM_SEARCH_SCHEMA,
229
+ "ok": True,
230
+ "query": raw_query,
231
+ "hub": hub_val,
232
+ "format": fmt_val,
233
+ "platform": plat,
234
+ "arch": arch,
235
+ "supported_formats": supported,
236
+ "results": results,
237
+ "warnings": warnings,
238
+ }
239
+
240
+
241
+ def _build_variants(
242
+ fetched: custom_hub.FetchedRepo,
243
+ variants: Sequence[custom_hub.GgufVariantGroup],
244
+ *,
245
+ estimates: Mapping[str, int],
246
+ basis: MemoryEstimateBasis,
247
+ disk_free_bytes: int,
248
+ soft_budget_bytes: int,
249
+ hard_ceiling_bytes: int,
250
+ installed_ids: set[str],
251
+ ) -> list[CustomQuantVariant]:
252
+ rows: list[CustomQuantVariant] = []
253
+ for v in variants:
254
+ custom_id = custom_hub.make_custom_model_id(fetched.hub, fetched.repo_id, v.variant_id)
255
+ total_dl = v.weights_bytes + v.mmproj_bytes
256
+ disk_req = int(total_dl * DISK_HEADROOM_MULTIPLIER)
257
+ est_mem = estimates[v.variant_id]
258
+ files: list[CustomVariantFile] = [
259
+ {
260
+ "path": f.path,
261
+ "size_bytes": f.size_bytes,
262
+ "sha256": f.sha256,
263
+ "revision": f.revision,
264
+ }
265
+ for f in v.files
266
+ ]
267
+ rows.append(
268
+ {
269
+ "id": v.variant_id,
270
+ "custom_model_id": custom_id,
271
+ "label": v.label,
272
+ "quant": v.quant,
273
+ "bits_per_weight": v.bits_per_weight,
274
+ "sharded": len(v.files) > 1,
275
+ "shard_count": len(v.files),
276
+ "files": files,
277
+ "weights_bytes": v.weights_bytes,
278
+ "mmproj_file": v.mmproj_file,
279
+ "mmproj_bytes": v.mmproj_bytes,
280
+ "total_download_bytes": total_dl,
281
+ "disk_required_bytes": disk_req,
282
+ "disk_ok": disk_free_bytes >= disk_req,
283
+ "estimated_memory_bytes": est_mem,
284
+ "memory_estimate_basis": basis,
285
+ "memory_status": _memory_status(est_mem, soft_budget_bytes, hard_ceiling_bytes),
286
+ "already_installed": custom_id in installed_ids,
287
+ }
288
+ )
289
+ return rows
290
+
291
+
292
+ def probe(
293
+ payload: Mapping[str, object],
294
+ base_dir: str,
295
+ *,
296
+ facts: HostFacts | None = None,
297
+ ) -> CustomProbeDoc:
298
+ """Execute read-only ``library custom probe`` from a stdin JSON payload."""
299
+ target = _optional_str(payload, "target")
300
+ if not target:
301
+ raise LibraryError("INVALID_REPO_SPEC", "target repository is required")
302
+ raw_hub = str(payload.get("hub") or "auto").strip().lower()
303
+ revision = _optional_str(payload, "revision")
304
+ file_name = _optional_str(payload, "file_name")
305
+ token = _optional_str(payload, "token")
306
+ spec = custom_hub.parse_repo_spec(target, hub=raw_hub, revision=revision, file_name=file_name)
307
+
308
+ outcome = custom_hub.fetch_repo(spec, token=token)
309
+ if isinstance(outcome, custom_hub.HubGated):
310
+ return {
311
+ "schema": CUSTOM_PROBE_SCHEMA,
312
+ "ok": True,
313
+ "outcome": "gated",
314
+ "hub_http_status": outcome.http_status,
315
+ "token_provided": outcome.token_provided,
316
+ "repo": {"hub": outcome.hub, "repo_id": outcome.repo_id, "url": outcome.url},
317
+ }
318
+ if isinstance(outcome, custom_hub.HubNotFound):
319
+ return {
320
+ "schema": CUSTOM_PROBE_SCHEMA,
321
+ "ok": True,
322
+ "outcome": "not_found",
323
+ "hub": outcome.hub,
324
+ "repo_id": outcome.repo_id,
325
+ }
326
+
327
+ inspected = custom_hub.inspect_tree(outcome)
328
+ if not inspected.compatible or not inspected.variants:
329
+ return {
330
+ "schema": CUSTOM_PROBE_SCHEMA,
331
+ "ok": True,
332
+ "outcome": "incompatible",
333
+ "reason": inspected.reason or "no_runnable_files",
334
+ "suggested_search_query": inspected.suggested_search_query
335
+ or custom_hub.build_suggested_gguf_query(outcome.repo_id),
336
+ "repo": {
337
+ "hub": outcome.hub,
338
+ "repo_id": outcome.repo_id,
339
+ "url": outcome.url,
340
+ "format": inspected.format,
341
+ },
342
+ }
343
+
344
+ host_facts = facts if facts is not None else library_jobs.probe()
345
+ plat, arch = _host_platform_arch(host_facts)
346
+ disk_free = library_pricing.base_free(base_dir)
347
+ pool_id, pool_total, pool_soft, pool_hard = _select_target_pool(host_facts)
348
+ fit_ceiling = pool_hard if pool_hard > 0 else pool_total
349
+
350
+ rough_map = {
351
+ v.variant_id: rough_memory_bytes(v.weights_bytes, v.mmproj_bytes)
352
+ for v in inspected.variants
353
+ }
354
+ sweet_id = _select_sweet_spot(inspected.variants, rough_map, fit_ceiling)
355
+ sweet_variant = next(v for v in inspected.variants if v.variant_id == sweet_id)
356
+
357
+ resolved_token = custom_hub.resolve_token(outcome.hub, token, hub_explicit=spec.hub is not None)
358
+ range_url = sweet_variant.files[0].download_url
359
+ range_token = custom_hub.token_for_endpoint(outcome.hub, range_url, resolved_token)
360
+ header, note = custom_hub.read_remote_gguf_header(range_url, token=range_token)
361
+ if header is not None:
362
+ try:
363
+ parsed_meta = _gguf_meta_dict(header)
364
+ parsed_estimates = {
365
+ v.variant_id: physics_memory_bytes(header, v.weights_bytes, v.mmproj_bytes)
366
+ for v in inspected.variants
367
+ }
368
+ except (ValueError, KeyError, TypeError, OverflowError) as exc:
369
+ metadata_complete = False
370
+ metadata_note: str | None = custom_hub.redact_secrets(
371
+ f"Malformed GGUF metadata ({type(exc).__name__}); using rough memory estimate",
372
+ extra_token=resolved_token,
373
+ )
374
+ gguf_meta: CustomGgufMeta | None = None
375
+ basis: MemoryEstimateBasis = "rough_1.2x_plus_0.8gb"
376
+ estimates = rough_map
377
+ recommended_id = sweet_id
378
+ else:
379
+ metadata_complete = True
380
+ metadata_note = None
381
+ gguf_meta = parsed_meta
382
+ basis = "gguf_header"
383
+ estimates = parsed_estimates
384
+ recommended_id = _select_sweet_spot(inspected.variants, estimates, fit_ceiling)
385
+ else:
386
+ metadata_complete = False
387
+ metadata_note = note
388
+ gguf_meta = None
389
+ basis = "rough_1.2x_plus_0.8gb"
390
+ estimates = rough_map
391
+ recommended_id = sweet_id
392
+
393
+ selected_id = _match_preselected(inspected.variants, spec, recommended_id)
394
+ installed_ids = {r["id"] for r in library_state.records()}
395
+ mmproj_rows: list[CustomMmprojCandidate] = [
396
+ {
397
+ "path": c.path,
398
+ "size_bytes": c.size_bytes,
399
+ "sha256": c.sha256,
400
+ "recommended": c.recommended,
401
+ }
402
+ for c in inspected.mmproj_candidates
403
+ ]
404
+ host_doc: CustomProbeHost = {
405
+ "platform": plat,
406
+ "arch": arch,
407
+ "supported_formats": list(custom_hub.SUPPORTED_FORMATS),
408
+ "disk_free_bytes": disk_free,
409
+ "target_pool": pool_id,
410
+ "pool_total_bytes": pool_total,
411
+ "pool_soft_budget_bytes": pool_soft,
412
+ "pool_hard_ceiling_bytes": pool_hard,
413
+ }
414
+ family = custom_hub.infer_family(
415
+ outcome.repo_id, outcome.tags, gguf_meta["architecture"] if gguf_meta else None
416
+ )
417
+ ready: CustomProbeReadyDoc = {
418
+ "schema": CUSTOM_PROBE_SCHEMA,
419
+ "ok": True,
420
+ "outcome": "ready",
421
+ "repo": {
422
+ "hub": outcome.hub,
423
+ "repo_id": outcome.repo_id,
424
+ "revision": outcome.revision,
425
+ "url": outcome.url,
426
+ "title": outcome.title,
427
+ "owner": outcome.owner,
428
+ "format": "gguf",
429
+ "family": family,
430
+ "license": outcome.license,
431
+ "gated": outcome.gated,
432
+ },
433
+ "metadata_complete": metadata_complete,
434
+ "metadata_note": metadata_note,
435
+ "gguf_meta": gguf_meta,
436
+ "host": host_doc,
437
+ "mmproj_candidates": mmproj_rows,
438
+ "recommended_variant_id": recommended_id,
439
+ "selected_quant_id": selected_id,
440
+ "quant_variants": _build_variants(
441
+ outcome,
442
+ inspected.variants,
443
+ estimates=estimates,
444
+ basis=basis,
445
+ disk_free_bytes=disk_free,
446
+ soft_budget_bytes=pool_soft,
447
+ hard_ceiling_bytes=pool_hard,
448
+ installed_ids=installed_ids,
449
+ ),
450
+ }
451
+ return ready
@@ -48,6 +48,8 @@ from localmodels.contracts import decode
48
48
  from localmodels.deploy_steps import Action, step_params
49
49
  from localmodels.engines import (
50
50
  EngineUnavailableError,
51
+ commit_matches,
52
+ engine_lock_commit,
51
53
  engine_lock_path,
52
54
  host_engine,
53
55
  release_engine,
@@ -131,6 +133,7 @@ class PlanOptions:
131
133
  )
132
134
  agent: AgentPosture | None = None # stack's agent posture; None: the generic ladder
133
135
  quant: str = "" # a catalog variant (stack --quant, a debug override); "": the last one
136
+ use_jinja: bool = True # False omits --jinja when a custom GGUF lacks a usable chat template
134
137
 
135
138
 
136
139
  class AgentMemoryError(PlanError):
@@ -323,7 +326,11 @@ def build_plan(
323
326
  "size_bytes": f["size_bytes"],
324
327
  "sha256": f["sha256"],
325
328
  "local_name": f["local_name"],
326
- "dest": f"{models_dir if f['path'] in model_names else assets_dir}/{f['local_name']}",
329
+ "dest": (
330
+ f"{models_dir}/{f['local_name']}"
331
+ if f["path"] in model_names or f["local_name"].startswith("custom/")
332
+ else f"{assets_dir}/{f['local_name']}"
333
+ ),
327
334
  "url": hub_url(options.hf_download_endpoint, f["repo"], f["revision"], f["path"]),
328
335
  }
329
336
  for f in pinned
@@ -359,7 +366,7 @@ def build_plan(
359
366
  str(options.port),
360
367
  "--api-key-file",
361
368
  where.api_key_file,
362
- "--jinja",
369
+ *(("--jinja",) if options.use_jinja else ()),
363
370
  "--metrics",
364
371
  "--slots",
365
372
  "--no-ui",
@@ -389,12 +396,15 @@ def build_plan(
389
396
  # Windows loads a program's DLLs from its own directory; LD_LIBRARY_PATH means nothing there.
390
397
  if facts["platform"] != "win32" and (engine["source"] == "release" or not options.engine_path):
391
398
  env["LD_LIBRARY_PATH"] = engine.get("dir") or engine["binary"].rsplit("/", 1)[0]
392
- # Older builds (< b12588) need CUDA graphs disabled on Linux SM 12.0; b12588+ runs cleanly.
399
+ # Older builds (< b12588) need CUDA graphs disabled on Linux SM 12.0; b12588+ and PrismML
400
+ # prism-b12178+ builds run cleanly with graphs enabled.
393
401
  build_num = cat.build_number(engine.get("build"))
402
+ prism_num = cat.prism_build_number(engine.get("build"))
394
403
  if (
395
404
  facts["platform"] == "linux"
396
405
  and placement.backend == "cuda"
397
406
  and (build_num is None or build_num < 12588)
407
+ and (prism_num is None or prism_num < 12178)
398
408
  and any(
399
409
  gpus[i]["vendor"] == "nvidia" and gpus[i].get("compute_capability") == "12.0"
400
410
  for i in placement.gpu_indices
@@ -535,11 +545,20 @@ def _engine_plan(
535
545
  argv: list[str],
536
546
  ) -> ReleaseEngine:
537
547
  required = entry.min_engine or entry.engine
548
+ lock_commit = engine_lock_commit(entry.engine or entry.min_engine) if required else None
538
549
  if options.engine_path:
539
550
  known = next((e for e in facts["engines"] if e["path"] == options.engine_path), None)
540
551
  tag = known["build"] if known else None
541
- if cat.engine_too_old(entry, tag):
552
+ commit_ok = bool(known and commit_matches(lock_commit, known.get("commit")))
553
+ if not commit_ok and cat.engine_too_old(entry, tag):
542
554
  raise PlanError(f"{entry.display_name} needs llama.cpp {required} or newer")
555
+ if commit_ok and (
556
+ not tag
557
+ or (
558
+ cat.prism_build_number(required) is not None and cat.prism_build_number(tag) is None
559
+ )
560
+ ):
561
+ tag = required
543
562
  if not tag:
544
563
  warnings.append("reused engine has no comparable release; model support unconfirmed")
545
564
  engine: ReleaseEngine = {"source": "existing", "binary": options.engine_path, "build": tag}
@@ -554,6 +573,7 @@ def _engine_plan(
554
573
  "probe again or use the pinned CPU engine"
555
574
  ),
556
575
  [],
576
+ commit=lock_commit,
557
577
  )
558
578
  else:
559
579
  try:
@@ -571,7 +591,9 @@ def _engine_plan(
571
591
  build = select_engine_build(facts, backend, lock)
572
592
  engine = release_engine(build, options.base_dir)
573
593
  except EngineUnavailableError as exc:
574
- engine = host_engine(facts, argv, required or None, False, exc, warnings)
594
+ engine = host_engine(
595
+ facts, argv, required or None, False, exc, warnings, commit=lock_commit
596
+ )
575
597
  if backend == "cpu" and engine["source"] == "existing":
576
598
  if entry.mmproj is not None or entry.mtp_capable:
577
599
  raise PlanError("CPU: reused engine vision/draft placement unknown; use pinned engine")
@@ -99,6 +99,8 @@ def _install_params(plan: Plan, api_key: str) -> InstallParams:
99
99
  for key in ("limits", "slice", "slice_limits", "config_files"):
100
100
  if svc.get(key):
101
101
  install[key] = svc[key]
102
+ if "autostart" in svc:
103
+ install["autostart"] = bool(svc["autostart"])
102
104
  return install
103
105
 
104
106
 
@@ -122,6 +124,9 @@ def _verify_params(plan: Plan, api_key: str) -> VerifyParams:
122
124
  if plan.get("input_tokens"):
123
125
  verify["input_tokens"] = plan["input_tokens"]
124
126
  launch = plan.get("launch") or {}
127
+ if launch.get("smoke"):
128
+ verify["smoke"] = True
129
+ return verify
125
130
  window = launch.get("window")
126
131
  if launch.get("posture") == "agent" and isinstance(window, int):
127
132
  verify["window"] = window # the server must serve at least the planned window
@@ -118,6 +118,14 @@
118
118
  "repo": "ornith-ai/Ornith-1.5-9B-GGUF",
119
119
  "path": "mmproj-Ornith-1.5-9B-BF16.gguf"
120
120
  },
121
+ "e0fc5f3d47b9c926d52677d303b19df356a2376614b3e1cb9973865fc04ca431": {
122
+ "repo": "prism-ml/Ternary-Bonsai-2.5-27B-GGUF",
123
+ "path": "Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf"
124
+ },
125
+ "e287342d92332fa3577ed1d42e921dac9370c08da58ba9337fa450f6cc76cfd7": {
126
+ "repo": "prism-ml/Ternary-Bonsai-2.5-27B-GGUF",
127
+ "path": "Ternary-Bonsai-2.5-27B-mmproj-BF16.gguf"
128
+ },
121
129
  "cd1140f4abba943ce8d9fa92fed8407e389954d26907efde7b72153c75bd8a60": {
122
130
  "repo": "ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF",
123
131
  "path": "mmproj-Swift-Qwen3.8-Flash-Next-BF16.gguf"