mlx-bun 0.2.0 → 0.4.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.
- package/README.md +71 -588
- package/docs/README.md +94 -0
- package/docs/{design → archive/investigations}/audio-input-plan.md +4 -4
- package/docs/{design → archive/investigations}/diffusion-gemma-port.md +3 -3
- package/docs/{design → archive/investigations}/faithful-l1-consolidation.md +4 -4
- package/docs/{design → archive/investigations}/minicpm5-decode-megakernel.md +11 -11
- package/docs/archive/investigations/openjarvis-fit.md +198 -0
- package/docs/{design → archive/investigations}/optimization_plan.md +1 -1
- package/docs/{design → archive/investigations}/pre-colibri-stabilization.md +5 -5
- package/docs/archive/investigations/qwen38-27b-campaign-log.md +1092 -0
- package/docs/{design → archive/investigations}/the-dreaming-handoff.md +2 -2
- package/docs/archive/planning/release-notes-v0.3.0.md +35 -0
- package/docs/design/batching.md +1841 -0
- package/docs/design/decode-speed-program.md +2346 -169
- package/docs/design/dreaming-nightly-pipeline.md +675 -282
- package/docs/design/generic-model-support.md +655 -334
- package/docs/design/kv-cache.md +824 -0
- package/docs/design/orpo-training.md +673 -1239
- package/docs/design/speculative-decoding.md +1990 -0
- package/docs/design/turboquant.md +2212 -0
- package/docs/design/unified-engine-frontier-plan.md +1833 -727
- package/docs/design/web-chat-redesign.md +666 -1083
- package/docs/planning/PRODUCT_ROADMAP.md +50 -1
- package/docs/planning/release-notes-v0.4.0.md +45 -0
- package/docs/planning/video-series.md +2 -2
- package/docs/reference/benchmarks.md +3613 -0
- package/docs/reference/cli.md +434 -160
- package/docs/reference/distribution.md +328 -182
- package/docs/reference/environment.md +398 -0
- package/docs/reference/glossary.md +39 -0
- package/docs/reference/library-api.md +566 -168
- package/docs/reference/memory.md +227 -64
- package/docs/reference/models.md +113 -6
- package/docs/reference/server-api.md +944 -429
- package/docs/reference/server-config.md +740 -338
- package/docs/reference/training.md +393 -254
- package/docs/reference/troubleshooting.md +158 -0
- package/package.json +9 -4
- package/src/audio/decode.ts +2 -2
- package/src/audio/features.ts +2 -2
- package/src/backends/mlx/assistant-target.ts +46 -0
- package/src/backends/mlx/autoregressive-draft-rows.ts +120 -0
- package/src/backends/mlx/autoregressive.ts +108 -0
- package/src/backends/mlx/batch-group.ts +1790 -0
- package/src/backends/mlx/cache-attachment.ts +67 -0
- package/src/backends/mlx/cache-layout.ts +31 -0
- package/src/backends/mlx/checkpoint-state.ts +53 -0
- package/src/backends/mlx/continuation-persistence.ts +106 -0
- package/src/backends/mlx/continuation-request.ts +43 -0
- package/src/backends/mlx/continuation.ts +77 -0
- package/src/backends/mlx/diffusion.ts +39 -0
- package/src/backends/mlx/draft-target.ts +32 -0
- package/src/backends/mlx/evaluation.ts +105 -0
- package/src/backends/mlx/fill-append.ts +45 -0
- package/src/backends/mlx/full-kv-row-append.ts +32 -0
- package/src/backends/mlx/full-kv-row-donor.ts +54 -0
- package/src/backends/mlx/full-transitioning-kv-rows.ts +65 -0
- package/src/backends/mlx/gateway-binding.ts +130 -0
- package/src/backends/mlx/graph.ts +38 -0
- package/src/backends/mlx/kv-codec.ts +9 -0
- package/src/backends/mlx/kv-maintenance.ts +133 -0
- package/src/backends/mlx/kv-tensor-rows.ts +212 -0
- package/src/backends/mlx/memory-client.ts +189 -0
- package/src/backends/mlx/methods.ts +90 -0
- package/src/backends/mlx/model-prompt.ts +164 -0
- package/src/backends/mlx/model-serving.ts +79 -0
- package/src/backends/mlx/prefill-cohort.ts +89 -0
- package/src/backends/mlx/prefill-rows.ts +200 -0
- package/src/backends/mlx/prefill.ts +33 -0
- package/src/backends/mlx/projected-context-rows.ts +72 -0
- package/src/backends/mlx/request-policy.ts +20 -0
- package/src/backends/mlx/request-state-policy.ts +41 -0
- package/src/backends/mlx/rollback.ts +89 -0
- package/src/backends/mlx/row-sampling.ts +49 -0
- package/src/backends/mlx/serial-executor.ts +242 -0
- package/src/backends/mlx/speculative-group.ts +359 -0
- package/src/backends/mlx/speculative-round.ts +161 -0
- package/src/backends/mlx/speculative.ts +114 -0
- package/src/backends/mlx/state-rows.ts +104 -0
- package/src/backends/mlx/state-views.ts +46 -0
- package/src/backends/mlx/target-layout-capability.ts +35 -0
- package/src/backends/mlx/text-engine.ts +73 -0
- package/src/backends/mlx/transitioning-kv-rows.ts +165 -0
- package/src/cli.ts +66 -58
- package/src/client.ts +66 -0
- package/src/config.ts +21 -4
- package/src/contracts/completion.ts +16 -0
- package/src/contracts/execution.ts +60 -0
- package/src/contracts/generation.ts +103 -0
- package/src/contracts/host.ts +7 -0
- package/src/contracts/jobs.ts +66 -0
- package/src/contracts/pi-provider.ts +30 -0
- package/src/contracts/pi.ts +259 -0
- package/src/contracts/prefix-cache.ts +23 -0
- package/src/contracts/resources.ts +25 -0
- package/src/contracts/sampling.ts +23 -0
- package/src/contracts/scheduling.ts +45 -0
- package/src/contracts/tsconfig.json +14 -0
- package/src/diffusion/diffusion-generate.ts +218 -153
- package/src/embed.ts +1 -1
- package/src/engine/admission.ts +59 -0
- package/src/engine/cancellation.ts +38 -0
- package/src/engine/engine.ts +56 -0
- package/src/engine/execution-coordinator.ts +70 -0
- package/src/engine/execution-plan.ts +53 -0
- package/src/engine/resources.ts +53 -0
- package/src/engine/scheduler.ts +72 -0
- package/src/engine/session.ts +247 -0
- package/src/eval/README.md +44 -1
- package/src/eval/kl.ts +236 -3
- package/src/eval/reference-logits.ts +207 -0
- package/src/eval/runner.ts +8 -96
- package/src/fill/echo-index.ts +188 -0
- package/src/fill/fill-session.ts +452 -0
- package/src/fill/proposal.ts +68 -0
- package/src/fill/schema-rows.ts +506 -0
- package/src/fill/tool-boundary.ts +103 -0
- package/src/fit.ts +30 -16
- package/src/generate.ts +709 -417
- package/src/grammar.ts +12 -7
- package/src/harness-pi.ts +14 -33
- package/src/hub-rest.ts +4 -4
- package/src/index.ts +7 -0
- package/src/inference/denoising.ts +17 -0
- package/src/inference/draft-acceptance.ts +41 -0
- package/src/inference/draft-output.ts +49 -0
- package/src/inference/graph.ts +33 -0
- package/src/inference/prefill.ts +39 -0
- package/src/inference/rollback.ts +7 -0
- package/src/jobs/db.ts +4 -0
- package/src/jobs/index.ts +2 -0
- package/src/jobs/job-entry.ts +12 -12
- package/src/jobs/runner.ts +98 -13
- package/src/jobs/task-client.ts +19 -0
- package/src/jobs/types.ts +2 -58
- package/src/kv-scheme.ts +70 -12
- package/src/kv-store.ts +177 -63
- package/src/lab/README.md +18 -0
- package/src/{assets → lab/curve}/curve-designer.html +2 -2
- package/src/{curve-sampler.ts → lab/curve/curve-sampler.ts} +2 -2
- package/src/{expert-trace.ts → lab/expert-trace/expert-trace.ts} +5 -5
- package/src/lab/paged-kv/paged-kv-rows.ts +83 -0
- package/src/{model → lab/paged-kv}/paged-kv.ts +32 -15
- package/src/library.ts +40 -0
- package/src/lora.ts +18 -0
- package/src/media-fetch.ts +1 -1
- package/src/memory/article.ts +1 -1
- package/src/memory/chunk.ts +1 -1
- package/src/memory/model.ts +30 -169
- package/src/memory/prompts.ts +1 -1
- package/src/memory/rest.ts +1 -1
- package/src/memory/schedule.ts +1 -1
- package/src/memory/stages.ts +4 -1
- package/src/memory/vault.ts +1 -3
- package/src/mlx/array.ts +11 -11
- package/src/mlx/compile.ts +12 -2
- package/src/mlx/ffi.ts +58 -11
- package/src/mlx/materialize.ts +23 -0
- package/src/mlx/metal-kernel.ts +10 -11
- package/src/mlx/ops.ts +33 -13
- package/src/mlx/quantized-rows.ts +36 -0
- package/src/mlx/token-bitmask.ts +52 -0
- package/src/mlx/turboquant-kv-decode.ts +82 -0
- package/src/mlx/turboquant-kv-inverse.ts +122 -0
- package/src/mlx/turboquant-ops.ts +33 -3
- package/src/mlx/turboquant-tables.ts +2 -2
- package/src/model/artifact-identity.ts +73 -0
- package/src/model/batched-kv.ts +235 -0
- package/src/model/batched-mask.ts +20 -6
- package/src/model/batched-quant.ts +9 -3
- package/src/model/batched-quantized-kv.ts +144 -0
- package/src/model/batched-rotating-quant.ts +78 -17
- package/src/model/batched-rotating-state.ts +76 -0
- package/src/model/batched-rotating.ts +65 -23
- package/src/model/batched-row-storage.ts +52 -0
- package/src/model/batched-ssm.ts +52 -0
- package/src/model/batched-turboquant-kv.ts +93 -0
- package/src/model/compiled-decode.ts +8 -2
- package/src/model/decoded-kv-donor.ts +12 -0
- package/src/model/delayed-quantized-kv.ts +72 -0
- package/src/model/delayed-rotating-quantized-kv.ts +93 -0
- package/src/model/delayed-turboquant-kv.ts +55 -0
- package/src/model/diffusion-gemma.ts +8 -8
- package/src/model/factory.ts +76 -33
- package/src/model/fingerprint.ts +1 -1
- package/src/model/flash-attention.ts +3 -3
- package/src/model/full-prefill-padding.ts +56 -0
- package/src/model/full-prefill-row.ts +105 -0
- package/src/model/gemma4-base.ts +179 -80
- package/src/model/gemma4.ts +40 -32
- package/src/model/generated/gemma4-12b.ts +6 -3
- package/src/model/generated/gemma4-26b.ts +6 -3
- package/src/model/generated/gemma4-e4b.ts +6 -3
- package/src/model/glm52-cache.ts +80 -4
- package/src/model/glm52-dsa.ts +13 -9
- package/src/model/glm52-memory.ts +1 -1
- package/src/model/glm52-mla.ts +12 -6
- package/src/model/glm52.ts +19 -40
- package/src/model/implementation.ts +69 -0
- package/src/model/kv-attention-view.ts +67 -0
- package/src/model/minicpm5.ts +17 -15
- package/src/model/profile.ts +12 -2
- package/src/model/qwen-append.ts +12 -0
- package/src/model/qwen-conv.ts +52 -0
- package/src/model/qwen3-delta-state.ts +74 -0
- package/src/model/qwen3-delta.ts +59 -36
- package/src/model/qwen3_5-checkpoint.ts +164 -0
- package/src/model/qwen3_5.ts +202 -78
- package/src/model/rotating-kv-donor.ts +35 -0
- package/src/model/rotating-kv-layout.ts +262 -0
- package/src/model/rotating-row-transaction.ts +35 -0
- package/src/model/speculative-rotating-kv.ts +101 -0
- package/src/model/ssm-prefill-padding.ts +39 -0
- package/src/model/support.ts +1 -1
- package/src/model/trellis-balanced-scatter.ts +51 -0
- package/src/model/trellis-linear.ts +672 -0
- package/src/model/trellis-shared-m.ts +151 -0
- package/src/model/trellis-shared-scatter.ts +144 -0
- package/src/model/trellis-splitk-prefill.ts +158 -0
- package/src/model/trellis-tiled-prefill.ts +136 -0
- package/src/model/trellis-vector-expand.ts +62 -0
- package/src/model/trellis-wide-prefill.ts +94 -0
- package/src/model/turboquant-codec.ts +83 -0
- package/src/model/universal/dense.ts +15 -14
- package/src/model/universal/modules.ts +8 -1
- package/src/native-pack.ts +6 -5
- package/src/pi-provider.ts +6 -64
- package/src/pi-web.ts +8 -315
- package/src/preflight.ts +31 -15
- package/src/prompt-cache.ts +110 -69
- package/src/quantize/allocator.ts +1 -1
- package/src/quantize/config-writer.ts +10 -3
- package/src/quantize/rotate.ts +4 -4
- package/src/quantize/trellis.ts +586 -0
- package/src/responses.ts +28 -1
- package/src/runtime-config.ts +18 -4
- package/src/sampler.ts +40 -29
- package/src/serve/batch-scheduler.ts +8 -1671
- package/src/serve/chat-request.ts +391 -0
- package/src/serve/chat-stage.ts +195 -0
- package/src/serve/checkpoint-identity.ts +64 -0
- package/src/serve/completion-executor.ts +15 -7
- package/src/serve/discovery-routes.ts +12 -13
- package/src/serve/generation-gateway.ts +183 -213
- package/src/serve/http.ts +159 -0
- package/src/serve/inference-request.ts +79 -0
- package/src/serve/isolate.ts +297 -105
- package/src/serve/lab-routes.ts +3 -0
- package/src/serve/lane-registry.ts +2 -1
- package/src/serve/model-admin-routes.ts +7 -5
- package/src/serve/model-binding.ts +43 -0
- package/src/serve/model-host.ts +511 -0
- package/src/serve/openai-wire.ts +103 -0
- package/src/serve/parent-application.ts +56 -0
- package/src/serve/pipeline.ts +33 -0
- package/src/serve/preparation.ts +33 -0
- package/src/serve/request-plan.ts +23 -18
- package/src/serve/request-prep.ts +344 -0
- package/src/serve/response-lease.ts +24 -0
- package/src/serve/responses-client.ts +69 -0
- package/src/serve/session-completion-engine.ts +110 -0
- package/src/serve/session-search.ts +1 -1
- package/src/serve/static-routes.ts +5 -5
- package/src/serve/text-completion-stage.ts +104 -0
- package/src/serve/token-streams.ts +519 -0
- package/src/server.ts +335 -2711
- package/src/spec/assistant-rows.ts +92 -0
- package/src/spec/assistant-source.ts +31 -55
- package/src/spec/cache-identity.ts +22 -0
- package/src/spec/deepspec-rows.ts +29 -0
- package/src/spec/deepspec-source.ts +16 -14
- package/src/spec/dflash-source.ts +36 -12
- package/src/spec/drafter.ts +153 -142
- package/src/spec/dspark/ab-stats.ts +3 -3
- package/src/spec/dspark/calibration.ts +2 -2
- package/src/spec/dspark/deepspec-module.ts +97 -122
- package/src/spec/dspark/generate-dflash.ts +2 -2
- package/src/spec/dspark/generate.ts +2 -2
- package/src/spec/dspark/loader.ts +1 -1
- package/src/spec/dspark/module-dflash.ts +129 -172
- package/src/spec/dspark/module.ts +3 -3
- package/src/spec/dspark/quantize-drafter.ts +1 -1
- package/src/spec/generate.ts +1 -1
- package/src/spec/glm52-mtp-graph.ts +29 -0
- package/src/spec/glm52-mtp-rows.ts +132 -0
- package/src/spec/glm52-mtp-source.ts +54 -137
- package/src/spec/glm52-mtp-state.ts +33 -0
- package/src/spec/ngram-source.ts +93 -21
- package/src/spec/projected-draft-rows.ts +73 -0
- package/src/spec/qwen-mtp-module.ts +171 -0
- package/src/spec/qwen-mtp-rows.ts +219 -0
- package/src/spec/qwen-mtp-source.ts +147 -195
- package/src/spec/qwen-mtp-state.ts +30 -0
- package/src/spec/serve-loop.ts +201 -201
- package/src/spec/source.ts +110 -13
- package/src/spec/two-model-rows.ts +61 -0
- package/src/spec/two-model.ts +44 -102
- package/src/ssd-cache.ts +99 -19
- package/src/ssd-durability.ts +36 -20
- package/src/tool-call.ts +51 -14
- package/src/train/flash-cce.ts +2 -2
- package/src/train/forward.ts +6 -0
- package/src/train/loss.ts +1 -1
- package/src/train/prefix-shared.ts +5 -1
- package/src/train/segmented.ts +5 -3
- package/src/train/trainer.ts +6 -6
- package/src/vision/prompt.ts +1 -1
- package/src/vision/qwen3vl-tower.ts +52 -10
- package/src/web/app.html +1 -1
- package/src/web/app.js +62 -60
- package/src/web/src/adapters-panel.ts +3 -3
- package/src/web/src/assistant.ts +2 -36
- package/src/web/src/chat.ts +4 -4
- package/src/web/src/composer.ts +4 -4
- package/src/web/src/hub.ts +1 -1
- package/src/web/src/markdown.ts +0 -0
- package/src/web/src/memory-panel.ts +1 -1
- package/src/web/src/model-picker.ts +1 -1
- package/src/web/src/palette.ts +1 -1
- package/src/web/src/protocol.ts +3 -39
- package/src/web/src/sessions.ts +1 -1
- package/src/web/src/ui-catalog.ts +4 -18
- package/src/web-assets.ts +47 -0
- package/src/weights.ts +55 -9
- package/docs/archive/investigations/curve-runs/bisector-route.json +0 -98
- package/docs/archive/investigations/curve-runs/bisector-trace.json +0 -1393
- package/docs/archive/investigations/curve-runs/curve-terrain.json +0 -1179
- package/docs/archive/investigations/curve-runs/curve-terrain.svg +0 -42
- package/docs/archive/investigations/hlg-ab.html +0 -34
- package/docs/archive/investigations/hlg-explorer.html +0 -238
- package/docs/archive/investigations/hlg-figs/cliff.svg +0 -1
- package/docs/archive/investigations/hlg-figs/cross.svg +0 -1
- package/docs/archive/investigations/hlg-figs/edges.svg +0 -1
- package/docs/archive/investigations/hlg-figs/k20-grids.svg +0 -1
- package/docs/archive/investigations/hlg-figs/k20-peaks.svg +0 -1
- package/docs/archive/investigations/hlg-figs/lw-curve.svg +0 -1
- package/docs/archive/investigations/hlg-figs/terrain.svg +0 -1
- package/docs/archive/investigations/hlg-report.html +0 -262
- package/docs/archive/investigations/hlg-runs/hlg-ab.json +0 -149
- package/docs/archive/investigations/hlg-runs/hlg-blind-prompts.md +0 -87
- package/docs/archive/investigations/hlg-runs/hlg-blind.json +0 -107
- package/docs/archive/investigations/hlg-runs/hlg-cliff.json +0 -197
- package/docs/archive/investigations/hlg-runs/hlg-cross.json +0 -505
- package/docs/archive/investigations/hlg-runs/hlg-edge.json +0 -388
- package/docs/archive/investigations/hlg-runs/hlg-eval1.json +0 -25
- package/docs/archive/investigations/hlg-runs/hlg-frontier.json +0 -86
- package/docs/archive/investigations/hlg-runs/hlg-grid.json +0 -242
- package/docs/archive/investigations/hlg-runs/hlg-grid2.json +0 -343
- package/docs/archive/investigations/hlg-runs/hlg-lw-coarse.json +0 -110
- package/docs/archive/investigations/hlg-runs/hlg-map.json +0 -383
- package/docs/archive/investigations/hlg-runs/run0-original.log +0 -159
- package/docs/archive/investigations/hlg-runs/runA-recommended.log +0 -131
- package/docs/archive/investigations/hlg-runs/runAA-cliff-cpm5.log +0 -26
- package/docs/archive/investigations/hlg-runs/runAB-grid2-e4b.log +0 -18
- package/docs/archive/investigations/hlg-runs/runAC-peak-e4b-partial.log +0 -25
- package/docs/archive/investigations/hlg-runs/runAD-ab-samples.log +0 -8
- package/docs/archive/investigations/hlg-runs/runAE-edge-e4b.log +0 -51
- package/docs/archive/investigations/hlg-runs/runAF-logit-calibration.log +0 -10
- package/docs/archive/investigations/hlg-runs/runAG-eval-config2.log +0 -16
- package/docs/archive/investigations/hlg-runs/runB-gain-variants.log +0 -192
- package/docs/archive/investigations/hlg-runs/runC-pivots.log +0 -162
- package/docs/archive/investigations/hlg-runs/runD-oetf.log +0 -132
- package/docs/archive/investigations/hlg-runs/runE-eotf.log +0 -162
- package/docs/archive/investigations/hlg-runs/runF-shaper-working.log +0 -86
- package/docs/archive/investigations/hlg-runs/runG-shaper-sweep.log +0 -101
- package/docs/archive/investigations/hlg-runs/runH-wsweep.log +0 -176
- package/docs/archive/investigations/hlg-runs/runI-asweep.log +0 -176
- package/docs/archive/investigations/hlg-runs/runJ-knobmap.log +0 -49
- package/docs/archive/investigations/hlg-runs/runK-frontier.log +0 -19
- package/docs/archive/investigations/hlg-runs/runL-widemap.log +0 -65
- package/docs/archive/investigations/hlg-runs/runM-frontier-emb.log +0 -15
- package/docs/archive/investigations/hlg-runs/runN-verify.log +0 -116
- package/docs/archive/investigations/hlg-runs/runO-frontier-seed5000.log +0 -15
- package/docs/archive/investigations/hlg-runs/runP-grid-AxSm.log +0 -15
- package/docs/archive/investigations/hlg-runs/runQ-grid-tgW.log +0 -15
- package/docs/archive/investigations/hlg-runs/runR-blind-transcript.log +0 -79
- package/docs/archive/investigations/hlg-runs/runS-cross-coherence.log +0 -33
- package/docs/archive/investigations/hlg-runs/runT-cross-cpm5.log +0 -33
- package/docs/archive/investigations/hlg-runs/runU-cross-12b.log +0 -33
- package/docs/archive/investigations/hlg-runs/runV-lw-e4b.log +0 -22
- package/docs/archive/investigations/hlg-runs/runW-lw-12b.log +0 -22
- package/docs/archive/investigations/hlg-runs/runX-lw-cpm5.log +0 -22
- package/docs/archive/investigations/hlg-runs/runY-cliff-e4b.log +0 -26
- package/docs/archive/investigations/hlg-runs/runZ-cliff-12b.log +0 -26
- package/docs/archive/mlx-bun-lab-report.html +0 -275
- package/docs/archive/wwdc-mlx-bun.html +0 -848
- package/docs/design/adapters-end-to-end.md +0 -205
- package/docs/design/batching-perf-path.md +0 -255
- package/docs/design/batching-v2-plan.md +0 -529
- package/docs/design/bucketing-stage.md +0 -197
- package/docs/design/compat-cli-surface-design.md +0 -230
- package/docs/design/docs-reorg-plan.md +0 -165
- package/docs/design/dspark-serving-program.md +0 -371
- package/docs/design/dspark-speculative-decoding.md +0 -318
- package/docs/design/grammar-spec-batching-integration.md +0 -301
- package/docs/design/memory-inference-path.md +0 -422
- package/docs/design/memory-synthesis.md +0 -287
- package/docs/design/memory-system.md +0 -237
- package/docs/design/mlx-lm-serving-execution-seam.md +0 -81
- package/docs/design/mlx-lm-tool-parity-plan.md +0 -545
- package/docs/design/omlx-adoption-map.md +0 -98
- package/docs/design/orpo-dynamic-lambda.md +0 -220
- package/docs/design/orpo-future-enhancements.md +0 -340
- package/docs/design/paged-kv-cache.md +0 -214
- package/docs/design/parallel-slots.md +0 -567
- package/docs/design/parity-tier-dag.md +0 -161
- package/docs/design/repo-cleanup-plan.md +0 -231
- package/docs/design/runtime-isolation.md +0 -263
- package/docs/design/segmented-backward-training.md +0 -543
- package/docs/design/spec-decode-larger-targets.md +0 -229
- package/docs/design/ssd-kv-cold-tier.md +0 -415
- package/docs/design/structured-output.md +0 -484
- package/docs/design/tauri-desktop-app.md +0 -127
- package/docs/design/the-dreaming-master-plan.md +0 -445
- package/docs/design/turboquant-kv.md +0 -235
- package/docs/design/turboquant-weights.md +0 -467
- package/docs/design/w4a16-compute-precision-spike.md +0 -232
- package/docs/design/web-chat-beat-matrix.md +0 -315
- package/docs/design/write-pipeline-entity.md +0 -468
- package/docs/planning/IDEAS.md +0 -69
- package/docs/reference/embedding.md +0 -197
- package/docs/reference/features-matrix.md +0 -101
- package/docs/reference/orpo-quickstart.md +0 -135
- package/src/flags.ts +0 -11
- /package/docs/{design → archive/investigations}/colibri-glm52-port.md +0 -0
- /package/docs/{planning → archive/planning}/chunk-task-roadmap.md +0 -0
- /package/docs/{planning → archive/planning}/curve-sampler-research-plan.md +0 -0
- /package/docs/{planning → archive/planning}/memory-docs-and-dag-plan.md +0 -0
- /package/docs/{planning → archive/planning}/pi-integration-review.md +0 -0
- /package/docs/{planning → archive/planning}/release-notes-v0.2.0.md +0 -0
- /package/src/{memory-plan.ts → admission-plan.ts} +0 -0
- /package/{docs/archive/investigations → src/serve/assets}/curve-terrain.html +0 -0
- /package/{docs/dag → src/serve/assets}/training-inference-map.html +0 -0
package/docs/reference/cli.md
CHANGED
|
@@ -1,119 +1,222 @@
|
|
|
1
1
|
# CLI reference
|
|
2
2
|
|
|
3
|
-
Every mlx-bun verb. Commands are shown as
|
|
4
|
-
|
|
5
|
-
`mlx-bun <verb> --help`)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
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
|
|
26
|
-
mlx-bun serve e4b
|
|
27
|
-
mlx-bun serve
|
|
28
|
-
mlx-bun serve e4b --no-open
|
|
29
|
-
mlx-bun serve GLM-5.2 --context-length 4096
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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.
|
|
66
|
+
|
|
67
|
+
Library requests support delayed uniform or per-layer affine conversion with
|
|
68
|
+
qualified shared drafting providers, including rotating caches. CLI affine
|
|
69
|
+
quantization starts at zero.
|
|
70
|
+
|
|
71
|
+
The unreleased shared executor supports qualified Qwen MTP and start-zero
|
|
72
|
+
TurboQuant at one or several active rows; `--batch 1` still selects the
|
|
73
|
+
legacy serial control. No new CLI flag is required for the shared interfaces.
|
|
74
|
+
Full-attention and rotating targets, including Llama, MiniCPM and Gemma, use shared bf16, uniform KV4/KV8, per-layer affine KV or TurboQuant
|
|
75
|
+
prompt lookup and standalone drafting, including generated RAM/SSD state.
|
|
76
|
+
Gemma assistant drafting also shares these target layouts and caches its last true target
|
|
77
|
+
hidden alongside target KV through the same RAM/SSD interfaces.
|
|
78
|
+
DeepSpec and DSpark use the same executor and persist their projected context through those
|
|
79
|
+
interfaces. DeepSpec accepts bf16 or affine-quantized weights; DSpark retains
|
|
80
|
+
its Markov/RNN head and checkpoint confidence policy.
|
|
81
|
+
|
|
82
|
+
Shared Qwen MTP retains completed decode state through the existing
|
|
83
|
+
`--prompt-cache` and `--ssd-cache` settings.
|
|
84
|
+
|
|
85
|
+
| Group | Flags |
|
|
35
86
|
|---|---|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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` \| `mtp` \| `ngram` (default: auto). `mtp` is a NATIVE multi-token-prediction head split from the target's own release (e.g. `mlx-community/Qwen3.8-27B-MTP-bf16`; auto-detected from a `*_mtp` `model_type`) — it binds the target's embeddings/lm-head and taps its pre-final-norm hiddens, and the serve loop rolls the target's recurrent DeltaNet caches back across rejected drafts via bit-exact snapshot/replay. `--draft-kind mtp` WITHOUT `--draft-model` resolves the companion from the artifact's own `mtp/` subfolder (single-repo bundles, e.g. the TQ releases) and refuses with a clear error when the model bundles none. `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-scheduler concurrency cap, mlx-lm parity at the same B (default 8; a lone admitted request uses the gated B=1 fast path, while `--batch 1` pins the preserved strict serial executor) |
|
|
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 |
|
|
87
|
+
| Network | `--host`, `--port`, `--no-open`, `--allow-private-media` |
|
|
88
|
+
| Memory & caches | `--memory-budget`, `--kv-budget`, `--prompt-cache`, `--ssd-cache`, `--ssd-cache-max`, `--ssd-cache-verify`, `--ssd-demote-idle`, `--generation-checkpoint` |
|
|
89
|
+
| Process model | `--isolate`, `--model-pool`, `--unix` (internal — the engine half of `--isolate`) |
|
|
90
|
+
| Scheduling | `--batch` (`--decode-concurrency` accepted as the mlx_lm.server alias) |
|
|
91
|
+
| KV cache | `--kv-quant`, `--paged-kv`, `--paged-kv-block-size` |
|
|
92
|
+
| Adapters (compatible sets can batch) | `--adapter` (`--adapter-path` alias) |
|
|
93
|
+
| Speculative decoding (Qwen methods and full-attention/rotating lookup/standalone and Gemma assistant/DeepSpec/DSpark drafting share execution) | `--draft-model`, `--draft-kind`, `--num-draft-tokens`, `--ngram-max`, `--ngram-min` |
|
|
94
|
+
| GLM-5.2 | `--mtp`, `--context-length` |
|
|
95
|
+
| Sampling defaults | `--temperature` (`--temp` alias), `--top-p`, `--top-k`, `--max-tokens`, `--thinking`, `--hlg-sampling`, `--hlg-width`, `--hlg-shoulder`, `--hlg-toe`, `--hlg-pivot-offset` |
|
|
96
|
+
| Parity tier | `--l1`, `--l2` (`--l3` errors — removed) |
|
|
97
|
+
| Kill switches | `--compiled-decode`, `--compiled-activations`, `--fused-sdpa`, `--force-wire`, `--expert-offload` |
|
|
98
|
+
|
|
99
|
+
Serving treats memory estimates as advisory by default and attempts the request.
|
|
100
|
+
`--memory-budget` opts into estimated admission limits; `--kv-budget` opts
|
|
101
|
+
into aggregate KV limits. `--max-tokens` supplies an explicit output cap.
|
|
62
102
|
|
|
63
103
|
Endpoints: `/v1/chat/completions`, `/v1/completions`, `/v1/messages`,
|
|
64
|
-
`/v1/responses`, `/v1/models`, `/v1/adapters`, `/health`,
|
|
65
|
-
`/library`, `/downloads
|
|
66
|
-
`/quantize`, `/finetune`, `/dataset` deep-link its views.
|
|
67
|
-
|
|
104
|
+
`/v1/responses`, `/v1/embeddings`, `/v1/models`, `/v1/adapters`, `/health`,
|
|
105
|
+
`/stats`, `/fit`, `/library`, `/downloads`; the web app at `/` (`/chat`,
|
|
106
|
+
`/status`, `/quantize`, `/finetune`, `/dataset` deep-link its views). Schemas
|
|
107
|
+
in [server-api.md](server-api.md).
|
|
68
108
|
|
|
69
109
|
### `pi` — built-in coding agent
|
|
70
110
|
|
|
71
111
|
Run the pi coding agent's terminal UI in-process against a local model —
|
|
72
|
-
nothing to install. Reuses a healthy
|
|
73
|
-
the session.
|
|
112
|
+
pi is bundled, nothing to install. Reuses a healthy server on the chosen
|
|
113
|
+
port; otherwise starts one that lives exactly as long as the session.
|
|
74
114
|
|
|
75
115
|
```sh
|
|
76
|
-
mlx-bun pi
|
|
77
|
-
mlx-bun pi
|
|
116
|
+
mlx-bun pi # interactive session
|
|
117
|
+
mlx-bun pi fix the failing test # pre-fill the first turn
|
|
118
|
+
mlx-bun pi -p "explain this repo" # one-shot: print the reply and exit
|
|
119
|
+
mlx-bun pi -p --json "summarize README" # one-shot with the full event stream
|
|
120
|
+
mlx-bun pi --mode rpc # JSONL RPC over stdio
|
|
121
|
+
mlx-bun pi -q qwen --port 8090 # model + server flags for the session server
|
|
122
|
+
git diff | mlx-bun pi -p "review this" # piped stdin makes it one-shot too
|
|
78
123
|
```
|
|
79
124
|
|
|
125
|
+
| Flag | Meaning |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `-q`, `--query <q>` | model to serve when starting a session server |
|
|
128
|
+
| `-p`, `--print [msg]` | one-shot print mode (also reads piped stdin) |
|
|
129
|
+
| `--json` | with `-p`: emit the full event stream as JSON |
|
|
130
|
+
| `--mode json\|rpc\|text` | `json` = print + JSON, `rpc` = JSONL RPC over stdio, `text` = print |
|
|
131
|
+
| `--verbose` | verbose agent logging |
|
|
132
|
+
| every `serve` flag | applies to the session server; ignored (with a note) when reusing a running one |
|
|
133
|
+
|
|
134
|
+
Other pi flags are dropped with a note — the full pi surface (`--continue`,
|
|
135
|
+
`--resume`, extensions, themes) lives in your own pi via `harness pi`.
|
|
136
|
+
`mlx-bun help pi` is our help; `mlx-bun pi --help` prints it only when it is
|
|
137
|
+
the sole argument.
|
|
138
|
+
|
|
80
139
|
### `harness pi` — connect your own pi
|
|
81
140
|
|
|
82
|
-
For people who already
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
141
|
+
For people who already run [pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent):
|
|
142
|
+
writes one reversible extension, `~/.pi/agent/extensions/mlx-bun-provider.ts`,
|
|
143
|
+
that registers `mlx-bun` as a pi provider. Models are discovered live from
|
|
144
|
+
`/v1/models` at pi startup (the list baked at install time is the fallback
|
|
145
|
+
when the server is down), exposed under the stable id `mlx-bun/local`. It
|
|
146
|
+
never touches your existing pi config.
|
|
86
147
|
|
|
87
148
|
```sh
|
|
88
|
-
mlx-bun harness pi
|
|
89
|
-
mlx-bun harness pi --
|
|
149
|
+
mlx-bun harness pi # install; requires pi on PATH
|
|
150
|
+
mlx-bun harness pi --base-url http://127.0.0.1:8090/v1
|
|
151
|
+
mlx-bun harness pi --remove # delete the extension
|
|
152
|
+
pi --provider mlx-bun # then run pi as usual
|
|
153
|
+
pi --models "mlx-bun/*" # or scope cycling
|
|
90
154
|
```
|
|
91
155
|
|
|
156
|
+
#### LoRA adapters from pi: the adapter extension
|
|
157
|
+
|
|
158
|
+
`scripts/packaging/pi-extensions/mlx-bun-adapter.ts` ships with the repo and
|
|
159
|
+
adds an `/adapter` command to pi. Install by copying (or symlinking) it into
|
|
160
|
+
`~/.pi/agent/extensions/`, then `/reload` inside pi:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
cp scripts/packaging/pi-extensions/mlx-bun-adapter.ts ~/.pi/agent/extensions/
|
|
164
|
+
MLX_BUN_URL=http://127.0.0.1:8080 pi --provider mlx-bun
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
| In pi | Effect |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `/adapter` or `/adapter list` | list adapters on disk (`/v1/adapters/available`), which are loaded, and the active one |
|
|
170
|
+
| `/adapter <id>` | mount it if needed (`POST /v1/adapters`) and inject `adapter: <id>` into every request |
|
|
171
|
+
| `/adapter off` | back to the base model (no field sent) |
|
|
172
|
+
|
|
173
|
+
The extension reads the server URL from `MLX_BUN_URL` (its built-in fallback
|
|
174
|
+
is port 8090, so set it to match your server). Default is no adapter; the
|
|
175
|
+
mechanism is pi's `before_provider_request` hook, the same one the web chat's
|
|
176
|
+
adapter selector uses. Serving-side detail: [server-api.md](server-api.md#adapters-lora-hot-swap)
|
|
177
|
+
and [docs/design/web-chat-redesign.md](../design/web-chat-redesign.md).
|
|
178
|
+
|
|
92
179
|
### `generate` (alias `gen`) — one-shot generation
|
|
93
180
|
|
|
94
|
-
Load the model, generate, print, exit
|
|
95
|
-
template
|
|
96
|
-
decode-path levers mirror `serve` (`--temperature`, `--seed`, `--l1/--l2`,
|
|
97
|
-
`--kv-quant`, …).
|
|
181
|
+
Load the model, generate, print, exit. The prompt is rendered through the
|
|
182
|
+
chat template unless `--raw`.
|
|
98
183
|
|
|
99
184
|
```sh
|
|
100
|
-
mlx-bun generate
|
|
185
|
+
mlx-bun generate e4b "a haiku about metal shaders"
|
|
101
186
|
mlx-bun gen e4b --prompt "…" --max-tokens 512 --seed 42
|
|
102
|
-
mlx-bun generate
|
|
187
|
+
mlx-bun generate qwen --raw --prompt "def fib(n):" --temperature 0
|
|
103
188
|
```
|
|
104
189
|
|
|
190
|
+
| Flag | Meaning |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `[query]` / `--query <q>` | model (auto-picks when omitted) |
|
|
193
|
+
| `--prompt "…"` | the prompt (or pass it as the positional after the model) |
|
|
194
|
+
| `--raw` | skip the chat template |
|
|
195
|
+
| `--max-tokens <n>` | completion cap |
|
|
196
|
+
| `--temperature <n>` (`--temp` alias), `--top-p`, `--top-k`, `--seed` | sampling |
|
|
197
|
+
| `--l1` / `--l2`, `--kv-quant`, `--fused-sdpa`, `--compiled-decode`, `--compiled-activations` | decode route, same meaning as for `serve` |
|
|
198
|
+
|
|
105
199
|
### `embed` — text embeddings
|
|
106
200
|
|
|
107
|
-
|
|
108
|
-
|
|
201
|
+
Embeddings from a local Qwen3-Embedding model, no server. One JSON vector
|
|
202
|
+
per input line.
|
|
109
203
|
|
|
110
204
|
```sh
|
|
111
205
|
mlx-bun embed --text "hello world"
|
|
112
|
-
|
|
206
|
+
mlx-bun embed Qwen3-Embedding "hello world"
|
|
207
|
+
printf 'line one\nline two\n' | mlx-bun embed --json
|
|
208
|
+
mlx-bun embed --instruct "Retrieve passages that answer the question" --text "what is a KV cache?"
|
|
113
209
|
```
|
|
114
210
|
|
|
115
|
-
|
|
116
|
-
|
|
211
|
+
| Flag | Meaning |
|
|
212
|
+
|---|---|
|
|
213
|
+
| `[query]` / `--query <q>` | embedding model; omitted = the first downloaded embedding model (errors with a `get` suggestion when none) |
|
|
214
|
+
| `--text "…"` | text to embed (omit to read one text per stdin line) |
|
|
215
|
+
| `--instruct "…"` | Qwen3-Embedding query instruction; omit for plain document embeddings |
|
|
216
|
+
| `--json` | one OpenAI-style `{object:"list",data:[…]}` object instead of bare arrays |
|
|
217
|
+
|
|
218
|
+
Server equivalent: `mlx-bun serve <embedding-model>` then
|
|
219
|
+
[`POST /v1/embeddings`](server-api.md#post-v1embeddings-openai-embeddings-api).
|
|
117
220
|
|
|
118
221
|
## Models & disk
|
|
119
222
|
|
|
@@ -121,26 +224,26 @@ Full guide: [models.md](models.md).
|
|
|
121
224
|
|
|
122
225
|
### `get` — download a model
|
|
123
226
|
|
|
124
|
-
Resumable
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
227
|
+
Resumable (Range requests against partial blobs), sha256-verified download
|
|
228
|
+
into the standard Hugging Face cache over plain HTTPS (no Xet). Complete
|
|
229
|
+
blobs and partial prefixes are credited before transfer, and the volume must
|
|
230
|
+
fit the remainder plus a 1 GiB reserve. Uses `HF_TOKEN` / `hf auth login`
|
|
231
|
+
credentials when present.
|
|
128
232
|
|
|
129
233
|
```sh
|
|
130
234
|
mlx-bun get mlx-community/gemma-4-12B-it-OptiQ-4bit
|
|
131
|
-
mlx-bun get 12B
|
|
132
|
-
mlx-bun get
|
|
133
|
-
--revision 3cc8db99b1b13fc79325d987ba3c1c430766b3b8
|
|
235
|
+
mlx-bun get 12B # no "/" = registry query; re-gets/refreshes the match
|
|
236
|
+
mlx-bun get mlx-community/MiniCPM5-1B-OptiQ-4bit --revision main
|
|
134
237
|
```
|
|
135
238
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
239
|
+
`--revision <rev>` selects a git revision. When upstream has pushed a new
|
|
240
|
+
revision the previous snapshot stays on disk — `get` says so and `gc`
|
|
241
|
+
reclaims it. GLM-5.2 specifics: [models.md](models.md#glm-52-on-a-32-gb-mac).
|
|
139
242
|
|
|
140
243
|
### `scan` — index your cache
|
|
141
244
|
|
|
142
|
-
Re-index the HF cache into the registry (config + safetensors headers
|
|
143
|
-
|
|
245
|
+
Re-index the HF cache into the registry (config + safetensors headers, never
|
|
246
|
+
tensor bytes) so `ls`, `serve`, and `fit` resolve models by substring.
|
|
144
247
|
|
|
145
248
|
```sh
|
|
146
249
|
mlx-bun scan
|
|
@@ -148,105 +251,139 @@ mlx-bun scan
|
|
|
148
251
|
|
|
149
252
|
### `ls` — list models
|
|
150
253
|
|
|
254
|
+
One row per repo (canonical revision, `refs/main`); superseded snapshots are
|
|
255
|
+
hidden.
|
|
256
|
+
|
|
151
257
|
```sh
|
|
152
|
-
mlx-bun ls # size, params, quant, capabilities
|
|
153
|
-
mlx-bun ls
|
|
154
|
-
mlx-bun ls --
|
|
258
|
+
mlx-bun ls # size, params, quant, license, capabilities
|
|
259
|
+
mlx-bun ls gemma # filter by substring
|
|
260
|
+
mlx-bun ls --vision --max-size 10GB # vision-capable, under 10 GB
|
|
261
|
+
mlx-bun ls --all-revisions # one row per cached snapshot (canonical marked *)
|
|
155
262
|
```
|
|
156
263
|
|
|
157
264
|
### `gc` — reclaim disk
|
|
158
265
|
|
|
159
|
-
Delete superseded snapshots and the blobs only they reference. Prints the
|
|
160
|
-
by default
|
|
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).
|
|
266
|
+
Delete superseded snapshots and the blobs only they reference. Prints the
|
|
267
|
+
plan by default.
|
|
163
268
|
|
|
164
269
|
```sh
|
|
165
|
-
mlx-bun gc
|
|
166
|
-
mlx-bun gc --yes
|
|
270
|
+
mlx-bun gc # dry run: what would be reclaimed
|
|
271
|
+
mlx-bun gc --yes # delete
|
|
272
|
+
mlx-bun gc --yes --force # also prune snapshots holding files the canonical revision lacks
|
|
167
273
|
```
|
|
168
274
|
|
|
275
|
+
`--dry-run` never deletes even with `--yes`. The same planner backs
|
|
276
|
+
[`GET /api/gc/plan` / `POST /api/gc/execute`](server-api.md#get-apigcplan--post-apigcexecute).
|
|
277
|
+
|
|
169
278
|
### `fit` — memory contract
|
|
170
279
|
|
|
171
|
-
Deterministic memory assessment: does it fit,
|
|
172
|
-
tok/s
|
|
173
|
-
|
|
174
|
-
flag: it bills the quantized cache at its true bytes/element, so the reported
|
|
175
|
-
window matches what serving with the same flag admits (a 4-bit cache holds
|
|
176
|
-
~3.5× the context of bf16 in the same budget).
|
|
280
|
+
Deterministic memory assessment: does it fit, max safe context, predicted
|
|
281
|
+
tok/s — from safetensors headers, the config's KV bytes/token, a calibrated
|
|
282
|
+
prefill transient, and the wired-memory ceiling.
|
|
177
283
|
|
|
178
284
|
```sh
|
|
179
|
-
mlx-bun fit gemma --ctx 32768 #
|
|
285
|
+
mlx-bun fit gemma --ctx 32768 # this machine
|
|
180
286
|
mlx-bun fit gemma --ctx 8192 --skus # across the Apple Silicon lineup
|
|
181
|
-
mlx-bun fit qwen --kv-quant 4 #
|
|
287
|
+
mlx-bun fit qwen --kv-quant 4 # bill a 4-bit-quantized KV cache
|
|
288
|
+
mlx-bun fit GLM-5.2 # streamed-artifact plan (resident weights, expert slabs, KV, reserves)
|
|
182
289
|
```
|
|
183
290
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
line is the measured warm quality-preserving result; the direct Colibri oracle
|
|
190
|
-
and the 2 tok/s aspiration are labeled separately. `--skus` explains that the
|
|
191
|
-
generic resident-model matrix does not apply to this streamed artifact.
|
|
192
|
-
|
|
193
|
-
```sh
|
|
194
|
-
mlx-bun fit GLM-5.2
|
|
195
|
-
mlx-bun fit GLM-5.2 --ctx 4096
|
|
196
|
-
```
|
|
291
|
+
| Flag | Meaning |
|
|
292
|
+
|---|---|
|
|
293
|
+
| `--ctx <tokens>` | context size to assess |
|
|
294
|
+
| `--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) |
|
|
295
|
+
| `--skus` | also print the Apple silicon SKU matrix (not applicable to the streamed GLM-5.2 artifact) |
|
|
197
296
|
|
|
198
297
|
## Training & model creation
|
|
199
298
|
|
|
200
299
|
Full reference: [training.md](training.md); guided walkthrough:
|
|
201
|
-
[
|
|
300
|
+
[docs/reference/training.md](./training.md).
|
|
202
301
|
|
|
203
302
|
### `train` — LoRA fine-tune
|
|
204
303
|
|
|
205
|
-
SFT / DPO / ORPO on
|
|
206
|
-
|
|
304
|
+
SFT / DPO / ORPO on `<dir>/train.jsonl` (+ optional `valid.jsonl`). Rows are
|
|
305
|
+
`{prompt, chosen, rejected}` for dpo/orpo or `{messages|text}` for sft. Runs
|
|
306
|
+
in the foreground and saves a mountable adapter.
|
|
207
307
|
|
|
208
308
|
```sh
|
|
209
|
-
mlx-bun train e4b --data ./prefs # ORPO (default)
|
|
210
|
-
mlx-bun train e4b --data ./prefs --method sft
|
|
211
|
-
mlx-bun train e4b --data ./prefs --dry-run # inspect
|
|
309
|
+
mlx-bun train e4b --data ./prefs # ORPO (default)
|
|
310
|
+
mlx-bun train e4b --data ./prefs --method sft
|
|
311
|
+
mlx-bun train e4b --data ./prefs --dry-run # inspect data + resolved plan, don't train
|
|
312
|
+
mlx-bun train cpm5 --data ./prefs --iters 400 --save-every 50 --adapter ~/adapters/cpm5-orpo
|
|
313
|
+
nohup mlx-bun train e4b --data ./prefs & # long runs: detach from your shell
|
|
212
314
|
```
|
|
213
315
|
|
|
316
|
+
| Flag | Meaning |
|
|
317
|
+
|---|---|
|
|
318
|
+
| `<model>` / `--query <q>` | model to fine-tune (auto-picks when omitted) |
|
|
319
|
+
| `--data <dir>` | dataset dir (required) |
|
|
320
|
+
| `--method sft\|dpo\|orpo` | objective |
|
|
321
|
+
| `--adapter <dir>` | output adapter dir (default under `~/.cache/mlx-bun/mlx-bun-finetunes/`) |
|
|
322
|
+
| `--iters`, `--lr`, `--rank`, `--scale`, `--seq`, `--batch`, `--grad-accum`, `--grad-clip`, `--seed`, `--val-size` | loop hyperparameters (method-dependent defaults: `mlx-bun help train`) |
|
|
323
|
+
| `--lambda <f>`, `--sft-scope full\|response` | ORPO odds-ratio weight and chosen-NLL scope |
|
|
324
|
+
| `--seg <n>`, `--no-segment` | segmented backward (layers per segment / off) |
|
|
325
|
+
| `--no-flash`, `--no-prefix` | disable the flash-CCE head / prefix-sharing |
|
|
326
|
+
| `--save-every <n>`, `--resume <dir>` | checkpoint cadence / warm-start LoRA weights |
|
|
327
|
+
| `--dry-run` | print the plan, don't train |
|
|
328
|
+
|
|
214
329
|
### `train-watch` — live training dashboard
|
|
215
330
|
|
|
216
|
-
Tails
|
|
331
|
+
Tails `<adapter-dir>/metrics.jsonl` (written by `train` and the web
|
|
332
|
+
fine-tune tile) and renders live loss / speed / memory.
|
|
217
333
|
|
|
218
334
|
```sh
|
|
219
335
|
mlx-bun train-watch ~/.cache/mlx-bun/mlx-bun-finetunes/orpo-e4b
|
|
336
|
+
mlx-bun train-watch --adapter ~/adapters/cpm5-orpo
|
|
220
337
|
```
|
|
221
338
|
|
|
222
339
|
### `fuse` — merge an adapter into the base
|
|
223
340
|
|
|
224
|
-
Folds LoRA deltas into the base weights and writes a standalone snapshot
|
|
225
|
-
|
|
226
|
-
`mlx_lm.fuse`.
|
|
341
|
+
Folds LoRA deltas into the base weights and writes a standalone snapshot
|
|
342
|
+
(weights + config + tokenizer); a quantized base keeps its per-module
|
|
343
|
+
quantization layout. Flag names follow `mlx_lm.fuse`.
|
|
227
344
|
|
|
228
345
|
```sh
|
|
229
346
|
mlx-bun fuse e4b --adapter ./adapters --save-path ./fused_model
|
|
347
|
+
mlx-bun fuse --model ./base-snapshot --adapter-path ./adapters
|
|
230
348
|
mlx-bun serve ./fused_model
|
|
231
349
|
```
|
|
232
350
|
|
|
351
|
+
| Flag | Meaning |
|
|
352
|
+
|---|---|
|
|
353
|
+
| `<model>` / `--model` | base model (query or snapshot path) |
|
|
354
|
+
| `--adapter <dir>` (`--adapter-path` alias) | adapter directory (`adapters.safetensors` + `adapter_config.json`); default `adapters` |
|
|
355
|
+
| `--save-path <dir>` | output directory; default `fused_model` |
|
|
356
|
+
|
|
357
|
+
Refused with an error (mlx_lm.fuse flags not implemented): `--de-quantize`,
|
|
358
|
+
`--dequantize`, `--export-gguf`, `--gguf-path`, `--upload-repo`.
|
|
359
|
+
|
|
233
360
|
### `convert` — quantize a model
|
|
234
361
|
|
|
235
|
-
Quantize an HF model (local path, downloaded model, or repo id
|
|
236
|
-
|
|
237
|
-
|
|
362
|
+
Quantize an HF model (local path, downloaded model, or repo id — an
|
|
363
|
+
un-downloaded repo is fetched first) into a local MLX snapshot: uniform
|
|
364
|
+
affine 4/8-bit, or mixed precision via `--target-bpw` (sensitivity sweep +
|
|
365
|
+
per-layer bit knapsack). Same engine as the web `/api/quantize`.
|
|
238
366
|
|
|
239
367
|
```sh
|
|
240
|
-
mlx-bun convert Qwen/Qwen3-4B -q
|
|
241
|
-
mlx-bun convert Qwen/Qwen3-4B --
|
|
242
|
-
mlx-bun convert
|
|
368
|
+
mlx-bun convert Qwen/Qwen3-4B -q # uniform 4-bit → ./mlx_model
|
|
369
|
+
mlx-bun convert --hf-path Qwen/Qwen3-4B -q --q-bits 8 --mlx-path ./qwen3-8bit
|
|
370
|
+
mlx-bun convert Qwen/Qwen3-4B --target-bpw 4.5 # mixed precision (implies -q)
|
|
371
|
+
mlx-bun convert ./qwen3.5-bf16 -q --rotate-weights # fold the TurboQuant rotation, then quantize
|
|
372
|
+
mlx-bun convert Qwen/Qwen3-4B -q --upload-repo you/qwen3-4b-4bit
|
|
243
373
|
```
|
|
244
374
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
`--
|
|
249
|
-
|
|
375
|
+
| Flag | Meaning |
|
|
376
|
+
|---|---|
|
|
377
|
+
| `--hf-path <src>` (`--model` or the bare positional) | source model |
|
|
378
|
+
| `--mlx-path <dir>` | output directory; must not already exist (mlx_lm.convert behavior) |
|
|
379
|
+
| `-q`, `--quantize`, `--q-bits 4\|8`, `--q-group-size 32\|64` | uniform affine quantization |
|
|
380
|
+
| `--target-bpw <f>`, `--candidate-bits <list>`, `--calibration-mix optiq\|<jsonl>`, `--n-calibration <n>` | mixed precision (writes per-module bits into `config.json`) |
|
|
381
|
+
| `--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` |
|
|
382
|
+
| `--upload-repo <id>` | push the result afterwards (token checked before any work starts) |
|
|
383
|
+
|
|
384
|
+
Refused with an error: `--dtype`, `-d`/`--dequantize`, `--quant-predicate`,
|
|
385
|
+
`--q-mode` other than `affine`, and plain non-quantizing conversion (pass `-q`
|
|
386
|
+
or `--target-bpw`).
|
|
250
387
|
|
|
251
388
|
### `upload` — push to the Hugging Face Hub
|
|
252
389
|
|
|
@@ -255,57 +392,194 @@ git-LFS batch protocol, commits. Flag names match `mlx_lm.upload`.
|
|
|
255
392
|
|
|
256
393
|
```sh
|
|
257
394
|
mlx-bun upload --path ./fused_model --upload-repo you/my-model
|
|
395
|
+
mlx-bun upload --path ./mlx_model --upload-repo you/my-model --private
|
|
258
396
|
```
|
|
259
397
|
|
|
398
|
+
Needs a WRITE token from `~/.mlx-bun/hf.json` (web UI Settings), `$HF_TOKEN`,
|
|
399
|
+
or `~/.cache/huggingface/token` (`hf auth login`); errors before uploading
|
|
400
|
+
anything when none is found. `--private` is an mlx-bun extension.
|
|
401
|
+
|
|
260
402
|
### `perplexity` — evaluate on your data
|
|
261
403
|
|
|
262
|
-
`mlx_lm.perplexity` methodology exactly
|
|
404
|
+
`mlx_lm.perplexity` methodology exactly (seeded sample order, concatenate,
|
|
405
|
+
non-overlapping rows, f32 CE at every position, delta-method standard
|
|
406
|
+
error) over a **local** `.jsonl` (`{"text": …}` rows) or `.txt` file — never
|
|
407
|
+
an HF dataset download.
|
|
263
408
|
|
|
264
409
|
```sh
|
|
265
410
|
mlx-bun perplexity e4b --data-path ./corpus.jsonl
|
|
411
|
+
mlx-bun perplexity ./fused_model --data-path ./corpus.txt --sequence-length 1024 --num-samples -1 --batch-size 4 --seed 7
|
|
266
412
|
```
|
|
267
413
|
|
|
414
|
+
Flags: `<model>` (`--model` / `--query` accepted), `--data-path <file>`
|
|
415
|
+
(required), `--sequence-length <n>`, `--num-samples <n>` (`-1` = all),
|
|
416
|
+
`--batch-size <n>`, `--seed <n>`.
|
|
417
|
+
|
|
268
418
|
## Memory
|
|
269
419
|
|
|
270
|
-
### `memory` — the personal wiki
|
|
420
|
+
### `memory` (alias `setup`) — the personal wiki
|
|
271
421
|
|
|
272
|
-
A local,
|
|
273
|
-
|
|
274
|
-
|
|
422
|
+
A local, git-tracked Markdown wiki at `~/.mlx-bun/wiki` that loads into
|
|
423
|
+
every `mlx-bun pi` / `mlx-bun serve` session. Full guide:
|
|
424
|
+
[memory.md](memory.md). `mlx-bun memory` with no subcommand runs `status`.
|
|
275
425
|
|
|
276
426
|
```sh
|
|
277
|
-
mlx-bun memory init
|
|
278
|
-
mlx-bun memory status
|
|
279
|
-
mlx-bun memory open
|
|
280
|
-
mlx-bun memory
|
|
281
|
-
mlx-bun memory
|
|
282
|
-
mlx-bun memory
|
|
427
|
+
mlx-bun memory init # create the wiki (idempotent); offers import + nightly job
|
|
428
|
+
mlx-bun memory status # path, article count, git + schedule state
|
|
429
|
+
mlx-bun memory open # open the vault in Obsidian (falls back to Finder)
|
|
430
|
+
mlx-bun memory open Archie_Project # open one article
|
|
431
|
+
mlx-bun memory list # article titles + read-only Reference docs
|
|
432
|
+
mlx-bun memory search kv cache # search from the terminal
|
|
433
|
+
mlx-bun memory read Archie_Project # print an article (stem)
|
|
434
|
+
mlx-bun memory toc Archie_Project # headings + anchors
|
|
435
|
+
mlx-bun memory section Archie_Project decisions # one section by anchor
|
|
436
|
+
mlx-bun memory links Archie_Project # outbound + inbound wikilinks
|
|
437
|
+
mlx-bun memory synthesize # conversations → articles, the full local DAG
|
|
438
|
+
mlx-bun memory synthesize --dry-run # plan only, never writes the vault
|
|
439
|
+
mlx-bun memory segment --limit 20 # one stage worker (also: extract, route, synthesize-stage)
|
|
440
|
+
mlx-bun memory extract --convs a1b2,c3d4 # restrict a stage to specific conversations
|
|
441
|
+
mlx-bun memory link --limit 50 # deterministic cross-linking pass (no model)
|
|
442
|
+
mlx-bun memory schedule --at 03:00 # install the nightly launchd job
|
|
443
|
+
mlx-bun memory unschedule # remove it
|
|
283
444
|
```
|
|
284
445
|
|
|
285
|
-
|
|
446
|
+
| Subcommand | Aliases | Meaning |
|
|
447
|
+
|---|---|---|
|
|
448
|
+
| `init` | `setup` | create the wiki; offers to import an existing vault and install the nightly job (TTY prompts; non-interactive shells take the defaults) |
|
|
449
|
+
| `status` | | path, counts, git + schedule state |
|
|
450
|
+
| `open [article]` | `browse` | open the vault or one article |
|
|
451
|
+
| `list` | | article titles + `Reference/` docs |
|
|
452
|
+
| `search <query>` | | ranked article hits with sample lines |
|
|
453
|
+
| `read <article>` | | print an article |
|
|
454
|
+
| `toc <article>` | | headings + anchors |
|
|
455
|
+
| `section <article> <anchor>` | | print one section |
|
|
456
|
+
| `links <article>` | | resolved outbound + inbound wikilinks |
|
|
457
|
+
| `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) |
|
|
458
|
+
| `segment` · `extract` · `route` · `synthesize-stage` | `stage-synthesize` | run one decomposed, resumable stage worker (`--limit <n>` except `route`; `--convs a,b`) |
|
|
459
|
+
| `link` | | inline-link first mentions + rebuild `## See also` (`--limit <n>`; no model) |
|
|
460
|
+
| `schedule` | | install the nightly launchd job (`--at HH:MM`) |
|
|
461
|
+
| `unschedule` | | remove it |
|
|
462
|
+
|
|
463
|
+
An unknown subcommand prints the help and exits non-zero, so launchd jobs
|
|
464
|
+
and scripts can detect typos.
|
|
286
465
|
|
|
287
466
|
## Measurement
|
|
288
467
|
|
|
289
468
|
### `benchmark` (alias `bench`) — measure our stack
|
|
290
469
|
|
|
291
|
-
Runs mlx-bun by itself
|
|
470
|
+
Runs mlx-bun by itself (greedy decode, in-process) and records the median
|
|
471
|
+
to the eval DB.
|
|
292
472
|
|
|
293
473
|
```sh
|
|
294
474
|
mlx-bun bench e4b --tokens 256 --runs 3
|
|
475
|
+
mlx-bun bench --model ./fused_model --prompt-tokens 4096 --kv-quant turbo:k8v3
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
| Flag | Meaning |
|
|
479
|
+
|---|---|
|
|
480
|
+
| `[query]` / `--query` / `--model <path\|query>` | model (auto-picks when omitted) |
|
|
481
|
+
| `--tokens <n>` | tokens decoded per run |
|
|
482
|
+
| `--runs <n>` | runs (median reported) |
|
|
483
|
+
| `--prompt-tokens <n>` | pad the prompt to about n tokens (long-context decode) |
|
|
484
|
+
| `--kv-quant config\|off\|4\|8\|turbo[:k<bits>v<bits>]` | KV scheme for the run |
|
|
485
|
+
| `--compiled-decode`, `--compiled-activations`, `--fused-sdpa` | kill switches; A/B by running twice |
|
|
486
|
+
|
|
487
|
+
For **quotable, cross-stack** numbers use the preflight-gated harness from
|
|
488
|
+
the repo — it spawns the real CLI at its real defaults next to the mlx-lm
|
|
489
|
+
and optiq reference servers and writes a dated report:
|
|
490
|
+
|
|
491
|
+
```sh
|
|
492
|
+
bun scripts/bench-serve.ts all
|
|
493
|
+
bun scripts/bench-serve.ts all --models cpm5,e4b --arms mlx-bun,mlx-lm --out report.md
|
|
494
|
+
bun scripts/bench-serve.ts all --models qwen27b --arms mlx-bun-serial,mlx-bun --logprobs --top-logprobs 3
|
|
495
|
+
# Same KV settings on both executors
|
|
496
|
+
bun scripts/bench-serve.ts all --models qwen27b --arms mlx-bun-serial,mlx-bun --kv-quant 4
|
|
497
|
+
# Same adapter settings on both execution arms:
|
|
498
|
+
bun scripts/bench-serve.ts all --models e4b --arms mlx-bun-serial,mlx-bun --adapter fixtures/adapters/upper
|
|
295
499
|
```
|
|
296
500
|
|
|
297
|
-
|
|
298
|
-
preflight-gates on an idle machine and runs the mlx-lm/optiq comparison legs,
|
|
299
|
-
writing `benchmarks-h2h-<date>.md`.
|
|
501
|
+
Curated results: [benchmarks.md](benchmarks.md).
|
|
300
502
|
|
|
301
503
|
### `evals` — recorded runs
|
|
302
504
|
|
|
303
505
|
```sh
|
|
304
|
-
mlx-bun evals # table: when, model, KV
|
|
506
|
+
mlx-bun evals # table: when, stack, model, bench, KV, prefill, decode, TTFT, peak, commit
|
|
507
|
+
mlx-bun evals --limit 50
|
|
305
508
|
mlx-bun evals --raw # JSON lines for scripts/jq
|
|
509
|
+
mlx-bun evals --clear # archive the DB to a timestamped backup and start fresh
|
|
306
510
|
```
|
|
307
511
|
|
|
308
|
-
##
|
|
309
|
-
|
|
310
|
-
-
|
|
311
|
-
|
|
512
|
+
## mlx-lm compatibility
|
|
513
|
+
|
|
514
|
+
mlx-bun borrows mlx-lm's verb and flag vocabulary so scripts drop in with a
|
|
515
|
+
rename of the executable: `mlx_lm.<verb> …` becomes `mlx-bun <verb> …`.
|
|
516
|
+
There is no `mlx-bun.<verb>` dotted alias (the package installs one binary,
|
|
517
|
+
`mlx-bun`). Surface parity is not architecture parity: a verb run against an
|
|
518
|
+
unsupported architecture errors clearly rather than guessing.
|
|
519
|
+
|
|
520
|
+
### What maps to what
|
|
521
|
+
|
|
522
|
+
| mlx-lm | mlx-bun | Accepted mlx-lm spellings | Not accepted |
|
|
523
|
+
|---|---|---|---|
|
|
524
|
+
| `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 |
|
|
525
|
+
| `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 |
|
|
526
|
+
| `mlx_lm.chat` | `pi` / the web chat | — | no terminal REPL verb; `pi` is the agent, `serve` opens the chat UI |
|
|
527
|
+
| `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** |
|
|
528
|
+
| `mlx_lm.fuse` | `fuse` | `--model`, `--adapter-path`, `--save-path` | `--de-quantize`, `--export-gguf`, `--gguf-path`, `--upload-repo` — **refused** |
|
|
529
|
+
| `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 |
|
|
530
|
+
| `mlx_lm.upload` | `upload` | `--path`, `--upload-repo` (+ `--private`) | — |
|
|
531
|
+
| `mlx_lm.perplexity` | `perplexity` | `--model`, `--sequence-length`, `--num-samples`, `--batch-size`, `--seed`; `--data-path` is a local file | HF dataset ids |
|
|
532
|
+
| `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) |
|
|
533
|
+
| `mlx_lm.manage` | `get` / `scan` / `ls` / `gc` | — | `--scan`/`--delete`/`--pattern` flag forms; `gc` deletes superseded snapshots, not whole repos |
|
|
534
|
+
| `mlx_lm.dynamic_quant` | `convert --target-bpw` | — | the `dynamic_quant` verb name |
|
|
535
|
+
|
|
536
|
+
mlx-optiq's CLI (`optiq convert` / `serve` / `lora` / `benchmark` / `eval` /
|
|
537
|
+
`latency` / `kv-cache` / `lab`) maps onto the same verbs where the concept
|
|
538
|
+
exists: `optiq convert` → `convert --target-bpw`; `optiq serve --kv-config`
|
|
539
|
+
→ `serve --kv-quant config` (the `--l2` preset); `optiq latency` → `fit`;
|
|
540
|
+
`optiq lab` → the web app served by `serve`. `optiq eval` and `optiq
|
|
541
|
+
kv-cache` have no verb (below).
|
|
542
|
+
|
|
543
|
+
### mlx-lm entry points: covered / not covered
|
|
544
|
+
|
|
545
|
+
Against the console scripts the pinned oracle ships
|
|
546
|
+
(`mlx_lm-*.dist-info/entry_points.txt` in the oracle venv). The scoping
|
|
547
|
+
behind each "not covered" row is in
|
|
548
|
+
[docs/reference/cli.md](./cli.md).
|
|
549
|
+
|
|
550
|
+
| Entry point | Status | Where |
|
|
551
|
+
|---|---|---|
|
|
552
|
+
| `mlx_lm.server` | covered | `serve` (incl. `--draft-model` speculative decoding) |
|
|
553
|
+
| `mlx_lm.generate` | covered | `generate` |
|
|
554
|
+
| `mlx_lm.chat` | covered differently | `pi` (agent TUI) + web chat; no plain REPL |
|
|
555
|
+
| `mlx_lm.convert` | covered | `convert` (quantizing paths only) |
|
|
556
|
+
| `mlx_lm.dynamic_quant` | covered | `convert --target-bpw` (sensitivity scan + per-layer bits) |
|
|
557
|
+
| `mlx_lm.lora` | covered (train) | `train`; the `--test` evaluation mode is not covered |
|
|
558
|
+
| `mlx_lm.fuse` | covered | `fuse` (no dequantize / GGUF / upload) |
|
|
559
|
+
| `mlx_lm.upload` | covered | `upload` |
|
|
560
|
+
| `mlx_lm.perplexity` | covered | `perplexity` (local files only) |
|
|
561
|
+
| `mlx_lm.benchmark` | covered | `benchmark` (own flag names; `evals` views the DB) |
|
|
562
|
+
| `mlx_lm.manage` | covered | `get` / `scan` / `ls` / `gc` |
|
|
563
|
+
| `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 |
|
|
564
|
+
| `mlx_lm.evaluate` | not covered | no lm-evaluation-harness backend; `benchmark`/`evals`/`perplexity` are the native measurement, and the `/v1` API accepts external harnesses |
|
|
565
|
+
| `mlx_lm.awq` | not covered | activation-aware weight quantization |
|
|
566
|
+
| `mlx_lm.dwq` | not covered | distilled weight quantization |
|
|
567
|
+
| `mlx_lm.gptq` | not covered | Hessian-conditioned rounding |
|
|
568
|
+
| `mlx_lm.share` | not covered | distributed cache share |
|
|
569
|
+
| `mlx_lm` (umbrella `mlx_lm <verb>`) | covered | `mlx-bun <verb>` is the same shape |
|
|
570
|
+
|
|
571
|
+
Native verbs with no mlx-lm counterpart — `pi`, `harness pi`, `embed`,
|
|
572
|
+
`fit`, `train-watch`, `memory`, `evals` — are the surface that makes mlx-bun
|
|
573
|
+
more than a drop-in.
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
`--kv-quant turbo` composes with grouped lookup, standalone, Gemma assistant,
|
|
577
|
+
DeepSpec and DSpark drafting on supported targets. Sliding layers stay bf16.
|
|
578
|
+
See [batching design](../design/batching.md) for composition evidence and limits.
|
|
579
|
+
|
|
580
|
+
Paged KV retains the configured `--batch` size. Gemma4 bf16 requests use the shared executor and bypass the prompt cache; quantized KV and draft combinations remain unavailable. See [server configuration](server-config.md).
|
|
581
|
+
|
|
582
|
+
`--generation-checkpoint N` requires `--ssd-cache` and queues owned snapshots
|
|
583
|
+
for eligible ordinary requests. Shared continuation supports eligible Qwen, Llama, MiniCPM and Gemma4 requests with or without adapters, excluding media, grammar, fill, paging, logprobs or speculation.
|
|
584
|
+
Repeat the identical request to replay and resume; flush before shutdown for
|
|
585
|
+
eventual queued snapshots to become durable.
|