@simplexai/localmodels-win32-x64 0.1.0-dev.63 → 0.1.0-dev.65

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 (142) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +140 -130
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +2 -2
  5. package/modules/localmodels/app.py +15 -2
  6. package/modules/localmodels/approval.py +5 -3
  7. package/modules/localmodels/bifrost_checks.py +2 -1
  8. package/modules/localmodels/catalog.json +36 -0
  9. package/modules/localmodels/catalog.py +28 -5
  10. package/modules/localmodels/catalog_recipes.py +40 -1
  11. package/modules/localmodels/component.py +1 -1
  12. package/modules/localmodels/context_policy.py +7 -2
  13. package/modules/localmodels/custom_probe.py +5 -5
  14. package/modules/localmodels/debug_mode.py +85 -103
  15. package/modules/localmodels/deploy.py +129 -18
  16. package/modules/localmodels/deployment_lifecycle.py +167 -0
  17. package/modules/localmodels/download-mirrors.json +126 -6
  18. package/modules/localmodels/draft_spec.py +164 -0
  19. package/modules/localmodels/engine_adapters/__init__.py +4 -0
  20. package/modules/localmodels/engine_adapters/auxiliary.py +27 -0
  21. package/modules/localmodels/engine_adapters/base.py +40 -0
  22. package/modules/localmodels/engine_adapters/strata_poly.py +57 -0
  23. package/modules/localmodels/engine_adapters/suite_plan.py +394 -0
  24. package/modules/localmodels/engines-prism-b12178-03ec600.json +7 -7
  25. package/modules/localmodels/gateway.py +124 -13
  26. package/modules/localmodels/gateway_accept.py +1 -6
  27. package/modules/localmodels/gateway_cli.py +13 -24
  28. package/modules/localmodels/gateway_ops.py +185 -0
  29. package/modules/localmodels/gateway_server.py +3 -2
  30. package/modules/localmodels/harness.py +13 -16
  31. package/modules/localmodels/harness_core.py +4 -9
  32. package/modules/localmodels/harness_gateway.py +4 -3
  33. package/modules/localmodels/hosts.py +22 -34
  34. package/modules/localmodels/install.py +15 -0
  35. package/modules/localmodels/library_convert.py +5 -11
  36. package/modules/localmodels/library_custom.py +6 -6
  37. package/modules/localmodels/library_elastic.py +24 -127
  38. package/modules/localmodels/library_jobs.py +14 -5
  39. package/modules/localmodels/library_order.py +4 -3
  40. package/modules/localmodels/library_poly.py +5 -4
  41. package/modules/localmodels/library_pricing.py +80 -255
  42. package/modules/localmodels/library_serve.py +13 -14
  43. package/modules/localmodels/library_smoke.py +8 -1
  44. package/modules/localmodels/library_status.py +16 -16
  45. package/modules/localmodels/llm_rank.py +1 -1
  46. package/modules/localmodels/magpie_legacy.py +160 -0
  47. package/modules/localmodels/magpie_setup.py +6 -1
  48. package/modules/localmodels/memcalc_cli.py +2 -2
  49. package/modules/localmodels/pi_profile.py +3 -7
  50. package/modules/localmodels/plan_envelope.py +1 -1
  51. package/modules/localmodels/planning/__init__.py +3 -0
  52. package/modules/localmodels/{budget.py → planning/budget.py} +48 -30
  53. package/modules/localmodels/{stack_llm_ram.py → planning/llm_ram.py} +11 -1
  54. package/modules/localmodels/{memcalc_load.py → planning/memcalc_load.py} +1 -1
  55. package/modules/localmodels/planning/memory_pools.py +403 -0
  56. package/modules/localmodels/{sizecalc.py → planning/sizecalc.py} +1 -1
  57. package/modules/localmodels/recommend.py +1 -1
  58. package/modules/localmodels/recommend_cli.py +3 -4
  59. package/modules/localmodels/residency_host.py +1 -1
  60. package/modules/localmodels/service_control.py +4 -4
  61. package/modules/localmodels/service_deployment.py +3 -2
  62. package/modules/localmodels/service_wiring.py +17 -19
  63. package/modules/localmodels/setup_inspection.py +1 -1
  64. package/modules/localmodels/setup_inspection_harness.py +1 -1
  65. package/modules/localmodels/setup_upgrade.py +3 -12
  66. package/modules/localmodels/sizecalc_cli.py +10 -2
  67. package/modules/localmodels/speech_admission.py +1 -1
  68. package/modules/localmodels/speech_jobs.py +2 -1
  69. package/modules/localmodels/speech_model.py +2 -0
  70. package/modules/localmodels/speech_server.py +130 -9
  71. package/modules/localmodels/speech_state.py +11 -0
  72. package/modules/localmodels/speech_worker_sensevoice.py +38 -0
  73. package/modules/localmodels/speech_workers.py +5 -1
  74. package/modules/localmodels/stack.py +4 -9
  75. package/modules/localmodels/stack_arena.py +2 -2
  76. package/modules/localmodels/stack_auto.py +5 -5
  77. package/modules/localmodels/stack_aux_gpu.py +5 -3
  78. package/modules/localmodels/stack_binding.py +24 -143
  79. package/modules/localmodels/stack_capacity.py +1 -1
  80. package/modules/localmodels/stack_card.py +3 -3
  81. package/modules/localmodels/stack_cleanup.py +6 -5
  82. package/modules/localmodels/stack_client_settings.py +9 -2
  83. package/modules/localmodels/stack_compose.py +43 -6
  84. package/modules/localmodels/stack_console.py +2 -2
  85. package/modules/localmodels/stack_debug.py +1 -1
  86. package/modules/localmodels/stack_decision.py +1 -1
  87. package/modules/localmodels/stack_doctor.py +10 -7
  88. package/modules/localmodels/stack_down.py +3 -3
  89. package/modules/localmodels/stack_gpu_memory.py +1 -1
  90. package/modules/localmodels/stack_hardware.py +3 -3
  91. package/modules/localmodels/stack_hardware_text.py +1 -1
  92. package/modules/localmodels/stack_ledger.py +2 -1
  93. package/modules/localmodels/stack_lifecycle.py +7 -7
  94. package/modules/localmodels/stack_mcp.py +1 -1
  95. package/modules/localmodels/stack_memory.py +4 -4
  96. package/modules/localmodels/stack_mlx.py +1 -1
  97. package/modules/localmodels/stack_plan.py +18 -13
  98. package/modules/localmodels/stack_ports.py +2 -2
  99. package/modules/localmodels/stack_preflight.py +4 -3
  100. package/modules/localmodels/stack_remove.py +13 -6
  101. package/modules/localmodels/stack_review.py +3 -5
  102. package/modules/localmodels/stack_rollback.py +1 -1
  103. package/modules/localmodels/stack_route.py +5 -4
  104. package/modules/localmodels/stack_run.py +16 -0
  105. package/modules/localmodels/stack_suite.py +14 -6
  106. package/modules/localmodels/stack_summary.py +1 -1
  107. package/modules/localmodels/stack_try.py +10 -14
  108. package/modules/localmodels/stack_up.py +25 -39
  109. package/modules/localmodels/stack_update.py +2 -1
  110. package/modules/localmodels/stack_verify.py +4 -30
  111. package/modules/localmodels/stack_view.py +6 -4
  112. package/modules/localmodels/stack_view_apply.py +2 -2
  113. package/modules/localmodels/stack_view_llm.py +12 -7
  114. package/modules/localmodels/stack_view_text.py +2 -6
  115. package/modules/localmodels/stack_view_tick.py +2 -2
  116. package/modules/localmodels/stack_view_words.py +5 -2
  117. package/modules/localmodels/stack_warm.py +7 -4
  118. package/modules/localmodels/stack_whatif.py +1 -1
  119. package/modules/localmodels/suite.py +6 -334
  120. package/modules/localmodels/tui_views.py +28 -7
  121. package/modules/localmodels/web/index.html +595 -226
  122. package/modules/localmodels/web/sizecalc/app.js +34 -40
  123. package/modules/localmodels/web/sizecalc/calc.js +3 -3
  124. package/modules/localmodels/web/sizecalc/page.html +4 -3
  125. package/modules/localmodels/web/view/fleet.html +18 -3
  126. package/modules/localmodels/web/view/fleet.js +135 -14
  127. package/modules/localmodels/web/view/i18n.js +4 -0
  128. package/modules/localmodels/web/view/index.html +16 -0
  129. package/modules/localmodels/web/view/nav.js +49 -0
  130. package/modules/localmodels/web/view/theme.js +1 -1
  131. package/modules/localmodels/web/view/view.css +51 -15
  132. package/modules/localmodels/web/view/view.js +22 -4
  133. package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/METADATA +1 -1
  134. package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/RECORD +137 -127
  135. package/package.json +1 -1
  136. package/tool.json +1 -1
  137. package/modules/localmodels/library_vram.py +0 -123
  138. /package/modules/localmodels/{memcalc.py → planning/memcalc.py} +0 -0
  139. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/WHEEL +0 -0
  140. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/entry_points.txt +0 -0
  141. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/licenses/NOTICE +0 -0
  142. /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -23,16 +23,16 @@ from localmodels import (
23
23
  harness,
24
24
  hosts,
25
25
  library_gateway,
26
- library_pricing,
27
26
  library_state,
28
27
  library_status,
29
28
  stack_run,
30
- stack_up,
29
+ stack_verify,
31
30
  )
32
31
  from localmodels.contracts import decode
33
32
  from localmodels.library_model import library_id
34
33
  from localmodels.library_state import Record, Registration
35
34
  from localmodels.plan_envelope import utc_now
35
+ from localmodels.planning import memory_pools
36
36
  from localmodels.records import Plan
37
37
  from localmodels.stack_plan import StackPlan
38
38
 
@@ -131,8 +131,6 @@ def _planned_stack_llms(plan: StackPlan | None) -> dict[str, str]:
131
131
  """``library_id -> stack_provider`` for every LLM declared by ``plan`` (running or unloaded)."""
132
132
  if plan is None:
133
133
  return {}
134
- from localmodels import stack_verify
135
-
136
134
  found: dict[str, str] = {}
137
135
  for component, part in stack_verify.parts(plan):
138
136
  if component not in STACK_LLMS:
@@ -149,8 +147,6 @@ def adopted_components(plan: StackPlan) -> set[str]:
149
147
  stays when ``library remove`` deletes the model's record; a converted record (an earlier
150
148
  one may lack ``stack_provider``: the main LLM's) names them too. Read only; it never
151
149
  converts."""
152
- from localmodels import stack_verify
153
-
154
150
  try:
155
151
  marker = json.loads((library_state.root() / MARKER).read_text("utf-8"))
156
152
  except (OSError, ValueError):
@@ -178,8 +174,6 @@ def _active_stack_llms(plan: StackPlan | None) -> dict[str, tuple[str, Plan]]:
178
174
  """Accepted stack LLM deployments still present and ok on disk: ``library_id -> (provider, plan)``."""
179
175
  if plan is None:
180
176
  return {}
181
- from localmodels import stack_verify
182
-
183
177
  found: dict[str, tuple[str, Plan]] = {}
184
178
  for component, part in stack_verify.parts(plan):
185
179
  if component not in STACK_LLMS:
@@ -310,7 +304,7 @@ def _adopt_record(model: str, provider: str, deployed: Plan, base_dir: str | Non
310
304
  if library_state.job_alive(model):
311
305
  return False
312
306
  spec = deployed["model"]
313
- pool = library_pricing.pool_of(deployed)
307
+ pool = memory_pools.pool_of(deployed)
314
308
  existing = library_state.load(model)
315
309
  prev_deploy_dir = existing["plan"]["service"]["deploy_dir"] if existing is not None else None
316
310
  if existing is None:
@@ -337,7 +331,7 @@ def _adopt_record(model: str, provider: str, deployed: Plan, base_dir: str | Non
337
331
  record["state"] = "loaded"
338
332
  record["converted"] = True
339
333
  record["stack_provider"] = provider
340
- record["memory_bytes"] = library_pricing.memory_bytes(deployed)
334
+ record["memory_bytes"] = memory_pools.memory_bytes(deployed)
341
335
  if base_dir is not None:
342
336
  record["base_dir"] = base_dir
343
337
  elif prev_deploy_dir != deployed["service"]["deploy_dir"]:
@@ -580,7 +574,7 @@ def convert_once() -> list[str]:
580
574
  if accepted is not None:
581
575
  plan, attempt_id, _ = accepted
582
576
  elif not hosts.stack_runs():
583
- plan = stack_up.accepted()
577
+ plan = stack_run.accepted()
584
578
  adopted = _sync_with_plan(plan, attempt_id)
585
579
  return adopted or _reconcile_live_bifrost()
586
580
  marker_doc = _read_marker(marker)
@@ -17,7 +17,6 @@ from pathlib import Path
17
17
  from typing import Any, cast
18
18
 
19
19
  from localmodels import (
20
- budget,
21
20
  catalog_add,
22
21
  custom_hub,
23
22
  custom_probe,
@@ -42,6 +41,7 @@ from localmodels.library_model import (
42
41
  split_id,
43
42
  )
44
43
  from localmodels.library_state import CustomMeta, Job, JobHandle, Record
44
+ from localmodels.planning import budget, memory_pools
45
45
  from localmodels.probe import HostFacts
46
46
  from localmodels.records import Plan, ReusableFile
47
47
 
@@ -232,7 +232,7 @@ def _select_pool_and_engine(
232
232
  facts: HostFacts, base_dir: str
233
233
  ) -> tuple[str, str, int, dict[str, object]]:
234
234
  """Return ``(pool_id, placement_id, memory_ceiling_bytes, release_engine_dict)``."""
235
- pool_map = library_pricing.pools(facts)
235
+ pool_map = memory_pools.pools(facts)
236
236
  preferred = [p for p in pool_map if p != "system"]
237
237
  if not preferred:
238
238
  vendor = str(facts.get("gpu_vendor_class") or "none")
@@ -243,13 +243,13 @@ def _select_pool_and_engine(
243
243
  pool_id = max(
244
244
  preferred,
245
245
  key=lambda p: (
246
- library_pricing.pool_free(facts, p),
247
- library_pricing.pool_total(facts, p),
246
+ memory_pools.pool_free(facts, p),
247
+ memory_pools.pool_total(facts, p),
248
248
  ),
249
249
  )
250
250
  placement_id = pool_map[pool_id]
251
251
  adm = budget.admission_budget(facts, pool_id)
252
- total = library_pricing.pool_total(facts, pool_id)
252
+ total = memory_pools.pool_total(facts, pool_id)
253
253
  ceiling = adm.hard_ceiling_bytes if adm is not None and adm.hard_ceiling_bytes > 0 else total
254
254
  backend = "metal" if pool_id == "unified" and facts.get("platform") == "darwin" else "cuda"
255
255
  lock_path = engines.engine_lock_path(CUSTOM_ENGINE_TAG)
@@ -387,7 +387,7 @@ def _build_download_plan(
387
387
  hosts.deployment_dirs(hosts.LOCAL_ID),
388
388
  )
389
389
  gpus = {g["index"]: g for g in facts.get("gpus") or []}
390
- gpu_idx = library_pricing.gpu_index(pool_id)
390
+ gpu_idx = memory_pools.gpu_index(pool_id)
391
391
  placement_gpus = (
392
392
  [
393
393
  {
@@ -10,13 +10,11 @@ non-critical VM pressure, admission succeeds at the floor posture with a pressur
10
10
 
11
11
  from __future__ import annotations
12
12
 
13
- import copy
14
- import math
15
13
  from dataclasses import dataclass, replace
16
14
  from typing import cast
17
15
 
16
+ from localmodels import catalog as cat
18
17
  from localmodels import (
19
- budget,
20
18
  context_policy,
21
19
  deploy,
22
20
  estimator,
@@ -28,11 +26,8 @@ from localmodels import (
28
26
  plan_envelope,
29
27
  vision,
30
28
  )
31
- from localmodels import catalog as cat
32
29
  from localmodels.context_policy import AgentPosture
33
30
  from localmodels.estimator import (
34
- AGENT_VRAM_RESERVE_BYTES,
35
- METAL_VRAM_RESERVE_BYTES,
36
31
  PhysicsRefusal,
37
32
  )
38
33
  from localmodels.library_model import (
@@ -42,7 +37,9 @@ from localmodels.library_model import (
42
37
  MemoryPressureWarningLevel,
43
38
  PostureSummary,
44
39
  )
45
- from localmodels.library_pricing import LiveMemoryUnavailable, Model, memory_bytes
40
+ from localmodels.library_pricing import LiveMemoryUnavailable, Model
41
+ from localmodels.planning import budget, memory_pools
42
+ from localmodels.planning.memory_pools import memory_bytes
46
43
  from localmodels.probe import HostFacts
47
44
  from localmodels.records import Plan
48
45
 
@@ -182,76 +179,6 @@ def elastic_posture_ladder(
182
179
  return tuple(rungs)
183
180
 
184
181
 
185
- def _project_cuda_uma(
186
- facts: HostFacts, unified: int, target: int, *, bypass_working_set: bool
187
- ) -> HostFacts:
188
- seen = copy.deepcopy(facts)
189
- need = target + AGENT_VRAM_RESERVE_BYTES
190
- raw = int(math.ceil(need / (1 - budget._UMA_HEADROOM_FRACTION)))
191
- while int(raw * (1 - budget._UMA_HEADROOM_FRACTION)) < need:
192
- raw += 1
193
- raw = raw if bypass_working_set else min(unified, raw)
194
- if bypass_working_set and isinstance(cuda_pool := seen.get("cuda_pool"), dict):
195
- cuda_pool["total_bytes"], cuda_pool["integrated"] = max(unified, raw), True
196
- for gpu in seen.get("gpus") or []:
197
- if gpu.get("vendor") == "nvidia" and gpu.get("mig_mode") != "enabled":
198
- gpu["free_bytes"], gpu["used_bytes"] = 0, gpu["total_bytes"]
199
- break
200
- ram = seen["ram"]
201
- if bypass_working_set:
202
- ram["total_bytes"] = max(int(ram["total_bytes"]), raw)
203
- if (cgroup := seen.get("cgroup_memory")) is not None:
204
- if (limit := cgroup.get("limit_bytes")) is not None and limit < raw:
205
- cgroup["limit_bytes"] = raw
206
- cgroup["usage_bytes"] = 0
207
- ram["available_bytes"] = min(int(ram["total_bytes"]), raw)
208
- return seen
209
-
210
-
211
- def facts_for_budget(
212
- facts: HostFacts,
213
- pool: str,
214
- target_bytes: int,
215
- *,
216
- wired_cap_bytes: int | None = None,
217
- bypass_working_set: bool = False,
218
- ) -> HostFacts:
219
- """Project ``facts`` so ``deploy.build_plan`` prices ``pool`` against ``target_bytes``
220
- (unified/total) and optional ``wired_cap_bytes`` (Metal GPU wired headroom)."""
221
- target = max(0, target_bytes)
222
- if pool == "unified" and metal.supported(facts):
223
- seen = copy.deepcopy(facts)
224
- ram = seen["ram"]
225
- needed_avail = target + metal.HOST_KEEP_BYTES + METAL_VRAM_RESERVE_BYTES
226
- ram["available_bytes"] = (
227
- needed_avail if bypass_working_set else min(int(ram["total_bytes"]), needed_avail)
228
- )
229
- ram["pressure_level"] = metal.PRESSURE_NORMAL
230
- ram.pop("pressure_kept_bytes", None)
231
- if isinstance(metal_doc := seen.get("metal"), dict):
232
- ceiling = (
233
- max(0, wired_cap_bytes) + METAL_VRAM_RESERVE_BYTES
234
- if wired_cap_bytes is not None
235
- else max(metal.wired_ceiling_bytes(facts), target + METAL_VRAM_RESERVE_BYTES)
236
- if bypass_working_set
237
- else metal.wired_ceiling_bytes(facts)
238
- )
239
- metal_doc["recommended_max_working_set_bytes"] = ceiling
240
- return seen
241
- if pool == "unified" and (unified := budget.unified_pool_bytes(facts)) is not None:
242
- return _project_cuda_uma(facts, unified, target, bypass_working_set=bypass_working_set)
243
- if (idx := library_pricing.gpu_index(pool)) is not None:
244
- seen = copy.deepcopy(facts)
245
- for gpu in seen.get("gpus") or []:
246
- if gpu["index"] == idx:
247
- free = target + AGENT_VRAM_RESERVE_BYTES
248
- gpu["free_bytes"] = free if bypass_working_set else min(gpu["total_bytes"], free)
249
- gpu["used_bytes"] = max(0, gpu["total_bytes"] - gpu["free_bytes"])
250
- break
251
- return seen
252
- return facts
253
-
254
-
255
182
  def _plan_posture(plan: Plan) -> PostureSpec:
256
183
  launch = plan["launch"]
257
184
  window = int(str(launch.get("window") or 0))
@@ -302,8 +229,8 @@ def _floor_need_bytes(
302
229
  else 0
303
230
  )
304
231
  return core + vis, core + vis
305
- if library_pricing.gpu_index(pool) is not None and model.entry.mmproj is not None:
306
- total = library_pricing.pool_total(facts, pool)
232
+ if memory_pools.gpu_index(pool) is not None and model.entry.mmproj is not None:
233
+ total = memory_pools.pool_total(facts, pool)
307
234
  mode = vision.reader(active.vision, total, unified=False)
308
235
  vis = vision.llama_device_bytes(model.entry.mmproj, mode)
309
236
  return core + vis, core + vis
@@ -319,7 +246,7 @@ def minimum_memory_bytes(facts: HostFacts, model: Model, pool: str) -> int | Non
319
246
  or library_kept.retired(model.entry)
320
247
  ):
321
248
  return None
322
- if pool not in library_pricing.pools(facts):
249
+ if pool not in memory_pools.pools(facts):
323
250
  return None
324
251
  backend = "metal" if pool == "unified" and metal.supported(facts) else "cuda"
325
252
  ladder = elastic_posture_ladder(
@@ -336,48 +263,6 @@ def minimum_memory_bytes(facts: HostFacts, model: Model, pool: str) -> int | Non
336
263
  return min_need
337
264
 
338
265
 
339
- def validate_plan_bounds(
340
- facts: HostFacts,
341
- model: Model,
342
- pool: str,
343
- plan: Plan,
344
- catalog: tuple[cat.CatalogEntry, ...],
345
- *,
346
- check_pool_total: bool = True,
347
- check_host_ram: bool = True,
348
- ) -> None:
349
- """Reject a plan exceeding ``pool``'s total capacity or host RAM on a discrete GPU."""
350
- if check_pool_total:
351
- total = library_pricing.pool_total(facts, pool)
352
- used = memory_bytes(plan)
353
- if used > total:
354
- refused = PhysicsRefusal(
355
- needed_bytes=used,
356
- available_bytes=total,
357
- message=f"{model.id} needs {used} bytes, exceeding pool {pool} total {total} bytes",
358
- )
359
- raise deploy.AgentMemoryError(
360
- refused.message,
361
- refused,
362
- "unified memory" if pool == "unified" else "GPU memory",
363
- )
364
- if check_host_ram and library_pricing.gpu_index(pool) is not None:
365
- needed_ram = (
366
- library_pricing.host_ram_bytes(plan, catalog) + budget.HARNESS_RAM + budget.RAM_FLOOR
367
- )
368
- _, avail_ram = budget.host_ram(facts)
369
- if needed_ram > avail_ram:
370
- refused = PhysicsRefusal(
371
- needed_bytes=needed_ram,
372
- available_bytes=avail_ram,
373
- message=(
374
- f"{model.id} needs {needed_ram} bytes of system memory, "
375
- f"exceeding {avail_ram} bytes available"
376
- ),
377
- )
378
- raise deploy.AgentMemoryError(refused.message, refused, "system memory")
379
-
380
-
381
266
  @dataclass(frozen=True)
382
267
  class _PriceCtx:
383
268
  facts: HostFacts
@@ -400,7 +285,7 @@ def _price_rung(
400
285
  check_host_ram: bool = True,
401
286
  bypass_working_set: bool = False,
402
287
  ) -> Plan:
403
- priced_facts = facts_for_budget(
288
+ priced_facts = memory_pools.facts_for_budget(
404
289
  ctx.facts,
405
290
  ctx.pool,
406
291
  budget_bytes,
@@ -424,7 +309,7 @@ def _price_rung(
424
309
  entries=ctx.catalog,
425
310
  resolver=deploy.catalog_pins,
426
311
  )
427
- validate_plan_bounds(
312
+ library_pricing.validate_plan_bounds(
428
313
  ctx.facts,
429
314
  ctx.model,
430
315
  ctx.pool,
@@ -639,6 +524,17 @@ def _custom_ctx_ladder(
639
524
  return (PostureRung(pinned, degraded=False, reason=None),)
640
525
 
641
526
 
527
+ def load_posture(model: Model, base_dir: str) -> AgentPosture:
528
+ """The library's agent posture for loading ``model`` from ``base_dir``. A load never fetches
529
+ and never fails for an optional accelerator: without its drafter verified on disk (a model
530
+ downloaded before the drafter shipped), the model is planned with the drafter off, exactly
531
+ as when there is no headroom for it."""
532
+ posture = library_pricing.posture()
533
+ if model.entry.draft is None or deploy.drafter_in_place(model.entry, base_dir):
534
+ return posture
535
+ return replace(posture, draft="off")
536
+
537
+
642
538
  def price_elastic(
643
539
  facts: HostFacts,
644
540
  model: Model,
@@ -657,7 +553,7 @@ def price_elastic(
657
553
  effective_catalog = (
658
554
  catalog if any(e.id == model.entry.id for e in catalog) else (*catalog, model.entry)
659
555
  )
660
- placement = library_pricing.pools(facts).get(pool)
556
+ placement = memory_pools.pools(facts).get(pool)
661
557
  if placement is None:
662
558
  raise plan_envelope.PlanError(f"this computer has no pool {pool}")
663
559
  if library_kept.retired(model.entry):
@@ -677,11 +573,12 @@ def price_elastic(
677
573
  )
678
574
  eff = _plan_posture(poly_plan)
679
575
  return ElasticPlan(poly_plan, 0, (), eff, eff, False, None, None, False, adm)
576
+ posture = load_posture(model, base_dir)
680
577
  if ctx_override is not None and ctx_override > 0:
681
- ladder = _custom_ctx_ladder(library_pricing.posture(), adm.backend, ctx_override)
578
+ ladder = _custom_ctx_ladder(posture, adm.backend, ctx_override)
682
579
  else:
683
580
  ladder = elastic_posture_ladder(
684
- library_pricing.posture(),
581
+ posture,
685
582
  backend=adm.backend,
686
583
  native_ctx=model.entry.n_ctx_train,
687
584
  max_agent_window=model.entry.max_agent_window,
@@ -21,8 +21,11 @@ from pathlib import Path
21
21
  from localmodels import (
22
22
  app,
23
23
  deploy_steps,
24
+ deployment_lifecycle,
25
+ draft_spec,
24
26
  frontend,
25
27
  hosts,
28
+ library_convert,
26
29
  library_gateway,
27
30
  library_pricing,
28
31
  library_state,
@@ -45,6 +48,7 @@ from localmodels.library_model import (
45
48
  )
46
49
  from localmodels.library_pricing import Model
47
50
  from localmodels.library_state import Job, JobHandle, Record
51
+ from localmodels.planning import memory_pools
48
52
  from localmodels.probe import HostFacts
49
53
  from localmodels.records import Plan, ReusableFile
50
54
  from localmodels.transport import Executor
@@ -130,7 +134,7 @@ def in_use(skip: str) -> set[str]:
130
134
  used.update(dests(record["plan"]))
131
135
  library_names = {r["plan"]["name"] for r in library_state.records()}
132
136
  for name, owned in hosts.load_owned()["deployments"].items():
133
- if name not in library_names and not owned["removed"]:
137
+ if name not in library_names and deployment_lifecycle.holds_service(owned):
134
138
  used.update(os.path.expanduser(f) for f in owned["files"])
135
139
  return used
136
140
 
@@ -537,15 +541,13 @@ def download(
537
541
  load: Callable[[str, str, list[str]], Row],
538
542
  ) -> Row:
539
543
  """Fetch the model into ``base_dir``, record it, then load it when its pool has room."""
540
- from localmodels import library_convert
541
-
542
544
  library_convert.convert_once()
543
545
  lib = library_status.Library.read(probe(), base_dir)
544
546
  model = library_pricing.find(model_id, lib.catalog)
545
547
  priced = _refuse_download(lib, model)
546
548
  assert priced.plan is not None
547
549
  plan, files = priced.plan, dests(priced.plan)
548
- memory = library_pricing.memory_bytes(plan)
550
+ memory = memory_pools.memory_bytes(plan)
549
551
  cancel_on_sigterm()
550
552
  with library_state.locked(): # validated again with the claim, as one step
551
553
  library_state.refuse_busy(model.id, "download")
@@ -634,4 +636,11 @@ def cancel(model_id: str, base_dir: str) -> Row:
634
636
 
635
637
 
636
638
  def files_missing(plan: Plan) -> list[str]:
637
- return [Path(f["dest"]).name for f in plan["files"] if not plan_envelope.verified_in_place(f)]
639
+ """The files ``plan`` cannot start without that are not verified in place. Its optional
640
+ drafter is never one: a load plans without it (``library_elastic.load_posture``)."""
641
+ optional = draft_spec.drafter_dest(plan)
642
+ return [
643
+ Path(f["dest"]).name
644
+ for f in plan["files"]
645
+ if f["dest"] != optional and not plan_envelope.verified_in_place(f)
646
+ ]
@@ -8,11 +8,12 @@ fallback below validated models whenever a validated model fits (Decision 69).
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
- from localmodels import budget, library_pricing, llm_rank, metal
12
11
  from localmodels import catalog as cat
12
+ from localmodels import llm_rank, metal
13
13
  from localmodels.estimator import HardwareBudget
14
14
  from localmodels.library_model import Row
15
15
  from localmodels.library_pricing import Model
16
+ from localmodels.planning import budget, memory_pools
16
17
  from localmodels.probe import HostFacts
17
18
 
18
19
  _ACTIONABLE_UNAVAILABLE = frozenset({"DRIVER_UPDATE_REQUIRED", "RUNTIME_DEPENDENCY_MISSING"})
@@ -89,7 +90,7 @@ def _mac_suitability_key(
89
90
 
90
91
 
91
92
  def _best_cuda_budget(facts: HostFacts) -> HardwareBudget | None:
92
- shown_cards = library_pricing.visible(facts)
93
+ shown_cards = memory_pools.visible(facts)
93
94
  cuda_placements = [
94
95
  p
95
96
  for p in budget.placements(facts, planning=True)
@@ -108,7 +109,7 @@ def _best_cuda_budget(facts: HostFacts) -> HardwareBudget | None:
108
109
 
109
110
 
110
111
  def _max_visible_nvidia_bytes(facts: HostFacts) -> int:
111
- shown_cards = library_pricing.visible(facts)
112
+ shown_cards = memory_pools.visible(facts)
112
113
  return max(
113
114
  (
114
115
  g["total_bytes"]
@@ -3,14 +3,14 @@
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
5
  supported NVIDIA Linux and Windows hosts alongside ``llama.cpp`` models. Pricing runs
6
- ``suite.build_plan`` so CUDA 13 driver checks, glibc checks, vision reader placement and host
6
+ ``suite_plan.build_plan`` so CUDA 13 driver checks, glibc checks, vision reader placement and host
7
7
  RAM ceilings stay identical to ``stack plan``.
8
8
  """
9
9
 
10
10
  from __future__ import annotations
11
11
 
12
+ from localmodels import catalog as cat
12
13
  from localmodels import (
13
- budget,
14
14
  catalog_recipes,
15
15
  deploy,
16
16
  engines,
@@ -20,10 +20,11 @@ from localmodels import (
20
20
  suite,
21
21
  vision,
22
22
  )
23
- from localmodels import catalog as cat
24
23
  from localmodels.context_policy import AgentPosture
24
+ from localmodels.engine_adapters import suite_plan
25
25
  from localmodels.estimator import PhysicsRefusal
26
26
  from localmodels.library_model import Reason, split_id
27
+ from localmodels.planning import budget
27
28
  from localmodels.probe import GPU, HostFacts
28
29
  from localmodels.records import Plan
29
30
 
@@ -297,7 +298,7 @@ def price(
297
298
  vram_reserve_mib=reserve,
298
299
  vision_reader=reader,
299
300
  )
300
- plan = suite.build_plan(hosts.LOCAL_ID, facts, recipe, opts)
301
+ plan = suite_plan.build_plan(hosts.LOCAL_ID, facts, recipe, opts)
301
302
  if facts["platform"] == "win32":
302
303
  plan = suite.unbounded(plan)
303
304
  _calibrate_host_ram(plan, recipe, gpu)