mlx-bun 0.0.13 → 0.3.0

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 (427) hide show
  1. package/README.md +71 -578
  2. package/bin/mlx-bun.mjs +1 -1
  3. package/docs/README.md +91 -0
  4. package/docs/{design → archive}/hlg-sampling.md +3 -3
  5. package/docs/{design → archive/investigations}/audio-input-plan.md +4 -4
  6. package/docs/{design → archive/investigations}/colibri-glm52-port.md +1 -1
  7. package/docs/{design → archive/investigations}/diffusion-gemma-port.md +3 -3
  8. package/docs/{design → archive/investigations}/faithful-l1-consolidation.md +4 -4
  9. package/docs/{investigations → archive/investigations}/hlg-sampling-investigation.md +1 -1
  10. package/docs/{design → archive/investigations}/minicpm5-decode-megakernel.md +11 -11
  11. package/docs/{design → archive/investigations}/optimization_plan.md +1 -1
  12. package/docs/archive/investigations/pareto-specialized-runtime-findings.md +92 -0
  13. package/docs/{design → archive/investigations}/pre-colibri-stabilization.md +5 -5
  14. package/docs/{design → archive/investigations}/the-dreaming-handoff.md +2 -2
  15. package/docs/{planning → archive/planning}/chat-ui-vision.md +1 -1
  16. package/docs/{planning → archive/planning}/chunk-task-roadmap.md +1 -1
  17. package/docs/{planning → archive/planning}/curve-sampler-research-plan.md +4 -4
  18. package/docs/{planning → archive/planning}/memory-docs-and-dag-plan.md +1 -1
  19. package/docs/{planning → archive/planning}/release-notes-v0.0.9.md +1 -1
  20. package/docs/archive/planning/release-notes-v0.2.0.md +49 -0
  21. package/docs/{planning → archive/planning}/website-readme-pass-plan.md +1 -1
  22. package/docs/design/batching.md +569 -0
  23. package/docs/design/decode-speed-program.md +3178 -169
  24. package/docs/design/dreaming-nightly-pipeline.md +675 -282
  25. package/docs/design/generic-model-support.md +579 -334
  26. package/docs/design/kv-cache.md +680 -0
  27. package/docs/design/orpo-training.md +673 -1239
  28. package/docs/design/speculative-decoding.md +1627 -0
  29. package/docs/design/turboquant.md +2102 -0
  30. package/docs/design/unified-engine-frontier-plan.md +1831 -727
  31. package/docs/design/web-chat-redesign.md +666 -1083
  32. package/docs/planning/PRODUCT_ROADMAP.md +34 -1
  33. package/docs/planning/release-notes-v0.3.0.md +35 -0
  34. package/docs/planning/video-series.md +421 -0
  35. package/docs/reference/benchmarks.md +1162 -0
  36. package/docs/reference/cli.md +395 -149
  37. package/docs/reference/distribution.md +321 -181
  38. package/docs/reference/environment.md +348 -0
  39. package/docs/reference/glossary.md +39 -0
  40. package/docs/reference/library-api.md +580 -142
  41. package/docs/reference/memory.md +227 -64
  42. package/docs/reference/models.md +137 -6
  43. package/docs/reference/server-api.md +938 -422
  44. package/docs/reference/server-config.md +652 -320
  45. package/docs/reference/training.md +393 -254
  46. package/docs/reference/troubleshooting.md +166 -0
  47. package/package.json +10 -5
  48. package/src/admission-plan.ts +18 -0
  49. package/src/anthropic.ts +92 -3
  50. package/src/audio/decode.ts +2 -2
  51. package/src/audio/features.ts +2 -2
  52. package/src/backends/mlx/autoregressive.ts +108 -0
  53. package/src/backends/mlx/batch-group.ts +1646 -0
  54. package/src/backends/mlx/diffusion.ts +39 -0
  55. package/src/backends/mlx/draft-target.ts +47 -0
  56. package/src/backends/mlx/evaluation.ts +105 -0
  57. package/src/backends/mlx/fill-append.ts +45 -0
  58. package/src/backends/mlx/gateway-binding.ts +71 -0
  59. package/src/backends/mlx/graph.ts +38 -0
  60. package/src/backends/mlx/memory-client.ts +189 -0
  61. package/src/backends/mlx/memory-guard.ts +40 -0
  62. package/src/backends/mlx/methods.ts +90 -0
  63. package/src/backends/mlx/model-prompt.ts +164 -0
  64. package/src/backends/mlx/model-serving.ts +79 -0
  65. package/src/backends/mlx/prefill.ts +33 -0
  66. package/src/backends/mlx/request-policy.ts +20 -0
  67. package/src/backends/mlx/rollback.ts +51 -0
  68. package/src/backends/mlx/serial-executor.ts +273 -0
  69. package/src/backends/mlx/speculative.ts +114 -0
  70. package/src/backends/mlx/state-views.ts +26 -0
  71. package/src/backends/mlx/text-engine.ts +73 -0
  72. package/src/cli.ts +189 -61
  73. package/src/client.ts +66 -0
  74. package/src/config.ts +21 -4
  75. package/src/contracts/completion.ts +16 -0
  76. package/src/contracts/execution.ts +49 -0
  77. package/src/contracts/generation.ts +103 -0
  78. package/src/contracts/host.ts +7 -0
  79. package/src/contracts/jobs.ts +66 -0
  80. package/src/contracts/pi-provider.ts +30 -0
  81. package/src/contracts/pi.ts +259 -0
  82. package/src/contracts/resources.ts +18 -0
  83. package/src/contracts/scheduling.ts +27 -0
  84. package/src/contracts/tsconfig.json +14 -0
  85. package/src/diffusion/diffusion-generate.ts +218 -153
  86. package/src/embed.ts +1 -1
  87. package/src/engine/admission.ts +59 -0
  88. package/src/engine/cancellation.ts +38 -0
  89. package/src/engine/engine.ts +56 -0
  90. package/src/engine/execution-coordinator.ts +70 -0
  91. package/src/engine/execution-plan.ts +51 -0
  92. package/src/engine/resources.ts +42 -0
  93. package/src/engine/scheduler.ts +67 -0
  94. package/src/engine/session.ts +247 -0
  95. package/src/eval/README.md +44 -1
  96. package/src/eval/kl.ts +263 -23
  97. package/src/eval/reference-logits.ts +207 -0
  98. package/src/eval/runner.ts +10 -79
  99. package/src/eval/tasks/bfcl.ts +2 -1
  100. package/src/eval/tasks/gsm8k.ts +2 -1
  101. package/src/eval/tasks/hashhop.ts +2 -1
  102. package/src/eval/tasks/humaneval.ts +5 -4
  103. package/src/eval/tasks/ifeval.ts +2 -1
  104. package/src/eval/tasks/mmlu.ts +2 -1
  105. package/src/expert-io.ts +3 -1
  106. package/src/expert-offload.ts +3 -1
  107. package/src/fill/echo-index.ts +188 -0
  108. package/src/fill/fill-session.ts +452 -0
  109. package/src/fill/proposal.ts +68 -0
  110. package/src/fill/schema-rows.ts +506 -0
  111. package/src/fill/tool-boundary.ts +103 -0
  112. package/src/fit.ts +24 -43
  113. package/src/generate.ts +740 -337
  114. package/src/grammar.ts +14 -8
  115. package/src/harness-pi.ts +15 -34
  116. package/src/hub-rest.ts +4 -4
  117. package/src/index.ts +27 -0
  118. package/src/inference/denoising.ts +17 -0
  119. package/src/inference/graph.ts +33 -0
  120. package/src/inference/prefill.ts +39 -0
  121. package/src/inference/rollback.ts +7 -0
  122. package/src/jobs/db.ts +4 -0
  123. package/src/jobs/index.ts +2 -0
  124. package/src/jobs/job-entry.ts +15 -14
  125. package/src/jobs/runner.ts +98 -13
  126. package/src/jobs/task-client.ts +19 -0
  127. package/src/jobs/types.ts +2 -58
  128. package/src/kv-scheme.ts +199 -0
  129. package/src/kv-store.ts +459 -234
  130. package/src/lab/README.md +18 -0
  131. package/src/{assets → lab/curve}/curve-designer.html +2 -2
  132. package/src/{curve-sampler.ts → lab/curve/curve-sampler.ts} +2 -2
  133. package/src/{expert-trace.ts → lab/expert-trace/expert-trace.ts} +7 -5
  134. package/src/{model → lab/paged-kv}/paged-kv.ts +9 -6
  135. package/src/library.ts +40 -0
  136. package/src/lora.ts +18 -0
  137. package/src/media-fetch.ts +20 -4
  138. package/src/memory/article.ts +1 -1
  139. package/src/memory/chunk.ts +1 -1
  140. package/src/memory/model.ts +32 -170
  141. package/src/memory/prompts.ts +1 -1
  142. package/src/memory/rest.ts +1 -1
  143. package/src/memory/schedule.ts +1 -1
  144. package/src/memory/stages.ts +4 -1
  145. package/src/memory/vault.ts +3 -4
  146. package/src/mlx/array.ts +9 -10
  147. package/src/mlx/compile.ts +12 -2
  148. package/src/mlx/ffi.ts +66 -22
  149. package/src/mlx/materialize.ts +23 -0
  150. package/src/mlx/metal-kernel.ts +10 -11
  151. package/src/mlx/ops.ts +64 -19
  152. package/src/mlx/quantized-rows.ts +36 -0
  153. package/src/mlx/token-bitmask.ts +52 -0
  154. package/src/mlx/turboquant-kv-decode.ts +82 -0
  155. package/src/mlx/turboquant-kv-inverse.ts +122 -0
  156. package/src/mlx/turboquant-ops.ts +33 -3
  157. package/src/mlx/turboquant-tables.ts +2 -2
  158. package/src/model/batched-mask.ts +9 -3
  159. package/src/model/batched-quant.ts +2 -2
  160. package/src/model/batched-rotating-quant.ts +45 -99
  161. package/src/model/batched-rotating-state.ts +73 -0
  162. package/src/model/batched-rotating.ts +57 -106
  163. package/src/model/batched-row-storage.ts +127 -0
  164. package/src/model/compiled-decode.ts +4 -3
  165. package/src/model/diffusion-gemma.ts +8 -8
  166. package/src/model/factory.ts +87 -49
  167. package/src/model/fingerprint.ts +1 -1
  168. package/src/model/flash-attention.ts +3 -3
  169. package/src/model/gemma4-base.ts +187 -17
  170. package/src/model/gemma4.ts +6 -6
  171. package/src/model/generated/gemma4-12b.ts +52 -148
  172. package/src/model/generated/gemma4-26b.ts +34 -94
  173. package/src/model/generated/gemma4-e4b.ts +28 -76
  174. package/src/model/glm52-cache.ts +19 -9
  175. package/src/model/glm52-dsa.ts +13 -9
  176. package/src/model/glm52-memory.ts +28 -1
  177. package/src/model/implementation.ts +69 -0
  178. package/src/model/minicpm5.ts +7 -8
  179. package/src/model/profile.ts +443 -0
  180. package/src/model/qwen-append.ts +12 -0
  181. package/src/model/qwen-conv.ts +52 -0
  182. package/src/model/qwen3-delta.ts +98 -2
  183. package/src/model/qwen3-mrope.ts +252 -0
  184. package/src/model/qwen3_5-checkpoint.ts +164 -0
  185. package/src/model/qwen3_5.ts +336 -60
  186. package/src/model/support.ts +1 -1
  187. package/src/model/trellis-balanced-scatter.ts +51 -0
  188. package/src/model/trellis-linear.ts +672 -0
  189. package/src/model/trellis-shared-m.ts +151 -0
  190. package/src/model/trellis-shared-scatter.ts +144 -0
  191. package/src/model/trellis-splitk-prefill.ts +158 -0
  192. package/src/model/trellis-tiled-prefill.ts +136 -0
  193. package/src/model/trellis-vector-expand.ts +62 -0
  194. package/src/model/trellis-wide-prefill.ts +94 -0
  195. package/src/model/universal/dense.ts +1 -1
  196. package/src/model/universal/modules.ts +8 -1
  197. package/src/native/frame_extract.swift +140 -0
  198. package/src/native-pack.ts +15 -7
  199. package/src/pi-provider.ts +6 -64
  200. package/src/pi-web.ts +14 -320
  201. package/src/prompt-cache.ts +97 -54
  202. package/src/quantize/allocator.ts +1 -1
  203. package/src/quantize/atomic-output.ts +38 -0
  204. package/src/quantize/calibration.ts +2 -1
  205. package/src/quantize/config-writer.ts +16 -3
  206. package/src/quantize/index.ts +28 -1
  207. package/src/quantize/job.ts +11 -0
  208. package/src/quantize/quantizer.ts +265 -100
  209. package/src/quantize/rotate.ts +603 -0
  210. package/src/quantize/safetensors-writer.ts +79 -1
  211. package/src/quantize/sensitivity.ts +41 -59
  212. package/src/quantize/trellis.ts +586 -0
  213. package/src/quantize/weight-transform.ts +292 -0
  214. package/src/responses.ts +130 -3
  215. package/src/runtime-config.ts +81 -0
  216. package/src/sampler.ts +276 -4
  217. package/src/serve/admin-routes.ts +184 -0
  218. package/src/serve/aux-routes.ts +132 -0
  219. package/src/serve/batch-scheduler.ts +8 -1558
  220. package/src/serve/chat-request.ts +391 -0
  221. package/src/serve/chat-stage.ts +195 -0
  222. package/src/serve/checkpoint-identity.ts +64 -0
  223. package/src/serve/completion-executor.ts +354 -0
  224. package/src/serve/completion-sink.ts +157 -0
  225. package/src/serve/discovery-routes.ts +204 -0
  226. package/src/serve/generation-gateway.ts +211 -243
  227. package/src/serve/http.ts +159 -0
  228. package/src/serve/inference-request.ts +79 -0
  229. package/src/serve/isolate.ts +297 -105
  230. package/src/serve/kv-budget.ts +14 -0
  231. package/src/serve/lab-routes.ts +341 -0
  232. package/src/serve/lane-registry.ts +2 -1
  233. package/src/serve/model-admin-routes.ts +155 -0
  234. package/src/serve/model-binding.ts +43 -0
  235. package/src/serve/model-host.ts +512 -0
  236. package/src/serve/openai-wire.ts +103 -0
  237. package/src/serve/parent-application.ts +56 -0
  238. package/src/serve/pipeline.ts +33 -0
  239. package/src/serve/preparation.ts +33 -0
  240. package/src/serve/prompt-response-trace.ts +147 -0
  241. package/src/serve/request-plan.ts +162 -0
  242. package/src/serve/request-prep.ts +346 -0
  243. package/src/serve/response-lease.ts +24 -0
  244. package/src/serve/responses-client.ts +69 -0
  245. package/src/serve/session-completion-engine.ts +110 -0
  246. package/src/serve/session-search.ts +1 -1
  247. package/src/serve/static-routes.ts +101 -0
  248. package/src/serve/text-completion-stage.ts +104 -0
  249. package/src/serve/token-streams.ts +519 -0
  250. package/src/server.ts +523 -3551
  251. package/src/spec/assistant-source.ts +10 -44
  252. package/src/spec/deepspec-source.ts +6 -6
  253. package/src/spec/dflash-source.ts +9 -8
  254. package/src/spec/dspark/ab-stats.ts +3 -3
  255. package/src/spec/dspark/calibration.ts +2 -2
  256. package/src/spec/dspark/deepspec-module.ts +2 -2
  257. package/src/spec/dspark/generate-dflash.ts +2 -2
  258. package/src/spec/dspark/generate.ts +2 -2
  259. package/src/spec/dspark/loader.ts +1 -1
  260. package/src/spec/dspark/module-dflash.ts +5 -4
  261. package/src/spec/dspark/module.ts +3 -3
  262. package/src/spec/dspark/quantize-drafter.ts +1 -1
  263. package/src/spec/generate.ts +1 -1
  264. package/src/spec/glm52-mtp-source.ts +9 -1
  265. package/src/spec/ngram-source.ts +1 -1
  266. package/src/spec/prefix-state.ts +45 -0
  267. package/src/spec/qwen-mtp-source.ts +528 -0
  268. package/src/spec/serve-loop.ts +179 -213
  269. package/src/spec/source.ts +42 -10
  270. package/src/spec/two-model.ts +1 -1
  271. package/src/ssd-cache.ts +95 -24
  272. package/src/ssd-durability.ts +207 -0
  273. package/src/tool-call.ts +51 -14
  274. package/src/train/flash-cce.ts +14 -13
  275. package/src/train/forward.ts +38 -1
  276. package/src/train/loss.ts +3 -2
  277. package/src/train/prefix-shared.ts +5 -1
  278. package/src/train/segmented.ts +9 -6
  279. package/src/train/trainer.ts +9 -8
  280. package/src/vision/preprocess.ts +1 -1
  281. package/src/vision/prompt.ts +48 -2
  282. package/src/vision/qwen3vl-preprocess.ts +409 -0
  283. package/src/vision/qwen3vl-prompt.ts +196 -0
  284. package/src/vision/qwen3vl-tower.ts +555 -0
  285. package/src/vision/video-frames.ts +148 -0
  286. package/src/web/app.html +1 -1
  287. package/src/web/app.js +15 -6
  288. package/src/web/src/adapters-panel.ts +3 -3
  289. package/src/web/src/assistant.ts +2 -36
  290. package/src/web/src/chat.ts +16 -9
  291. package/src/web/src/composer.ts +4 -4
  292. package/src/web/src/hub.ts +1 -1
  293. package/src/web/src/markdown.ts +0 -0
  294. package/src/web/src/memory-panel.ts +1 -1
  295. package/src/web/src/model-picker.ts +1 -1
  296. package/src/web/src/palette.ts +1 -1
  297. package/src/web/src/protocol.ts +3 -39
  298. package/src/web/src/sessions.ts +1 -1
  299. package/src/web/src/ui-catalog.ts +4 -18
  300. package/src/web-assets.ts +47 -0
  301. package/src/weights.ts +134 -33
  302. package/docs/archive/mlx-bun-lab-report.html +0 -275
  303. package/docs/archive/wwdc-mlx-bun.html +0 -848
  304. package/docs/design/adapters-end-to-end.md +0 -205
  305. package/docs/design/batching-perf-path.md +0 -255
  306. package/docs/design/batching-v2-plan.md +0 -529
  307. package/docs/design/bucketing-stage.md +0 -197
  308. package/docs/design/compat-cli-surface-design.md +0 -230
  309. package/docs/design/docs-reorg-plan.md +0 -165
  310. package/docs/design/dspark-serving-program.md +0 -371
  311. package/docs/design/dspark-speculative-decoding.md +0 -268
  312. package/docs/design/grammar-spec-batching-integration.md +0 -301
  313. package/docs/design/memory-inference-path.md +0 -422
  314. package/docs/design/memory-synthesis.md +0 -287
  315. package/docs/design/memory-system.md +0 -237
  316. package/docs/design/mlx-lm-tool-parity-plan.md +0 -545
  317. package/docs/design/omlx-adoption-map.md +0 -98
  318. package/docs/design/orpo-dynamic-lambda.md +0 -220
  319. package/docs/design/orpo-future-enhancements.md +0 -340
  320. package/docs/design/paged-kv-cache.md +0 -214
  321. package/docs/design/parallel-slots.md +0 -567
  322. package/docs/design/parity-tier-dag.md +0 -161
  323. package/docs/design/repo-cleanup-plan.md +0 -189
  324. package/docs/design/runtime-isolation.md +0 -263
  325. package/docs/design/segmented-backward-training.md +0 -543
  326. package/docs/design/spec-decode-larger-targets.md +0 -229
  327. package/docs/design/ssd-kv-cold-tier.md +0 -288
  328. package/docs/design/structured-output.md +0 -484
  329. package/docs/design/tauri-desktop-app.md +0 -127
  330. package/docs/design/the-dreaming-master-plan.md +0 -445
  331. package/docs/design/turboquant-kv.md +0 -235
  332. package/docs/design/w4a16-compute-precision-spike.md +0 -232
  333. package/docs/design/web-chat-beat-matrix.md +0 -315
  334. package/docs/design/write-pipeline-entity.md +0 -468
  335. package/docs/investigations/curve-runs/bisector-route.json +0 -98
  336. package/docs/investigations/curve-runs/bisector-trace.json +0 -1393
  337. package/docs/investigations/curve-runs/curve-terrain.json +0 -1179
  338. package/docs/investigations/curve-runs/curve-terrain.svg +0 -42
  339. package/docs/investigations/hlg-ab.html +0 -34
  340. package/docs/investigations/hlg-explorer.html +0 -238
  341. package/docs/investigations/hlg-figs/cliff.svg +0 -1
  342. package/docs/investigations/hlg-figs/cross.svg +0 -1
  343. package/docs/investigations/hlg-figs/edges.svg +0 -1
  344. package/docs/investigations/hlg-figs/k20-grids.svg +0 -1
  345. package/docs/investigations/hlg-figs/k20-peaks.svg +0 -1
  346. package/docs/investigations/hlg-figs/lw-curve.svg +0 -1
  347. package/docs/investigations/hlg-figs/terrain.svg +0 -1
  348. package/docs/investigations/hlg-report.html +0 -262
  349. package/docs/investigations/hlg-runs/hlg-ab.json +0 -149
  350. package/docs/investigations/hlg-runs/hlg-blind-prompts.md +0 -87
  351. package/docs/investigations/hlg-runs/hlg-blind.json +0 -107
  352. package/docs/investigations/hlg-runs/hlg-cliff.json +0 -197
  353. package/docs/investigations/hlg-runs/hlg-cross.json +0 -505
  354. package/docs/investigations/hlg-runs/hlg-edge.json +0 -388
  355. package/docs/investigations/hlg-runs/hlg-eval1.json +0 -25
  356. package/docs/investigations/hlg-runs/hlg-frontier.json +0 -86
  357. package/docs/investigations/hlg-runs/hlg-grid.json +0 -242
  358. package/docs/investigations/hlg-runs/hlg-grid2.json +0 -343
  359. package/docs/investigations/hlg-runs/hlg-lw-coarse.json +0 -110
  360. package/docs/investigations/hlg-runs/hlg-map.json +0 -383
  361. package/docs/investigations/hlg-runs/run0-original.log +0 -159
  362. package/docs/investigations/hlg-runs/runA-recommended.log +0 -131
  363. package/docs/investigations/hlg-runs/runAA-cliff-cpm5.log +0 -26
  364. package/docs/investigations/hlg-runs/runAB-grid2-e4b.log +0 -18
  365. package/docs/investigations/hlg-runs/runAC-peak-e4b-partial.log +0 -25
  366. package/docs/investigations/hlg-runs/runAD-ab-samples.log +0 -8
  367. package/docs/investigations/hlg-runs/runAE-edge-e4b.log +0 -51
  368. package/docs/investigations/hlg-runs/runAF-logit-calibration.log +0 -10
  369. package/docs/investigations/hlg-runs/runAG-eval-config2.log +0 -16
  370. package/docs/investigations/hlg-runs/runB-gain-variants.log +0 -192
  371. package/docs/investigations/hlg-runs/runC-pivots.log +0 -162
  372. package/docs/investigations/hlg-runs/runD-oetf.log +0 -132
  373. package/docs/investigations/hlg-runs/runE-eotf.log +0 -162
  374. package/docs/investigations/hlg-runs/runF-shaper-working.log +0 -86
  375. package/docs/investigations/hlg-runs/runG-shaper-sweep.log +0 -101
  376. package/docs/investigations/hlg-runs/runH-wsweep.log +0 -176
  377. package/docs/investigations/hlg-runs/runI-asweep.log +0 -176
  378. package/docs/investigations/hlg-runs/runJ-knobmap.log +0 -49
  379. package/docs/investigations/hlg-runs/runK-frontier.log +0 -19
  380. package/docs/investigations/hlg-runs/runL-widemap.log +0 -65
  381. package/docs/investigations/hlg-runs/runM-frontier-emb.log +0 -15
  382. package/docs/investigations/hlg-runs/runN-verify.log +0 -116
  383. package/docs/investigations/hlg-runs/runO-frontier-seed5000.log +0 -15
  384. package/docs/investigations/hlg-runs/runP-grid-AxSm.log +0 -15
  385. package/docs/investigations/hlg-runs/runQ-grid-tgW.log +0 -15
  386. package/docs/investigations/hlg-runs/runR-blind-transcript.log +0 -79
  387. package/docs/investigations/hlg-runs/runS-cross-coherence.log +0 -33
  388. package/docs/investigations/hlg-runs/runT-cross-cpm5.log +0 -33
  389. package/docs/investigations/hlg-runs/runU-cross-12b.log +0 -33
  390. package/docs/investigations/hlg-runs/runV-lw-e4b.log +0 -22
  391. package/docs/investigations/hlg-runs/runW-lw-12b.log +0 -22
  392. package/docs/investigations/hlg-runs/runX-lw-cpm5.log +0 -22
  393. package/docs/investigations/hlg-runs/runY-cliff-e4b.log +0 -26
  394. package/docs/investigations/hlg-runs/runZ-cliff-12b.log +0 -26
  395. package/docs/planning/IDEAS.md +0 -69
  396. package/docs/reference/embedding.md +0 -197
  397. package/docs/reference/features-matrix.md +0 -100
  398. package/docs/reference/orpo-quickstart.md +0 -135
  399. package/src/flags.ts +0 -13
  400. /package/docs/{investigations → archive/investigations}/chunk-finetune-experiment.md +0 -0
  401. /package/docs/{investigations → archive/investigations}/colibri-oracle-pin.md +0 -0
  402. /package/docs/{investigations → archive/investigations}/curve-bisector-routing.md +0 -0
  403. /package/docs/{investigations → archive/investigations}/decode-roofline-lookagain.md +0 -0
  404. /package/docs/{investigations → archive/investigations}/dspark-handoff.md +0 -0
  405. /package/docs/{investigations → archive/investigations}/expert-offload-single-user-moe.md +0 -0
  406. /package/docs/{investigations → archive/investigations}/indexshare-performance-spike.md +0 -0
  407. /package/docs/{investigations → archive/investigations}/kernel-perf-review-2026-07.md +0 -0
  408. /package/docs/{investigations → archive/investigations}/lab-build-journal.md +0 -0
  409. /package/docs/{investigations → archive/investigations}/openwiki-evaluation.md +0 -0
  410. /package/docs/{investigations → archive/investigations}/orpo-base-uf-experiment-and-directions.md +0 -0
  411. /package/docs/{investigations → archive/investigations}/orpo-flash-cce-pin-leak.md +0 -0
  412. /package/docs/{investigations → archive/investigations}/orpo-uf-testing-handoff.md +0 -0
  413. /package/docs/{investigations → archive/investigations}/pi-builtin-investigation.md +0 -0
  414. /package/docs/{investigations → archive/investigations}/segmented-backward-handoff.md +0 -0
  415. /package/docs/{investigations → archive/investigations}/starter-model-port-handoff.md +0 -0
  416. /package/docs/{investigations → archive/investigations}/steel-flash-cce-handoff.md +0 -0
  417. /package/docs/{investigations → archive/investigations}/trainer-validation-experiment.md +0 -0
  418. /package/docs/{planning → archive/planning}/chat-ui-vision-memory-first.md +0 -0
  419. /package/docs/{planning → archive/planning}/journal.md +0 -0
  420. /package/docs/{planning → archive/planning}/pi-integration-review.md +0 -0
  421. /package/docs/{planning → archive/planning}/release-notes-v0.0.10.md +0 -0
  422. /package/docs/{planning → archive/planning}/release-notes-v0.0.11.md +0 -0
  423. /package/docs/{planning → archive/planning}/release-notes-v0.0.12.md +0 -0
  424. /package/docs/{planning → archive/planning}/release-notes-v0.0.13.md +0 -0
  425. /package/docs/{planning → archive/planning}/web-ui-pass-plan.md +0 -0
  426. /package/{docs/investigations → src/serve/assets}/curve-terrain.html +0 -0
  427. /package/{docs/dag → src/serve/assets}/training-inference-map.html +0 -0
@@ -1,119 +1,200 @@
1
1
  # CLI reference
2
2
 
3
- Every mlx-bun verb. Commands are shown as `mlx-bun <verb>`; from a clone the
4
- identical command is `bun src/cli.ts <verb>`. `mlx-bun help <verb>` (or
5
- `mlx-bun <verb> --help`) prints the full flag list for any command.
6
-
7
- Model arguments are **substring queries** against the registry (`e4b`, `26B`,
8
- `12B-it`); a query matching more than one model errors out and lists the
9
- candidates — just make it more specific.
10
-
11
- Bare `mlx-bun` with no verb runs `serve` — the appliance path: first run
12
- downloads a starter model, serves it, and opens the chat UI.
13
-
14
- > All verbs below ship in current releases; the release notes in
15
- > `docs/planning/` record when each verb first appeared.
16
-
17
- ## Serving & chat
3
+ Every mlx-bun verb, from `src/cli.ts`. Commands are shown as
4
+ `mlx-bun <verb>`; from a clone the identical command is
5
+ `bun src/cli.ts <verb>`. `mlx-bun help <verb>` (or `mlx-bun <verb> --help`)
6
+ prints the full flag list for any command; `mlx-bun --version` (also `-v` or
7
+ `mlx-bun version`) prints the version.
8
+
9
+ **Model arguments are substring queries** against the registry (`e4b`,
10
+ `12B`, `qwen`, a repo substring); a query that matches more than one model
11
+ errors and lists the candidates. A directory containing `config.json` is
12
+ loaded directly wherever a model is accepted (`serve`, `pi`, `benchmark`,
13
+ `embed`, `fuse`, `convert`, `perplexity`).
14
+
15
+ **Bare `mlx-bun`** (no verb, or only options such as `mlx-bun --port 9000`)
16
+ runs `serve`. Explicit verbs and `--help`/`--version` still win.
17
+
18
+ **Unknown flags are ignored**, not rejected — `mlx-bun serve --kv-bits 4`
19
+ starts a server as if the flag were absent. The exceptions are `fuse` and
20
+ `convert`, which refuse the mlx-lm flags they don't implement (listed under
21
+ each verb).
22
+
23
+ ## Verb index
24
+
25
+ | Verb | Does | mlx-lm counterpart |
26
+ |---|---|---|
27
+ | `serve` | OpenAI/Anthropic-compatible server + web app | `mlx_lm.server` |
28
+ | `pi` | built-in coding agent on a local model | — (`mlx_lm.chat` is the nearest) |
29
+ | `harness pi` | connect your own pi install to the local server | — |
30
+ | `generate` (`gen`) | one-shot generation, no server | `mlx_lm.generate` |
31
+ | `embed` | text embeddings, no server | — |
32
+ | `get` | download a model (resumable, verified) | `mlx_lm.manage` (partial) |
33
+ | `scan` | re-index the Hugging Face cache | `mlx_lm.manage --scan` |
34
+ | `ls` | list downloaded models | `mlx_lm.manage --scan` |
35
+ | `gc` | reclaim superseded snapshots + dead blobs | `mlx_lm.manage --delete` (different unit) |
36
+ | `fit` | will it fit? memory + speed assessment | — (`optiq latency`) |
37
+ | `train` | LoRA fine-tune (SFT / DPO / ORPO) | `mlx_lm.lora --train` |
38
+ | `train-watch` | live dashboard for a training run | — |
39
+ | `fuse` | merge an adapter into the base weights | `mlx_lm.fuse` |
40
+ | `convert` | quantize an HF model into a local MLX snapshot | `mlx_lm.convert` (+ `mlx_lm.dynamic_quant`, `optiq convert`) |
41
+ | `upload` | push a model directory to the Hub | `mlx_lm.upload` |
42
+ | `perplexity` | perplexity over a local dataset | `mlx_lm.perplexity` |
43
+ | `memory` (`setup`) | the assistant's personal wiki | — |
44
+ | `benchmark` (`bench`) | decode/prefill speed of our stack | `mlx_lm.benchmark` |
45
+ | `evals` | recorded benchmark runs | — |
46
+ | `help` | overview or per-verb help | — |
47
+
48
+ ## Serving & agents
18
49
 
19
50
  ### `serve` — run the server
20
51
 
21
- Start the OpenAI/Anthropic-compatible server plus the browser web app (chat,
22
- status, and model tools).
52
+ Start the OpenAI/Anthropic-compatible server plus the browser web app.
23
53
 
24
54
  ```sh
25
- mlx-bun serve # default model, http://localhost:8080
26
- mlx-bun serve e4b # pick a model by substring
27
- mlx-bun serve gemma --memory-budget 18 # ...with admission control (GB)
28
- mlx-bun serve e4b --no-open # don't open the browser chat UI
29
- mlx-bun serve GLM-5.2 --context-length 4096 # bounded Colibri runtime, native MTP
55
+ mlx-bun serve # default model
56
+ mlx-bun serve e4b # pick a model by substring
57
+ mlx-bun serve --model ./fused_model # explicit path (mlx_lm.server spelling)
58
+ mlx-bun serve e4b --no-open # don't open the chat UI
59
+ mlx-bun serve GLM-5.2 --context-length 4096
30
60
  ```
31
61
 
32
- Common flags (full list in [server-config.md](server-config.md)):
62
+ `serve` takes the model as a positional, `--query <q>`, or `--model <path|query>`
63
+ (`--model` wins). The flag set below is **shared with `mlx-bun pi`**. Defaults,
64
+ semantics, and which combinations compose live in
65
+ **[server-config.md](server-config.md)** — this page only names them.
33
66
 
34
- | Flag | Effect |
67
+ | Group | Flags |
35
68
  |---|---|
36
- | `--host <addr>` | Interface to bind (default `127.0.0.1`, loopback only; `0.0.0.0` to expose) |
37
- | `--port <n>` | Listen port (default 8080) |
38
- | `--memory-budget <GB>` | Reject loads/requests that can't fit the budget |
39
- | `--kv-budget <GB>` | Aggregate KV budget across concurrent batch rows: over-budget joiners queue until rows finish; a request over the budget alone is rejected (off unless set) |
40
- | `--prompt-cache <GB>` | RAM prefix-KV cache, byte-capped LRU (default 8; `0` disables). Non-consuming prefix sharing: a hit clones instead of consuming the donor entry |
41
- | `--isolate` | Run the inference engine as a crash-isolated child process on a unix socket; this process becomes a pure reverse-proxy (instant under GPU load, auto-respawns on engine crash) — default off ([runtime-isolation.md](../design/runtime-isolation.md)) |
42
- | `--model-pool <n>` | With `--isolate`: cap on resident per-model engine children (default 1); over the cap the LRU engine drains its cache to the SSD tier and exits, respawning on demand |
43
- | `--ssd-cache <dir>` | SSD cold tier under the prompt cache: idle/evicted prefix-KV spills to disk and restores on reattach, surviving restarts (default off — [ssd-kv-cold-tier.md](../design/ssd-kv-cold-tier.md)) |
44
- | `--ssd-cache-max <GB>` | SSD tier byte cap, oldest-mtime evicted first (default 32; `--ssd-cache` only) |
45
- | `--ssd-cache-verify` | Verify every tensor hash on restore, not just the header (integrity paranoia; roughly doubles restore reads; `--ssd-cache` only) |
46
- | `--ssd-demote-idle <sec>` | Idle prompt-cache entries spill to the SSD tier and free GPU memory after this long (default 300 with `--ssd-cache`; `0` disables) |
47
- | `--kv-quant config\|off\|4\|8\|turbo[:k<bits>v<bits>]` | KV cache quantization: per-layer `kv_config.json`, bf16, uniform bits, or TurboQuant (rotation-based, default `k8v3` — [turboquant-kv.md](../design/turboquant-kv.md); full-attention layers only, solo-only/serial) (default `off` — quantized KV trades 5–20% decode speed for memory headroom, so it's opt-in) |
48
- | `--paged-kv` | OPTIONAL vLLM-style paged KV cache (block pool + gather before the stock SDPA; env `MLX_BUN_PAGED_KV=1`) — bit-exact with the plain path, default off. v1: serial only (pins `--batch 1` unless `--batch` is given; refuses `--batch N>1`, `--kv-quant`, `--draft-model`), Gemma4-family, bf16; bypasses the prompt cache and runs uncompiled decode. Expect a small decode cost at batch=1 — v1 ships the abstraction for batched/CoW follow-ups ([paged-kv-cache.md](../design/paged-kv-cache.md)) |
49
- | `--paged-kv-block-size <n>` | Tokens per KV block (default 256 = the plain cache's growth step; `--paged-kv` only) |
50
- | `--adapter <dir>` | Mount a LoRA adapter at startup (`--adapter-path` accepted as the mlx_lm.server alias) |
51
- | `--draft-model <path\|query>` | Speculative decoding: a drafter proposes, the main model verifies — exact results, faster decode when drafts land. The artifact's kind is auto-detected: a full same-tokenizer model (mlx_lm.server parity), a Gemma `-assistant` KV-borrowing drafter, a DSpark checkpoint trained here, or one of DeepSeek's released DSpark drafters (DeepSpec `Gemma4DSparkModel`, e.g. `dspark_gemma4_12b_block7`). Serial lane only: with `--batch N` a mounted draft routes every request serial |
52
- | `--draft-kind <kind>` | Override draft-artifact detection: `two-model` \| `assistant` \| `dspark` \| `deepspec` \| `ngram` (default: auto). `ngram` is MODEL-FREE prompt lookup — no `--draft-model` (mounting one alongside it is refused): drafts are copied from the request's own prompt+generation whenever its trailing tokens have occurred earlier in that stream, verified by the target like any other draft, so results stay exact at any temperature. Zero weights, zero memory; best on agentic/RAG/code-edit traffic that re-emits spans already in context (prior art: prompt-lookup decoding / vLLM's `ngram` proposer) |
53
- | `--num-draft-tokens <n>` | Drafts per verify round (default 3; `ngram` defaults to 10 — drafting is free; a DSpark draft pins to its trained block width) |
54
- | `--ngram-max <k>` / `--ngram-min <k>` | Prompt-lookup match-window bounds, `--draft-kind ngram` only: the longest/shortest trailing k-gram searched (defaults 3 / 1, the reference values) |
55
- | `--mtp on\|off` | GLM-5.2 checkpoint-native MTP (default on). Native MTP uses the exact serial verify lane; `off` enables ordinary continuous batching (batched per-row MTP is post-release) |
56
- | `--context-length <n>` | GLM-5.2 context reserved by the header-only resource equation (default 4096) |
57
- | `--batch <n>` | Continuous-batched serving cap, mlx-lm B=N parity (default 8; `--batch 1` pins the serial path) |
58
- | `--temperature` / `--top-p` / `--top-k` / `--max-tokens` | Server-wide sampling defaults (per-request fields still win; GLM-5.2 defaults to the planned 128 generated tokens) |
59
- | `--l1` / `--l2` | Parity tier alias: bit-exact to mlx-lm / bit-exact to mlx-optiq. **No tier = `--l1`** (the default since 2026-07-05 — output-changing levers are opt-in until they beat the L1 baseline in a paired A/B). Each expands to per-fork flags (`--compiled-decode`, `--compiled-activations`, `--fused-sdpa`, `--kv-quant`); a fork flag overrides one. `--l3` was removed 2026-07-05 and now errors (the Lab replaces it — [unified-engine-frontier-plan.md](../design/unified-engine-frontier-plan.md)). See [server-config.md](server-config.md#fidelity-tiers-and-the-decode-route---l1----l2). |
60
- | `--allow-private-media` | Let `image_url`/`audio_url` parts fetch from private/loopback/link-local hosts (blocked by default — SSRF guard; the 10 s timeout and 64 MB cap on remote media apply either way) |
61
- | `--no-open` | Don't auto-open the chat UI |
69
+ | Network | `--host`, `--port`, `--no-open`, `--allow-private-media` |
70
+ | Memory & caches | `--memory-budget`, `--kv-budget`, `--prompt-cache`, `--ssd-cache`, `--ssd-cache-max`, `--ssd-cache-verify`, `--ssd-demote-idle`, `--generation-checkpoint` |
71
+ | Process model | `--isolate`, `--model-pool`, `--unix` (internal — the engine half of `--isolate`) |
72
+ | Scheduling | `--batch` (`--decode-concurrency` accepted as the mlx_lm.server alias) |
73
+ | KV cache | `--kv-quant`, `--paged-kv`, `--paged-kv-block-size` |
74
+ | Adapters | `--adapter` (`--adapter-path` alias) |
75
+ | Speculative decoding | `--draft-model`, `--draft-kind`, `--num-draft-tokens`, `--ngram-max`, `--ngram-min` |
76
+ | GLM-5.2 | `--mtp`, `--context-length` |
77
+ | Sampling defaults | `--temperature` (`--temp` alias), `--top-p`, `--top-k`, `--max-tokens`, `--thinking`, `--hlg-sampling`, `--hlg-width`, `--hlg-shoulder`, `--hlg-toe`, `--hlg-pivot-offset` |
78
+ | Parity tier | `--l1`, `--l2` (`--l3` errors — removed) |
79
+ | Kill switches | `--compiled-decode`, `--compiled-activations`, `--fused-sdpa`, `--force-wire`, `--expert-offload` |
62
80
 
63
81
  Endpoints: `/v1/chat/completions`, `/v1/completions`, `/v1/messages`,
64
- `/v1/responses`, `/v1/models`, `/v1/adapters`, `/health`, `/stats`, `/fit`,
65
- `/library`, `/downloads` — web app at `/` (lands on chat); `/chat`, `/status`,
66
- `/quantize`, `/finetune`, `/dataset` deep-link its views. Full
67
- schemas in [server-api.md](server-api.md).
82
+ `/v1/responses`, `/v1/embeddings`, `/v1/models`, `/v1/adapters`, `/health`,
83
+ `/stats`, `/fit`, `/library`, `/downloads`; the web app at `/` (`/chat`,
84
+ `/status`, `/quantize`, `/finetune`, `/dataset` deep-link its views). Schemas
85
+ in [server-api.md](server-api.md).
68
86
 
69
87
  ### `pi` — built-in coding agent
70
88
 
71
89
  Run the pi coding agent's terminal UI in-process against a local model —
72
- nothing to install. Reuses a healthy running server, otherwise starts one for
73
- the session.
90
+ pi is bundled, nothing to install. Reuses a healthy server on the chosen
91
+ port; otherwise starts one that lives exactly as long as the session.
74
92
 
75
93
  ```sh
76
- mlx-bun pi # interactive agent session
77
- mlx-bun pi -p "explain this repo" # one-shot: print the reply and exit
94
+ mlx-bun pi # interactive session
95
+ mlx-bun pi fix the failing test # pre-fill the first turn
96
+ mlx-bun pi -p "explain this repo" # one-shot: print the reply and exit
97
+ mlx-bun pi -p --json "summarize README" # one-shot with the full event stream
98
+ mlx-bun pi --mode rpc # JSONL RPC over stdio
99
+ mlx-bun pi -q qwen --port 8090 # model + server flags for the session server
100
+ git diff | mlx-bun pi -p "review this" # piped stdin makes it one-shot too
78
101
  ```
79
102
 
103
+ | Flag | Meaning |
104
+ |---|---|
105
+ | `-q`, `--query <q>` | model to serve when starting a session server |
106
+ | `-p`, `--print [msg]` | one-shot print mode (also reads piped stdin) |
107
+ | `--json` | with `-p`: emit the full event stream as JSON |
108
+ | `--mode json\|rpc\|text` | `json` = print + JSON, `rpc` = JSONL RPC over stdio, `text` = print |
109
+ | `--verbose` | verbose agent logging |
110
+ | every `serve` flag | applies to the session server; ignored (with a note) when reusing a running one |
111
+
112
+ Other pi flags are dropped with a note — the full pi surface (`--continue`,
113
+ `--resume`, extensions, themes) lives in your own pi via `harness pi`.
114
+ `mlx-bun help pi` is our help; `mlx-bun pi --help` prints it only when it is
115
+ the sole argument.
116
+
80
117
  ### `harness pi` — connect your own pi
81
118
 
82
- For people who already use
83
- [pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent): installs a small,
84
- reversible discovery extension that registers the local server as a pi
85
- provider.
119
+ For people who already run [pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent):
120
+ writes one reversible extension, `~/.pi/agent/extensions/mlx-bun-provider.ts`,
121
+ that registers `mlx-bun` as a pi provider. Models are discovered live from
122
+ `/v1/models` at pi startup (the list baked at install time is the fallback
123
+ when the server is down), exposed under the stable id `mlx-bun/local`. It
124
+ never touches your existing pi config.
125
+
126
+ ```sh
127
+ mlx-bun harness pi # install; requires pi on PATH
128
+ mlx-bun harness pi --base-url http://127.0.0.1:8090/v1
129
+ mlx-bun harness pi --remove # delete the extension
130
+ pi --provider mlx-bun # then run pi as usual
131
+ pi --models "mlx-bun/*" # or scope cycling
132
+ ```
133
+
134
+ #### LoRA adapters from pi: the adapter extension
135
+
136
+ `scripts/packaging/pi-extensions/mlx-bun-adapter.ts` ships with the repo and
137
+ adds an `/adapter` command to pi. Install by copying (or symlinking) it into
138
+ `~/.pi/agent/extensions/`, then `/reload` inside pi:
86
139
 
87
140
  ```sh
88
- mlx-bun harness pi # then: pi --provider mlx-bun
89
- mlx-bun harness pi --remove # disconnect
141
+ cp scripts/packaging/pi-extensions/mlx-bun-adapter.ts ~/.pi/agent/extensions/
142
+ MLX_BUN_URL=http://127.0.0.1:8080 pi --provider mlx-bun
90
143
  ```
91
144
 
145
+ | In pi | Effect |
146
+ |---|---|
147
+ | `/adapter` or `/adapter list` | list adapters on disk (`/v1/adapters/available`), which are loaded, and the active one |
148
+ | `/adapter <id>` | mount it if needed (`POST /v1/adapters`) and inject `adapter: <id>` into every request |
149
+ | `/adapter off` | back to the base model (no field sent) |
150
+
151
+ The extension reads the server URL from `MLX_BUN_URL` (its built-in fallback
152
+ is port 8090, so set it to match your server). Default is no adapter; the
153
+ mechanism is pi's `before_provider_request` hook, the same one the web chat's
154
+ adapter selector uses. Serving-side detail: [server-api.md](server-api.md#adapters-lora-hot-swap)
155
+ and [docs/design/web-chat-redesign.md](../design/web-chat-redesign.md).
156
+
92
157
  ### `generate` (alias `gen`) — one-shot generation
93
158
 
94
- Load the model, generate, print, exit — no server. Renders through the chat
95
- template by default; `--raw` feeds the prompt verbatim. Sampling and
96
- decode-path levers mirror `serve` (`--temperature`, `--seed`, `--l1/--l2`,
97
- `--kv-quant`, …).
159
+ Load the model, generate, print, exit. The prompt is rendered through the
160
+ chat template unless `--raw`.
98
161
 
99
162
  ```sh
100
- mlx-bun generate gemma "a haiku about metal shaders"
163
+ mlx-bun generate e4b "a haiku about metal shaders"
101
164
  mlx-bun gen e4b --prompt "…" --max-tokens 512 --seed 42
102
- mlx-bun generate GLM-5.2 --prompt "Explain DSA" --max-tokens 128
165
+ mlx-bun generate qwen --raw --prompt "def fib(n):" --temperature 0
103
166
  ```
104
167
 
168
+ | Flag | Meaning |
169
+ |---|---|
170
+ | `[query]` / `--query <q>` | model (auto-picks when omitted) |
171
+ | `--prompt "…"` | the prompt (or pass it as the positional after the model) |
172
+ | `--raw` | skip the chat template |
173
+ | `--max-tokens <n>` | completion cap |
174
+ | `--temperature <n>` (`--temp` alias), `--top-p`, `--top-k`, `--seed` | sampling |
175
+ | `--l1` / `--l2`, `--kv-quant`, `--fused-sdpa`, `--compiled-decode`, `--compiled-activations` | decode route, same meaning as for `serve` |
176
+
105
177
  ### `embed` — text embeddings
106
178
 
107
- One-shot embeddings from a local Qwen3-Embedding model (last-token pooled,
108
- L2-normalized — bit-exact vs mlx-lm). One JSON vector per input line.
179
+ Embeddings from a local Qwen3-Embedding model, no server. One JSON vector
180
+ per input line.
109
181
 
110
182
  ```sh
111
183
  mlx-bun embed --text "hello world"
112
- echo -e "line one\nline two" | mlx-bun embed --json
184
+ mlx-bun embed Qwen3-Embedding "hello world"
185
+ printf 'line one\nline two\n' | mlx-bun embed --json
186
+ mlx-bun embed --instruct "Retrieve passages that answer the question" --text "what is a KV cache?"
113
187
  ```
114
188
 
115
- For a server endpoint, `mlx-bun serve <embedding-model>` then
116
- `POST /v1/embeddings`.
189
+ | Flag | Meaning |
190
+ |---|---|
191
+ | `[query]` / `--query <q>` | embedding model; omitted = the first downloaded embedding model (errors with a `get` suggestion when none) |
192
+ | `--text "…"` | text to embed (omit to read one text per stdin line) |
193
+ | `--instruct "…"` | Qwen3-Embedding query instruction; omit for plain document embeddings |
194
+ | `--json` | one OpenAI-style `{object:"list",data:[…]}` object instead of bare arrays |
195
+
196
+ Server equivalent: `mlx-bun serve <embedding-model>` then
197
+ [`POST /v1/embeddings`](server-api.md#post-v1embeddings-openai-embeddings-api).
117
198
 
118
199
  ## Models & disk
119
200
 
@@ -121,26 +202,26 @@ Full guide: [models.md](models.md).
121
202
 
122
203
  ### `get` — download a model
123
204
 
124
- Resumable, checksum-verified download into the standard Hugging Face cache
125
- (plain HTTPS, no Xet — no 0% stalls). Before payload transfer, the downloader
126
- credits complete blobs and partial prefixes, then requires enough free space
127
- for the exact remainder plus a fixed 1 GiB reserve.
205
+ Resumable (Range requests against partial blobs), sha256-verified download
206
+ into the standard Hugging Face cache over plain HTTPS (no Xet). Complete
207
+ blobs and partial prefixes are credited before transfer, and the volume must
208
+ fit the remainder plus a 1 GiB reserve. Uses `HF_TOKEN` / `hf auth login`
209
+ credentials when present.
128
210
 
129
211
  ```sh
130
212
  mlx-bun get mlx-community/gemma-4-12B-it-OptiQ-4bit
131
- mlx-bun get 12B # no "/" = registry query; re-gets/refreshes the match
132
- mlx-bun get mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp \
133
- --revision 3cc8db99b1b13fc79325d987ba3c1c430766b3b8
213
+ mlx-bun get 12B # no "/" = registry query; re-gets/refreshes the match
214
+ mlx-bun get mlx-community/MiniCPM5-1B-OptiQ-4bit --revision main
134
215
  ```
135
216
 
136
- The GLM artifact is roughly 357 GiB; select `HF_HUB_CACHE` on a sufficiently
137
- large fast volume before starting. Rerunning the same command resumes verified
138
- `.incomplete` prefixes. See the [32 GB GLM quickstart](models.md#glm-52-on-a-32-gb-mac).
217
+ `--revision <rev>` selects a git revision. When upstream has pushed a new
218
+ revision the previous snapshot stays on disk — `get` says so and `gc`
219
+ reclaims it. GLM-5.2 specifics: [models.md](models.md#glm-52-on-a-32-gb-mac).
139
220
 
140
221
  ### `scan` — index your cache
141
222
 
142
- Re-index the HF cache into the registry (config + safetensors headers only,
143
- never tensor bytes) so `ls`, `serve`, and `fit` can find models by substring.
223
+ Re-index the HF cache into the registry (config + safetensors headers, never
224
+ tensor bytes) so `ls`, `serve`, and `fit` resolve models by substring.
144
225
 
145
226
  ```sh
146
227
  mlx-bun scan
@@ -148,95 +229,140 @@ mlx-bun scan
148
229
 
149
230
  ### `ls` — list models
150
231
 
232
+ One row per repo (canonical revision, `refs/main`); superseded snapshots are
233
+ hidden.
234
+
151
235
  ```sh
152
- mlx-bun ls # size, params, quant, capabilities
153
- mlx-bun ls --vision --max-size 10GB # filter
154
- mlx-bun ls --all-revisions # one row per cached snapshot
236
+ mlx-bun ls # size, params, quant, license, capabilities
237
+ mlx-bun ls gemma # filter by substring
238
+ mlx-bun ls --vision --max-size 10GB # vision-capable, under 10 GB
239
+ mlx-bun ls --all-revisions # one row per cached snapshot (canonical marked *)
155
240
  ```
156
241
 
157
242
  ### `gc` — reclaim disk
158
243
 
159
- Delete superseded snapshots and the blobs only they reference. Prints the plan
160
- by default; `--yes` actually deletes. Same planner (`src/registry.ts`
161
- `planGc`/`executeGc`) also backs `GET /api/gc/plan` / `POST /api/gc/execute`
162
- on a running `serve` — see [server-api.md](server-api.md#get-apigcplan--post-apigcexecute).
244
+ Delete superseded snapshots and the blobs only they reference. Prints the
245
+ plan by default.
163
246
 
164
247
  ```sh
165
- mlx-bun gc # dry-run: what would be reclaimed
166
- mlx-bun gc --yes # delete
248
+ mlx-bun gc # dry run: what would be reclaimed
249
+ mlx-bun gc --yes # delete
250
+ mlx-bun gc --yes --force # also prune snapshots holding files the canonical revision lacks
167
251
  ```
168
252
 
253
+ `--dry-run` never deletes even with `--yes`. The same planner backs
254
+ [`GET /api/gc/plan` / `POST /api/gc/execute`](server-api.md#get-apigcplan--post-apigcexecute).
255
+
169
256
  ### `fit` — memory contract
170
257
 
171
- Deterministic memory assessment: does it fit, what's the max context, predicted
172
- tok/s. Weights bytes from safetensors headers, KV bytes/token from the config,
173
- calibrated prefill transient, wired-memory ceiling.
258
+ Deterministic memory assessment: does it fit, max safe context, predicted
259
+ tok/s — from safetensors headers, the config's KV bytes/token, a calibrated
260
+ prefill transient, and the wired-memory ceiling.
174
261
 
175
262
  ```sh
176
- mlx-bun fit gemma --ctx 32768 # for this machine
263
+ mlx-bun fit gemma --ctx 32768 # this machine
177
264
  mlx-bun fit gemma --ctx 8192 --skus # across the Apple Silicon lineup
265
+ mlx-bun fit qwen --kv-quant 4 # bill a 4-bit-quantized KV cache
266
+ mlx-bun fit GLM-5.2 # streamed-artifact plan (resident weights, expert slabs, KV, reserves)
178
267
  ```
179
268
 
180
- The direct Colibri GLM-5.2 artifact is handled by its streamed-runtime
181
- contract, not by the generic resident-weights estimator. `fit GLM-5.2`
182
- defaults to the supported 4,096-token / 128-generation-token plan and reports
183
- the artifact's disk footprint separately from resident weights, the main and
184
- MTP expert slabs, KV, reserves, and the 25 GiB process ceiling. Its throughput
185
- line is the measured warm quality-preserving result; the direct Colibri oracle
186
- and the 2 tok/s aspiration are labeled separately. `--skus` explains that the
187
- generic resident-model matrix does not apply to this streamed artifact.
188
-
189
- ```sh
190
- mlx-bun fit GLM-5.2
191
- mlx-bun fit GLM-5.2 --ctx 4096
192
- ```
269
+ | Flag | Meaning |
270
+ |---|---|
271
+ | `--ctx <tokens>` | context size to assess |
272
+ | `--kv-quant 4\|8\|config\|off` | bill the KV cache at the quantized bytes/element (`config` needs a model that ships `kv_config.json`; `turbo` is not accepted here) |
273
+ | `--skus` | also print the Apple silicon SKU matrix (not applicable to the streamed GLM-5.2 artifact) |
193
274
 
194
275
  ## Training & model creation
195
276
 
196
277
  Full reference: [training.md](training.md); guided walkthrough:
197
- [orpo-quickstart.md](orpo-quickstart.md).
278
+ [docs/reference/training.md](./training.md).
198
279
 
199
280
  ### `train` — LoRA fine-tune
200
281
 
201
- SFT / DPO / ORPO on your data, with the full memory stack (flash-CCE head,
202
- prefix-sharing, segmented backward) on by default. Saves a mountable adapter.
282
+ SFT / DPO / ORPO on `<dir>/train.jsonl` (+ optional `valid.jsonl`). Rows are
283
+ `{prompt, chosen, rejected}` for dpo/orpo or `{messages|text}` for sft. Runs
284
+ in the foreground and saves a mountable adapter.
203
285
 
204
286
  ```sh
205
- mlx-bun train e4b --data ./prefs # ORPO (default) on {prompt,chosen,rejected}
206
- mlx-bun train e4b --data ./prefs --method sft # SFT on {messages|text}
207
- mlx-bun train e4b --data ./prefs --dry-run # inspect the plan, don't train
287
+ mlx-bun train e4b --data ./prefs # ORPO (default)
288
+ mlx-bun train e4b --data ./prefs --method sft
289
+ mlx-bun train e4b --data ./prefs --dry-run # inspect data + resolved plan, don't train
290
+ mlx-bun train cpm5 --data ./prefs --iters 400 --save-every 50 --adapter ~/adapters/cpm5-orpo
291
+ nohup mlx-bun train e4b --data ./prefs & # long runs: detach from your shell
208
292
  ```
209
293
 
294
+ | Flag | Meaning |
295
+ |---|---|
296
+ | `<model>` / `--query <q>` | model to fine-tune (auto-picks when omitted) |
297
+ | `--data <dir>` | dataset dir (required) |
298
+ | `--method sft\|dpo\|orpo` | objective |
299
+ | `--adapter <dir>` | output adapter dir (default under `~/.cache/mlx-bun/mlx-bun-finetunes/`) |
300
+ | `--iters`, `--lr`, `--rank`, `--scale`, `--seq`, `--batch`, `--grad-accum`, `--grad-clip`, `--seed`, `--val-size` | loop hyperparameters (method-dependent defaults: `mlx-bun help train`) |
301
+ | `--lambda <f>`, `--sft-scope full\|response` | ORPO odds-ratio weight and chosen-NLL scope |
302
+ | `--seg <n>`, `--no-segment` | segmented backward (layers per segment / off) |
303
+ | `--no-flash`, `--no-prefix` | disable the flash-CCE head / prefix-sharing |
304
+ | `--save-every <n>`, `--resume <dir>` | checkpoint cadence / warm-start LoRA weights |
305
+ | `--dry-run` | print the plan, don't train |
306
+
210
307
  ### `train-watch` — live training dashboard
211
308
 
212
- Tails an adapter dir's `metrics.jsonl` and renders live loss / speed / memory.
309
+ Tails `<adapter-dir>/metrics.jsonl` (written by `train` and the web
310
+ fine-tune tile) and renders live loss / speed / memory.
213
311
 
214
312
  ```sh
215
313
  mlx-bun train-watch ~/.cache/mlx-bun/mlx-bun-finetunes/orpo-e4b
314
+ mlx-bun train-watch --adapter ~/adapters/cpm5-orpo
216
315
  ```
217
316
 
218
317
  ### `fuse` — merge an adapter into the base
219
318
 
220
- Folds LoRA deltas into the base weights and writes a standalone snapshot; a
221
- quantized base keeps its exact quantization layout. Flag names match
222
- `mlx_lm.fuse`.
319
+ Folds LoRA deltas into the base weights and writes a standalone snapshot
320
+ (weights + config + tokenizer); a quantized base keeps its per-module
321
+ quantization layout. Flag names follow `mlx_lm.fuse`.
223
322
 
224
323
  ```sh
225
324
  mlx-bun fuse e4b --adapter ./adapters --save-path ./fused_model
325
+ mlx-bun fuse --model ./base-snapshot --adapter-path ./adapters
226
326
  mlx-bun serve ./fused_model
227
327
  ```
228
328
 
329
+ | Flag | Meaning |
330
+ |---|---|
331
+ | `<model>` / `--model` | base model (query or snapshot path) |
332
+ | `--adapter <dir>` (`--adapter-path` alias) | adapter directory (`adapters.safetensors` + `adapter_config.json`); default `adapters` |
333
+ | `--save-path <dir>` | output directory; default `fused_model` |
334
+
335
+ Refused with an error (mlx_lm.fuse flags not implemented): `--de-quantize`,
336
+ `--dequantize`, `--export-gguf`, `--gguf-path`, `--upload-repo`.
337
+
229
338
  ### `convert` — quantize a model
230
339
 
231
- Quantize an HF model (local path, downloaded model, or repo id) into a local
232
- MLX snapshot — uniform 4/8-bit, or mixed-precision via `--target-bpw`
233
- (sensitivity sweep + per-layer bit knapsack). `--upload-repo` pushes the result.
340
+ Quantize an HF model (local path, downloaded model, or repo id — an
341
+ un-downloaded repo is fetched first) into a local MLX snapshot: uniform
342
+ affine 4/8-bit, or mixed precision via `--target-bpw` (sensitivity sweep +
343
+ per-layer bit knapsack). Same engine as the web `/api/quantize`.
234
344
 
235
345
  ```sh
236
- mlx-bun convert Qwen/Qwen3-4B -q # uniform 4-bit
237
- mlx-bun convert Qwen/Qwen3-4B --target-bpw 4.5 # mixed precision
346
+ mlx-bun convert Qwen/Qwen3-4B -q # uniform 4-bit → ./mlx_model
347
+ mlx-bun convert --hf-path Qwen/Qwen3-4B -q --q-bits 8 --mlx-path ./qwen3-8bit
348
+ mlx-bun convert Qwen/Qwen3-4B --target-bpw 4.5 # mixed precision (implies -q)
349
+ mlx-bun convert ./qwen3.5-bf16 -q --rotate-weights # fold the TurboQuant rotation, then quantize
350
+ mlx-bun convert Qwen/Qwen3-4B -q --upload-repo you/qwen3-4b-4bit
238
351
  ```
239
352
 
353
+ | Flag | Meaning |
354
+ |---|---|
355
+ | `--hf-path <src>` (`--model` or the bare positional) | source model |
356
+ | `--mlx-path <dir>` | output directory; must not already exist (mlx_lm.convert behavior) |
357
+ | `-q`, `--quantize`, `--q-bits 4\|8`, `--q-group-size 32\|64` | uniform affine quantization |
358
+ | `--target-bpw <f>`, `--candidate-bits <list>`, `--calibration-mix optiq\|<jsonl>`, `--n-calibration <n>` | mixed precision (writes per-module bits into `config.json`) |
359
+ | `--rotate-weights`, `--rotation-seed <n>` | fold the offline TurboQuant rotation first (auto-detects Llama / Qwen3.5 trunk / Qwen MTP; an MTP companion must use its trunk's seed); recipe recorded in `optiq_metadata.json` |
360
+ | `--upload-repo <id>` | push the result afterwards (token checked before any work starts) |
361
+
362
+ Refused with an error: `--dtype`, `-d`/`--dequantize`, `--quant-predicate`,
363
+ `--q-mode` other than `affine`, and plain non-quantizing conversion (pass `-q`
364
+ or `--target-bpw`).
365
+
240
366
  ### `upload` — push to the Hugging Face Hub
241
367
 
242
368
  Native push-to-hub, no Python: creates the repo if needed, uploads via the
@@ -244,57 +370,177 @@ git-LFS batch protocol, commits. Flag names match `mlx_lm.upload`.
244
370
 
245
371
  ```sh
246
372
  mlx-bun upload --path ./fused_model --upload-repo you/my-model
373
+ mlx-bun upload --path ./mlx_model --upload-repo you/my-model --private
247
374
  ```
248
375
 
376
+ Needs a WRITE token from `~/.mlx-bun/hf.json` (web UI Settings), `$HF_TOKEN`,
377
+ or `~/.cache/huggingface/token` (`hf auth login`); errors before uploading
378
+ anything when none is found. `--private` is an mlx-bun extension.
379
+
249
380
  ### `perplexity` — evaluate on your data
250
381
 
251
- `mlx_lm.perplexity` methodology exactly, over a **local** `.jsonl`/`.txt` file.
382
+ `mlx_lm.perplexity` methodology exactly (seeded sample order, concatenate,
383
+ non-overlapping rows, f32 CE at every position, delta-method standard
384
+ error) over a **local** `.jsonl` (`{"text": …}` rows) or `.txt` file — never
385
+ an HF dataset download.
252
386
 
253
387
  ```sh
254
388
  mlx-bun perplexity e4b --data-path ./corpus.jsonl
389
+ mlx-bun perplexity ./fused_model --data-path ./corpus.txt --sequence-length 1024 --num-samples -1 --batch-size 4 --seed 7
255
390
  ```
256
391
 
392
+ Flags: `<model>` (`--model` / `--query` accepted), `--data-path <file>`
393
+ (required), `--sequence-length <n>`, `--num-samples <n>` (`-1` = all),
394
+ `--batch-size <n>`, `--seed <n>`.
395
+
257
396
  ## Memory
258
397
 
259
- ### `memory` — the personal wiki
398
+ ### `memory` (alias `setup`) — the personal wiki
260
399
 
261
- A local, durable memory for the assistant: a git-tracked Markdown wiki at
262
- `~/.mlx-bun/wiki` that loads into every `mlx-bun pi` / `mlx-bun serve` session.
263
- Full guide: [memory.md](memory.md).
400
+ A local, git-tracked Markdown wiki at `~/.mlx-bun/wiki` that loads into
401
+ every `mlx-bun pi` / `mlx-bun serve` session. Full guide:
402
+ [memory.md](memory.md). `mlx-bun memory` with no subcommand runs `status`.
264
403
 
265
404
  ```sh
266
- mlx-bun memory init # create the wiki (idempotent); import + schedule
267
- mlx-bun memory status # path, article count, git + schedule state
268
- mlx-bun memory open [article] # open in Obsidian (falls back to Finder)
269
- mlx-bun memory search <query> # search articles from the terminal
270
- mlx-bun memory synthesize # conversations → cross-linked articles, all local
271
- mlx-bun memory schedule --at 03:00
405
+ mlx-bun memory init # create the wiki (idempotent); offers import + nightly job
406
+ mlx-bun memory status # path, article count, git + schedule state
407
+ mlx-bun memory open # open the vault in Obsidian (falls back to Finder)
408
+ mlx-bun memory open Archie_Project # open one article
409
+ mlx-bun memory list # article titles + read-only Reference docs
410
+ mlx-bun memory search kv cache # search from the terminal
411
+ mlx-bun memory read Archie_Project # print an article (stem)
412
+ mlx-bun memory toc Archie_Project # headings + anchors
413
+ mlx-bun memory section Archie_Project decisions # one section by anchor
414
+ mlx-bun memory links Archie_Project # outbound + inbound wikilinks
415
+ mlx-bun memory synthesize # conversations → articles, the full local DAG
416
+ mlx-bun memory synthesize --dry-run # plan only, never writes the vault
417
+ mlx-bun memory segment --limit 20 # one stage worker (also: extract, route, synthesize-stage)
418
+ mlx-bun memory extract --convs a1b2,c3d4 # restrict a stage to specific conversations
419
+ mlx-bun memory link --limit 50 # deterministic cross-linking pass (no model)
420
+ mlx-bun memory schedule --at 03:00 # install the nightly launchd job
421
+ mlx-bun memory unschedule # remove it
272
422
  ```
273
423
 
274
- `setup` is an alias for `memory`.
424
+ | Subcommand | Aliases | Meaning |
425
+ |---|---|---|
426
+ | `init` | `setup` | create the wiki; offers to import an existing vault and install the nightly job (TTY prompts; non-interactive shells take the defaults) |
427
+ | `status` | | path, counts, git + schedule state |
428
+ | `open [article]` | `browse` | open the vault or one article |
429
+ | `list` | | article titles + `Reference/` docs |
430
+ | `search <query>` | | ranked article hits with sample lines |
431
+ | `read <article>` | | print an article |
432
+ | `toc <article>` | | headings + anchors |
433
+ | `section <article> <anchor>` | | print one section |
434
+ | `links <article>` | | resolved outbound + inbound wikilinks |
435
+ | `synthesize` | `pipeline`, `all` | run the full synthesis DAG; `--dry-run` plans without writing. `--since` and `--model` are parsed but the pipeline does not consume them yet (`src/memory/pipeline.ts` marks `model` reserved) |
436
+ | `segment` · `extract` · `route` · `synthesize-stage` | `stage-synthesize` | run one decomposed, resumable stage worker (`--limit <n>` except `route`; `--convs a,b`) |
437
+ | `link` | | inline-link first mentions + rebuild `## See also` (`--limit <n>`; no model) |
438
+ | `schedule` | | install the nightly launchd job (`--at HH:MM`) |
439
+ | `unschedule` | | remove it |
440
+
441
+ An unknown subcommand prints the help and exits non-zero, so launchd jobs
442
+ and scripts can detect typos.
275
443
 
276
444
  ## Measurement
277
445
 
278
446
  ### `benchmark` (alias `bench`) — measure our stack
279
447
 
280
- Runs mlx-bun by itself on this machine and records to the eval DB.
448
+ Runs mlx-bun by itself (greedy decode, in-process) and records the median
449
+ to the eval DB.
281
450
 
282
451
  ```sh
283
452
  mlx-bun bench e4b --tokens 256 --runs 3
453
+ mlx-bun bench --model ./fused_model --prompt-tokens 4096 --kv-quant turbo:k8v3
454
+ ```
455
+
456
+ | Flag | Meaning |
457
+ |---|---|
458
+ | `[query]` / `--query` / `--model <path\|query>` | model (auto-picks when omitted) |
459
+ | `--tokens <n>` | tokens decoded per run |
460
+ | `--runs <n>` | runs (median reported) |
461
+ | `--prompt-tokens <n>` | pad the prompt to about n tokens (long-context decode) |
462
+ | `--kv-quant config\|off\|4\|8\|turbo[:k<bits>v<bits>]` | KV scheme for the run |
463
+ | `--compiled-decode`, `--compiled-activations`, `--fused-sdpa` | kill switches; A/B by running twice |
464
+
465
+ For **quotable, cross-stack** numbers use the preflight-gated harness from
466
+ the repo — it spawns the real CLI at its real defaults next to the mlx-lm
467
+ and optiq reference servers and writes a dated report:
468
+
469
+ ```sh
470
+ bun scripts/bench-serve.ts all
471
+ bun scripts/bench-serve.ts all --models cpm5,e4b --arms mlx-bun,mlx-lm --out report.md
284
472
  ```
285
473
 
286
- For quotable **cross-stack** numbers use `./benchmark.sh` from the repo — it
287
- preflight-gates on an idle machine and runs the mlx-lm/optiq comparison legs,
288
- writing `benchmarks-h2h-<date>.md`.
474
+ Curated results: [benchmarks.md](benchmarks.md).
289
475
 
290
476
  ### `evals` — recorded runs
291
477
 
292
478
  ```sh
293
- mlx-bun evals # table: when, model, KV mode, tok/s, TTFT, peak, commit
479
+ mlx-bun evals # table: when, stack, model, bench, KV, prefill, decode, TTFT, peak, commit
480
+ mlx-bun evals --limit 50
294
481
  mlx-bun evals --raw # JSON lines for scripts/jq
482
+ mlx-bun evals --clear # archive the DB to a timestamped backup and start fresh
295
483
  ```
296
484
 
297
- ## Everything else
298
-
299
- - `help [verb]` — overview, or per-verb help (same as `<verb> --help`).
300
- - `--version` / `-v` — print the version.
485
+ ## mlx-lm compatibility
486
+
487
+ mlx-bun borrows mlx-lm's verb and flag vocabulary so scripts drop in with a
488
+ rename of the executable: `mlx_lm.<verb> …` becomes `mlx-bun <verb> …`.
489
+ There is no `mlx-bun.<verb>` dotted alias (the package installs one binary,
490
+ `mlx-bun`). Surface parity is not architecture parity: a verb run against an
491
+ unsupported architecture errors clearly rather than guessing.
492
+
493
+ ### What maps to what
494
+
495
+ | mlx-lm | mlx-bun | Accepted mlx-lm spellings | Not accepted |
496
+ |---|---|---|---|
497
+ | `mlx_lm.server` | `serve` | `--model`, `--host`, `--port`, `--adapter-path`, `--temp`, `--top-p`, `--top-k`, `--max-tokens`, `--draft-model`, `--num-draft-tokens`, `--decode-concurrency` (semantics differ — [server-config.md](server-config.md)) | `--prompt-cache-size`/`--prompt-cache-bytes` (use `--prompt-cache`), `--min-p`, `--chat-template`, `--chat-template-args`, `--use-default-chat-template`, `--trust-remote-code`, `--log-level`, `--allowed-origins`, `--pipeline`, `--prefill-step-size`, `--prompt-concurrency` — silently ignored |
498
+ | `mlx_lm.generate` | `generate` | `--prompt`, `--max-tokens`, `--temp`, `--top-p`, `--top-k`, `--seed` | `--kv-bits`/`--kv-group-size`/`--quantized-kv-start` (use `--kv-quant`), `--min-p`, `--xtc-*`, `--prompt-cache-file`, `--max-kv-size`, `--adapter-path`, `--draft-model`, `--system-prompt`, `--ignore-chat-template` (use `--raw`), `--verbose` — silently ignored |
499
+ | `mlx_lm.chat` | `pi` / the web chat | — | no terminal REPL verb; `pi` is the agent, `serve` opens the chat UI |
500
+ | `mlx_lm.convert` | `convert` | `--hf-path`, `--mlx-path`, `-q`/`--quantize`, `--q-bits`, `--q-group-size`, `--q-mode affine`, `--upload-repo` | `--dtype`, `-d`/`--dequantize`, `--quant-predicate`, non-affine `--q-mode`, plain non-quantizing conversion — **refused** |
501
+ | `mlx_lm.fuse` | `fuse` | `--model`, `--adapter-path`, `--save-path` | `--de-quantize`, `--export-gguf`, `--gguf-path`, `--upload-repo` — **refused** |
502
+ | `mlx_lm.lora --train` | `train` | `--data`, `--iters`, `--seed` (same names); otherwise own names (`--method`, `--adapter`, `--lr`, `--rank`, `--seq`, `--batch`, `--grad-accum`, `--save-every`, `--resume`) | `--train`/`--test`, `--config` (YAML), `--fine-tune-type`, `--adapter-path`, `--learning-rate`, `--max-seq-length`, `--batch-size`, `--num-layers`, `--mask-prompt`, `--optimizer` — silently ignored |
503
+ | `mlx_lm.upload` | `upload` | `--path`, `--upload-repo` (+ `--private`) | — |
504
+ | `mlx_lm.perplexity` | `perplexity` | `--model`, `--sequence-length`, `--num-samples`, `--batch-size`, `--seed`; `--data-path` is a local file | HF dataset ids |
505
+ | `mlx_lm.benchmark` | `benchmark` | `--model` | `-p`/`--prompt-tokens` short form, `-g`/`--generation-tokens`, `-b`/`--batch-size`, `-n`/`--num-trials` (ours: `--prompt-tokens`, `--tokens`, `--runs`; one stream) |
506
+ | `mlx_lm.manage` | `get` / `scan` / `ls` / `gc` | — | `--scan`/`--delete`/`--pattern` flag forms; `gc` deletes superseded snapshots, not whole repos |
507
+ | `mlx_lm.dynamic_quant` | `convert --target-bpw` | — | the `dynamic_quant` verb name |
508
+
509
+ mlx-optiq's CLI (`optiq convert` / `serve` / `lora` / `benchmark` / `eval` /
510
+ `latency` / `kv-cache` / `lab`) maps onto the same verbs where the concept
511
+ exists: `optiq convert` → `convert --target-bpw`; `optiq serve --kv-config`
512
+ → `serve --kv-quant config` (the `--l2` preset); `optiq latency` → `fit`;
513
+ `optiq lab` → the web app served by `serve`. `optiq eval` and `optiq
514
+ kv-cache` have no verb (below).
515
+
516
+ ### mlx-lm entry points: covered / not covered
517
+
518
+ Against the console scripts the pinned oracle ships
519
+ (`mlx_lm-*.dist-info/entry_points.txt` in the oracle venv). The scoping
520
+ behind each "not covered" row is in
521
+ [docs/reference/cli.md](./cli.md).
522
+
523
+ | Entry point | Status | Where |
524
+ |---|---|---|
525
+ | `mlx_lm.server` | covered | `serve` (incl. `--draft-model` speculative decoding) |
526
+ | `mlx_lm.generate` | covered | `generate` |
527
+ | `mlx_lm.chat` | covered differently | `pi` (agent TUI) + web chat; no plain REPL |
528
+ | `mlx_lm.convert` | covered | `convert` (quantizing paths only) |
529
+ | `mlx_lm.dynamic_quant` | covered | `convert --target-bpw` (sensitivity scan + per-layer bits) |
530
+ | `mlx_lm.lora` | covered (train) | `train`; the `--test` evaluation mode is not covered |
531
+ | `mlx_lm.fuse` | covered | `fuse` (no dequantize / GGUF / upload) |
532
+ | `mlx_lm.upload` | covered | `upload` |
533
+ | `mlx_lm.perplexity` | covered | `perplexity` (local files only) |
534
+ | `mlx_lm.benchmark` | covered | `benchmark` (own flag names; `evals` views the DB) |
535
+ | `mlx_lm.manage` | covered | `get` / `scan` / `ls` / `gc` |
536
+ | `mlx_lm.cache_prompt` | not covered | no on-disk prompt-cache files; the server's prompt cache (+ `--ssd-cache`) is the equivalent for served traffic |
537
+ | `mlx_lm.evaluate` | not covered | no lm-evaluation-harness backend; `benchmark`/`evals`/`perplexity` are the native measurement, and the `/v1` API accepts external harnesses |
538
+ | `mlx_lm.awq` | not covered | activation-aware weight quantization |
539
+ | `mlx_lm.dwq` | not covered | distilled weight quantization |
540
+ | `mlx_lm.gptq` | not covered | Hessian-conditioned rounding |
541
+ | `mlx_lm.share` | not covered | distributed cache share |
542
+ | `mlx_lm` (umbrella `mlx_lm <verb>`) | covered | `mlx-bun <verb>` is the same shape |
543
+
544
+ Native verbs with no mlx-lm counterpart — `pi`, `harness pi`, `embed`,
545
+ `fit`, `train-watch`, `memory`, `evals` — are the surface that makes mlx-bun
546
+ more than a drop-in.