mlx-bun 0.0.4
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/LICENSE +21 -0
- package/README.md +362 -0
- package/THIRD_PARTY_LICENSES.md +41 -0
- package/bin/mlx-bun.mjs +32 -0
- package/docs/curve-designer.html +303 -0
- package/docs/design/adapters-end-to-end.md +201 -0
- package/docs/design/compat-cli-surface-design.md +227 -0
- package/docs/design/docs-reorg-plan.md +152 -0
- package/docs/design/hlg-sampling.md +340 -0
- package/docs/design/memory-system.md +339 -0
- package/docs/design/optimization_plan.md +344 -0
- package/docs/design/parallel-slots.md +515 -0
- package/docs/design/runtime-isolation.md +247 -0
- package/docs/design/segmented-backward-training.md +508 -0
- package/docs/investigations/chunk-finetune-experiment.md +84 -0
- package/docs/investigations/curve-bisector-routing.md +123 -0
- package/docs/investigations/curve-runs/bisector-route.json +98 -0
- package/docs/investigations/curve-runs/bisector-trace.json +1393 -0
- package/docs/investigations/curve-runs/curve-terrain.json +1179 -0
- package/docs/investigations/curve-runs/curve-terrain.svg +42 -0
- package/docs/investigations/curve-terrain.html +105 -0
- package/docs/investigations/expert-offload-single-user-moe.md +292 -0
- package/docs/investigations/hlg-ab.html +34 -0
- package/docs/investigations/hlg-explorer.html +238 -0
- package/docs/investigations/hlg-figs/cliff.svg +1 -0
- package/docs/investigations/hlg-figs/cross.svg +1 -0
- package/docs/investigations/hlg-figs/edges.svg +1 -0
- package/docs/investigations/hlg-figs/k20-grids.svg +1 -0
- package/docs/investigations/hlg-figs/k20-peaks.svg +1 -0
- package/docs/investigations/hlg-figs/lw-curve.svg +1 -0
- package/docs/investigations/hlg-figs/terrain.svg +1 -0
- package/docs/investigations/hlg-report.html +262 -0
- package/docs/investigations/hlg-runs/hlg-ab.json +149 -0
- package/docs/investigations/hlg-runs/hlg-blind-prompts.md +87 -0
- package/docs/investigations/hlg-runs/hlg-blind.json +107 -0
- package/docs/investigations/hlg-runs/hlg-cliff.json +197 -0
- package/docs/investigations/hlg-runs/hlg-cross.json +505 -0
- package/docs/investigations/hlg-runs/hlg-edge.json +388 -0
- package/docs/investigations/hlg-runs/hlg-eval1.json +25 -0
- package/docs/investigations/hlg-runs/hlg-frontier.json +86 -0
- package/docs/investigations/hlg-runs/hlg-grid.json +242 -0
- package/docs/investigations/hlg-runs/hlg-grid2.json +343 -0
- package/docs/investigations/hlg-runs/hlg-lw-coarse.json +110 -0
- package/docs/investigations/hlg-runs/hlg-map.json +383 -0
- package/docs/investigations/hlg-runs/run0-original.log +159 -0
- package/docs/investigations/hlg-runs/runA-recommended.log +131 -0
- package/docs/investigations/hlg-runs/runAA-cliff-cpm5.log +26 -0
- package/docs/investigations/hlg-runs/runAB-grid2-e4b.log +18 -0
- package/docs/investigations/hlg-runs/runAC-peak-e4b-partial.log +25 -0
- package/docs/investigations/hlg-runs/runAD-ab-samples.log +8 -0
- package/docs/investigations/hlg-runs/runAE-edge-e4b.log +51 -0
- package/docs/investigations/hlg-runs/runAF-logit-calibration.log +10 -0
- package/docs/investigations/hlg-runs/runAG-eval-config2.log +16 -0
- package/docs/investigations/hlg-runs/runB-gain-variants.log +192 -0
- package/docs/investigations/hlg-runs/runC-pivots.log +162 -0
- package/docs/investigations/hlg-runs/runD-oetf.log +132 -0
- package/docs/investigations/hlg-runs/runE-eotf.log +162 -0
- package/docs/investigations/hlg-runs/runF-shaper-working.log +86 -0
- package/docs/investigations/hlg-runs/runG-shaper-sweep.log +101 -0
- package/docs/investigations/hlg-runs/runH-wsweep.log +176 -0
- package/docs/investigations/hlg-runs/runI-asweep.log +176 -0
- package/docs/investigations/hlg-runs/runJ-knobmap.log +49 -0
- package/docs/investigations/hlg-runs/runK-frontier.log +19 -0
- package/docs/investigations/hlg-runs/runL-widemap.log +65 -0
- package/docs/investigations/hlg-runs/runM-frontier-emb.log +15 -0
- package/docs/investigations/hlg-runs/runN-verify.log +116 -0
- package/docs/investigations/hlg-runs/runO-frontier-seed5000.log +15 -0
- package/docs/investigations/hlg-runs/runP-grid-AxSm.log +15 -0
- package/docs/investigations/hlg-runs/runQ-grid-tgW.log +15 -0
- package/docs/investigations/hlg-runs/runR-blind-transcript.log +79 -0
- package/docs/investigations/hlg-runs/runS-cross-coherence.log +33 -0
- package/docs/investigations/hlg-runs/runT-cross-cpm5.log +33 -0
- package/docs/investigations/hlg-runs/runU-cross-12b.log +33 -0
- package/docs/investigations/hlg-runs/runV-lw-e4b.log +22 -0
- package/docs/investigations/hlg-runs/runW-lw-12b.log +22 -0
- package/docs/investigations/hlg-runs/runX-lw-cpm5.log +22 -0
- package/docs/investigations/hlg-runs/runY-cliff-e4b.log +26 -0
- package/docs/investigations/hlg-runs/runZ-cliff-12b.log +26 -0
- package/docs/investigations/hlg-sampling-investigation.md +970 -0
- package/docs/investigations/lab-build-journal.md +157 -0
- package/docs/investigations/pi-builtin-investigation.md +308 -0
- package/docs/investigations/starter-model-port-handoff.md +323 -0
- package/docs/planning/IDEAS.md +26 -0
- package/docs/planning/PRODUCT_ROADMAP.md +426 -0
- package/docs/planning/ResearchTopics.md +119 -0
- package/docs/planning/chunk-task-roadmap.md +77 -0
- package/docs/planning/journal.md +155 -0
- package/docs/reference/distribution.md +121 -0
- package/docs/reference/embedding.md +168 -0
- package/docs/reference/library-api.md +153 -0
- package/docs/reference/server-api.md +224 -0
- package/docs/reference/server-config.md +243 -0
- package/docs/segmented-backward-handoff.md +148 -0
- package/package.json +68 -0
- package/src/anthropic.ts +491 -0
- package/src/chat-template.ts +186 -0
- package/src/cli.ts +1075 -0
- package/src/config.ts +229 -0
- package/src/curve-sampler.ts +122 -0
- package/src/dataset/generators.ts +1087 -0
- package/src/dataset/index.ts +12 -0
- package/src/dataset/job.ts +81 -0
- package/src/dataset/llm.ts +71 -0
- package/src/dataset/registry.ts +528 -0
- package/src/download.ts +283 -0
- package/src/eval/README.md +86 -0
- package/src/eval/kl-prompts.ts +29 -0
- package/src/eval/kl.ts +294 -0
- package/src/eval/quality-db.ts +92 -0
- package/src/eval/runner.ts +102 -0
- package/src/eval/score.ts +49 -0
- package/src/eval/tasks/bfcl.ts +500 -0
- package/src/eval/tasks/gsm8k.ts +85 -0
- package/src/eval/tasks/hashhop.ts +109 -0
- package/src/eval/tasks/humaneval.ts +252 -0
- package/src/eval/tasks/ifeval.ts +354 -0
- package/src/eval/tasks/mmlu.ts +145 -0
- package/src/evaldb.ts +199 -0
- package/src/expert-offload-build.ts +77 -0
- package/src/expert-offload.ts +61 -0
- package/src/expert-trace.ts +67 -0
- package/src/fit.ts +254 -0
- package/src/generate.ts +451 -0
- package/src/harness-pi.ts +177 -0
- package/src/hf-push.ts +628 -0
- package/src/index.ts +22 -0
- package/src/jobs/db.ts +139 -0
- package/src/jobs/index.ts +29 -0
- package/src/jobs/job-entry.ts +106 -0
- package/src/jobs/runner.ts +304 -0
- package/src/jobs/sse.ts +114 -0
- package/src/jobs/types.ts +58 -0
- package/src/kv-store.ts +185 -0
- package/src/lora.ts +314 -0
- package/src/md-modules.d.ts +7 -0
- package/src/mlx/array.ts +237 -0
- package/src/mlx/autograd.ts +267 -0
- package/src/mlx/checkpoint.ts +116 -0
- package/src/mlx/compile.ts +158 -0
- package/src/mlx/custom-vjp.ts +140 -0
- package/src/mlx/ffi.ts +433 -0
- package/src/mlx/metal-kernel.ts +130 -0
- package/src/mlx/ops.ts +707 -0
- package/src/mmap.ts +90 -0
- package/src/model/batched-mask.ts +204 -0
- package/src/model/batched-rotating.ts +300 -0
- package/src/model/compiled-decode.ts +681 -0
- package/src/model/factory.ts +27 -0
- package/src/model/fingerprint.ts +33 -0
- package/src/model/flash-attention.ts +674 -0
- package/src/model/fused-decode-kernel.ts +305 -0
- package/src/model/fused-geglu-kernel.ts +87 -0
- package/src/model/gemma4-base.ts +1616 -0
- package/src/model/gemma4.ts +1012 -0
- package/src/model/generated/gemma4-12b.ts +526 -0
- package/src/model/generated/gemma4-26b.ts +500 -0
- package/src/model/generated/gemma4-e4b.ts +757 -0
- package/src/model/generated/index.ts +18 -0
- package/src/model/minicpm5.ts +278 -0
- package/src/model/qwen3-delta.ts +224 -0
- package/src/model/qwen3_5.ts +429 -0
- package/src/model/support.ts +46 -0
- package/src/native-pack.ts +152 -0
- package/src/pi-provider.ts +95 -0
- package/src/pi-terminal.ts +264 -0
- package/src/pi-web.ts +924 -0
- package/src/preflight.ts +123 -0
- package/src/prompt-cache.ts +113 -0
- package/src/quantize/allocator.ts +627 -0
- package/src/quantize/calibration.ts +180 -0
- package/src/quantize/config-writer.ts +132 -0
- package/src/quantize/index.ts +57 -0
- package/src/quantize/job.ts +136 -0
- package/src/quantize/quantizer.ts +462 -0
- package/src/quantize/safetensors-writer.ts +171 -0
- package/src/quantize/sensitivity.ts +234 -0
- package/src/registry.ts +336 -0
- package/src/responses.ts +774 -0
- package/src/safetensors.ts +158 -0
- package/src/sampler.ts +517 -0
- package/src/serve/batch-scheduler.ts +362 -0
- package/src/serve/generation-gateway.ts +160 -0
- package/src/server.ts +1891 -0
- package/src/spec/drafter.ts +261 -0
- package/src/spec/generate.ts +221 -0
- package/src/status-page.html +497 -0
- package/src/tokenizer.ts +38 -0
- package/src/tool-call.ts +242 -0
- package/src/train/dataset.ts +461 -0
- package/src/train/export.ts +32 -0
- package/src/train/forward.ts +229 -0
- package/src/train/index.ts +43 -0
- package/src/train/job.ts +148 -0
- package/src/train/lora-params.ts +194 -0
- package/src/train/loss.ts +342 -0
- package/src/train/merge.ts +195 -0
- package/src/train/optimizer.ts +176 -0
- package/src/train/rank.ts +101 -0
- package/src/train/segmented.ts +520 -0
- package/src/train/trainer.ts +600 -0
- package/src/tui.ts +161 -0
- package/src/vision/embedder.ts +168 -0
- package/src/vision/preprocess.ts +247 -0
- package/src/vision/prompt.ts +158 -0
- package/src/vision/siglip.ts +599 -0
- package/src/web/app.html +2471 -0
- package/src/web/skills/web-research/SKILL.md +44 -0
- package/src/web/skills.ts +59 -0
- package/src/web-tools.ts +426 -0
- package/src/weights.ts +91 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Compat CLI surface + parity harness — design
|
|
2
|
+
|
|
3
|
+
Status: design (2026-06-12). Engineering tracking lives in PLAN.md
|
|
4
|
+
Phase 17. UX/DX rationale lives in docs/planning/PRODUCT_ROADMAP.md ("The three
|
|
5
|
+
modes"). This doc is the surface contract: every verb, the flag
|
|
6
|
+
vocabulary, how optiq is absorbed, the parity harness, and **the
|
|
7
|
+
matrix of what we still lack**.
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
Design mlx-bun's entire CLI/flag surface from scratch (nothing is
|
|
12
|
+
published, nothing is set in stone) so that one coherent set of verbs
|
|
13
|
+
serves three audiences at three depths — automatic / compat /
|
|
14
|
+
stick-shift (see PRODUCT_ROADMAP). mlx-lm is the vocabulary we borrow,
|
|
15
|
+
because it is the Apple-WWDC-referenced default and outweighs the
|
|
16
|
+
alternative ~425× on monthly installs (1.64M vs 3.85k; mlx-lm 5.8k
|
|
17
|
+
stars / 765 forks; mlx-optiq has no public repo — measured
|
|
18
|
+
2026-06-12).
|
|
19
|
+
|
|
20
|
+
## Scope boundary: surface parity ≠ architecture parity
|
|
21
|
+
|
|
22
|
+
This is CLI/flag-**surface** parity. It is NOT a promise to run every
|
|
23
|
+
model architecture mlx-lm supports — the design principle "scope is the
|
|
24
|
+
survival strategy: target Gemma, Qwen, one MoE; not parity with mlx-lm's
|
|
25
|
+
dozens" still holds. A compat verb invoked against an unsupported
|
|
26
|
+
architecture returns a clear `architecture not supported by mlx-bun yet
|
|
27
|
+
(supported: …)` error, never a silent failure or a wrong answer. The
|
|
28
|
+
flag is accepted; the model may not be.
|
|
29
|
+
|
|
30
|
+
## The three laws (from PRODUCT_ROADMAP, restated as surface rules)
|
|
31
|
+
|
|
32
|
+
1. **One surface, mlx-lm vocabulary.** `mlx-bun.<verb>` is a pure alias
|
|
33
|
+
of `mlx-bun <verb>`. Adopt mlx-lm's flag name wherever it is the
|
|
34
|
+
standard; name a flag ourselves only where mlx-lm has no concept for
|
|
35
|
+
it (free to beat optiq's name there).
|
|
36
|
+
2. **Superset, never intersection.** Every documented mlx-lm flag
|
|
37
|
+
behaves faithfully so scripts drop in unchanged; we never gate a free
|
|
38
|
+
capability to resemble an upstream (OpenAI+Anthropic+Responses all
|
|
39
|
+
stay on).
|
|
40
|
+
3. **Gate only on conflict.** A capability is always on unless leaving
|
|
41
|
+
it on would degrade the automatic or compat experience (changes
|
|
42
|
+
output determinism, trades quality, surprises a script) — only then
|
|
43
|
+
does it move behind a stick-shift flag.
|
|
44
|
+
|
|
45
|
+
## Verb map (the spine = mlx-lm)
|
|
46
|
+
|
|
47
|
+
Each verb is reachable as `mlx-bun <verb>` and the dotted alias
|
|
48
|
+
`mlx-bun.<verb>`. Flags follow `mlx_lm.<verb> --help` exactly for the
|
|
49
|
+
shared subset; optiq-only features are additive (marked ⊕).
|
|
50
|
+
|
|
51
|
+
| Verb | Maps to | mlx-bun engine today | Notes |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| `generate` | mlx_lm.generate | ✅ `generate.ts` (no CLI verb) | wire verb + full flag set |
|
|
54
|
+
| `chat` | mlx_lm.chat | engine ✅, web chat ✅; no terminal REPL (`tui.ts` is help-formatting) | build REPL frontend over `generate` |
|
|
55
|
+
| `server` | mlx_lm.server / optiq serve | ✅ `serve` | rename flags; ⊕ `--kv-config`, `--anthropic` honored (default on) |
|
|
56
|
+
| `convert` | mlx_lm.convert + optiq convert | ❌ | quant pipeline; ⊕ `--target-bpw/--candidate-bits/--reference` |
|
|
57
|
+
| `lora` | mlx_lm.lora + optiq lora | serve/hot-swap ✅, train ❌ | `--train/--test`; ⊕ `--rank-scaling by_bits\|by_kl`; `lora info` |
|
|
58
|
+
| `fuse` | mlx_lm.fuse | ❌ | fuse adapters, dequant, GGUF export, upload |
|
|
59
|
+
| `cache_prompt` | mlx_lm.cache_prompt | runtime ✅, CLI ❌ | precompute + save reusable KV cache file |
|
|
60
|
+
| `benchmark` | mlx_lm.benchmark / optiq benchmark | ✅ `benchmark` | flag-name parity (`-p/-g/-b/-n`); ppl half ❌ |
|
|
61
|
+
| `evaluate` | mlx_lm.evaluate / optiq eval | ❌ (`evals` = our bench viewer) | task harness; ⊕ optiq task names |
|
|
62
|
+
| `perplexity` | mlx_lm.perplexity | ❌ | ppl on HF dataset |
|
|
63
|
+
| `upload` | mlx_lm.upload | ❌ | push MLX dir to HF |
|
|
64
|
+
| `manage` | mlx_lm.manage | ✅ `get`/`scan`/`ls` | add `--delete/--pattern/--scan` parity |
|
|
65
|
+
| `kv-cache` | optiq kv-cache | runtime ✅, profiler ❌ | per-layer sensitivity → `kv_config.json` |
|
|
66
|
+
| `latency` | optiq latency | ✅ `fit` | alias + `--calibrate` |
|
|
67
|
+
| `awq` | mlx_lm.awq | ❌ | activation-aware quant |
|
|
68
|
+
| `dwq` | mlx_lm.dwq | ❌ | distilled quant |
|
|
69
|
+
| `dynamic_quant` | mlx_lm.dynamic_quant | ❌ | sensitivity mixed-bit (overlaps convert/TurboQuant) |
|
|
70
|
+
| `gptq` | mlx_lm.gptq | ❌ | GPTQ |
|
|
71
|
+
| `share` | mlx_lm.share | ❌ | distributed cache share (lowest priority) |
|
|
72
|
+
|
|
73
|
+
Our own verbs stay (`fit`, `pi`, `harness`, `doctor`, no-args
|
|
74
|
+
appliance) — they are the automatic/stick-shift surface and have no
|
|
75
|
+
mlx-lm equivalent. See the native-surface section below.
|
|
76
|
+
|
|
77
|
+
## mlx-bun-native surface (the differentiators)
|
|
78
|
+
|
|
79
|
+
These have NO mlx-lm/optiq equivalent — they are not parity items, they
|
|
80
|
+
are what makes mlx-bun *more* than a faster mlx-lm. The compat layer
|
|
81
|
+
(Phase 17) is the "drop-in for mlx-lm" half; this is the "more than
|
|
82
|
+
mlx-lm" half.
|
|
83
|
+
|
|
84
|
+
### pi — the built-in agentic coding CLI
|
|
85
|
+
|
|
86
|
+
(Phase 16; full plan in **docs/pi-builtin-investigation.md**.) pi is an
|
|
87
|
+
MIT, Bun-native (`bun build --compile`) coding agent — the "CLI
|
|
88
|
+
experience inside our package" that neither Python package has. Two
|
|
89
|
+
commands, one for each audience:
|
|
90
|
+
|
|
91
|
+
1. **`mlx-bun pi`** (the appliance, exists) — start the server (reuse if
|
|
92
|
+
healthy) and run pi's own `InteractiveMode` **in-process**: one
|
|
93
|
+
binary, one command, a real agent on a local model with nothing to
|
|
94
|
+
install (pi is a bundled dep). Custom mlx-bun coding-agent prompt,
|
|
95
|
+
full coding tools + web tools, pi's native approval prompts.
|
|
96
|
+
`-p`→`runPrintMode`, `--mode json/rpc`→`runPrintMode`/`runRpcMode`.
|
|
97
|
+
2. **`mlx-bun harness pi`** (for people who already use pi, exists) —
|
|
98
|
+
point the user's OWN pi at mlx-bun's local model, via a generated
|
|
99
|
+
extension that dynamically discovers models from our `/v1/models`.
|
|
100
|
+
No models.json surgery; reversible. This is where the full pi flag
|
|
101
|
+
surface (`--continue`, `--resume`, `@file`, extensions, themes) lives.
|
|
102
|
+
|
|
103
|
+
History: an earlier cut shipped `mlx-bun pi` as a subprocess launcher of
|
|
104
|
+
the user's own pi (and briefly a `--external-pi` flag); both were dropped
|
|
105
|
+
(2026-06-14) — a user who already has pi already knows how to run it, so
|
|
106
|
+
it was pure duplication. The embedded agent + `harness pi` is the clean
|
|
107
|
+
split.
|
|
108
|
+
|
|
109
|
+
### Built-in web UI (OptIQ-Lab parity, pi-powered)
|
|
110
|
+
|
|
111
|
+
The web UI's agent backbone is pi's RPC / `AgentSession.subscribe()`
|
|
112
|
+
event stream (investigation Option 4) — the SAME events drive the
|
|
113
|
+
embedded TUI and the browser, so tool calls / steering / progress come
|
|
114
|
+
for free. Tiles: chat ✅; quantize / fine-tune / training-data gate on
|
|
115
|
+
the capability matrix.
|
|
116
|
+
|
|
117
|
+
## Flag-vocabulary reconciliation (where we currently diverge)
|
|
118
|
+
|
|
119
|
+
- `serve --kv-quant N` → adopt mlx-lm's `--kv-bits` + `--kv-group-size`
|
|
120
|
+
+ `--quantized-kv-start` (keep `--kv-quant` as a deprecated alias).
|
|
121
|
+
- `serve --prompt-cache` → mlx-lm's `--prompt-cache-size` (entries) +
|
|
122
|
+
`--prompt-cache-bytes` (our byte-cap is already the right model).
|
|
123
|
+
- Our runtime levers (`--compiled-decode`, `--perf-kernel`,
|
|
124
|
+
`--fused-decode`, `--fused-sdpa`, `--force-wire`) have no mlx-lm
|
|
125
|
+
equivalent → keep, these are stick-shift flags.
|
|
126
|
+
- Adopt mlx-lm's sampling names verbatim: `--temp`, `--top-p`,
|
|
127
|
+
`--top-k`, `--min-p`, `--max-tokens/-m`, `--seed`, `--xtc-*`.
|
|
128
|
+
|
|
129
|
+
## What we still lack — capability gap matrix
|
|
130
|
+
|
|
131
|
+
Legend: ✅ have · 🔌 wiring-only (engine exists, needs verb/flags) ·
|
|
132
|
+
🟥 missing capability (real build). The compat **layer** is the 🔌
|
|
133
|
+
column; the 🟥 column is the capability matrix that fills in behind it.
|
|
134
|
+
|
|
135
|
+
| Capability | Verb(s) | Status | Bucket / owning phase |
|
|
136
|
+
|---|---|---|---|
|
|
137
|
+
| One-shot generate | `generate` | 🔌 | Phase 17 (compat) |
|
|
138
|
+
| Chat REPL | `chat` | 🔌 | Phase 17 |
|
|
139
|
+
| OpenAI/Anthropic/Responses serve | `server` | ✅ | done (Phase 4/11) |
|
|
140
|
+
| Server flag parity | `server` | 🔌 | Phase 17 |
|
|
141
|
+
| Benchmark (throughput) | `benchmark` | ✅ flags 🔌 | Phase 17 |
|
|
142
|
+
| Latency prediction | `latency`/`fit` | ✅ | done; `--calibrate` 🔌 |
|
|
143
|
+
| Model cache manage | `manage` | 🔌 | Phase 17 |
|
|
144
|
+
| Precompute prompt cache | `cache_prompt` | 🔌 | Phase 17 |
|
|
145
|
+
| LoRA serve / hot-swap | `lora` (serve) | ✅ | done (Phase 8) |
|
|
146
|
+
| `lora info` reporting | `lora info` | 🔌 | Phase 17 |
|
|
147
|
+
| **HF→MLX convert → new model artifact** | `convert` | 🟥 | Model-quant (new phase) |
|
|
148
|
+
| **Sensitivity / mixed-precision weights** | `convert`, `dynamic_quant` | 🟥 | Model-quant |
|
|
149
|
+
| **AWQ / DWQ / GPTQ (weights)** | `awq`/`dwq`/`gptq` | 🟥 | Model-quant |
|
|
150
|
+
| KV-cache quant: bf16 / uniform / **mixed per-layer** (kv_config.json) | `server` (`off`/`N`/`config`) | ✅ | done (Phase 9/10; config.ts reads, generate.ts applies per-layer) |
|
|
151
|
+
| KV sensitivity *profiler* (authors a NEW kv_config.json) | `kv-cache` | 🟥 | model-prep, low pri (shipped artifacts already include one) |
|
|
152
|
+
| TurboQuant — optional extra quant *method* (rotation VQ) | scheme, not a verb | 🟥 | Phase 13 (KV plumbing already exists) |
|
|
153
|
+
| **LoRA / DoRA / full training** | `lora --train` | 🟥 | Training (new phase) |
|
|
154
|
+
| **Sensitivity-aware rank scaling** | `lora --rank-scaling` | 🟥 | Training |
|
|
155
|
+
| **Fuse adapters (+GGUF/upload)** | `fuse` | 🟥 | Training |
|
|
156
|
+
| **lm-eval-harness tasks** | `evaluate` | 🟥 | Eval (new phase) |
|
|
157
|
+
| **optiq eval suite (kl/gsm8k/ifeval/bfcl/hashhop…)** | `evaluate` | 🟥 | Eval |
|
|
158
|
+
| **Perplexity** | `perplexity` | 🟥 | Eval |
|
|
159
|
+
| **HF upload** | `upload` | 🟥 | Distribution |
|
|
160
|
+
| **Distributed share** | `share` | 🟥 | Distribution (lowest pri) |
|
|
161
|
+
| **Web UI: quantize** | `lab`/UI | 🟥 | gated on Quantize |
|
|
162
|
+
| **Web UI: fine-tune** | `lab`/UI | 🟥 | gated on Training |
|
|
163
|
+
| **Web UI: training-data template + gen** | `lab`/UI | 🟥 | new (no engine dep) |
|
|
164
|
+
| Web UI: chat | `/chat` | ✅ | done (publishing gate 2) |
|
|
165
|
+
| **Native: pi embedded** (`mlx-bun pi`, in-process TUI) | — | ✅ (P3/P4) | Phase 16 (flagship) |
|
|
166
|
+
| **Native: connect user's own pi** (`harness pi`) | — | ✅ (P1) | Phase 16 |
|
|
167
|
+
|
|
168
|
+
Summary: serving and the read-only/measurement verbs are **🔌
|
|
169
|
+
wiring-only** — the compat layer ships over what the engine already
|
|
170
|
+
does. The real capability work splits along two axes:
|
|
171
|
+
|
|
172
|
+
- **Model quantization** (offline, makes a new artifact): `convert`,
|
|
173
|
+
`awq`, `dwq`, `gptq`, `dynamic_quant`. Its own new phase.
|
|
174
|
+
- **Inference-time KV-cache quant** (online, no artifact): bf16 /
|
|
175
|
+
uniform / **mixed per-layer** from kv_config.json all ✅ today
|
|
176
|
+
(Phase 9/10 — we read & apply shipped configs). The only KV gaps are
|
|
177
|
+
optional and not inference plumbing: a *profiler* to author a new
|
|
178
|
+
kv_config.json (model-prep, low pri) and extra methods like TurboQuant
|
|
179
|
+
(Phase 13).
|
|
180
|
+
- **Training**: LoRA/DoRA/full + `fuse`.
|
|
181
|
+
- **Eval**: harness + `perplexity`.
|
|
182
|
+
- **Distribution**: `upload`/`share`.
|
|
183
|
+
|
|
184
|
+
The OptIQ-Lab web-UI tiles gate on these: quantize ← model-quant,
|
|
185
|
+
fine-tune ← training, training-data ← independent, chat ✅.
|
|
186
|
+
|
|
187
|
+
Plus the **native half** (no parity equivalent — the differentiators):
|
|
188
|
+
the pi agentic coding CLI (Phase 16: `mlx-bun pi` is the embedded
|
|
189
|
+
in-process agent, `harness pi` connects the user's own pi) and the web
|
|
190
|
+
UI, both riding pi's `AgentSession` event stream. Compat makes us a
|
|
191
|
+
drop-in for mlx-lm;
|
|
192
|
+
the native half makes us more than it.
|
|
193
|
+
|
|
194
|
+
## Parity harness (turns "drop-in" into a passing test)
|
|
195
|
+
|
|
196
|
+
Same discipline as logit parity. For each compat verb, a test diffs
|
|
197
|
+
mlx-bun against the Python oracle in `/Users/joshrossi/Code/mlx-lm/.venv`:
|
|
198
|
+
|
|
199
|
+
- **Flag-surface parity**: parse `mlx_lm.<verb> --help`, assert every
|
|
200
|
+
documented flag is accepted by `mlx-bun <verb>` (or explicitly
|
|
201
|
+
rejected with a clear message — never silently ignored).
|
|
202
|
+
- **Behavior parity** where deterministic: `generate --seed --temp 0`
|
|
203
|
+
output, `manage --scan` listing shape, `cache_prompt` round-trip,
|
|
204
|
+
`benchmark` column schema.
|
|
205
|
+
- **Gap honesty**: a not-yet-built verb (`convert`, `evaluate`, …)
|
|
206
|
+
exits non-zero with `not implemented in mlx-bun yet` — the harness
|
|
207
|
+
asserts the message, so gaps are visible, not silent.
|
|
208
|
+
|
|
209
|
+
Gated by `benchmark.sh`-style preflight only where it measures speed;
|
|
210
|
+
correctness diffs need no clean machine.
|
|
211
|
+
|
|
212
|
+
## Build sequencing
|
|
213
|
+
|
|
214
|
+
1. **Phase 17 — this layer**: verb router + dotted aliases + flag
|
|
215
|
+
vocabulary + reconcile existing commands + parity harness, over
|
|
216
|
+
existing capabilities (`generate`, `chat`, `server`, `benchmark`,
|
|
217
|
+
`manage`, `cache_prompt`, `lora info`, `latency`). Honest stubs for
|
|
218
|
+
🟥 verbs.
|
|
219
|
+
2. Model quantization (new phase) → `convert`/`dynamic_quant`/`awq`/
|
|
220
|
+
`dwq`/`gptq` (new model artifacts) + web-UI quantize tile.
|
|
221
|
+
3. Inference-time KV quant → already done (bf16 / uniform / mixed
|
|
222
|
+
per-layer via kv_config.json, Phase 9/10). Optional later: a profiler
|
|
223
|
+
to author new configs (low pri) + the TurboQuant method (Phase 13).
|
|
224
|
+
4. Training → `lora --train`/`fuse` + web-UI fine-tune tile.
|
|
225
|
+
5. Eval → `evaluate`/`perplexity`.
|
|
226
|
+
6. Distribution → `upload`/`share`.
|
|
227
|
+
7. Web UI training-data tile (independent of engine work).
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Docs & repo-organization cleanup plan
|
|
2
|
+
|
|
3
|
+
**Status:** executed 2026-06-14 (P0 + P1 + P2 #11). Held: P2 #9/#10
|
|
4
|
+
(src/ and scripts/ moves — they change import paths / script references
|
|
5
|
+
and need a test run, so deferred to their own pass). Authored 2026-06-14.
|
|
6
|
+
|
|
7
|
+
**Scope & ethos.** Private repo, single author + agents, MLX-by-identity.
|
|
8
|
+
No OSS/community scaffolding (CONTRIBUTING, issue templates, badges) —
|
|
9
|
+
out of scope by design. **Prefer move / consolidate over delete.** The
|
|
10
|
+
one exception is regenerable benchmark *output* (md/json/html report
|
|
11
|
+
artifacts): those are noise, not experiments, and are explicitly
|
|
12
|
+
deletable per Josh's direction. Losing *experiments* and code paths are
|
|
13
|
+
never deleted (see memory: "don't delete optionality on one
|
|
14
|
+
measurement").
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## The centerpiece: benchmark provenance (corrected)
|
|
19
|
+
|
|
20
|
+
The original analysis mis-framed this. The correct policy:
|
|
21
|
+
|
|
22
|
+
- Benchmark **runs** are date- and machine-stamped, regenerable, and
|
|
23
|
+
machine-specific. They do **not** belong in the durable repo. The
|
|
24
|
+
existing `.gitignore` rule `benchmarks-h2h-*` (ignore all raw runs) is
|
|
25
|
+
**correct and stays**.
|
|
26
|
+
- The actual defect today: a handful of raw run files leaked into git
|
|
27
|
+
history (committed before that ignore rule existed), and the README's
|
|
28
|
+
headline performance claims cite one of them
|
|
29
|
+
(`benchmarks/benchmarks-h2h-2026-06-11-Joshs-MBP-2025.md`) as the
|
|
30
|
+
source of truth. The repo's central perf claim depends on exactly the
|
|
31
|
+
kind of ephemeral artifact the gitignore says shouldn't be tracked.
|
|
32
|
+
|
|
33
|
+
**The fix:** one curated, intentionally-maintained record, structured
|
|
34
|
+
around the **three distinct kinds of measurement** below; raw runs stay
|
|
35
|
+
local/ignored; the eval DB remains the structured backing record.
|
|
36
|
+
|
|
37
|
+
### The three kinds of benchmarks (the record's structure)
|
|
38
|
+
|
|
39
|
+
These are categorically different — one is pass/fail correctness, one is
|
|
40
|
+
a perf number, one is a quality delta — and `RESULTS.md` must keep them
|
|
41
|
+
in separate sections rather than one undifferentiated table. They map to
|
|
42
|
+
the project's three-tier parity model (L1/L2/L3).
|
|
43
|
+
|
|
44
|
+
1. **Parity (porting correctness) — pass/fail, not a number.** Are we
|
|
45
|
+
bit-for-bit with the upstream oracle under like-for-like config?
|
|
46
|
+
- mlx-lm + standard (bf16) KV cache → bit-exact (L1).
|
|
47
|
+
- mlx-optiq + mixed-precision KV cache → bit-exact (L2).
|
|
48
|
+
Record as a matrix of model × mode → ✓/✗ (+ commit, oracle versions).
|
|
49
|
+
This is the gate the perf/quality numbers are only meaningful *under*.
|
|
50
|
+
|
|
51
|
+
2. **Performance — like-for-like numbers, two comparison axes.** Under
|
|
52
|
+
the parity constraints above, measure tok/s, prefill/s, decode/s,
|
|
53
|
+
TTFT, startup, RSS, peak memory. Two axes:
|
|
54
|
+
- **vs the oracles** — mlx-bun vs mlx-lm / mlx-optiq, same model, same
|
|
55
|
+
mode, same machine, same day.
|
|
56
|
+
- **vs our own compat mode** — mlx-bun's NEW optimizations vs
|
|
57
|
+
mlx-bun's own compatible (bit-exact) path, to prove an optimization
|
|
58
|
+
actually beats the baseline it diverges from.
|
|
59
|
+
|
|
60
|
+
3. **Quality — for our non-bit-exact optimizations only (L3).** When a
|
|
61
|
+
custom path trades exactness for speed, quantify what the trade costs:
|
|
62
|
+
- **mean score across the 6 eval tasks** (`src/eval/tasks/`: bfcl,
|
|
63
|
+
gsm8k, hashhop, humaneval, ifeval, mmlu), vs the compatible upstream.
|
|
64
|
+
- **KL divergence** vs the compatible distribution.
|
|
65
|
+
Purpose: enable statements like *"the optimized path gains 23% tok/s
|
|
66
|
+
while holding ±5% on the 6-test mean"* — the perf win is only worth
|
|
67
|
+
claiming alongside its measured quality cost.
|
|
68
|
+
|
|
69
|
+
### B1. Create `benchmarks/RESULTS.md` (the new durable record)
|
|
70
|
+
- Three top-level sections: **Parity** (model × mode → ✓/✗), **Performance**
|
|
71
|
+
(oracle comparison + our-optimized-vs-our-compat), **Quality** (6-test
|
|
72
|
+
mean + KL for non-exact paths). Each row carries provenance (machine,
|
|
73
|
+
date, commit, model, mode, oracle versions).
|
|
74
|
+
- Named so it does **not** match `benchmarks-h2h-*`, so it's tracked
|
|
75
|
+
deliberately and future raw runs never auto-collide with it.
|
|
76
|
+
- Migrate the headline numbers Josh wants to keep (currently the 06-11
|
|
77
|
+
matrix, plus the 06-13/06-14 follow-ups) into the right section
|
|
78
|
+
**before** removing the raw files, so README's claims never lose their
|
|
79
|
+
source.
|
|
80
|
+
- Point README's "Full table" link at `benchmarks/RESULTS.md`.
|
|
81
|
+
|
|
82
|
+
### B2. Remove the old committed benchmark artifacts
|
|
83
|
+
`git rm` the leaked raw runs and verification dumps (numbers preserved in
|
|
84
|
+
B1 + the eval DB):
|
|
85
|
+
- `benchmarks/benchmarks-h2h-2026-06-10-Joshs-MBP-2025.md`
|
|
86
|
+
- `benchmarks/benchmarks-h2h-2026-06-10-Joshs-MacBook-Pro.md`
|
|
87
|
+
- `benchmarks/benchmarks-h2h-2026-06-10.md`
|
|
88
|
+
- `benchmarks/benchmarks-h2h-2026-06-11-Joshs-MBP-2025.md`
|
|
89
|
+
- `benchmarks/lab-verification.json`
|
|
90
|
+
- `benchmarks/lab-verification-mixed.json`
|
|
91
|
+
|
|
92
|
+
Also clear the loose **untracked** root spew (delete or move to an
|
|
93
|
+
ignored `reports/`): `benchmarks-h2h-2026-06-13-*.md`,
|
|
94
|
+
`benchmarks-h2h-2026-06-14-*.{md,html}`, `benchmark-report-*.html`,
|
|
95
|
+
`kernel-fusion-report-*.html`, `project-review.html`.
|
|
96
|
+
|
|
97
|
+
`scripts/verify-lab.ts` keeps writing `benchmarks/lab-verification.json`
|
|
98
|
+
locally — it'll just be gitignored now (add `benchmarks/lab-verification*.json`
|
|
99
|
+
to `.gitignore`).
|
|
100
|
+
|
|
101
|
+
### B3. Eval DB — leave where it is (decided 2026-06-14)
|
|
102
|
+
- `~/.cache/mlx-bun/evals.sqlite` ([src/evaldb.ts:8](../../src/evaldb.ts))
|
|
103
|
+
stays user-local — it is the structured backing record of every run.
|
|
104
|
+
**Not tracked in-repo** (binary SQLite in git doesn't diff, churns, and
|
|
105
|
+
grows history). `RESULTS.md` is the committed human-readable record; the
|
|
106
|
+
DB is its machine-local source. Decision confirmed by Josh — closed.
|
|
107
|
+
|
|
108
|
+
### Do NOT touch
|
|
109
|
+
`goldens/*.json` and `goldens/**` are the correctness oracle golden
|
|
110
|
+
files, not benchmark output. Leave entirely alone.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## P0 — Quick, safe wins (low risk)
|
|
115
|
+
|
|
116
|
+
| # | Action | Why |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| 1 | Collapse `AGENTS.md` → `CLAUDE.md` (make AGENTS.md a 1-line pointer or symlink). | They're byte-identical except the title line — guaranteed to drift. |
|
|
119
|
+
| 2 | B1–B2 above: create `RESULTS.md`, migrate numbers, `git rm` old artifacts, point README at it, gitignore `lab-verification*.json`. | Fixes benchmark provenance; declutters; keeps gitignore policy honest. |
|
|
120
|
+
| 3 | Relocate untracked root HTML/md spew into an ignored `reports/` (or delete). | De-clutters the working-tree root. |
|
|
121
|
+
| 4 | Drop the hardcoded "All 72 tests" in CLAUDE.md (say "the suite" / reference the count command). | 57 test files now — a baked-in number that's already wrong. |
|
|
122
|
+
|
|
123
|
+
## P1 — Structural consolidation (the real navigability win)
|
|
124
|
+
|
|
125
|
+
| # | Action | Why |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| 5 | Add `STATUS.md` (or a pinned top section in PLAN.md) holding only live handoff: current state + next action + blockers. Move PLAN.md's `NEXT UP` / `NEXT SESSION PICKUP` / `SESSION SWEEP` blocks into it. | Separates transient "do this next" from 2,475 lines of durable phase history; gives agents one entry point. |
|
|
128
|
+
| 6 | Create `docs/planning/` and move `PRODUCT_ROADMAP.md`, `IDEAS.md`, `ResearchTopics.md`, `journal.md` under it. Leave only README + PLAN.md (+ STATUS.md) at root. Add a ~6-line "doc map" to README. | Root is currently a 6-file planning thicket; extends the taxonomy that already works in `docs/`. |
|
|
129
|
+
| 7 | Pick one home for the optimization plan: fold `docs/design/optimization_plan.md` into PLAN.md Phase A–E, or have PLAN.md link out to it as canonical. | Two homes for the same plan = drift. |
|
|
130
|
+
| 8 | Resolve the archive overlap: `archive/pi-builtin-investigation.html` duplicates [docs/investigations/pi-builtin-investigation.md](../investigations/pi-builtin-investigation.md). Decide whether `archive/` (tracked; 8 generated HTML files incl. a 374 KB pi-session transcript) should be tracked at all, or moved to an ignored location. Keep the `.md`, drop the duplicate. | Stops committing heavyweight generated HTML; one source per investigation. |
|
|
131
|
+
|
|
132
|
+
## P2 — Polish (optional)
|
|
133
|
+
|
|
134
|
+
| # | Action | Why |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| 9 | Group `src/pi/` (`harness-pi.ts`, `pi-provider.ts`, `pi-terminal.ts`, `pi-web.ts`). | `src/` root is 31 flat files; this is an obvious cohesive cluster. |
|
|
137
|
+
| 10 | Sort `scripts/` into `scripts/{bench,regen,build}/` (40 files, clear prefixes). | Navigability only; low urgency. |
|
|
138
|
+
| 11 | Reconcile CLI vocabulary: README quickstart uses the shipped `mlx-bun` verb (with a one-line "from a clone, `bun src/cli.ts` is the same"). | README/roadmap/package.json currently mix `bun src/cli.ts` and `mlx-bun`. |
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Execution order (after slots work is pushed)
|
|
143
|
+
|
|
144
|
+
1. P0 #1, #4 (trivial, isolated).
|
|
145
|
+
2. Benchmark block B1 → B2 → README relink (do B1 fully before B2).
|
|
146
|
+
3. P0 #3 (root spew).
|
|
147
|
+
4. Confirm B3 eval-DB decision with Josh.
|
|
148
|
+
5. P1 #5–#8 (the structural moves; one commit per item so history stays legible).
|
|
149
|
+
6. P2 as appetite allows.
|
|
150
|
+
|
|
151
|
+
Each step keeps the test suite green and changes no source behavior — this
|
|
152
|
+
is docs + file layout only.
|