@simplexai/localmodels-linux-arm64 0.1.0-dev.103 → 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.
Files changed (172) hide show
  1. package/LICENSE +201 -0
  2. package/{modules/simplex_localmodels-0.1.0.dev103.dist-info/licenses/NOTICE → NOTICE} +42 -13
  3. package/README.md +10 -0
  4. package/bootstrap.identity +1 -1
  5. package/bootstrap.sha256 +159 -158
  6. package/modules/localmodels/__init__.py +1 -1
  7. package/modules/localmodels/__main__.py +204 -86
  8. package/modules/localmodels/apple_sensors.py +23 -0
  9. package/modules/localmodels/approval.py +25 -2
  10. package/modules/localmodels/catalog.json +584 -158
  11. package/modules/localmodels/catalog.py +18 -3
  12. package/modules/localmodels/catalog_recipes.py +64 -6
  13. package/modules/localmodels/cli_help.py +10 -0
  14. package/modules/localmodels/cli_parser.py +313 -230
  15. package/modules/localmodels/component.py +21 -3
  16. package/modules/localmodels/console.py +1 -1
  17. package/modules/localmodels/context_policy.py +6 -5
  18. package/modules/localmodels/custom_probe.py +4 -2
  19. package/modules/localmodels/debug_cli.py +0 -12
  20. package/modules/localmodels/debug_mode.py +0 -6
  21. package/modules/localmodels/decode_calibration.json +3 -4
  22. package/modules/localmodels/decode_calibration.py +5 -2
  23. package/modules/localmodels/deploy.py +11 -1
  24. package/modules/localmodels/deployment_lifecycle.py +1 -1
  25. package/modules/localmodels/download-mirrors.json +1 -1
  26. package/modules/localmodels/engine_adapters/base.py +11 -1
  27. package/modules/localmodels/engine_adapters/strata_poly.py +65 -3
  28. package/modules/localmodels/engine_adapters/suite_plan.py +61 -24
  29. package/modules/localmodels/engines-b11583.json +6 -26
  30. package/modules/localmodels/engines-b12588-mix-c0c3de8.json +3 -15
  31. package/modules/localmodels/engines-b12757-mix-ef2df21.json +3 -15
  32. package/modules/localmodels/engines-prism-b12178-03ec600.json +3 -15
  33. package/modules/localmodels/engines-speechcpp-v0.11.3.json +4 -20
  34. package/modules/localmodels/engines-strata-0.1.47.json +1 -5
  35. package/modules/localmodels/engines-strata-0.1.49.2.json +1 -5
  36. package/modules/localmodels/engines-strata-0.1.59.1.json +1 -5
  37. package/modules/localmodels/engines-strata-poly-0.2.20-poly.1.json +6 -30
  38. package/modules/localmodels/engines-strata-poly-0.2.20-poly.9.json +129 -0
  39. package/modules/localmodels/engines-whisper-b5454.json +6 -30
  40. package/modules/localmodels/engines.json +13 -61
  41. package/modules/localmodels/estimator.py +10 -5
  42. package/modules/localmodels/gpu_specs.py +1 -1
  43. package/modules/localmodels/host_sensors.py +25 -2
  44. package/modules/localmodels/hosts.py +38 -21
  45. package/modules/localmodels/kokoro-tts-0.6.1.txt +1 -1
  46. package/modules/localmodels/library_cli.py +34 -16
  47. package/modules/localmodels/library_custom.py +9 -1
  48. package/modules/localmodels/library_direct.py +41 -1
  49. package/modules/localmodels/library_elastic.py +135 -6
  50. package/modules/localmodels/library_jobs.py +23 -4
  51. package/modules/localmodels/library_kept.py +9 -1
  52. package/modules/localmodels/library_model.py +174 -2
  53. package/modules/localmodels/library_order.py +175 -69
  54. package/modules/localmodels/library_poly.py +150 -21
  55. package/modules/localmodels/library_presentation.py +485 -0
  56. package/modules/localmodels/library_pricing.py +15 -4
  57. package/modules/localmodels/library_serve.py +342 -70
  58. package/modules/localmodels/library_smoke.py +63 -5
  59. package/modules/localmodels/library_state.py +48 -10
  60. package/modules/localmodels/library_status.py +37 -17
  61. package/modules/localmodels/llm_rank.py +22 -11
  62. package/modules/localmodels/metal.py +1 -2
  63. package/modules/localmodels/plan_envelope.py +40 -13
  64. package/modules/localmodels/planning/budget.py +14 -12
  65. package/modules/localmodels/planning/memory_pools.py +7 -1
  66. package/modules/localmodels/privacy_acceptance.py +6 -5
  67. package/modules/localmodels/probe.py +34 -7
  68. package/modules/localmodels/py.typed +0 -0
  69. package/modules/localmodels/quant_formats.py +10 -3
  70. package/modules/localmodels/recommend_cli.py +1 -1
  71. package/modules/localmodels/records.py +19 -2
  72. package/modules/localmodels/remote_ops_launchd.py +8 -1
  73. package/modules/localmodels/remote_ops_verify.py +91 -24
  74. package/modules/localmodels/runtime_index.py +303 -0
  75. package/modules/localmodels/runtime_process.py +1 -1
  76. package/modules/localmodels/service_deployment.py +2 -4
  77. package/modules/localmodels/service_probe.py +59 -13
  78. package/modules/localmodels/setup_inspection.py +94 -73
  79. package/modules/localmodels/setup_text.py +7 -56
  80. package/modules/localmodels/sidecar_downloads.py +34 -0
  81. package/modules/localmodels/sidecar_http.py +61 -5
  82. package/modules/localmodels/sidecar_state.py +52 -2
  83. package/modules/localmodels/speech_admission.py +20 -4
  84. package/modules/localmodels/speech_catalog.py +23 -0
  85. package/modules/localmodels/speech_cli.py +30 -16
  86. package/modules/localmodels/speech_jobs.py +42 -17
  87. package/modules/localmodels/speech_serve.py +9 -2
  88. package/modules/localmodels/speech_server.py +185 -81
  89. package/modules/localmodels/speech_state.py +4 -1
  90. package/modules/localmodels/speech_workers.py +11 -0
  91. package/modules/localmodels/stack.py +1 -1
  92. package/modules/localmodels/stack_args.py +276 -145
  93. package/modules/localmodels/stack_auto.py +91 -6
  94. package/modules/localmodels/stack_aux_gpu.py +1 -1
  95. package/modules/localmodels/stack_cleanup.py +21 -18
  96. package/modules/localmodels/stack_cli.py +120 -115
  97. package/modules/localmodels/stack_compose.py +16 -5
  98. package/modules/localmodels/stack_debug.py +15 -6
  99. package/modules/localmodels/stack_decision.py +4 -4
  100. package/modules/localmodels/stack_doctor.py +2 -2
  101. package/modules/localmodels/stack_down.py +2 -0
  102. package/modules/localmodels/stack_events.py +1 -1
  103. package/modules/localmodels/stack_gpu_memory.py +1 -1
  104. package/modules/localmodels/stack_hardware.py +17 -15
  105. package/modules/localmodels/stack_mcp.py +1 -2
  106. package/modules/localmodels/stack_mlx.py +8 -1
  107. package/modules/localmodels/stack_picks.py +20 -21
  108. package/modules/localmodels/stack_plan.py +12 -11
  109. package/modules/localmodels/stack_ports.py +31 -4
  110. package/modules/localmodels/stack_review.py +28 -7
  111. package/modules/localmodels/stack_rollback.py +1 -1
  112. package/modules/localmodels/stack_run.py +1 -1
  113. package/modules/localmodels/stack_suite.py +72 -21
  114. package/modules/localmodels/stack_up.py +2 -0
  115. package/modules/localmodels/stack_view.py +180 -35
  116. package/modules/localmodels/stack_view_agent.py +1 -1
  117. package/modules/localmodels/stack_view_demo.py +2 -0
  118. package/modules/localmodels/stack_view_gpu.py +36 -2
  119. package/modules/localmodels/stack_view_schema.py +26 -3
  120. package/modules/localmodels/stack_view_serve.py +0 -2
  121. package/modules/localmodels/stack_view_slots.py +3 -1
  122. package/modules/localmodels/stack_view_telemetry.py +90 -4
  123. package/modules/localmodels/stack_view_tick.py +246 -40
  124. package/modules/localmodels/stack_view_words.py +9 -2
  125. package/modules/localmodels/stack_warm.py +2 -2
  126. package/modules/localmodels/stack_whatif.py +524 -41
  127. package/modules/localmodels/stack_whatif_html.py +900 -0
  128. package/modules/localmodels/startlux-decide-83fe6c7d.txt +2 -2
  129. package/modules/localmodels/{strata-poly-serve-0.2.20-poly.7.txt → strata-poly-serve-0.2.20-poly.9.txt} +1 -1
  130. package/modules/localmodels/strata_poly_server.py +114 -3
  131. package/modules/localmodels/suite.py +265 -6
  132. package/modules/localmodels/telemetry_math.py +458 -18
  133. package/modules/localmodels/transport.py +8 -1
  134. package/modules/localmodels/tts_admission.py +2 -17
  135. package/modules/localmodels/tts_catalog.py +29 -1
  136. package/modules/localmodels/tts_cli.py +45 -22
  137. package/modules/localmodels/tts_http.py +10 -4
  138. package/modules/localmodels/tts_jobs.py +49 -19
  139. package/modules/localmodels/tts_serve.py +9 -2
  140. package/modules/localmodels/tts_server.py +1 -1
  141. package/modules/localmodels/tts_sidecar.py +69 -28
  142. package/modules/localmodels/tts_state.py +7 -2
  143. package/modules/localmodels/vision.py +5 -3
  144. package/modules/localmodels/web/view/ASSET-SOURCES.md +4 -7
  145. package/modules/localmodels/web/view/view.css +0 -1
  146. package/modules/localmodels/web/view/view.js +2 -5
  147. package/modules/localmodels/web/whatif/app.js +730 -0
  148. package/modules/localmodels/web/whatif/page.html +1172 -0
  149. package/modules/localmodels/web/whatif/sim.js +297 -0
  150. package/modules/localmodels/win_probe.py +89 -16
  151. package/modules/localmodels/windows_job.py +179 -11
  152. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/METADATA +14 -0
  153. package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +151 -145
  154. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/LICENSE +201 -0
  155. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/NOTICE +126 -0
  156. package/package.json +11 -2
  157. package/tool.json +1 -1
  158. package/modules/localmodels/engines-strata-poly-0.2.20-poly.7.json +0 -94
  159. package/modules/localmodels/fixtures/stack-research-demo-plan.json +0 -1059
  160. package/modules/localmodels/stack_research.py +0 -716
  161. package/modules/localmodels/stack_research_demo.py +0 -125
  162. package/modules/localmodels/stack_research_plan.py +0 -146
  163. package/modules/localmodels/web/index.html +0 -2605
  164. package/modules/localmodels/web/sizecalc/app.js +0 -1306
  165. package/modules/localmodels/web/sizecalc/calc.js +0 -269
  166. package/modules/localmodels/web/sizecalc/page.html +0 -520
  167. package/modules/localmodels/web/view/logo-claude.svg +0 -3
  168. package/modules/localmodels/web/view/logo-codex.png +0 -0
  169. package/modules/simplex_localmodels-0.1.0.dev103.dist-info/METADATA +0 -9
  170. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
  171. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
  172. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -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 NVIDIA Linux and Windows hosts alongside ``llama.cpp`` models. Pricing runs
6
- ``suite_plan.build_plan`` so CUDA 13 driver checks, glibc checks, vision reader placement and host
7
- RAM ceilings stay identical to ``stack plan``.
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,18 +77,33 @@ 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 recipe.get("status") != "validated" or not stack_suite.built_for(recipe, platform):
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 platform in scope or (platform == "win32" and "linux" in scope)
87
+ return key in scope or (key == "win32" and "linux" in scope)
88
+
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
+ )
82
100
 
83
101
 
84
102
  def eligible(recipe: suite.SuiteRecipe, platform: str) -> bool:
85
103
  """Whether ``recipe`` should be shown by ``library status`` on ``platform``."""
86
- return is_library_recipe(recipe) and _validated_for(recipe, platform)
104
+ return is_library_recipe(recipe) and (
105
+ _validated_for(recipe, platform) or _candidate_for(recipe, platform)
106
+ )
87
107
 
88
108
 
89
109
  def in_library(recipe_id: str, facts: HostFacts) -> bool:
@@ -109,6 +129,7 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
109
129
  path=f"{alias}.gguf" if i == 0 else str(f.get("local_name") or f["path"]),
110
130
  size_bytes=int(f["size_bytes"]),
111
131
  local=str(f.get("local_name") or "") or None,
132
+ repo=str(f.get("repo") or "") or None,
112
133
  revision=str(f.get("revision") or recipe["revision"]),
113
134
  sha256=str(f["sha256"]),
114
135
  )
@@ -121,6 +142,7 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
121
142
  path=str(vision_files[0]["path"]),
122
143
  size_bytes=int(vision_files[0]["size_bytes"]),
123
144
  local=str(vision_files[0].get("local_name") or "") or None,
145
+ repo=str(vision_files[0].get("repo") or "") or None,
124
146
  revision=str(vision_files[0].get("revision") or recipe["revision"]),
125
147
  sha256=str(vision_files[0]["sha256"]),
126
148
  )
@@ -131,35 +153,63 @@ def as_entry(recipe: suite.SuiteRecipe) -> tuple[cat.CatalogEntry, cat.QuantVari
131
153
  quant=recipe["version"],
132
154
  files=weight_files,
133
155
  validated=recipe.get("status") == "validated",
156
+ embd_table_bytes=int(recipe.get("embd_table_bytes") or 0),
134
157
  )
135
158
  quality_doc = recipe.get("quality")
136
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")
137
172
  entry = cat.CatalogEntry(
138
173
  id=recipe["id"],
139
174
  display_name=recipe.get("display_name") or alias,
140
175
  description=recipe.get("description") or "",
141
176
  repo=recipe["repo"],
142
177
  variants=(variant,),
143
- n_ctx_train=int(recipe.get("context") or 65536),
144
- full_layers=0,
178
+ n_ctx_train=max(
179
+ [
180
+ int(recipe.get("context") or 65536),
181
+ *(int(g.get("context") or 0) for g in recipe.get("card_args") or ()),
182
+ ]
183
+ ),
184
+ full_layers=int(recipe.get("full_layers") or 0),
145
185
  recurrent_layers=0,
146
- per_layer_f16=0,
186
+ per_layer_f16=int(recipe.get("per_layer_f16") or 0),
187
+ swa_layers=int(recipe.get("swa_layers") or 0),
188
+ swa_window=int(recipe.get("swa_window") or 0),
147
189
  moe=bool(recipe.get("moe", True)),
148
190
  mmproj=mmproj,
149
191
  quality=score,
192
+ decode_fraction=float(raw_df) if raw_df is not None else 1.0,
150
193
  license=recipe.get("license") or "",
151
194
  license_url=recipe.get("license_url") or "",
152
195
  status=recipe.get("status") or "",
153
196
  tasks=tuple(recipe.get("tasks") or ("llm",)),
154
197
  evidence=tuple(recipe.get("evidence") or ()),
198
+ quality_sources=quality_sources,
155
199
  validated_on=tuple(recipe.get("validated_on") or ()),
156
200
  reasoning_efforts=tuple(recipe.get("reasoning_efforts") or ()),
201
+ library=bool(recipe.get("library", False)),
157
202
  runtime="strata-poly",
158
203
  engine=recipe.get("engine") or "",
159
204
  family=recipe.get("family") or "",
160
205
  publisher=recipe.get("publisher") or "",
161
206
  parameters=recipe.get("parameters") or "",
162
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)),
163
213
  )
164
214
  return entry, variant
165
215
 
@@ -193,12 +243,6 @@ def _gpu_for_pool(facts: HostFacts, pool: str) -> GPU:
193
243
  return gpu
194
244
 
195
245
 
196
- # Measured non-expert VRAM overhead (KV cache + compute buffers + CUDA context) for PolyStrata
197
- # recipes when experts fit in VRAM: SP219 inkling-2-mini-q3-poly on 16 GB peaked at 14,498 MiB
198
- # for 12.69 GiB of weights (~1.47 GiB overhead); 2 GiB keeps a conservative safety margin.
199
- _VRAM_NON_EXPERT_BYTES = 2 << 30
200
-
201
-
202
246
  def _ram_experts_bytes(recipe: suite.SuiteRecipe) -> int:
203
247
  profile = recipe.get("profile")
204
248
  raw_args = profile.get("args") if isinstance(profile, dict) else None
@@ -228,11 +272,12 @@ def _calibrate_host_ram(plan: Plan, recipe: suite.SuiteRecipe, gpu: GPU) -> None
228
272
  recipe_base = int(recipe.get("memory_estimate_bytes") or 0)
229
273
  if ram_experts <= 0 or recipe_base <= ram_experts:
230
274
  return
231
- weight_bytes = sum(int(f["size_bytes"]) for f in recipe["files"] if not f.get("vision"))
275
+ weight_bytes = suite.poly_weight_bytes(recipe)
232
276
  if weight_bytes <= 0:
233
277
  return
234
- vram_for_weights = max(0, gpu["free_bytes"] - _VRAM_NON_EXPERT_BYTES)
235
- spilled = min(ram_experts, max(0, weight_bytes - vram_for_weights))
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))
236
281
  saved = ram_experts - spilled
237
282
  if saved <= 0:
238
283
  return
@@ -250,6 +295,88 @@ def _calibrate_host_ram(plan: Plan, recipe: suite.SuiteRecipe, gpu: GPU) -> None
250
295
  limits["MemoryMax"] = f"{(new_max + (1 << 20) - 1) >> 20}M"
251
296
 
252
297
 
298
+ def unified_floor_bytes(recipe: suite.SuiteRecipe, posture: AgentPosture) -> int:
299
+ """Compositional Apple Silicon unified-memory estimate for ``recipe`` at its base context."""
300
+ reader = vision.strata_mode(posture.vision, 0, bool(recipe.get("vision")), unified=True)
301
+ total, _ = suite.poly_unified_footprint(recipe, vision_reader=reader)
302
+ return total
303
+
304
+
305
+ def build_unified_plan(
306
+ facts: HostFacts,
307
+ recipe_id: str,
308
+ base_dir: str,
309
+ port: int,
310
+ posture: AgentPosture,
311
+ ) -> tuple[Plan, int, int]:
312
+ """Build an Apple Silicon Metal ``strata-poly`` plan and return ``(plan, unified_bytes, wired_bytes)``."""
313
+ gpu = metal.device(facts)
314
+ if gpu is None:
315
+ raise plan_envelope.PlanError("this computer has no Metal GPU for unified memory")
316
+ recipe = suite.recipe(recipe_id)
317
+ if not stack_suite.built_for(recipe, facts["platform"]):
318
+ raise plan_envelope.PlanError(f"{recipe_id} has no engine build for {facts['platform']}")
319
+ spec = recipe.get("vision") or {}
320
+ reader = vision.strata_mode(posture.vision, gpu["total_bytes"], bool(spec), unified=True)
321
+ raw_reserve = int(recipe.get("vram_reserve_mib") or METAL_POLY_RESERVE_MIB)
322
+ reserve = min(raw_reserve, METAL_POLY_RESERVE_MIB)
323
+ opts = suite.SuiteOptions(
324
+ base_dir=base_dir,
325
+ hf_endpoint=deploy.hf_endpoint(),
326
+ gpu=gpu,
327
+ port=port,
328
+ vram_reserve_mib=reserve,
329
+ vision_reader=reader,
330
+ )
331
+ plan = suite.unbounded(suite_plan.build_plan(hosts.LOCAL_ID, facts, recipe, opts))
332
+ window = int(str(plan["launch"].get("window") or 0))
333
+ slots = int(str(plan["launch"].get("slots") or 1))
334
+ kv_fmt = suite.plan_kv_format(plan, recipe)
335
+ needed, wired = suite.poly_unified_footprint(
336
+ recipe, window=window, slots=slots, kv_fmt=kv_fmt, vision_reader=reader
337
+ )
338
+ plan["launch"]["unified_bytes"] = needed
339
+ plan["launch"]["vram_bytes"] = wired
340
+ plan["launch"].pop("min_vram_free_bytes", None)
341
+ return plan, needed, wired
342
+
343
+
344
+ def _price_unified(
345
+ facts: HostFacts,
346
+ recipe_id: str,
347
+ base_dir: str,
348
+ port: int,
349
+ posture: AgentPosture,
350
+ *,
351
+ require_live: bool = False,
352
+ ) -> Plan:
353
+ if require_live and (problem := metal.problem(facts)):
354
+ raise plan_envelope.PlanError(problem)
355
+ plan, needed, wired = build_unified_plan(facts, recipe_id, base_dir, port, posture)
356
+ working_set = metal.working_set_bytes(facts)
357
+ pool_cap = memory_pools.pool_total(facts, "unified")
358
+ adm = budget.admission_budget(facts, "unified")
359
+ limit = (
360
+ min(working_set, pool_cap, adm.soft_budget_bytes)
361
+ if adm is not None
362
+ else min(working_set, pool_cap)
363
+ )
364
+ if needed > limit:
365
+ msg = (
366
+ f"{recipe_id} needs {needed} bytes of unified memory, exceeding {limit} bytes available"
367
+ )
368
+ raise deploy.AgentMemoryError(msg, PhysicsRefusal(needed, limit, msg), "unified memory")
369
+ if require_live and adm is not None and wired > adm.hard_ceiling_bytes:
370
+ msg = (
371
+ f"{recipe_id} needs {wired} bytes of wired Metal memory, "
372
+ f"exceeding {adm.hard_ceiling_bytes} bytes headroom"
373
+ )
374
+ raise deploy.AgentMemoryError(
375
+ msg, PhysicsRefusal(wired, adm.hard_ceiling_bytes, msg), "unified memory"
376
+ )
377
+ return plan
378
+
379
+
253
380
  def price(
254
381
  facts: HostFacts,
255
382
  recipe_id: str,
@@ -260,10 +387,12 @@ def price(
260
387
  *,
261
388
  require_live: bool = False,
262
389
  ) -> Plan:
263
- """Price one ``strata-poly`` library model on discrete pool ``pool``."""
390
+ """Price one ``strata-poly`` library model on discrete NVIDIA or Apple Silicon unified pool."""
391
+ if pool == "unified" and metal.supported(facts):
392
+ return _price_unified(facts, recipe_id, base_dir, port, posture, require_live=require_live)
264
393
  if facts["platform"] not in ("linux", "win32"):
265
394
  raise plan_envelope.PlanError(
266
- "PolyStrata recipes run on Linux and Windows NVIDIA GPUs only"
395
+ "PolyStrata recipes run on Apple Silicon Metal and Linux/Windows NVIDIA GPUs only"
267
396
  )
268
397
  gpu = _gpu_for_pool(facts, pool)
269
398
  recipe = suite.recipe(recipe_id)