@simplexai/localmodels-darwin-x64 0.1.0-dev.107 → 0.1.0-dev.108
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.
- package/README.md +1 -1
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +34 -31
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/catalog.json +217 -10
- package/modules/localmodels/catalog.py +11 -1
- package/modules/localmodels/catalog_recipes.py +15 -0
- package/modules/localmodels/engine_adapters/llama_cpp.py +11 -5
- package/modules/localmodels/engine_adapters/strata_poly.py +1 -1
- package/modules/localmodels/engines-b12973.json +248 -0
- package/modules/localmodels/library_cli.py +68 -1
- package/modules/localmodels/library_elastic.py +1 -1
- package/modules/localmodels/library_pricing.py +1 -2
- package/modules/localmodels/library_unload.py +274 -0
- package/modules/localmodels/probe.py +98 -7
- package/modules/localmodels/service_roots.py +148 -0
- package/modules/localmodels/service_upgrade.py +46 -1
- package/modules/localmodels/services_cli.py +8 -28
- package/modules/localmodels/speech_workers.py +4 -4
- package/modules/localmodels/stack_args.py +11 -4
- package/modules/localmodels/stack_down.py +368 -42
- package/modules/localmodels/stack_memory.py +1 -1
- package/modules/localmodels/stack_preflight.py +2 -2
- package/modules/localmodels/stack_view_llm.py +2 -2
- package/modules/localmodels/tts_backend_speechcpp.py +2 -2
- package/modules/localmodels/tts_workers.py +3 -3
- package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/RECORD +30 -27
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/licenses/LICENSE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev107.dist-info → simplex_localmodels-0.1.0.dev108.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "localmodels.engine-lock/v1",
|
|
3
|
+
"tag": "b12973",
|
|
4
|
+
"commit": "59b716523f1ba73be12a9f0f51eb4c072b7fa523",
|
|
5
|
+
"source": "https://github.com/ggml-org/llama.cpp/releases/tag/b12973",
|
|
6
|
+
"note": "Release asset digests from the GitHub release API (ggml-org/llama.cpp b12973, published 2026-12-03T23:47:15Z, includes PR #33626 qwen4exp/qwen4_moe architecture and --ple/--lazy-mode engram support). Required for Qwen4-35B-A3B (qwen4exp with per_layer_token_embd n-gram table, needs llama.cpp >= b12969). Linux x64 CPU tarball verified locally on 2026-12-04: highest GLIBC 2.34, libggml-base.so.1.1.1 links libgomp.so.1, llama-server --version reports build 12973 commit 59b716523, and --help lists every SERVER_FLAGS option plus --load-mode, --lazy-mode, -ot, --spec-type draft-mtp, --mmproj, and --ple. Upstream Ubuntu CUDA 12.8/13.5, arm64, and ROCm builds compile in Ubuntu 24.04 containers (min_glibc 2.38, libgomp.so.1); an Ubuntu 22.04 CUDA rebuild and npm mirror copies are deferred to the engine unification follow-up. Windows CUDA 12.4 shares the exact cudart-llama-bin-win-cuda-12.4-x64.zip digest pinned in engines.json.",
|
|
7
|
+
"builds": [
|
|
8
|
+
{
|
|
9
|
+
"platform": "linux",
|
|
10
|
+
"arch": "x64",
|
|
11
|
+
"backend": "cuda",
|
|
12
|
+
"min_cuda": "12.8",
|
|
13
|
+
"min_glibc": "2.38",
|
|
14
|
+
"host_libraries": {
|
|
15
|
+
"libgomp.so.1": "libgomp1"
|
|
16
|
+
},
|
|
17
|
+
"assets": [
|
|
18
|
+
{
|
|
19
|
+
"name": "llama-b12973-bin-ubuntu-cuda-12.8-x64.tar.gz",
|
|
20
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-cuda-12.8-x64.tar.gz",
|
|
21
|
+
"sha256": "82b3f9079add7d141315bb194bd8b2e875b8c00f1960f9e16227be2a38733f36",
|
|
22
|
+
"size_bytes": 229761544
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "cudart-llama-b12973-bin-ubuntu-cuda-12.8-x64.tar.gz",
|
|
26
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/cudart-llama-b12973-bin-ubuntu-cuda-12.8-x64.tar.gz",
|
|
27
|
+
"sha256": "3e17b4e70e317ae2074fa100e1483526e9666b557eea2b7ec156a0f5d231738b",
|
|
28
|
+
"size_bytes": 594373582
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"platform": "linux",
|
|
34
|
+
"arch": "x64",
|
|
35
|
+
"backend": "cuda",
|
|
36
|
+
"min_cuda": "13.5",
|
|
37
|
+
"min_glibc": "2.38",
|
|
38
|
+
"host_libraries": {
|
|
39
|
+
"libgomp.so.1": "libgomp1"
|
|
40
|
+
},
|
|
41
|
+
"assets": [
|
|
42
|
+
{
|
|
43
|
+
"name": "llama-b12973-bin-ubuntu-cuda-13.5-x64.tar.gz",
|
|
44
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-cuda-13.5-x64.tar.gz",
|
|
45
|
+
"sha256": "095fc3cc21193ad7a809d6d45c0c74d9a37244975c011e7e691ef6fa57b084fa",
|
|
46
|
+
"size_bytes": 233674501
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "cudart-llama-b12973-bin-ubuntu-cuda-13.5-x64.tar.gz",
|
|
50
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/cudart-llama-b12973-bin-ubuntu-cuda-13.5-x64.tar.gz",
|
|
51
|
+
"sha256": "49d8fbbb37ac0f1c1ce8e3a167f3287b8c89f12940d3fc7b22ac827989ae9f14",
|
|
52
|
+
"size_bytes": 444078976
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"platform": "linux",
|
|
58
|
+
"arch": "arm64",
|
|
59
|
+
"backend": "cuda",
|
|
60
|
+
"min_cuda": "13.5",
|
|
61
|
+
"min_glibc": "2.38",
|
|
62
|
+
"host_libraries": {
|
|
63
|
+
"libgomp.so.1": "libgomp1"
|
|
64
|
+
},
|
|
65
|
+
"assets": [
|
|
66
|
+
{
|
|
67
|
+
"name": "llama-b12973-bin-ubuntu-cuda-13.5-arm64.tar.gz",
|
|
68
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-cuda-13.5-arm64.tar.gz",
|
|
69
|
+
"sha256": "ceaf333fde37ab7c14a4a7a7f99f4a3b8505f2f1e5af9545443828b4fa19364e",
|
|
70
|
+
"size_bytes": 228559452
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "cudart-llama-b12973-bin-ubuntu-cuda-13.5-arm64.tar.gz",
|
|
74
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/cudart-llama-b12973-bin-ubuntu-cuda-13.5-arm64.tar.gz",
|
|
75
|
+
"sha256": "1b452a16d6629ca63438e91bd00a5c72f24e81279f76fde81e2cd64f92fb8d7b",
|
|
76
|
+
"size_bytes": 559873929
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"platform": "linux",
|
|
82
|
+
"arch": "x64",
|
|
83
|
+
"backend": "vulkan",
|
|
84
|
+
"min_glibc": "2.34",
|
|
85
|
+
"host_libraries": {
|
|
86
|
+
"libgomp.so.1": "libgomp1"
|
|
87
|
+
},
|
|
88
|
+
"assets": [
|
|
89
|
+
{
|
|
90
|
+
"name": "llama-b12973-bin-ubuntu-vulkan-x64.tar.gz",
|
|
91
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-vulkan-x64.tar.gz",
|
|
92
|
+
"sha256": "aadbc4fdc0ea7fea4ed613768fa225f8fe2742b6d85c3cfb8363a8748b2297fa",
|
|
93
|
+
"size_bytes": 36501538
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"platform": "linux",
|
|
99
|
+
"arch": "arm64",
|
|
100
|
+
"backend": "vulkan",
|
|
101
|
+
"min_glibc": "2.38",
|
|
102
|
+
"host_libraries": {
|
|
103
|
+
"libgomp.so.1": "libgomp1"
|
|
104
|
+
},
|
|
105
|
+
"assets": [
|
|
106
|
+
{
|
|
107
|
+
"name": "llama-b12973-bin-ubuntu-vulkan-arm64.tar.gz",
|
|
108
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-vulkan-arm64.tar.gz",
|
|
109
|
+
"sha256": "8ec919d3c2cb9ea3d4e9809d5121db68707c516f265f5a99f7ed91eab38bafcb",
|
|
110
|
+
"size_bytes": 29300770
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"platform": "linux",
|
|
116
|
+
"arch": "x64",
|
|
117
|
+
"backend": "rocm",
|
|
118
|
+
"min_glibc": "2.38",
|
|
119
|
+
"host_libraries": {
|
|
120
|
+
"libgomp.so.1": "libgomp1"
|
|
121
|
+
},
|
|
122
|
+
"assets": [
|
|
123
|
+
{
|
|
124
|
+
"name": "llama-b12973-bin-ubuntu-rocm-10.0-x64.tar.gz",
|
|
125
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-rocm-10.0-x64.tar.gz",
|
|
126
|
+
"sha256": "216f580f73752de2696061f605bb90b8f576b78abbbeb2890f10db3b713d610b",
|
|
127
|
+
"size_bytes": 305990859
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"platform": "linux",
|
|
133
|
+
"arch": "x64",
|
|
134
|
+
"backend": "cpu",
|
|
135
|
+
"min_glibc": "2.34",
|
|
136
|
+
"host_libraries": {
|
|
137
|
+
"libgomp.so.1": "libgomp1"
|
|
138
|
+
},
|
|
139
|
+
"assets": [
|
|
140
|
+
{
|
|
141
|
+
"name": "llama-b12973-bin-ubuntu-x64.tar.gz",
|
|
142
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-x64.tar.gz",
|
|
143
|
+
"sha256": "ab43171d0d7abe93d89c5eb87f4e0979ed1f576a151e60ffda3562d6fd347b04",
|
|
144
|
+
"size_bytes": 23770836
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"platform": "linux",
|
|
150
|
+
"arch": "arm64",
|
|
151
|
+
"backend": "cpu",
|
|
152
|
+
"min_glibc": "2.38",
|
|
153
|
+
"host_libraries": {
|
|
154
|
+
"libgomp.so.1": "libgomp1"
|
|
155
|
+
},
|
|
156
|
+
"assets": [
|
|
157
|
+
{
|
|
158
|
+
"name": "llama-b12973-bin-ubuntu-arm64.tar.gz",
|
|
159
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-ubuntu-arm64.tar.gz",
|
|
160
|
+
"sha256": "465f5a667489d0f5505cafe40157e19b85d41cc1850cf3cac4d8e5189933d265",
|
|
161
|
+
"size_bytes": 19311484
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"platform": "darwin",
|
|
167
|
+
"arch": "arm64",
|
|
168
|
+
"backend": "metal",
|
|
169
|
+
"assets": [
|
|
170
|
+
{
|
|
171
|
+
"name": "llama-b12973-bin-macos-arm64.tar.gz",
|
|
172
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-macos-arm64.tar.gz",
|
|
173
|
+
"sha256": "532a020383a8f6a6431a5ea84bf8c65e5cfa8e6be6a89d1f6ef40d5a283b366e",
|
|
174
|
+
"size_bytes": 17065928
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"platform": "darwin",
|
|
180
|
+
"arch": "x64",
|
|
181
|
+
"backend": "cpu",
|
|
182
|
+
"assets": [
|
|
183
|
+
{
|
|
184
|
+
"name": "llama-b12973-bin-macos-x64.tar.gz",
|
|
185
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-macos-x64.tar.gz",
|
|
186
|
+
"sha256": "2a80b40f2e5aab0fea20d3bd06e9ab3cae88188d15dcc2d5957609b08b2365b3",
|
|
187
|
+
"size_bytes": 12778121
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"platform": "win32",
|
|
193
|
+
"arch": "x64",
|
|
194
|
+
"backend": "cuda",
|
|
195
|
+
"min_cuda": "12.4",
|
|
196
|
+
"binary": "llama-server.exe",
|
|
197
|
+
"assets": [
|
|
198
|
+
{
|
|
199
|
+
"name": "llama-b12973-bin-win-cuda-12.4-x64.zip",
|
|
200
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-win-cuda-12.4-x64.zip",
|
|
201
|
+
"sha256": "a66111df88e53aef4cfb17309be34b5f368b8a072168efbf8764b49a7dff7aa2",
|
|
202
|
+
"size_bytes": 375547479
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"name": "cudart-llama-bin-win-cuda-12.4-x64.zip",
|
|
206
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/cudart-llama-bin-win-cuda-12.4-x64.zip",
|
|
207
|
+
"sha256": "8c79a9b226de4b3cacfd1f83d24f962d0773be79f1e7b75c6af4ded7e32ae1d6",
|
|
208
|
+
"size_bytes": 391443627
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"platform": "win32",
|
|
214
|
+
"arch": "x64",
|
|
215
|
+
"backend": "cuda",
|
|
216
|
+
"min_cuda": "13.5",
|
|
217
|
+
"binary": "llama-server.exe",
|
|
218
|
+
"assets": [
|
|
219
|
+
{
|
|
220
|
+
"name": "llama-b12973-bin-win-cuda-13.5-x64.zip",
|
|
221
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-win-cuda-13.5-x64.zip",
|
|
222
|
+
"sha256": "dc5f735d0804ce17ceae5bca3cf6becb22f165df28620ed6f343432ea2f67226",
|
|
223
|
+
"size_bytes": 234761071
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"name": "cudart-llama-bin-win-cuda-13.5-x64.zip",
|
|
227
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/cudart-llama-bin-win-cuda-13.5-x64.zip",
|
|
228
|
+
"sha256": "c2bf4cc202bfbaaa7a0b75f5082457c3811326947bb216059b72839d844e9cba",
|
|
229
|
+
"size_bytes": 426314199
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"platform": "win32",
|
|
235
|
+
"arch": "x64",
|
|
236
|
+
"backend": "cpu",
|
|
237
|
+
"binary": "llama-server.exe",
|
|
238
|
+
"assets": [
|
|
239
|
+
{
|
|
240
|
+
"name": "llama-b12973-bin-win-cpu-x64.zip",
|
|
241
|
+
"url": "https://github.com/ggml-org/llama.cpp/releases/download/b12973/llama-b12973-bin-win-cpu-x64.zip",
|
|
242
|
+
"sha256": "617e10f8d9ad0029660fa2507c330e2141f98fb29c8712af6f4e4af7a2b3785f",
|
|
243
|
+
"size_bytes": 25598826
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
}
|
|
@@ -147,8 +147,36 @@ def add_parser(sub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None
|
|
|
147
147
|
"record verification status, and stop the server so active models and routing stay untouched.",
|
|
148
148
|
examples=[("%(prog)s custom.hf.owner--repo:Q4_K_M --ctx 4096 --jsonl", "")],
|
|
149
149
|
)
|
|
150
|
+
unload_cmd = verbs.add_parser("unload", help="stop a model's server; its weights stay")
|
|
151
|
+
unload_cmd.add_argument(
|
|
152
|
+
"model",
|
|
153
|
+
nargs="?",
|
|
154
|
+
default=None,
|
|
155
|
+
metavar="MODEL",
|
|
156
|
+
help="a library model id, CATALOG_ID:QUANT (omit when using --all)",
|
|
157
|
+
)
|
|
158
|
+
unload_cmd.add_argument(
|
|
159
|
+
"--all",
|
|
160
|
+
action="store_true",
|
|
161
|
+
help="unload every loaded or active library model and cancel active library jobs",
|
|
162
|
+
)
|
|
163
|
+
_base(unload_cmd)
|
|
164
|
+
unload_cmd.add_argument(
|
|
165
|
+
"--json",
|
|
166
|
+
action="store_true",
|
|
167
|
+
help="print one result as JSON (single-model unload always prints JSON)",
|
|
168
|
+
)
|
|
169
|
+
cli_help.document(
|
|
170
|
+
unload_cmd,
|
|
171
|
+
"Stop a model's server (or every active library model with --all); its weights stay. "
|
|
172
|
+
"Single-model unload prints one localmodels.library-event/v1 JSON object; --all prints "
|
|
173
|
+
"localmodels.library-unload-all/v1 with --json or a concise text summary otherwise.",
|
|
174
|
+
examples=[
|
|
175
|
+
("%(prog)s qwen3.8-27b-iq3s:UD-IQ3_S --json", ""),
|
|
176
|
+
("%(prog)s --all --json", "unload every active or loaded library model"),
|
|
177
|
+
],
|
|
178
|
+
)
|
|
150
179
|
for verb, text, note in (
|
|
151
|
-
("unload", "stop a model's server; its weights stay", "stop the server"),
|
|
152
180
|
("remove", "delete a model's weights (unloads it first)", "keeps files others use"),
|
|
153
181
|
("cancel", "stop a running download and delete its files", "the download exits 130"),
|
|
154
182
|
):
|
|
@@ -337,12 +365,51 @@ def _status(args: argparse.Namespace) -> int:
|
|
|
337
365
|
return 0
|
|
338
366
|
|
|
339
367
|
|
|
368
|
+
def _unload_all(args: argparse.Namespace) -> int:
|
|
369
|
+
from localmodels import library_unload
|
|
370
|
+
|
|
371
|
+
as_json = bool(getattr(args, "json", False))
|
|
372
|
+
try:
|
|
373
|
+
report = library_unload.unload_all(args.base_dir)
|
|
374
|
+
except KeyboardInterrupt:
|
|
375
|
+
error = LibraryError("CANCELLED", "the unload was interrupted")
|
|
376
|
+
if as_json:
|
|
377
|
+
emit_final(error_doc(error), jsonl=False)
|
|
378
|
+
else:
|
|
379
|
+
print("error: library unload --all was interrupted", file=sys.stderr)
|
|
380
|
+
return error.exit_code
|
|
381
|
+
except Exception as exc: # noqa: BLE001 - consistent CLI error handling
|
|
382
|
+
if as_json:
|
|
383
|
+
emit_final(error_doc(LibraryError(FALLBACK["unload"], str(exc))), jsonl=False)
|
|
384
|
+
else:
|
|
385
|
+
print(f"error: library unload --all failed: {exc}", file=sys.stderr)
|
|
386
|
+
return EXIT_FAILED
|
|
387
|
+
if as_json:
|
|
388
|
+
print(json.dumps(report, ensure_ascii=False, indent=1))
|
|
389
|
+
return 0 if report["ok"] else EXIT_FAILED
|
|
390
|
+
return library_unload.print_report(report)
|
|
391
|
+
|
|
392
|
+
|
|
340
393
|
def cli(args: argparse.Namespace) -> int:
|
|
341
394
|
verb = args.library_command
|
|
342
395
|
if verb == "status":
|
|
343
396
|
return _status(args)
|
|
344
397
|
if verb == "custom":
|
|
345
398
|
return _custom(args)
|
|
399
|
+
if verb == "unload":
|
|
400
|
+
use_all = bool(getattr(args, "all", False))
|
|
401
|
+
model_id = getattr(args, "model", None)
|
|
402
|
+
if use_all and model_id is not None:
|
|
403
|
+
print(
|
|
404
|
+
"error: library unload: specify either MODEL or --all, not both",
|
|
405
|
+
file=sys.stderr,
|
|
406
|
+
)
|
|
407
|
+
return 2
|
|
408
|
+
if not use_all and model_id is None:
|
|
409
|
+
print("error: library unload: specify MODEL or --all", file=sys.stderr)
|
|
410
|
+
return 2
|
|
411
|
+
if use_all:
|
|
412
|
+
return _unload_all(args)
|
|
346
413
|
from localmodels import library_jobs, library_serve, library_smoke
|
|
347
414
|
|
|
348
415
|
jsonl = verb in ("download", "load", "smoke-test")
|
|
@@ -203,7 +203,7 @@ def _floor_need_bytes(
|
|
|
203
203
|
) -> tuple[int, int]:
|
|
204
204
|
"""(total_need_bytes, wired_need_bytes) at ``floor_posture`` (compact KV)."""
|
|
205
205
|
active = model.entry.agent_posture(floor_posture)
|
|
206
|
-
profile =
|
|
206
|
+
profile = model.entry.agent_profile(model.variant)
|
|
207
207
|
window = min(active.floor, profile.n_ctx_train) if profile.n_ctx_train > 0 else active.floor
|
|
208
208
|
kv = active.kv_types[-1]
|
|
209
209
|
mtp = bool(model.entry.mtp_capable and model.entry.agent_mtp and active.mtp_draft_depth > 0)
|
|
@@ -43,7 +43,6 @@ from localmodels.estimator import (
|
|
|
43
43
|
AGENT_VRAM_RESERVE_BYTES,
|
|
44
44
|
PhysicsRefusal,
|
|
45
45
|
agent_footprint_bytes,
|
|
46
|
-
eager,
|
|
47
46
|
)
|
|
48
47
|
from localmodels.library_model import LibraryError, Reason, display_name, split_id
|
|
49
48
|
from localmodels.planning import budget, llm_ram, memory_pools
|
|
@@ -613,7 +612,7 @@ def floor_metadata(
|
|
|
613
612
|
active = model.entry.agent_posture(
|
|
614
613
|
context_policy.posture_for(posture(), "metal" if metal_unified else "cuda")
|
|
615
614
|
)
|
|
616
|
-
profile =
|
|
615
|
+
profile = model.entry.agent_profile(model.variant)
|
|
617
616
|
window = profile.n_ctx_train if 0 < profile.n_ctx_train < active.floor else active.floor
|
|
618
617
|
vision_on = vision.llama_reader_enabled(model.entry.mmproj, active.vision)
|
|
619
618
|
mtp = bool(model.entry.mtp_capable and model.entry.agent_mtp and active.mtp_draft_depth > 0)
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"""``library unload --all``: unload every active library model and cancel active library jobs.
|
|
2
|
+
|
|
3
|
+
Composes with ``library_serve.stop`` and ``library_state`` / ``library_jobs`` without requiring
|
|
4
|
+
hardware probing or catalog resolution, so retired, custom, and legacy on-disk records unload
|
|
5
|
+
cleanly. Idle records and failed-download jobs (with resumable partials) are safely skipped.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
from typing import Literal, TypedDict
|
|
13
|
+
|
|
14
|
+
from localmodels import (
|
|
15
|
+
cli_help,
|
|
16
|
+
console,
|
|
17
|
+
library_jobs,
|
|
18
|
+
library_serve,
|
|
19
|
+
library_state,
|
|
20
|
+
runtime_index,
|
|
21
|
+
)
|
|
22
|
+
from localmodels.library_model import DETAIL_LIMIT, ERROR_CODES, LibraryError
|
|
23
|
+
from localmodels.library_state import Job
|
|
24
|
+
from localmodels.transport import Executor
|
|
25
|
+
|
|
26
|
+
UNLOAD_ALL_SCHEMA: Literal["localmodels.library-unload-all/v1"] = (
|
|
27
|
+
"localmodels.library-unload-all/v1"
|
|
28
|
+
)
|
|
29
|
+
Out = Callable[[str], None]
|
|
30
|
+
|
|
31
|
+
PreviousState = Literal["loaded", "starting", "failed", "loading", "downloading", "smoke_test"]
|
|
32
|
+
UnloadAction = Literal["unloaded", "cancelled"]
|
|
33
|
+
SkipReason = Literal["already_idle", "failed_download"]
|
|
34
|
+
|
|
35
|
+
_DOWNLOAD_STOP_GRACE_S = 20.0
|
|
36
|
+
_ACTIVE_JOB_GRACE_POSIX_S = 5.0
|
|
37
|
+
_ACTIVE_JOB_GRACE_WINDOWS_S = 2.0
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class UnloadAllItem(TypedDict):
|
|
41
|
+
id: str
|
|
42
|
+
previous_state: PreviousState
|
|
43
|
+
action: UnloadAction
|
|
44
|
+
detail: str
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class UnloadAllSkipped(TypedDict):
|
|
48
|
+
id: str
|
|
49
|
+
state: Literal["idle", "failed"]
|
|
50
|
+
reason: SkipReason
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class UnloadAllError(TypedDict):
|
|
54
|
+
id: str
|
|
55
|
+
code: str
|
|
56
|
+
detail: str
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class UnloadAllReport(TypedDict):
|
|
60
|
+
schema: Literal["localmodels.library-unload-all/v1"]
|
|
61
|
+
ok: bool
|
|
62
|
+
unloaded: list[UnloadAllItem]
|
|
63
|
+
skipped: list[UnloadAllSkipped]
|
|
64
|
+
errors: list[UnloadAllError]
|
|
65
|
+
runtime_index_refreshed: bool
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _previous_job_state(kind: str) -> PreviousState:
|
|
69
|
+
if kind == "download":
|
|
70
|
+
return "downloading"
|
|
71
|
+
if kind == "smoke_test":
|
|
72
|
+
return "smoke_test"
|
|
73
|
+
return "loading"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _previous_record_state(raw: str) -> PreviousState:
|
|
77
|
+
if raw == "starting":
|
|
78
|
+
return "starting"
|
|
79
|
+
if raw == "failed":
|
|
80
|
+
return "failed"
|
|
81
|
+
return "loaded"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _job_grace_seconds(kind: str) -> float:
|
|
85
|
+
if kind == "download":
|
|
86
|
+
return _DOWNLOAD_STOP_GRACE_S
|
|
87
|
+
return _ACTIVE_JOB_GRACE_WINDOWS_S if sys.platform == "win32" else _ACTIVE_JOB_GRACE_POSIX_S
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _stop_active_job(model_id: str, job: Job, base_dir: str) -> PreviousState:
|
|
91
|
+
"""Cancel an in-flight download, load, or smoke-test job using its verified process receipt."""
|
|
92
|
+
kind = job["kind"]
|
|
93
|
+
if kind in ("unload", "remove"):
|
|
94
|
+
raise LibraryError("JOB_RUNNING", f"{model_id} has a running {kind}", failed=True)
|
|
95
|
+
|
|
96
|
+
with library_state.locked():
|
|
97
|
+
current_job = library_state.read_job(model_id)
|
|
98
|
+
if current_job is None or current_job.get("id") != job.get("id"):
|
|
99
|
+
return _previous_job_state(kind)
|
|
100
|
+
if not library_state.job_alive(model_id):
|
|
101
|
+
if kind != "download" or library_state.load(model_id) is not None:
|
|
102
|
+
library_state.clear_job(model_id)
|
|
103
|
+
return _previous_job_state(kind)
|
|
104
|
+
identity = library_state.receipt(model_id)
|
|
105
|
+
library_state.mark_cancelled(current_job)
|
|
106
|
+
|
|
107
|
+
if identity is not None:
|
|
108
|
+
try:
|
|
109
|
+
library_state.stop_process(identity, grace=_job_grace_seconds(kind))
|
|
110
|
+
except (OSError, RuntimeError) as exc:
|
|
111
|
+
code = "INVALID_STATE" if kind == "download" else "ENGINE_START_FAILED"
|
|
112
|
+
raise LibraryError(code, f"cannot stop active {kind}: {exc}", failed=True) from None
|
|
113
|
+
elif library_state.job_alive(model_id):
|
|
114
|
+
raise LibraryError(
|
|
115
|
+
"ENGINE_START_FAILED",
|
|
116
|
+
f"cannot stop active {kind}: missing process receipt",
|
|
117
|
+
failed=True,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
with library_state.locked():
|
|
121
|
+
committed = library_state.load(model_id) is not None
|
|
122
|
+
if library_state.current(job) and not library_state.job_alive(model_id):
|
|
123
|
+
if kind == "download" and not committed:
|
|
124
|
+
gone = library_jobs.leftovers(job)
|
|
125
|
+
library_jobs.delete_weights(gone, library_jobs.in_use(model_id))
|
|
126
|
+
library_jobs.prune_empty_custom_dirs(gone, job.get("base_dir") or base_dir)
|
|
127
|
+
library_state.clear_job(model_id)
|
|
128
|
+
else:
|
|
129
|
+
library_state.clear_job(model_id)
|
|
130
|
+
|
|
131
|
+
return _previous_job_state(kind)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _inspect_and_handle_job(
|
|
135
|
+
model_id: str, base_dir: str
|
|
136
|
+
) -> tuple[PreviousState | None, UnloadAllSkipped | None]:
|
|
137
|
+
"""Handle any live or stale job for ``model_id``; returns ``(cancelled_state, skipped)``."""
|
|
138
|
+
with library_state.locked():
|
|
139
|
+
job = library_state.read_job(model_id)
|
|
140
|
+
if job is None:
|
|
141
|
+
return None, None
|
|
142
|
+
alive = library_state.job_alive(model_id)
|
|
143
|
+
record = library_state.load(model_id)
|
|
144
|
+
if not alive:
|
|
145
|
+
if job["kind"] == "download" and record is None:
|
|
146
|
+
return None, {
|
|
147
|
+
"id": model_id,
|
|
148
|
+
"state": "failed",
|
|
149
|
+
"reason": "failed_download",
|
|
150
|
+
}
|
|
151
|
+
library_state.clear_job(model_id)
|
|
152
|
+
return None, None
|
|
153
|
+
cancelled_state = _stop_active_job(model_id, job, base_dir)
|
|
154
|
+
return cancelled_state, None
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _unload_one(
|
|
158
|
+
model_id: str,
|
|
159
|
+
base_dir: str,
|
|
160
|
+
executor: Executor,
|
|
161
|
+
) -> tuple[UnloadAllItem | None, UnloadAllSkipped | None]:
|
|
162
|
+
"""Best-effort unload/cancel of one model id; raises ``LibraryError`` on failure."""
|
|
163
|
+
cancelled_state, skipped = _inspect_and_handle_job(model_id, base_dir)
|
|
164
|
+
if skipped is not None:
|
|
165
|
+
return None, skipped
|
|
166
|
+
|
|
167
|
+
with library_state.locked():
|
|
168
|
+
record = library_state.load(model_id)
|
|
169
|
+
if record is None:
|
|
170
|
+
if cancelled_state is None:
|
|
171
|
+
return None, None
|
|
172
|
+
return {
|
|
173
|
+
"id": model_id,
|
|
174
|
+
"previous_state": cancelled_state,
|
|
175
|
+
"action": "cancelled",
|
|
176
|
+
"detail": "",
|
|
177
|
+
}, None
|
|
178
|
+
if record["state"] == "idle":
|
|
179
|
+
if cancelled_state is not None:
|
|
180
|
+
return {
|
|
181
|
+
"id": model_id,
|
|
182
|
+
"previous_state": cancelled_state,
|
|
183
|
+
"action": "cancelled",
|
|
184
|
+
"detail": "",
|
|
185
|
+
}, None
|
|
186
|
+
return None, {"id": model_id, "state": "idle", "reason": "already_idle"}
|
|
187
|
+
library_state.refuse_busy(model_id, "unload")
|
|
188
|
+
prev_state = cancelled_state or _previous_record_state(record["state"])
|
|
189
|
+
claim = library_state.acquire("unload", model_id, record["pool"], 0, [])
|
|
190
|
+
|
|
191
|
+
with library_state.held([claim]):
|
|
192
|
+
library_serve.stop(record, executor)
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
"id": model_id,
|
|
196
|
+
"previous_state": prev_state,
|
|
197
|
+
"action": "unloaded",
|
|
198
|
+
"detail": "",
|
|
199
|
+
}, None
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _error_entry(model_id: str, exc: Exception) -> UnloadAllError:
|
|
203
|
+
if isinstance(exc, LibraryError):
|
|
204
|
+
code = exc.code if exc.code in ERROR_CODES else "ENGINE_START_FAILED"
|
|
205
|
+
detail = exc.detail
|
|
206
|
+
else:
|
|
207
|
+
code = "ENGINE_START_FAILED"
|
|
208
|
+
detail = str(exc) or type(exc).__name__
|
|
209
|
+
return {"id": model_id, "code": code, "detail": detail[-DETAIL_LIMIT:]}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def unload_all(base_dir: str = cli_help.DEFAULT_BASE_DIR) -> UnloadAllReport:
|
|
213
|
+
"""Unload every active/loaded library model and cancel active jobs (best-effort)."""
|
|
214
|
+
records = library_state.records()
|
|
215
|
+
jobs = library_state.jobs()
|
|
216
|
+
model_ids = sorted({record["id"] for record in records} | set(jobs))
|
|
217
|
+
|
|
218
|
+
unloaded: list[UnloadAllItem] = []
|
|
219
|
+
skipped: list[UnloadAllSkipped] = []
|
|
220
|
+
errors: list[UnloadAllError] = []
|
|
221
|
+
|
|
222
|
+
if model_ids:
|
|
223
|
+
executor = library_jobs.executor()
|
|
224
|
+
for model_id in model_ids:
|
|
225
|
+
try:
|
|
226
|
+
item, skip = _unload_one(model_id, base_dir, executor)
|
|
227
|
+
except (LibraryError, OSError, RuntimeError, ValueError) as exc:
|
|
228
|
+
errors.append(_error_entry(model_id, exc))
|
|
229
|
+
continue
|
|
230
|
+
if item is not None:
|
|
231
|
+
unloaded.append(item)
|
|
232
|
+
elif skip is not None:
|
|
233
|
+
skipped.append(skip)
|
|
234
|
+
|
|
235
|
+
refreshed = runtime_index.refresh() is not None
|
|
236
|
+
return {
|
|
237
|
+
"schema": UNLOAD_ALL_SCHEMA,
|
|
238
|
+
"ok": not errors,
|
|
239
|
+
"unloaded": unloaded,
|
|
240
|
+
"skipped": skipped,
|
|
241
|
+
"errors": errors,
|
|
242
|
+
"runtime_index_refreshed": refreshed,
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def print_report(report: UnloadAllReport, out: Out = print) -> int:
|
|
247
|
+
"""Print a concise human-readable summary of ``library unload --all``."""
|
|
248
|
+
t = console.term(sys.stdout)
|
|
249
|
+
for item in report["unloaded"]:
|
|
250
|
+
out(
|
|
251
|
+
f"{t.mark('ok')} {item['id']} {item['action']} (was {item['previous_state']})"
|
|
252
|
+
+ (f": {item['detail']}" if item["detail"] else "")
|
|
253
|
+
)
|
|
254
|
+
for skip in report["skipped"]:
|
|
255
|
+
reason = "already idle" if skip["reason"] == "already_idle" else "failed download kept"
|
|
256
|
+
out(f"{t.mark('skip')} {skip['id']} skipped ({reason})")
|
|
257
|
+
for err in report["errors"]:
|
|
258
|
+
out(f"{t.mark('fail')} {err['id']} {err['code']}: {err['detail']}")
|
|
259
|
+
if not report["unloaded"] and not report["skipped"] and not report["errors"]:
|
|
260
|
+
out("No library models or active jobs under this state directory")
|
|
261
|
+
if report["ok"]:
|
|
262
|
+
count = len(report["unloaded"])
|
|
263
|
+
out(
|
|
264
|
+
t.paint(
|
|
265
|
+
f"Unloaded {count} active library model(s); downloaded weights remain on disk",
|
|
266
|
+
"green",
|
|
267
|
+
"bold",
|
|
268
|
+
)
|
|
269
|
+
if count
|
|
270
|
+
else t.paint("No active library models were running", "green", "bold")
|
|
271
|
+
)
|
|
272
|
+
return 0
|
|
273
|
+
out(t.paint("Some library models could not be unloaded", "red", "bold"))
|
|
274
|
+
return 1
|