@simplexai/localmodels-linux-x64 0.1.0-dev.38 → 0.1.0-dev.39

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 (61) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +60 -54
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +4 -0
  5. package/modules/localmodels/bifrost_config.py +19 -0
  6. package/modules/localmodels/catalog.json +18 -6
  7. package/modules/localmodels/cli_parser.py +26 -3
  8. package/modules/localmodels/deploy.py +37 -9
  9. package/modules/localmodels/deploy_steps.py +6 -3
  10. package/modules/localmodels/download-mirrors.json +52 -4
  11. package/modules/localmodels/engines-b11583.json +20 -4
  12. package/modules/localmodels/engines-b12167.json +5 -1
  13. package/modules/localmodels/engines-strata-0.1.47.json +5 -1
  14. package/modules/localmodels/engines-strata-0.1.49.2.json +5 -1
  15. package/modules/localmodels/engines-strata-0.1.59.1.json +5 -1
  16. package/modules/localmodels/engines-strata-poly-0.1.45-poly.9.json +5 -1
  17. package/modules/localmodels/engines-whisper-b5454.json +5 -1
  18. package/modules/localmodels/engines.json +55 -11
  19. package/modules/localmodels/frontend.py +5 -2
  20. package/modules/localmodels/guard.py +15 -6
  21. package/modules/localmodels/harness.py +65 -33
  22. package/modules/localmodels/harness_gateway.py +9 -3
  23. package/modules/localmodels/hf_repo.py +15 -8
  24. package/modules/localmodels/library_gateway.py +15 -13
  25. package/modules/localmodels/metal_probe.py +16 -6
  26. package/modules/localmodels/npm_signatures.py +131 -0
  27. package/modules/localmodels/npm_transport.py +26 -10
  28. package/modules/localmodels/process_identity.py +21 -5
  29. package/modules/localmodels/region.py +244 -0
  30. package/modules/localmodels/remote_ops.py +69 -13
  31. package/modules/localmodels/remote_ops_download.py +210 -10
  32. package/modules/localmodels/remote_ops_prepare.py +61 -8
  33. package/modules/localmodels/runtime-lock.json +13 -13
  34. package/modules/localmodels/runtime_args.py +4 -2
  35. package/modules/localmodels/runtime_cli.py +19 -37
  36. package/modules/localmodels/runtime_discovery.py +30 -0
  37. package/modules/localmodels/runtime_install.py +81 -6
  38. package/modules/localmodels/runtime_io.py +61 -5
  39. package/modules/localmodels/runtime_pi.py +79 -0
  40. package/modules/localmodels/runtime_process.py +99 -15
  41. package/modules/localmodels/runtime_releases.py +51 -71
  42. package/modules/localmodels/service_probe.py +62 -4
  43. package/modules/localmodels/setup_inspection.py +21 -4
  44. package/modules/localmodels/setup_text.py +6 -0
  45. package/modules/localmodels/source_byok.py +484 -0
  46. package/modules/localmodels/source_byok_probe.py +275 -0
  47. package/modules/localmodels/source_cli.py +426 -0
  48. package/modules/localmodels/stack_args.py +2 -1
  49. package/modules/localmodels/stack_binding.py +47 -4
  50. package/modules/localmodels/stack_events.py +3 -0
  51. package/modules/localmodels/stack_hardware.py +17 -3
  52. package/modules/localmodels/tools.json +1364 -14
  53. package/modules/localmodels/transport.py +2 -0
  54. package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/METADATA +1 -1
  55. package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/RECORD +57 -51
  56. package/package.json +1 -1
  57. package/tool.json +1 -1
  58. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/WHEEL +0 -0
  59. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/entry_points.txt +0 -0
  60. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/licenses/NOTICE +0 -0
  61. /package/modules/{simplex_localmodels-0.1.0.dev38.dist-info → simplex_localmodels-0.1.0.dev39.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -289,7 +289,8 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
289
289
  default=deploy.hf_endpoint(),
290
290
  metavar="URL",
291
291
  help="where weights are downloaded from (default: $HF_ENDPOINT, else Hugging Face); "
292
- "faster sources of the same pinned files, such as ModelScope, are still tried",
292
+ "other sources of the same pinned files (ModelScope, hf-mirror.com) are still tried, "
293
+ "China-first in download region cn",
293
294
  )
294
295
  where.add_argument(
295
296
  "--offline",
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import hashlib
6
+ import json
6
7
  import os
7
8
  from pathlib import Path
8
9
  from typing import TypedDict, cast
@@ -64,8 +65,33 @@ def _acceptance_ready(plan: StackPlan) -> bool:
64
65
  return bool(view and view["ok"])
65
66
 
66
67
 
67
- def _deployments_ready(plan: StackPlan, owned: hosts.Owned) -> bool:
68
- parts = {part["name"]: part for part in deployments(plan)}
68
+ def _adopted(plan: StackPlan) -> set[str]:
69
+ """The plan's LLM components the library adopted (``library_convert``): from then on the
70
+ library loads, unloads and wires them, so their deployments, gateway route and pi selection
71
+ are no longer the stack's to check. Read only; it never converts."""
72
+ from localmodels import library_convert, library_state, stack_verify
73
+
74
+ try:
75
+ marker = json.loads((library_state.root() / library_convert.MARKER).read_text("utf-8"))
76
+ except (OSError, ValueError):
77
+ return set()
78
+ if not isinstance(marker, dict) or marker.get("plan_id") != plan["plan_id"]:
79
+ return set()
80
+ providers = {r.get("stack_provider") for r in library_state.records() if r.get("converted")}
81
+ return {
82
+ component
83
+ for component, _ in stack_verify.parts(plan)
84
+ if library_convert.STACK_LLMS.get(component) in providers
85
+ }
86
+
87
+
88
+ def _deployments_ready(
89
+ plan: StackPlan, owned: hosts.Owned, adopted: frozenset[str] | set[str] = frozenset()
90
+ ) -> bool:
91
+ from localmodels import stack_verify
92
+
93
+ library = {part["name"] for component, part in stack_verify.parts(plan) if component in adopted}
94
+ parts = {part["name"]: part for part in deployments(plan) if part["name"] not in library}
69
95
  records = [
70
96
  record for record in hosts.records(hosts.LOCAL_ID) if record["plan"]["name"] in parts
71
97
  ]
@@ -211,6 +237,22 @@ def _pi_binding(plan: StackPlan, owned: hosts.Owned, lang: Lang = "zh") -> PiBin
211
237
  }
212
238
 
213
239
 
240
+ def _library_binding(plan: StackPlan) -> PiBinding:
241
+ """The stack's pi once the library adopted its LLM: the library unwires the route and may
242
+ stop the gateway on unload, so only the executable and the owned profile are checked."""
243
+ from localmodels import bifrost_pi
244
+
245
+ executable = Path(harness.tool_path(plan["harness"], "pi"))
246
+ profile = bifrost_pi.pi_profile(harness.gateway_environment(plan["harness"]))
247
+ if not executable.is_absolute() or not profile.is_absolute():
248
+ raise ValueError("Pi paths must be absolute")
249
+ return {
250
+ "executable": str(executable),
251
+ "environment": {"PI_CODING_AGENT_DIR": str(profile)},
252
+ "configFingerprint": _profile_fingerprint(executable, profile),
253
+ }
254
+
255
+
214
256
  def inspect_binding(path: Path, lang: Lang = "zh") -> BindingReport:
215
257
  report: BindingReport = {
216
258
  "schema": "localmodels.stack-binding/v1",
@@ -234,10 +276,11 @@ def inspect_binding(path: Path, lang: Lang = "zh") -> BindingReport:
234
276
  report["reasons"] = [_reason("acceptance-unavailable", lang)]
235
277
  return report
236
278
  owned = hosts.load_owned(plan["harness"]["tools_dir"])
237
- if not _deployments_ready(plan, owned):
279
+ adopted = _adopted(plan)
280
+ if not _deployments_ready(plan, owned, adopted):
238
281
  report["reasons"] = [_reason("deployment-unavailable", lang)]
239
282
  return report
240
- binding = _pi_binding(plan, owned, lang)
283
+ binding = _library_binding(plan) if adopted else _pi_binding(plan, owned, lang)
241
284
  if "code" in binding:
242
285
  report["reasons"] = [cast(Reason, binding)]
243
286
  else:
@@ -5,6 +5,8 @@ import json
5
5
  from collections.abc import Callable, Mapping, Sequence
6
6
  from typing import Literal, Protocol, TypedDict, runtime_checkable
7
7
 
8
+ from localmodels import region
9
+
8
10
  MAX_SAFE_INTEGER = 9_007_199_254_740_991
9
11
  MAX_EVENT_CHARS = 65_536
10
12
  STACK_PLAN_SECTIONS = (
@@ -293,6 +295,7 @@ class ToolEvents(io.StringIO):
293
295
  return
294
296
  if not isinstance(event, dict):
295
297
  return
298
+ region.observe(event)
296
299
  if event.get("event") == "log":
297
300
  self.log(str(event.get("message", "")))
298
301
  elif event.get("event") == "progress":
@@ -19,7 +19,15 @@ from localmodels import (
19
19
  stack_warm_store,
20
20
  suite,
21
21
  )
22
- from localmodels.budget import gib, holders, host_ram, placements, sharing_cards, unknown_services
22
+ from localmodels.budget import (
23
+ gib,
24
+ gpu_conflicts,
25
+ holders,
26
+ host_ram,
27
+ placements,
28
+ sharing_cards,
29
+ unknown_services,
30
+ )
23
31
  from localmodels.context_policy import AGENT, AgentPosture, cache_floor_bytes, posture_for
24
32
  from localmodels.estimator import (
25
33
  AGENT_VRAM_RESERVE_BYTES,
@@ -70,6 +78,10 @@ _FIRST_TIER_RAM = 60 * GIB # 64 GB of RAM reads about 62 GiB
70
78
  UNIFIED_MEMORY_ENV = "LOCALMODELS_UNIFIED_MEMORY"
71
79
 
72
80
 
81
+ class GpuOwnershipError(StackError):
82
+ """No eligible GPU can be shared because discovery could not verify ownership."""
83
+
84
+
73
85
  def add_arguments(parser: argparse._ActionsContainer) -> None:
74
86
  """``--unified-memory``, which ``stack plan``, ``install``, ``stack hardware`` and
75
87
  ``setup inspect`` share; LOCALMODELS_UNIFIED_MEMORY is its default."""
@@ -128,7 +140,7 @@ def decision_reserve(card_budget_bytes: int, options: StackOptions) -> int:
128
140
  def cards(facts: HostFacts, gpu: int | None = None, *, share_gpu: bool = False) -> list[int]:
129
141
  """Single-card choices by free memory; foreign GPU work needs explicit sharing."""
130
142
  if share_gpu and unknown_services(facts):
131
- raise StackError(
143
+ raise GpuOwnershipError(
132
144
  "GPU service owners unknown; explicit sharing cannot skip the unknown-service check"
133
145
  )
134
146
  if metal.device(facts) is not None:
@@ -145,9 +157,11 @@ def cards(facts: HostFacts, gpu: int | None = None, *, share_gpu: bool = False)
145
157
  f"no placeable GPU {gpu} here (usable cards: {found}; MIG-mode cards excluded)"
146
158
  )
147
159
  if share_gpu and gpu not in {g["index"] for g in sharing_cards(facts, 0)}:
148
- raise StackError("GPU process owners unknown; cannot share this GPU")
160
+ raise GpuOwnershipError("GPU process owners unknown; cannot share this GPU")
149
161
  return [gpu]
150
162
  allowed = {g["index"] for g in sharing_cards(facts, 0)} if share_gpu else set()
163
+ if share_gpu and singles and not allowed and gpu_conflicts(facts):
164
+ raise GpuOwnershipError("GPU process owners unknown; cannot share any GPU")
151
165
  free = [
152
166
  p.gpu_indices[0]
153
167
  for p in singles