mlx-bun 0.0.11 → 0.0.12
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 +43 -13
- package/THIRD_PARTY_LICENSES.md +9 -0
- package/docs/design/colibri-glm52-port.md +1479 -0
- package/docs/design/pre-colibri-stabilization.md +329 -0
- package/docs/investigations/colibri-oracle-pin.md +1284 -0
- package/docs/investigations/indexshare-performance-spike.md +357 -0
- package/docs/planning/release-notes-v0.0.12.md +80 -0
- package/docs/reference/cli.md +28 -2
- package/docs/reference/distribution.md +25 -1
- package/docs/reference/embedding.md +5 -2
- package/docs/reference/features-matrix.md +4 -2
- package/docs/reference/library-api.md +41 -13
- package/docs/reference/models.md +49 -2
- package/docs/reference/server-api.md +90 -9
- package/docs/reference/server-config.md +21 -14
- package/docs/reference/training.md +10 -1
- package/package.json +1 -1
- package/src/anthropic.ts +54 -44
- package/src/chat-template.ts +155 -10
- package/src/cli.ts +127 -8
- package/src/config.ts +71 -26
- package/src/diffusion/diffusion-generate.ts +14 -8
- package/src/download.ts +103 -12
- package/src/eval/ifeval.ts +63 -120
- package/src/eval/runner.ts +14 -5
- package/src/eval/tasks/ifeval.ts +167 -31
- package/src/expert-io.ts +391 -0
- package/src/expert-residency.ts +1134 -0
- package/src/expert-usage.ts +415 -0
- package/src/generate.ts +114 -17
- package/src/hf-push.ts +1 -1
- package/src/index.ts +14 -2
- package/src/jobs/runner.ts +37 -18
- package/src/kv-store.ts +147 -8
- package/src/lora.ts +77 -14
- package/src/media-fetch.ts +198 -56
- package/src/mlx/array.ts +43 -0
- package/src/mlx/autograd.ts +51 -14
- package/src/mlx/checkpoint.ts +46 -13
- package/src/mlx/custom-vjp.ts +83 -35
- package/src/model/factory.ts +96 -5
- package/src/model/gemma4-base.ts +32 -0
- package/src/model/glm52-atlas.ts +511 -0
- package/src/model/glm52-cache.ts +706 -0
- package/src/model/glm52-config.ts +262 -0
- package/src/model/glm52-container.ts +305 -0
- package/src/model/glm52-coupling.ts +388 -0
- package/src/model/glm52-dsa.ts +602 -0
- package/src/model/glm52-expert-layout.ts +253 -0
- package/src/model/glm52-layout.ts +152 -0
- package/src/model/glm52-memory.ts +473 -0
- package/src/model/glm52-mla.ts +786 -0
- package/src/model/glm52-moe.ts +223 -0
- package/src/model/glm52-pilot.ts +537 -0
- package/src/model/glm52-reference.ts +445 -0
- package/src/model/glm52-residency.ts +557 -0
- package/src/model/glm52-resident-weights.ts +135 -0
- package/src/model/glm52-streamed-experts.ts +453 -0
- package/src/model/glm52-streamed-metal.ts +610 -0
- package/src/model/glm52-weights.ts +503 -0
- package/src/model/glm52.ts +1153 -0
- package/src/model/support.ts +8 -1
- package/src/native/expert_io.c +523 -0
- package/src/native-pack.ts +6 -4
- package/src/responses.ts +62 -49
- package/src/serve/batch-scheduler.ts +95 -16
- package/src/serve/generation-gateway.ts +41 -16
- package/src/server.ts +362 -81
- package/src/spec/glm52-mtp-source.ts +392 -0
- package/src/spec/serve-loop.ts +99 -18
- package/src/spec/source.ts +31 -6
- package/src/ssd-cache.ts +6 -2
- package/src/tool-call.ts +30 -2
- package/src/train/job.ts +0 -10
- package/src/train/lora-params.ts +17 -6
- package/src/train/trainer.ts +59 -26
- package/src/web/app.html +13 -2
- package/src/web/app.js +30 -3
- package/src/web/src/status.ts +51 -3
- package/src/web-tools.ts +54 -2
- package/src/weights.ts +82 -19
package/README.md
CHANGED
|
@@ -90,8 +90,9 @@ nothing to install:
|
|
|
90
90
|
bunx mlx-bun
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
First run fetches the MLX native runtime
|
|
94
|
-
caches, then serves. (Bun only — `npx
|
|
93
|
+
First run fetches the MLX native runtime plus the streamed-expert helper
|
|
94
|
+
(~52 MB) and the model into your caches, then serves. (Bun only — `npx
|
|
95
|
+
mlx-bun` under Node exits with a
|
|
95
96
|
"requires Bun" notice by design.)
|
|
96
97
|
|
|
97
98
|
### From source
|
|
@@ -116,7 +117,8 @@ mlx-bun
|
|
|
116
117
|
Bare `mlx-bun` is an alias for `mlx-bun serve`. On its first run, with no
|
|
117
118
|
model named, it does everything for you:
|
|
118
119
|
|
|
119
|
-
1. pulls the MLX native runtime (~52 MB) into
|
|
120
|
+
1. pulls the MLX native runtime plus streamed-expert helper (~52 MB) into
|
|
121
|
+
`~/Library/Caches/mlx-bun/`
|
|
120
122
|
(skipped on the Homebrew install — the runtime ships in the bottle);
|
|
121
123
|
2. downloads the sub-GB `MiniCPM5-1B` starter and serves it, so you're
|
|
122
124
|
chatting in well under a minute;
|
|
@@ -221,9 +223,9 @@ On the site: [The lab](https://mlx-bun.dev/about/lab/).
|
|
|
221
223
|
|
|
222
224
|
## Supported models
|
|
223
225
|
|
|
224
|
-
Scope is deliberate: a few model families held to
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
Scope is deliberate: a few model families held to explicit oracle contracts,
|
|
227
|
+
rather than dozens held to none. Currently MiniCPM5, the Gemma-4 OptiQ quants,
|
|
228
|
+
Qwen3.5-4B, and the direct-container GLM-5.2 path:
|
|
227
229
|
|
|
228
230
|
| Model | Download | Fits on | Vision | Notes |
|
|
229
231
|
|---|---|---|---|---|
|
|
@@ -232,6 +234,7 @@ Currently MiniCPM5, the Gemma-4 OptiQ quants, and Qwen3.5-4B:
|
|
|
232
234
|
| [`mlx-community/gemma-4-e4b-it-OptiQ-4bit`](https://huggingface.co/mlx-community/gemma-4-e4b-it-OptiQ-4bit) | 7.0 GB | 16 GB | ✓ | **Recommended starter** (16 GB+); ~56 tok/s |
|
|
233
235
|
| [`mlx-community/gemma-4-12B-it-OptiQ-4bit`](https://huggingface.co/mlx-community/gemma-4-12B-it-OptiQ-4bit) | 8.4 GB | 16 GB | ✓ | Vision + tool calling, both verified end-to-end |
|
|
234
236
|
| [`mlx-community/gemma-4-26B-A4B-it-OptiQ-4bit`](https://huggingface.co/mlx-community/gemma-4-26B-A4B-it-OptiQ-4bit) | 18 GB | 24 GB | — | MoE (top-8 of 128 experts); ~54 tok/s |
|
|
237
|
+
| [`mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp`](https://huggingface.co/mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp) | ~384 GB / 357 GiB | 32 GB + fast disk | — | Direct streamed Colibri container; true top-8, native MTP, bounded 25 GiB process plan; warm single-stream performance is disk-bound and below the aspirational 2 tok/s target |
|
|
235
238
|
|
|
236
239
|
Not sure what fits your machine? `bun src/cli.ts fit <model> --ctx 8192`
|
|
237
240
|
gives a deterministic answer (see below). The larger
|
|
@@ -240,6 +243,26 @@ remain (see [PLAN.md](./PLAN.md)). Downloading, cache layout, and reclaiming
|
|
|
240
243
|
disk: [docs/reference/models.md](./docs/reference/models.md); on the site:
|
|
241
244
|
[Choosing a model](https://mlx-bun.dev/getting-started/models/).
|
|
242
245
|
|
|
246
|
+
### GLM-5.2: 32 GB quickstart
|
|
247
|
+
|
|
248
|
+
Choose a volume with at least the artifact remainder plus 1 GiB free before
|
|
249
|
+
starting; mlx-bun checks this before the first payload and credits resumable
|
|
250
|
+
partials. The validated artifact revision and exact 25 GiB serving command are
|
|
251
|
+
documented in the [model-management guide](./docs/reference/models.md#glm-52-on-a-32-gb-mac):
|
|
252
|
+
|
|
253
|
+
```sh
|
|
254
|
+
export HF_HUB_CACHE=/Volumes/FastSSD/huggingface/hub # optional large fast volume
|
|
255
|
+
mlx-bun get mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp \
|
|
256
|
+
--revision 3cc8db99b1b13fc79325d987ba3c1c430766b3b8
|
|
257
|
+
mlx-bun scan
|
|
258
|
+
mlx-bun serve GLM-5.2-colibri --memory-budget 26.8435456 \
|
|
259
|
+
--context-length 4096 --max-tokens 128 --mtp on
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Rerun `get` after interruption; partial files resume and every completed blob
|
|
263
|
+
is checksum-verified. The model remains in the standard Hugging Face cache—no
|
|
264
|
+
Python environment and no second converted copy inside this repository.
|
|
265
|
+
|
|
243
266
|
## Why
|
|
244
267
|
|
|
245
268
|
MLX is Apple's ML framework: hand-tuned Metal kernels for Apple Silicon,
|
|
@@ -278,6 +301,7 @@ bun src/cli.ts ls # list models (size, params, quant, capabili
|
|
|
278
301
|
bun src/cli.ts ls --vision --max-size 10GB
|
|
279
302
|
bun src/cli.ts fit gemma --ctx 32768 # memory contract: fits? max context? predicted tok/s
|
|
280
303
|
bun src/cli.ts fit gemma --ctx 8192 --skus # ...same, across the Apple Silicon lineup
|
|
304
|
+
bun src/cli.ts fit GLM-5.2 # streamed plan: disk vs resident slabs + measured speed
|
|
281
305
|
bun src/cli.ts serve gemma --port 8080 # OpenAI-compatible server
|
|
282
306
|
bun src/cli.ts serve gemma --memory-budget 18 # ...with admission control (GB)
|
|
283
307
|
bun src/cli.ts generate gemma "a haiku about metal shaders" # raw one-shot generation
|
|
@@ -299,7 +323,10 @@ listing the candidates — just make it more specific.
|
|
|
299
323
|
headers, KV bytes/token from the config (sliding-window layers capped,
|
|
300
324
|
MoE active-expert bytes for decode), calibrated prefill transient, and
|
|
301
325
|
the machine's wired-memory ceiling. Predictions are recorded next to
|
|
302
|
-
measured peaks in the eval DB.
|
|
326
|
+
measured peaks in the eval DB. The direct Colibri GLM-5.2 path uses its exact
|
|
327
|
+
streamed plan instead: full artifact-on-disk size is separated from bounded
|
|
328
|
+
resident weights, main/MTP expert slabs, KV, and reserves, and measured warm
|
|
329
|
+
decode is separated from the direct oracle and the 2 tok/s aspiration.
|
|
303
330
|
|
|
304
331
|
Every verb, with flags: [docs/reference/cli.md](./docs/reference/cli.md);
|
|
305
332
|
on the site: [CLI reference](https://mlx-bun.dev/reference/cli/).
|
|
@@ -328,13 +355,17 @@ agent CLIs like pi/OpenClaw via their provider config.
|
|
|
328
355
|
(Gemma 4 `<|tool_call>` sentinel tokens; MiniCPM5 / Qwen3.5
|
|
329
356
|
`<function name=…>` XML with schema-aware argument decoding);
|
|
330
357
|
`role: "tool"` round-trips, including multi-turn agent loops.
|
|
358
|
+
The built-in `web_fetch` tool accepts public HTTP(S) destinations only,
|
|
359
|
+
revalidates DNS and every redirect, and streams into a 1 MiB response cap.
|
|
331
360
|
- **Structured output** — `response_format` (JSON mode / JSON schema),
|
|
332
361
|
plus the vLLM/oMLX aliases `guided_grammar`, `guided_regex`,
|
|
333
362
|
`guided_choice`, and `structured_outputs`, enforced by
|
|
334
363
|
grammar-constrained decoding (xgrammar) on chat and raw completions,
|
|
335
364
|
serial and batched lanes alike; a grammar that fails to compile
|
|
336
|
-
degrades to
|
|
337
|
-
(
|
|
365
|
+
degrades to a string-valued constraint-specific prompt injection
|
|
366
|
+
(oMLX parity) instead of an error
|
|
367
|
+
(`MLX_BUN_GRAMMAR=0` disables mask compilation server-wide and routes
|
|
368
|
+
requested constraints through that same warning-bearing degrade path).
|
|
338
369
|
- **Vision** — `image_url` content parts (data: URLs or http/s), on
|
|
339
370
|
models with the vision sidecar. PNG, JPEG, HEIC, AVIF, WebP, TIFF,
|
|
340
371
|
GIF, BMP via native OS codecs. Remote fetches are SSRF-guarded by
|
|
@@ -424,13 +455,12 @@ in [docs/reference/embedding.md](./docs/reference/embedding.md).
|
|
|
424
455
|
|
|
425
456
|
```ts
|
|
426
457
|
import {
|
|
427
|
-
|
|
428
|
-
|
|
458
|
+
openModel, // artifact-aware, incl. bounded streamed GLM-5.2
|
|
459
|
+
loadTokenizer, ChatTemplate, generate,
|
|
429
460
|
} from "mlx-bun"; // or "./src/index" in a clone
|
|
430
461
|
|
|
431
462
|
const dir = "/path/to/hf/snapshot";
|
|
432
|
-
const
|
|
433
|
-
const model = createModel(await Weights.open(dir), config); // RuntimeModel
|
|
463
|
+
const model = await openModel(dir); // RuntimeModel
|
|
434
464
|
const tok = await loadTokenizer(dir);
|
|
435
465
|
const template = await ChatTemplate.load(dir);
|
|
436
466
|
|
package/THIRD_PARTY_LICENSES.md
CHANGED
|
@@ -21,6 +21,7 @@ the upstream algorithm and is a derivative work of the original.
|
|
|
21
21
|
| [mlx-vlm](https://github.com/Blaizzy/mlx-vlm) (BSD-3-Clause) — Gemma-4 unified `VisionEmbedder`, `MultimodalEmbedder`, image preprocessing (as vendored in mlx-optiq) | BSD-3-Clause | `src/vision/embedder.ts`, `src/vision/preprocess.ts` |
|
|
22
22
|
| mlx-optiq (MIT) — vision sidecar wiring, fused quantized SDPA orchestration | MIT | `src/vision/`, quantized-KV paths in `src/model/gemma4.ts` |
|
|
23
23
|
| [Pillow](https://github.com/python-pillow/Pillow) (MIT-CMU / HPND) — `ImagingResample` bicubic convolution algorithm | HPND | `resizeBicubic` in `src/vision/preprocess.ts` (algorithm port) |
|
|
24
|
+
| [Colibri](https://github.com/JustVugg/colibri) (pinned development oracle `44e489b196c9b7876b3d37a0570ebf1c6f90f54c`) — direct-container layout, expert-residency/I/O policy, GLM-5.2 execution and Metal-kernel reference | Apache-2.0 | Native GLM-5.2 implementation under `src/model/glm52-*`, `src/expert-*`, and `src/native/expert_io.c`; rewritten for Bun + MLX, with direct Colibri retained only as an external oracle |
|
|
24
25
|
|
|
25
26
|
## Runtime npm dependencies
|
|
26
27
|
|
|
@@ -40,3 +41,11 @@ Model weights (e.g. `mlx-community/gemma-4-12B-it-OptiQ-4bit`) are not
|
|
|
40
41
|
part of this repository and are governed by their own licenses and use
|
|
41
42
|
policies (e.g. Google's Gemma Terms of Use). Check the model card on
|
|
42
43
|
Hugging Face before redistribution.
|
|
44
|
+
|
|
45
|
+
The validated GLM-5.2 direct-container artifact,
|
|
46
|
+
[`mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp`](https://huggingface.co/mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp),
|
|
47
|
+
declares MIT and identifies itself as a Colibri conversion/derivative of
|
|
48
|
+
[`zai-org/GLM-5.2-FP8`](https://huggingface.co/zai-org/GLM-5.2-FP8), with
|
|
49
|
+
lineage through `jlnsrk/GLM-5.2-colibri-int4` and added int8 MTP weights. The
|
|
50
|
+
artifact is downloaded separately into the Hugging Face cache and is not part
|
|
51
|
+
of the mlx-bun distribution.
|