@simplexai/localmodels-win32-x64 0.1.0-dev.60 → 0.1.0-dev.62

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 (79) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +78 -64
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/__main__.py +5 -3
  5. package/modules/localmodels/auth_proxy.py +185 -19
  6. package/modules/localmodels/catalog.json +363 -0
  7. package/modules/localmodels/catalog.py +1 -1
  8. package/modules/localmodels/catalog_add.py +5 -5
  9. package/modules/localmodels/catalog_license.py +2 -0
  10. package/modules/localmodels/catalog_recipes.py +2 -0
  11. package/modules/localmodels/cli_parser.py +6 -2
  12. package/modules/localmodels/context_policy.py +40 -4
  13. package/modules/localmodels/custom_hub_http.py +27 -104
  14. package/modules/localmodels/debug_mode.py +13 -0
  15. package/modules/localmodels/debug_stub_server.py +156 -1
  16. package/modules/localmodels/deploy.py +11 -2
  17. package/modules/localmodels/download-mirrors.json +12 -0
  18. package/modules/localmodels/engines-b12757-mix-ef2df21.json +26 -0
  19. package/modules/localmodels/engines-whisper-b5454.json +120 -1
  20. package/modules/localmodels/gateway_app_bifrost.py +14 -14
  21. package/modules/localmodels/gateway_bifrost.py +4 -1
  22. package/modules/localmodels/gateway_cli.py +14 -80
  23. package/modules/localmodels/gateway_server.py +88 -16
  24. package/modules/localmodels/gpu_specs.py +35 -1
  25. package/modules/localmodels/harness.py +1 -2
  26. package/modules/localmodels/hf_repo.py +12 -4
  27. package/modules/localmodels/install.py +4 -4
  28. package/modules/localmodels/library_jobs.py +4 -0
  29. package/modules/localmodels/library_serve.py +69 -13
  30. package/modules/localmodels/memcalc_load.py +9 -4
  31. package/modules/localmodels/npm_transport.py +4 -58
  32. package/modules/localmodels/recommend_cli.py +2 -1
  33. package/modules/localmodels/remote_ops.py +120 -713
  34. package/modules/localmodels/remote_ops_common.py +670 -0
  35. package/modules/localmodels/remote_ops_download.py +399 -381
  36. package/modules/localmodels/remote_ops_mirrors.py +27 -66
  37. package/modules/localmodels/remote_ops_prepare.py +43 -35
  38. package/modules/localmodels/remote_ops_ranges.py +102 -63
  39. package/modules/localmodels/remote_ops_redirect.py +393 -0
  40. package/modules/localmodels/remote_ops_remove.py +30 -22
  41. package/modules/localmodels/remote_ops_service.py +102 -95
  42. package/modules/localmodels/remote_ops_verify.py +94 -63
  43. package/modules/localmodels/runtime_cli.py +15 -5
  44. package/modules/localmodels/runtime_io.py +54 -1
  45. package/modules/localmodels/source_cli.py +136 -23
  46. package/modules/localmodels/speech-sv.txt +93 -0
  47. package/modules/localmodels/speech_admission.py +437 -0
  48. package/modules/localmodels/speech_catalog.py +170 -0
  49. package/modules/localmodels/speech_cli.py +273 -0
  50. package/modules/localmodels/speech_jobs.py +776 -0
  51. package/modules/localmodels/speech_model.py +404 -0
  52. package/modules/localmodels/speech_serve.py +287 -0
  53. package/modules/localmodels/speech_server.py +837 -0
  54. package/modules/localmodels/speech_state.py +697 -0
  55. package/modules/localmodels/speech_worker_sensevoice.py +255 -0
  56. package/modules/localmodels/speech_workers.py +783 -0
  57. package/modules/localmodels/stack.py +0 -33
  58. package/modules/localmodels/stack_auto.py +5 -3
  59. package/modules/localmodels/stack_aux_gpu.py +45 -4
  60. package/modules/localmodels/stack_capacity.py +77 -8
  61. package/modules/localmodels/stack_cli.py +16 -1
  62. package/modules/localmodels/stack_compose.py +1 -1
  63. package/modules/localmodels/stack_down.py +24 -1
  64. package/modules/localmodels/stack_hardware.py +57 -88
  65. package/modules/localmodels/stack_hardware_text.py +4 -59
  66. package/modules/localmodels/stack_memory.py +13 -3
  67. package/modules/localmodels/stack_suite.py +9 -10
  68. package/modules/localmodels/stack_summary.py +4 -4
  69. package/modules/localmodels/stack_view_llm.py +1 -1
  70. package/modules/localmodels/transport.py +4 -2
  71. package/modules/localmodels/tui_views.py +2 -2
  72. package/modules/{simplex_localmodels-0.1.0.dev60.dist-info → simplex_localmodels-0.1.0.dev62.dist-info}/METADATA +1 -1
  73. package/modules/{simplex_localmodels-0.1.0.dev60.dist-info → simplex_localmodels-0.1.0.dev62.dist-info}/RECORD +75 -61
  74. package/modules/{simplex_localmodels-0.1.0.dev60.dist-info → simplex_localmodels-0.1.0.dev62.dist-info}/licenses/NOTICE +9 -0
  75. package/package.json +1 -1
  76. package/tool.json +1 -1
  77. /package/modules/{simplex_localmodels-0.1.0.dev60.dist-info → simplex_localmodels-0.1.0.dev62.dist-info}/WHEEL +0 -0
  78. /package/modules/{simplex_localmodels-0.1.0.dev60.dist-info → simplex_localmodels-0.1.0.dev62.dist-info}/entry_points.txt +0 -0
  79. /package/modules/{simplex_localmodels-0.1.0.dev60.dist-info → simplex_localmodels-0.1.0.dev62.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -7,21 +7,20 @@ sizes well below the repository line cap. Strictly stdlib Python (no third-party
7
7
  from __future__ import annotations
8
8
 
9
9
  import hashlib
10
- import ipaddress
11
10
  import json
12
11
  import os
13
12
  import re
14
- import socket
15
- import urllib.error
16
13
  import urllib.parse
17
14
  import urllib.request
18
15
  from collections.abc import Mapping, Sequence
19
- from http.client import HTTPMessage
20
- from typing import IO, NamedTuple, cast
16
+ from typing import NamedTuple, cast
21
17
 
22
- from localmodels import region
18
+ from localmodels import region, remote_ops_redirect
23
19
  from localmodels.library_model import CustomHub, LibraryError
24
20
 
21
+ UnsafeRedirectError = remote_ops_redirect.UnsafeRedirectError
22
+ is_hf_mirror_host = remote_ops_redirect.is_hf_mirror_host
23
+
25
24
  HF_HOSTS = frozenset({"huggingface.co", "www.huggingface.co", "hf-mirror.com", "www.hf-mirror.com"})
26
25
  HF_OFFICIAL_HOSTS = frozenset({"huggingface.co", "www.huggingface.co"})
27
26
  HF_MIRROR_HOSTS = frozenset({"hf-mirror.com", "www.hf-mirror.com"})
@@ -37,7 +36,6 @@ MAX_JSON_RESPONSE_BYTES = 16 * 1024 * 1024
37
36
  _BEARER_SECRET_RE = re.compile(r"(?i)\bBearer\s+[^\s,;\"']+")
38
37
  _HF_TOKEN_RE = re.compile(r"\bhf_[A-Za-z0-9]+\b")
39
38
  _MS_TOKEN_RE = re.compile(r"\bms[-_][A-Za-z0-9_-]+\b")
40
- _BLOCKED_HOST_SUFFIXES = (".localhost", ".local", ".internal", ".home.arpa")
41
39
 
42
40
  # Internal unit-test hook ONLY; strictly False in production.
43
41
  _ALLOW_INSECURE_LOOPBACK_FOR_TESTS = False
@@ -105,8 +103,8 @@ def _configured_hf_endpoint_host(env: Mapping[str, str] | None = None) -> str |
105
103
  parsed = urllib.parse.urlsplit(raw)
106
104
  if parsed.scheme.lower() != "https" or not parsed.hostname:
107
105
  return None
108
- host = parsed.hostname.lower()
109
- return None if host in HF_MIRROR_HOSTS else host
106
+ host = remote_ops_redirect.normalize_host(parsed.hostname)
107
+ return None if not host or is_hf_mirror_host(host) else host
110
108
 
111
109
 
112
110
  def token_for_endpoint(
@@ -125,19 +123,19 @@ def token_for_endpoint(
125
123
  return None
126
124
  parts = urllib.parse.urlsplit(url)
127
125
  scheme = parts.scheme.lower()
128
- host = (parts.hostname or "").lower()
126
+ host = remote_ops_redirect.normalize_host(parts.hostname)
129
127
  if not host:
130
128
  return None
131
129
  if scheme != "https":
132
130
  if (
133
131
  _ALLOW_INSECURE_LOOPBACK_FOR_TESTS
134
132
  and scheme == "http"
135
- and host in ("127.0.0.1", "localhost")
133
+ and host in ("127.0.0.1", "localhost", "::1")
136
134
  ):
137
135
  return clean
138
136
  return None
139
137
  if hub == "huggingface":
140
- if host in HF_MIRROR_HOSTS:
138
+ if is_hf_mirror_host(host):
141
139
  return None
142
140
  if host in HF_OFFICIAL_HOSTS:
143
141
  return clean
@@ -146,103 +144,28 @@ def token_for_endpoint(
146
144
  return clean if host in MS_HOSTS else None
147
145
 
148
146
 
149
- def _effective_port(parts: urllib.parse.SplitResult) -> int:
150
- if parts.port is not None:
151
- return parts.port
152
- scheme = parts.scheme.lower()
153
- return 443 if scheme == "https" else 80 if scheme == "http" else 0
154
-
155
-
156
- def _origin(url: str) -> tuple[str, str, int]:
157
- parts = urllib.parse.urlsplit(url)
158
- return (
159
- parts.scheme.lower(),
160
- (parts.hostname or "").lower().rstrip("."),
161
- _effective_port(parts),
162
- )
163
-
164
-
165
- def _is_disallowed_ip(addr: ipaddress.IPv4Address | ipaddress.IPv6Address) -> bool:
166
- if isinstance(addr, ipaddress.IPv6Address) and addr.ipv4_mapped is not None:
167
- addr = addr.ipv4_mapped
168
- return (
169
- addr.is_loopback
170
- or addr.is_private
171
- or addr.is_link_local
172
- or addr.is_multicast
173
- or addr.is_unspecified
174
- or addr.is_reserved
175
- or not addr.is_global
176
- )
177
-
178
-
179
- def validate_redirect_target(url: str, *, allow_insecure_loopback: bool | None = None) -> None:
180
- """Enforce HTTPS and block loopback/private/link-local SSRF targets on redirects."""
147
+ def validate_redirect_target(
148
+ url: str,
149
+ *,
150
+ allow_insecure_loopback: bool | None = None,
151
+ source_url: str | None = None,
152
+ ) -> None:
153
+ """Enforce HTTPS and apply unified proxy/Fake-IP-aware anti-SSRF validation on redirects."""
181
154
  allow_test = (
182
155
  _ALLOW_INSECURE_LOOPBACK_FOR_TESTS
183
156
  if allow_insecure_loopback is None
184
157
  else allow_insecure_loopback
185
158
  )
186
- parts = urllib.parse.urlsplit(url)
187
- scheme = parts.scheme.lower()
188
- host = (parts.hostname or "").lower().rstrip(".")
189
- if scheme != "https" and not (allow_test and scheme == "http"):
190
- raise urllib.error.URLError(f"blocked redirect to non-HTTPS scheme {scheme!r}")
191
- if not host:
192
- raise urllib.error.URLError("blocked redirect with missing hostname")
193
- if allow_test:
194
- return
195
- if host == "localhost" or host.endswith(_BLOCKED_HOST_SUFFIXES):
196
- raise urllib.error.URLError(f"blocked redirect to local hostname {host!r}")
197
- try:
198
- literal = ipaddress.ip_address(host.split("%", 1)[0])
199
- except ValueError:
200
- literal = None
201
- if literal is not None:
202
- if _is_disallowed_ip(literal):
203
- raise urllib.error.URLError(f"blocked redirect to non-public IP {host!r}")
204
- return
205
- port = _effective_port(parts) or 443
206
- try:
207
- infos = socket.getaddrinfo(host, port, type=socket.SOCK_STREAM)
208
- except OSError as exc:
209
- raise urllib.error.URLError(
210
- f"blocked redirect: DNS resolution failed for {host!r}: {exc}"
211
- ) from None
212
- if not infos:
213
- raise urllib.error.URLError(f"blocked redirect: no addresses resolved for {host!r}")
214
- for info in infos:
215
- raw_ip = str(info[4][0]).split("%", 1)[0]
216
- try:
217
- resolved_ip = ipaddress.ip_address(raw_ip)
218
- except ValueError:
219
- raise urllib.error.URLError(f"blocked redirect: unparseable IP for {host!r}") from None
220
- if _is_disallowed_ip(resolved_ip):
221
- raise urllib.error.URLError(f"blocked redirect to non-public IP for {host!r}")
222
-
223
-
224
- class SafeRedirectHandler(urllib.request.HTTPRedirectHandler):
225
- """Enforce HTTPS + anti-SSRF on redirects and strip ``Authorization`` on any origin change."""
226
-
227
- def redirect_request(
228
- self,
229
- req: urllib.request.Request,
230
- fp: IO[bytes],
231
- code: int,
232
- msg: str,
233
- headers: HTTPMessage,
234
- newurl: str,
235
- ) -> urllib.request.Request | None:
236
- resolved = urllib.parse.urljoin(req.full_url, newurl)
237
- validate_redirect_target(resolved)
238
- new_req = super().redirect_request(req, fp, code, msg, headers, newurl)
239
- if new_req is None:
240
- return None
241
- if _origin(req.full_url) != _origin(resolved):
242
- for mapping in (new_req.headers, new_req.unredirected_hdrs):
243
- for key in [k for k in mapping if k.lower() == "authorization"]:
244
- del mapping[key]
245
- return new_req
159
+ remote_ops_redirect.validate_redirect_url(
160
+ url, source_url=source_url, allow_insecure_loopback=allow_test
161
+ )
162
+
163
+
164
+ class SafeRedirectHandler(remote_ops_redirect.SafeRedirectHandler):
165
+ """Enforce HTTPS + anti-SSRF on redirects and strip sensitive headers on origin change."""
166
+
167
+ def allow_loopback(self) -> bool:
168
+ return super().allow_loopback() or _ALLOW_INSECURE_LOOPBACK_FOR_TESTS
246
169
 
247
170
 
248
171
  def build_opener() -> urllib.request.OpenerDirector:
@@ -325,6 +325,12 @@ def _apply_simulated_occupancy(facts: dict[str, Any]) -> dict[str, Any]:
325
325
  return adjusted
326
326
 
327
327
 
328
+ def simulated_facts(config: DebugConfig | None = None) -> dict[str, Any]:
329
+ """Synthetic local host facts reflecting simulated VRAM sizing and loaded LLM occupancy."""
330
+ cfg = current() if config is None else config
331
+ return _apply_simulated_occupancy(_synthetic_facts(None, cfg.vram_gb or 24))
332
+
333
+
328
334
  def _sim_dir() -> Path:
329
335
  path = hosts.state_dir() / "simulate"
330
336
  path.mkdir(parents=True, exist_ok=True)
@@ -373,6 +379,9 @@ class SimulatedExecutor:
373
379
  binary.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")
374
380
  with contextlib.suppress(OSError):
375
381
  binary.chmod(0o755)
382
+ complete = directory / ".complete"
383
+ if not complete.exists():
384
+ complete.write_text("simulated\n", encoding="utf-8")
376
385
  return {"event": "result", "binary": str(binary), "reused": True}
377
386
 
378
387
  def _download_one(
@@ -397,6 +406,8 @@ class SimulatedExecutor:
397
406
  "done": size,
398
407
  "total": size,
399
408
  "bytes_per_s": max(1, size),
409
+ "source": "cache",
410
+ "connections": 0,
400
411
  }
401
412
  )
402
413
  return
@@ -416,6 +427,8 @@ class SimulatedExecutor:
416
427
  "done": done,
417
428
  "total": size,
418
429
  "bytes_per_s": rate,
430
+ "source": "cache",
431
+ "connections": 0,
419
432
  }
420
433
  )
421
434
  part.unlink(missing_ok=True)
@@ -4,12 +4,156 @@ from __future__ import annotations
4
4
 
5
5
  import argparse
6
6
  import json
7
+ import math
8
+ import re
7
9
  import signal
8
10
  import sys
9
11
  import time
12
+ import urllib.parse
13
+ from http import HTTPStatus
10
14
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
11
15
  from typing import Any
12
16
 
17
+ from localmodels import speech_worker_sensevoice
18
+
19
+ _SPEECH_SILENCE_RMS = 150.0
20
+ _BOUNDARY_RE = re.compile(r'boundary=(?:"([^"]+)"|([^;\s]+))', re.IGNORECASE)
21
+ _NAME_RE = re.compile(r'name="([^"]+)"')
22
+
23
+
24
+ def _speech_wav_metrics(wav_bytes: bytes) -> tuple[float, float]:
25
+ samples, _rate, duration = speech_worker_sensevoice.read_pcm16_wav(wav_bytes)
26
+ if not samples:
27
+ return duration, 0.0
28
+ mean_sq = sum(sample * sample for sample in samples) / len(samples)
29
+ return duration, math.sqrt(mean_sq) * 32768.0
30
+
31
+
32
+ def _extract_multipart_speech(content_type: str, body: bytes) -> tuple[str, bytes]:
33
+ match = _BOUNDARY_RE.search(content_type)
34
+ if match is None:
35
+ raise ValueError("missing multipart boundary")
36
+ boundary = (match.group(1) or match.group(2) or "").encode("latin-1")
37
+ lang = "auto"
38
+ wav_bytes = b""
39
+ for raw_part in body.split(b"--" + boundary)[1:]:
40
+ if raw_part.startswith(b"--"):
41
+ break
42
+ part = raw_part[2:] if raw_part.startswith(b"\r\n") else raw_part.lstrip(b"\n")
43
+ sep = b"\r\n\r\n" if b"\r\n\r\n" in part else b"\n\n"
44
+ if sep not in part:
45
+ continue
46
+ head, content = part.split(sep, 1)
47
+ if content.endswith(b"\r\n"):
48
+ content = content[:-2]
49
+ elif content.endswith(b"\n"):
50
+ content = content[:-1]
51
+ name_match = _NAME_RE.search(head.decode("latin-1", errors="replace"))
52
+ if name_match is None:
53
+ continue
54
+ field_name = name_match.group(1)
55
+ if field_name == "language":
56
+ lang = content.decode("utf-8", errors="replace").strip() or "auto"
57
+ elif field_name == "file":
58
+ wav_bytes = content
59
+ return lang, wav_bytes
60
+
61
+
62
+ def _make_speech_handler(served_model: str, engine_mode: str) -> type[BaseHTTPRequestHandler]:
63
+ engine_name = "whisper.cpp" if engine_mode == "speech-whisper" else "sherpa-onnx"
64
+
65
+ class SpeechHandler(BaseHTTPRequestHandler):
66
+ protocol_version = "HTTP/1.1"
67
+
68
+ def log_message(self, format: str, *args: object) -> None: # noqa: A002
69
+ _ = (format, args)
70
+
71
+ def _send(self, status: HTTPStatus, body: dict[str, Any]) -> None:
72
+ speech_worker_sensevoice.send_json_response(self, status, body)
73
+
74
+ def do_GET(self) -> None: # noqa: N802
75
+ path = urllib.parse.urlsplit(self.path).path
76
+ if path == "/health" or (engine_mode == "speech-whisper" and path == "/"):
77
+ self._send(
78
+ HTTPStatus.OK,
79
+ {"status": "ok", "engine": engine_name, "simulated": True},
80
+ )
81
+ return
82
+ self._send(HTTPStatus.NOT_FOUND, {"error": {"message": "not found"}})
83
+
84
+ def do_POST(self) -> None: # noqa: N802
85
+ parsed = urllib.parse.urlsplit(self.path)
86
+ length = int(self.headers.get("Content-Length") or "0")
87
+ raw = self.rfile.read(length) if length > 0 else b""
88
+ if engine_mode == "speech-whisper" and parsed.path == "/v1/audio/transcriptions":
89
+ try:
90
+ lang, wav_bytes = _extract_multipart_speech(
91
+ self.headers.get("Content-Type") or "", raw
92
+ )
93
+ duration, rms = _speech_wav_metrics(wav_bytes)
94
+ except ValueError as exc:
95
+ self._send(HTTPStatus.BAD_REQUEST, {"error": {"message": str(exc)}})
96
+ return
97
+ if rms < _SPEECH_SILENCE_RMS:
98
+ self._send(
99
+ HTTPStatus.OK,
100
+ {
101
+ "text": "",
102
+ "language": "" if lang == "auto" else lang,
103
+ "duration": round(duration, 3),
104
+ "segments": [],
105
+ },
106
+ )
107
+ return
108
+ resolved_lang = "en" if lang == "auto" else lang
109
+ text = f"Simulated {served_model} transcript ({resolved_lang})."
110
+ dur = round(duration, 3)
111
+ self._send(
112
+ HTTPStatus.OK,
113
+ {
114
+ "text": text,
115
+ "language": resolved_lang,
116
+ "duration": dur,
117
+ "segments": [{"start": 0.0, "end": dur, "text": text}],
118
+ },
119
+ )
120
+ return
121
+
122
+ if engine_mode == "speech-sensevoice" and parsed.path == "/transcribe":
123
+ query = urllib.parse.parse_qs(parsed.query)
124
+ lang = (query.get("language") or ["auto"])[0] or "auto"
125
+ try:
126
+ duration, rms = _speech_wav_metrics(raw)
127
+ except ValueError as exc:
128
+ self._send(HTTPStatus.BAD_REQUEST, {"error": {"message": str(exc)}})
129
+ return
130
+ dur = round(duration, 3)
131
+ if rms < _SPEECH_SILENCE_RMS:
132
+ self._send(
133
+ HTTPStatus.OK,
134
+ {
135
+ "text": "<|zh|><|NEUTRAL|><|nospeech|>",
136
+ "language": "",
137
+ "duration": dur,
138
+ "segments": [],
139
+ },
140
+ )
141
+ return
142
+ resolved_lang = lang if lang in speech_worker_sensevoice.KNOWN_LANGUAGES else "zh"
143
+ text = (
144
+ f"<|{resolved_lang}|><|NEUTRAL|><|Speech|><|withitn|>"
145
+ f"Simulated {served_model} transcript ({resolved_lang})."
146
+ )
147
+ self._send(
148
+ HTTPStatus.OK,
149
+ {"text": text, "language": "", "duration": dur, "segments": []},
150
+ )
151
+ return
152
+
153
+ self._send(HTTPStatus.NOT_FOUND, {"error": {"message": "not found"}})
154
+
155
+ return SpeechHandler
156
+
13
157
 
14
158
  def _last_user_text(messages: Any) -> str:
15
159
  if not isinstance(messages, list):
@@ -176,8 +320,19 @@ def main(argv: list[str] | None = None) -> int:
176
320
  parser.add_argument("--bind", default="127.0.0.1")
177
321
  parser.add_argument("--port", type=int, required=True)
178
322
  parser.add_argument("--model", required=True)
323
+ parser.add_argument(
324
+ "--mode",
325
+ choices=("llm", "speech-whisper", "speech-sensevoice"),
326
+ default="llm",
327
+ )
179
328
  args = parser.parse_args(argv)
180
- server = ThreadingHTTPServer((args.bind, args.port), _make_handler(args.model))
329
+ handler = (
330
+ _make_handler(args.model)
331
+ if args.mode == "llm"
332
+ else _make_speech_handler(args.model, args.mode)
333
+ )
334
+ server = ThreadingHTTPServer((args.bind, args.port), handler)
335
+ server.daemon_threads = True
181
336
  signal.signal(signal.SIGTERM, lambda *_a: sys.exit(0))
182
337
  try:
183
338
  server.serve_forever(poll_interval=0.2)
@@ -33,6 +33,7 @@ from localmodels.budget import (
33
33
  unknown_services,
34
34
  )
35
35
  from localmodels.context_policy import (
36
+ DEFAULT_UBATCH,
36
37
  RUNTIME_OVERHEAD_BYTES,
37
38
  AgentPosture,
38
39
  LaunchPlan,
@@ -80,6 +81,7 @@ from localmodels.transport import Executor
80
81
 
81
82
  DEFAULT_BASE_DIR = "~/.local/share/localmodels"
82
83
  DEFAULT_PORT = 18100
84
+ METAL_DEFAULT_ENGINE = "b12757-mix-ef2df21"
83
85
  HF_API = region.HF_API
84
86
 
85
87
 
@@ -384,7 +386,7 @@ def build_plan(
384
386
  argv += CPU_ARGS
385
387
  elif placement.backend == "metal":
386
388
  argv += ["--device", "MTL0"]
387
- engine = _engine_plan(facts, options, entry, placement.backend, warnings, argv)
389
+ engine = engine_plan(facts, options, entry, placement.backend, warnings, argv)
388
390
  argv[0] = engine["binary"]
389
391
 
390
392
  gpus = {g["index"]: g for g in facts.get("gpus") or []}
@@ -467,6 +469,7 @@ def build_plan(
467
469
  "mtp_draft_depth": decision.mtp_draft_depth,
468
470
  "posture": "agent",
469
471
  "vram_bytes": decision.vram_bytes,
472
+ **({"ubatch": decision.ubatch} if decision.ubatch != DEFAULT_UBATCH else {}),
470
473
  }
471
474
  if options.agent is not None
472
475
  else {}
@@ -536,7 +539,7 @@ def _placement_warnings(placement: Placement, facts: HostFacts) -> list[str]:
536
539
  return warnings
537
540
 
538
541
 
539
- def _engine_plan(
542
+ def engine_plan(
540
543
  facts: HostFacts,
541
544
  options: PlanOptions,
542
545
  entry: cat.CatalogEntry,
@@ -581,6 +584,12 @@ def _engine_plan(
581
584
  if lock_tag is None:
582
585
  build = select_engine_build(facts, backend)
583
586
  lock_tag = entry.min_engine if cat.engine_too_old(entry, build["tag"]) else None
587
+ metal_num = cat.build_number(METAL_DEFAULT_ENGINE) or 0
588
+ if backend == "metal" and (
589
+ lock_tag is None
590
+ or (lock_tag.startswith("b") and (cat.build_number(lock_tag) or 0) < metal_num)
591
+ ):
592
+ lock_tag = METAL_DEFAULT_ENGINE
584
593
  if lock_tag is not None:
585
594
  lock = engine_lock_path(lock_tag)
586
595
  if not lock.is_file():
@@ -50,10 +50,22 @@
50
50
  "repo": "XHToken/Spark-X2.6-4B-GGUF",
51
51
  "path": "Spark-X2.6-4B-Q8_0.gguf"
52
52
  },
53
+ "12ca1a2ae7ecf3e0019ef2822307ee0b5cadc9196569e379b4c4026f8205276d": {
54
+ "repo": "aistoy/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09",
55
+ "path": "model.int8.onnx"
56
+ },
57
+ "f449eb28dc567533d7fa59be34e2abca8784f771850c78a47fb731a31429a1dc": {
58
+ "repo": "aistoy/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09",
59
+ "path": "tokens.txt"
60
+ },
53
61
  "a43c7c9b11a4c1517e5bf95151960e1621d1b72f7a493364b01e386cf1aaa1d3": {
54
62
  "repo": "gpustack/bge-reranker-v2-m3-GGUF",
55
63
  "path": "bge-reranker-v2-m3-Q8_0.gguf"
56
64
  },
65
+ "394221709cd5ad1f40c46e6031ca61bce88931e6e088c188294c6d5a55ffa7e2": {
66
+ "repo": "iceCream2025/whisper.cpp",
67
+ "path": "ggml-large-v3-turbo-q5_0.bin"
68
+ },
57
69
  "246d67d45f5b0c7447ca0ce0bdb8b46b8a47b593c5068635dc16422c051d7be9": {
58
70
  "repo": "inclusionAI/Ling-3.0-tiny-GGUF",
59
71
  "path": "Ling-3.0-tiny-Q4_K_M.gguf"
@@ -0,0 +1,26 @@
1
+ {
2
+ "schema": "localmodels.engine-lock/v1",
3
+ "tag": "b12757-mix-ef2df21",
4
+ "commit": "9b3ec1144de6b33c2f1589e81ae49f51b310a9ba",
5
+ "source": "https://github.com/unslothai/llama.cpp/releases/tag/b12757-mix-ef2df21",
6
+ "note": "Apple Silicon Metal build from unslothai/llama.cpp b12757-mix-ef2df21 (upstream llama.cpp b12757 + Unsloth looped Inkling 2 & DSpark patches, published 2026-11-26, verified byte-for-byte against GitHub release API and llama-prebuilt-sha256.json). Includes late-Nov Metal kernel speedups (+27.3% decode, +22-32% prefill, -711 MiB RSS on Inkling 2 Mini vs b12588-mix-c0c3de8; +61% 1K prefill and +5-7% decode on Spark-X2.6-4B vs b11370) while supporting both standard llama.cpp GGUFs and looped Inkling 2 Mini architectures in one Metal binary. Unpacks with a single top directory llama-b12757-mix-ef2df21/ stripped by remote_ops.unpack.",
7
+ "builds": [
8
+ {
9
+ "platform": "darwin",
10
+ "arch": "arm64",
11
+ "backend": "metal",
12
+ "assets": [
13
+ {
14
+ "name": "llama-b12757-mix-ef2df21-bin-macos-arm64.tar.gz",
15
+ "url": "https://github.com/unslothai/llama.cpp/releases/download/b12757-mix-ef2df21/llama-b12757-mix-ef2df21-bin-macos-arm64.tar.gz",
16
+ "sha256": "1982808b8ab586c55eb406028a8543f7460b8bfe89708c8d1c6c5e7da78a06f0",
17
+ "size_bytes": 13462270,
18
+ "npm_copy": {
19
+ "package": "@simplexai/engine-llama-b12757-mix-ef2df21-bin-macos-arm64",
20
+ "version": "0.0.0-sha256-1982808b8ab586c5"
21
+ }
22
+ }
23
+ ]
24
+ }
25
+ ]
26
+ }
@@ -3,8 +3,36 @@
3
3
  "tag": "whisper-b5454",
4
4
  "commit": "d1be6fde11ac6e0407606b4e42fe72d34add8037",
5
5
  "source": "https://github.com/ggml-org/whisper.cpp/releases/tag/b5454",
6
- "note": "whisper.cpp release build b5454, the same commit as v1.9.5 (whose tag has no assets), read 2026-10-21. CPU only, RUNPATH $ORIGIN; binaries import at most GLIBC_2.34. whisper-server has no --version; whisper-cli --version prints the release version, 1.9.5. Like upstream llama.cpp's Linux builds, it links GCC's OpenMP runtime (libgomp.so.1, Debian package libgomp1), which minimal images lack (readelf NEEDED, 2026-10-23); a plan on such a host stops instead of installing it.",
6
+ "note": "whisper.cpp release build b5454, the same commit as v1.9.5 (whose tag has no assets). Linux CPU and Windows x64 CPU/CUDA digests are from the GitHub release API (Linux x64 read 2026-10-21; Linux arm64 and Windows x64 read 2026-11-26). Upstream Linux CPU tarballs (ubuntu-22.04) use RUNPATH $ORIGIN, import at most GLIBC_2.34, and link libgomp.so.1 (Debian package libgomp1), which minimal images lack. Linux x64 CUDA 12.8 (ubuntu22.04-r1, built 2026-11-27 via scripts/build_whisper_engine.py in pinned nvidia/cuda:12.8.2-devel-ubuntu22.04) bundles libgomp.so.1 with RUNPATH $ORIGIN, imports at most GLIBC_2.34 / GLIBCXX_3.4.30 / CXXABI_1.3.13, targets CUDA archs 50-virtual..120a-real, pairs with its CUDA 12.8.2 cudart companion, and is hosted on the public CloudFront CDN with provenance JSON. macOS arm64 Metal (embedded Metal shaders, runtime -ng CPU fallback) and macOS x64 CPU tarballs (built 2026-11-27 on Apple Silicon Xcode 27.2 targeting macOS 13.0 with @loader_path rpath and system frameworks only) are hosted on the same CloudFront CDN alongside their provenance JSONs. Windows x64 zips unpack a single Release/ top directory stripped by remote_ops.unpack to yield whisper-server.exe beside its ggml/whisper/SDL2 DLLs; the CUDA 12.4 zip is self-contained and already bundles cudart64_12.dll, cublas64_12.dll and cublasLt64_12.dll. whisper-server has no --version; whisper-cli --version prints 1.9.5. Linux Vulkan awaits a container-verified Ubuntu 22.04 glslc + spirv-headers toolchain.",
7
7
  "builds": [
8
+ {
9
+ "platform": "linux",
10
+ "arch": "x64",
11
+ "backend": "cuda",
12
+ "min_cuda": "12.8",
13
+ "min_glibc": "2.34",
14
+ "variant": "ubuntu22.04-r1",
15
+ "binary": "whisper-server",
16
+ "provenance": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/whisper/b5454/whisper-b5454-bin-ubuntu22.04-r1-cuda-12.8-x64.provenance.json",
17
+ "assets": [
18
+ {
19
+ "name": "whisper-b5454-bin-ubuntu22.04-r1-cuda-12.8-x64.tar.gz",
20
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/whisper/b5454/whisper-b5454-bin-ubuntu22.04-r1-cuda-12.8-x64.tar.gz",
21
+ "sha256": "4848c97a7ef34cd0a42a132dbbf6f21a538701f71469f9c861657ff6ed32f314",
22
+ "size_bytes": 162307029,
23
+ "npm_copy": {
24
+ "package": "@simplexai/engine-whisper-b5454-bin-ubuntu22.04-r1-cuda-12.8-x64",
25
+ "version": "0.0.0-sha256-4848c97a7ef34cd0"
26
+ }
27
+ },
28
+ {
29
+ "name": "cudart-whisper-b5454-bin-ubuntu22.04-r1-cuda-12.8-x64.tar.gz",
30
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/whisper/b5454/cudart-whisper-b5454-bin-ubuntu22.04-r1-cuda-12.8-x64.tar.gz",
31
+ "sha256": "70f571e233c8a89f9fa176bb6861015b5827778b241bf61de55affb6eb270e86",
32
+ "size_bytes": 593656061
33
+ }
34
+ ]
35
+ },
8
36
  {
9
37
  "platform": "linux",
10
38
  "arch": "x64",
@@ -26,6 +54,97 @@
26
54
  }
27
55
  }
28
56
  ]
57
+ },
58
+ {
59
+ "platform": "linux",
60
+ "arch": "arm64",
61
+ "backend": "cpu",
62
+ "min_glibc": "2.34",
63
+ "binary": "whisper-server",
64
+ "host_libraries": {
65
+ "libgomp.so.1": "libgomp1"
66
+ },
67
+ "assets": [
68
+ {
69
+ "name": "whisper-bin-ubuntu-arm64.tar.gz",
70
+ "url": "https://github.com/ggml-org/whisper.cpp/releases/download/b5454/whisper-bin-ubuntu-arm64.tar.gz",
71
+ "sha256": "6b95ebfc60447df48e70ef00a73bdc3f41679ed2d01ef465827206a2ff325149",
72
+ "size_bytes": 4608377,
73
+ "npm_copy": {
74
+ "package": "@simplexai/engine-whisper-bin-ubuntu-arm64",
75
+ "version": "0.0.0-sha256-6b95ebfc60447df4"
76
+ }
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ "platform": "darwin",
82
+ "arch": "arm64",
83
+ "backend": "metal",
84
+ "binary": "whisper-server",
85
+ "assets": [
86
+ {
87
+ "name": "whisper-b5454-bin-macos-arm64.tar.gz",
88
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/whisper/b5454/whisper-b5454-bin-macos-arm64.tar.gz",
89
+ "sha256": "cd70f1be3676db1280775df08294340cb36e625c8370385ca8c2acac7fe0e6d1",
90
+ "size_bytes": 3372342,
91
+ "npm_copy": {
92
+ "package": "@simplexai/engine-whisper-b5454-bin-macos-arm64",
93
+ "version": "0.0.0-sha256-cd70f1be3676db12"
94
+ }
95
+ }
96
+ ]
97
+ },
98
+ {
99
+ "platform": "darwin",
100
+ "arch": "x64",
101
+ "backend": "cpu",
102
+ "binary": "whisper-server",
103
+ "assets": [
104
+ {
105
+ "name": "whisper-b5454-bin-macos-x64.tar.gz",
106
+ "url": "https://d2ikbbcl3j6jz9.cloudfront.net/cli/localmodels/engines/whisper/b5454/whisper-b5454-bin-macos-x64.tar.gz",
107
+ "sha256": "445c8f42ac3326221c5c1aa990a49be9590ea33d59b6ffdeadc44d0c5303d5d2",
108
+ "size_bytes": 2623802,
109
+ "npm_copy": {
110
+ "package": "@simplexai/engine-whisper-b5454-bin-macos-x64",
111
+ "version": "0.0.0-sha256-445c8f42ac332622"
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ "platform": "win32",
118
+ "arch": "x64",
119
+ "backend": "cuda",
120
+ "min_cuda": "12.4",
121
+ "binary": "whisper-server.exe",
122
+ "assets": [
123
+ {
124
+ "name": "whisper-bin-win-cuda-12.4.0-x64.zip",
125
+ "url": "https://github.com/ggml-org/whisper.cpp/releases/download/b5454/whisper-bin-win-cuda-12.4.0-x64.zip",
126
+ "sha256": "afef0b881c500958921c3f5523b50e59ee2ec9b6f5cbd25b324c51ed308a957a",
127
+ "size_bytes": 684913404
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "platform": "win32",
133
+ "arch": "x64",
134
+ "backend": "cpu",
135
+ "binary": "whisper-server.exe",
136
+ "assets": [
137
+ {
138
+ "name": "whisper-bin-x64.zip",
139
+ "url": "https://github.com/ggml-org/whisper.cpp/releases/download/b5454/whisper-bin-x64.zip",
140
+ "sha256": "6ba69e3482d7826214f90a6a9c84ca07782aec1e1d0c6a7c30c994fd5d816ccb",
141
+ "size_bytes": 8928640,
142
+ "npm_copy": {
143
+ "package": "@simplexai/engine-whisper-bin-x64",
144
+ "version": "0.0.0-sha256-6ba69e3482d78262"
145
+ }
146
+ }
147
+ ]
29
148
  }
30
149
  ],
31
150
  "version": "1.9.5"