@simplexai/localmodels-win32-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
@@ -17,7 +17,6 @@ from localmodels import (
17
17
  debug_mode,
18
18
  hosts,
19
19
  library_elastic,
20
- library_floor,
21
20
  library_gateway,
22
21
  library_order,
23
22
  library_pricing,
@@ -35,6 +34,8 @@ from localmodels.library_model import (
35
34
  LOAD_STEPS_PUBLIC,
36
35
  STATUS_SCHEMA,
37
36
  Availability,
37
+ CustomHub,
38
+ CustomRowMeta,
38
39
  DebugInfo,
39
40
  DegradationReason,
40
41
  Download,
@@ -54,6 +55,10 @@ from localmodels.library_model import (
54
55
  Problem,
55
56
  Row,
56
57
  Status,
58
+ VerificationFailure,
59
+ VerificationFailureKind,
60
+ VerificationMeta,
61
+ VerificationStatus,
57
62
  sanitize_problem,
58
63
  )
59
64
  from localmodels.library_pricing import Model, Priced
@@ -141,6 +146,14 @@ class Library:
141
146
  if model_id not in known:
142
147
  try:
143
148
  rows.append(library_pricing.find(model_id, self.catalog))
149
+ known.add(model_id)
150
+ except (ValueError, LibraryError):
151
+ continue
152
+ for model_id, (job, _alive) in self.jobs.items():
153
+ if model_id not in known and job.get("custom") is not None:
154
+ try:
155
+ rows.append(library_pricing.find(model_id, self.catalog))
156
+ known.add(model_id)
144
157
  except (ValueError, LibraryError):
145
158
  continue
146
159
  return rows
@@ -161,8 +174,10 @@ class Library:
161
174
  def _state(lib: Library, model: str, record: Record | None) -> tuple[str, Problem | None]:
162
175
  job, alive = lib.jobs.get(model, (None, False))
163
176
  if job is not None and alive:
177
+ if job["kind"] == "smoke_test":
178
+ return ("idle" if record is not None else "absent"), None
164
179
  return ("downloading" if job["kind"] == "download" else "loading"), None
165
- if job is not None: # its process ended without clearing it, or it failed and kept its partials
180
+ if job is not None and job["kind"] != "smoke_test": # process ended or failed with partials
166
181
  if isinstance(err := job.get("error"), dict) and isinstance(err.get("code"), str):
167
182
  return "failed", sanitize_problem(err)
168
183
  code = "DOWNLOAD_FAILED" if job["kind"] == "download" else "ENGINE_START_FAILED"
@@ -186,10 +201,24 @@ def _state(lib: Library, model: str, record: Record | None) -> tuple[str, Proble
186
201
  return "idle", None
187
202
 
188
203
 
189
- def _plan_of(lib: Library, model: Model, record: Record | None, priced: Priced) -> Plan | None:
190
- """The plan a row shows: its record's; for a model a live job is downloading, the price on
191
- the pool that job recorded (status never moves a running download to another card)."""
204
+ def _plan_of(
205
+ lib: Library,
206
+ model: Model,
207
+ record: Record | None,
208
+ priced: Priced,
209
+ *,
210
+ state: str | None = None,
211
+ ) -> Plan | None:
212
+ """The plan a row shows: its record's (preferring ``baseline_plan`` whenever not loaded so a
213
+ prior degraded load never pollutes idle/failed specs); for a model a live job is downloading,
214
+ the price on the pool that job recorded (status never moves a running download to another card)."""
192
215
  if record is not None:
216
+ if (
217
+ state is not None
218
+ and state != "loaded"
219
+ and (baseline := record.get("baseline_plan")) is not None
220
+ ):
221
+ return baseline
193
222
  return record["plan"]
194
223
  job, alive = lib.jobs.get(model.id, (None, False))
195
224
  if job is not None and alive and job["pool"] != priced.pool:
@@ -284,6 +313,12 @@ def _downloading(job: Job) -> Download:
284
313
  conns = job.get("connections")
285
314
  if isinstance(conns, int) and not isinstance(conns, bool) and conns >= 0:
286
315
  dl["connections"] = conns
316
+ s_idx = job.get("shard_index")
317
+ if isinstance(s_idx, int) and not isinstance(s_idx, bool) and s_idx >= 1:
318
+ dl["shard_index"] = s_idx
319
+ s_cnt = job.get("shard_count")
320
+ if isinstance(s_cnt, int) and not isinstance(s_cnt, bool) and s_cnt >= 1:
321
+ dl["shard_count"] = s_cnt
287
322
  return dl
288
323
 
289
324
 
@@ -325,7 +360,11 @@ def _apply_engine_meta(lib: Library, found: Row, model: Model, plan: Plan | None
325
360
  found["concurrency"] = (
326
361
  parsed_slots
327
362
  if parsed_slots >= 1
328
- else (1 if engine in ("polystrata", "strata") else library_pricing.posture().slots)
363
+ else (
364
+ 2
365
+ if engine == "polystrata"
366
+ else (1 if engine == "strata" else library_pricing.posture().slots)
367
+ )
329
368
  )
330
369
  if plan is not None and engine in ("polystrata", "strata"):
331
370
  host_ram = library_pricing.host_ram_bytes(plan, lib.catalog)
@@ -424,14 +463,108 @@ def _apply_record_meta(
424
463
  found["error"] = sanitize_problem(problem)
425
464
 
426
465
 
466
+ def _custom_row_meta(raw: Mapping[str, object]) -> CustomRowMeta:
467
+ hub_val = str(raw.get("hub") or "huggingface")
468
+ hub: CustomHub = "modelscope" if hub_val == "modelscope" else "huggingface"
469
+ fmt_val = str(raw.get("format") or "gguf")
470
+ meta: CustomRowMeta = {
471
+ "hub": hub,
472
+ "repo_id": str(raw.get("repo_id") or ""),
473
+ "format": "mlx" if fmt_val == "mlx" else "gguf",
474
+ "variant_id": str(raw.get("variant_id") or ""),
475
+ "shard_count": max(1, int(str(raw.get("shard_count") or 1))),
476
+ "standby_on_restart": bool(raw.get("standby_on_restart", True)),
477
+ }
478
+ if isinstance(rev := raw.get("revision"), str) and rev:
479
+ meta["revision"] = rev
480
+ if isinstance(url := raw.get("url"), str) and url:
481
+ meta["url"] = url
482
+ if isinstance(mmproj := raw.get("mmproj_file"), str) and mmproj:
483
+ meta["mmproj_file"] = mmproj
484
+ mmproj_b = raw.get("mmproj_bytes")
485
+ if isinstance(mmproj_b, int) and not isinstance(mmproj_b, bool) and mmproj_b >= 0:
486
+ meta["mmproj_bytes"] = mmproj_b
487
+ if isinstance(risk := raw.get("accepted_risk"), bool):
488
+ meta["accepted_risk"] = risk
489
+ return meta
490
+
491
+
492
+ def _verification_meta(
493
+ raw: Mapping[str, object] | None, *, smoke_running: bool
494
+ ) -> VerificationMeta:
495
+ if smoke_running:
496
+ out: VerificationMeta = {"status": "running"}
497
+ if raw is not None:
498
+ ctx = raw.get("context_tokens")
499
+ if isinstance(ctx, int) and not isinstance(ctx, bool) and ctx > 0:
500
+ out["context_tokens"] = ctx
501
+ return out
502
+ if raw is None:
503
+ return {"status": "untested"}
504
+ raw_status = str(raw.get("status") or "untested")
505
+ status: VerificationStatus = (
506
+ cast(VerificationStatus, raw_status)
507
+ if raw_status in ("untested", "running", "verified", "failed")
508
+ else "untested"
509
+ )
510
+ out = {"status": status}
511
+ ctx = raw.get("context_tokens")
512
+ if isinstance(ctx, int) and not isinstance(ctx, bool) and ctx > 0:
513
+ out["context_tokens"] = ctx
514
+ if isinstance(tested_at := raw.get("tested_at"), str) and tested_at:
515
+ out["tested_at"] = tested_at
516
+ raw_fail = raw.get("failure")
517
+ if isinstance(raw_fail, Mapping):
518
+ raw_kind = str(raw_fail.get("kind") or "unknown")
519
+ kind: VerificationFailureKind = (
520
+ cast(VerificationFailureKind, raw_kind)
521
+ if raw_kind in ("oom", "unsupported_arch", "corrupt", "unknown")
522
+ else "unknown"
523
+ )
524
+ fail_ctx = raw_fail.get("context_tokens")
525
+ failure: VerificationFailure = {
526
+ "kind": kind,
527
+ "code": str(raw_fail.get("code") or "ENGINE_START_FAILED"),
528
+ "context_tokens": int(fail_ctx) if isinstance(fail_ctx, int) and fail_ctx >= 0 else 0,
529
+ "can_retry_lower_ctx": bool(raw_fail.get("can_retry_lower_ctx", False)),
530
+ "can_redownload": bool(raw_fail.get("can_redownload", False)),
531
+ }
532
+ if isinstance(diag := raw_fail.get("diagnostic_log"), str) and diag:
533
+ failure["diagnostic_log"] = diag[:4000]
534
+ out["failure"] = failure
535
+ return out
536
+
537
+
538
+ def _apply_custom_meta(
539
+ found: Row,
540
+ record: Record | None,
541
+ job: Job | None,
542
+ alive: bool,
543
+ ) -> None:
544
+ raw_custom = (record.get("custom") if record is not None else None) or (
545
+ job.get("custom") if job is not None else None
546
+ )
547
+ if raw_custom is None:
548
+ return
549
+ meta = _custom_row_meta(raw_custom)
550
+ found["origin"] = "custom"
551
+ found["recommended"] = False
552
+ found["custom"] = meta
553
+ if (url := meta.get("url")) and url.startswith("https://"):
554
+ found["source_url"] = url
555
+ smoke_running = job is not None and alive and job["kind"] == "smoke_test"
556
+ raw_ver = record.get("verification") if record is not None else None
557
+ found["verification"] = _verification_meta(raw_ver, smoke_running=smoke_running)
558
+
559
+
427
560
  def row(lib: Library, model: Model) -> Row:
428
561
  record = lib.records.get(model.id)
429
562
  priced = lib.judge(model)
430
563
  state, problem = _state(lib, model.id, record)
431
- plan = _plan_of(lib, model, record, priced)
564
+ plan = _plan_of(lib, model, record, priced, state=state)
432
565
  job, alive = lib.jobs.get(model.id, (None, False))
433
566
  fallback_memory, fallback_window, fallback_vision, fallback_download = (
434
- library_floor.floor_metadata(
567
+ library_pricing.floor_metadata(
435
568
  lib.facts, model, priced.need_bytes, memory_kind=priced.memory_kind
436
569
  )
437
570
  if plan is None
@@ -486,6 +619,7 @@ def row(lib: Library, model: Model) -> Row:
486
619
  found.update(card(model, found["vision"]))
487
620
  _apply_engine_meta(lib, found, model, plan)
488
621
  _apply_record_meta(found, model, record, state, problem)
622
+ _apply_custom_meta(found, record, job, alive)
489
623
  return found
490
624
 
491
625
 
@@ -627,6 +761,7 @@ def host(lib: Library) -> Host:
627
761
  "ram_total_bytes": facts["ram"]["total_bytes"],
628
762
  "ram_available_bytes": facts["ram"]["available_bytes"],
629
763
  "disk_free_bytes": library_pricing.base_free(lib.base_dir),
764
+ "supported_formats": ["gguf"],
630
765
  "gpus": [
631
766
  {
632
767
  "index": g["index"],
@@ -664,6 +799,7 @@ def build(lib: Library) -> Status:
664
799
  if r["state"] == "absent"
665
800
  and r["availability"]["downloadable"]
666
801
  and r.get("fits_now") is True
802
+ and r.get("origin") != "custom"
667
803
  ]
668
804
  chosen = library_pricing.recommend(now, candidates, lib.base_dir)
669
805
  for r in rows:
@@ -226,8 +226,8 @@ def inactive_anon_bytes(facts: HostFacts) -> int:
226
226
  anonymous = max(0, int(ram["anonymous_bytes"]))
227
227
  purgeable = max(0, int(ram["purgeable_bytes"]))
228
228
  non_purgeable_anon = max(0, anonymous - purgeable)
229
- lower = max(0, inactive - max(0, file_backed - speculative))
230
229
  upper = min(inactive, non_purgeable_anon)
230
+ lower = min(upper, max(0, inactive - max(0, file_backed - speculative) - purgeable))
231
231
  if active + inactive > 0:
232
232
  est = int(non_purgeable_anon * (inactive / (active + inactive)))
233
233
  return max(lower, min(upper, est))
@@ -87,9 +87,9 @@ def parse_vm_stat_details(vm_stat: str) -> dict[str, int]:
87
87
  """Byte breakdown of macOS ``vm_stat`` counters, including estimated inactive anonymous memory.
88
88
 
89
89
  Returns an empty dict when ``vm_stat`` is unreadable. Inactive anonymous pages are bounded
90
- between ``max(0, inactive - max(0, file_backed - speculative))`` and
91
- ``min(inactive, max(0, anonymous - purgeable))``, estimated proportionally by the inactive
92
- share of active+inactive paged memory.
90
+ between ``min(upper, max(0, inactive - max(0, file_backed - speculative) - purgeable))`` and
91
+ ``upper = min(inactive, max(0, anonymous - purgeable))``, estimated proportionally by the
92
+ inactive share of active+inactive paged memory without double-counting purgeable pages.
93
93
  """
94
94
  parsed = _vm_stat_counts(vm_stat)
95
95
  if parsed is None:
@@ -122,8 +122,8 @@ def parse_vm_stat_details(vm_stat: str) -> dict[str, int]:
122
122
  anonymous = counts["Anonymous pages"]
123
123
  purgeable = counts["Pages purgeable"]
124
124
  non_purgeable_anon = max(0, anonymous - purgeable)
125
- lower = max(0, inactive - max(0, file_backed - speculative))
126
125
  upper = min(inactive, non_purgeable_anon)
126
+ lower = min(upper, max(0, inactive - max(0, file_backed - speculative) - purgeable))
127
127
  if active + inactive > 0:
128
128
  est = int(non_purgeable_anon * (inactive / (active + inactive)))
129
129
  inactive_anon = max(lower, min(upper, est))