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.
- package/README.md +71 -578
- package/bin/mlx-bun.mjs +1 -1
- package/docs/README.md +91 -0
- package/docs/{design → archive}/hlg-sampling.md +3 -3
- package/docs/{design → archive/investigations}/audio-input-plan.md +4 -4
- package/docs/{design → archive/investigations}/colibri-glm52-port.md +1 -1
- package/docs/{design → archive/investigations}/diffusion-gemma-port.md +3 -3
- package/docs/{design → archive/investigations}/faithful-l1-consolidation.md +4 -4
- package/docs/{investigations → archive/investigations}/hlg-sampling-investigation.md +1 -1
- package/docs/{design → archive/investigations}/minicpm5-decode-megakernel.md +11 -11
- package/docs/{design → archive/investigations}/optimization_plan.md +1 -1
- package/docs/archive/investigations/pareto-specialized-runtime-findings.md +92 -0
- package/docs/{design → archive/investigations}/pre-colibri-stabilization.md +5 -5
- package/docs/{design → archive/investigations}/the-dreaming-handoff.md +2 -2
- package/docs/{planning → archive/planning}/chat-ui-vision.md +1 -1
- package/docs/{planning → archive/planning}/chunk-task-roadmap.md +1 -1
- package/docs/{planning → archive/planning}/curve-sampler-research-plan.md +4 -4
- package/docs/{planning → archive/planning}/memory-docs-and-dag-plan.md +1 -1
- package/docs/{planning → archive/planning}/release-notes-v0.0.9.md +1 -1
- package/docs/archive/planning/release-notes-v0.2.0.md +49 -0
- package/docs/{planning → archive/planning}/website-readme-pass-plan.md +1 -1
- package/docs/design/batching.md +569 -0
- package/docs/design/decode-speed-program.md +3178 -169
- package/docs/design/dreaming-nightly-pipeline.md +675 -282
- package/docs/design/generic-model-support.md +579 -334
- package/docs/design/kv-cache.md +680 -0
- package/docs/design/orpo-training.md +673 -1239
- package/docs/design/speculative-decoding.md +1627 -0
- package/docs/design/turboquant.md +2102 -0
- package/docs/design/unified-engine-frontier-plan.md +1831 -727
- package/docs/design/web-chat-redesign.md +666 -1083
- package/docs/planning/PRODUCT_ROADMAP.md +34 -1
- package/docs/planning/release-notes-v0.3.0.md +35 -0
- package/docs/planning/video-series.md +421 -0
- package/docs/reference/benchmarks.md +1162 -0
- package/docs/reference/cli.md +395 -149
- package/docs/reference/distribution.md +321 -181
- package/docs/reference/environment.md +348 -0
- package/docs/reference/glossary.md +39 -0
- package/docs/reference/library-api.md +580 -142
- package/docs/reference/memory.md +227 -64
- package/docs/reference/models.md +137 -6
- package/docs/reference/server-api.md +938 -422
- package/docs/reference/server-config.md +652 -320
- package/docs/reference/training.md +393 -254
- package/docs/reference/troubleshooting.md +166 -0
- package/package.json +10 -5
- package/src/admission-plan.ts +18 -0
- package/src/anthropic.ts +92 -3
- package/src/audio/decode.ts +2 -2
- package/src/audio/features.ts +2 -2
- package/src/backends/mlx/autoregressive.ts +108 -0
- package/src/backends/mlx/batch-group.ts +1646 -0
- package/src/backends/mlx/diffusion.ts +39 -0
- package/src/backends/mlx/draft-target.ts +47 -0
- package/src/backends/mlx/evaluation.ts +105 -0
- package/src/backends/mlx/fill-append.ts +45 -0
- package/src/backends/mlx/gateway-binding.ts +71 -0
- package/src/backends/mlx/graph.ts +38 -0
- package/src/backends/mlx/memory-client.ts +189 -0
- package/src/backends/mlx/memory-guard.ts +40 -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.ts +33 -0
- package/src/backends/mlx/request-policy.ts +20 -0
- package/src/backends/mlx/rollback.ts +51 -0
- package/src/backends/mlx/serial-executor.ts +273 -0
- package/src/backends/mlx/speculative.ts +114 -0
- package/src/backends/mlx/state-views.ts +26 -0
- package/src/backends/mlx/text-engine.ts +73 -0
- package/src/cli.ts +189 -61
- package/src/client.ts +66 -0
- package/src/config.ts +21 -4
- package/src/contracts/completion.ts +16 -0
- package/src/contracts/execution.ts +49 -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/resources.ts +18 -0
- package/src/contracts/scheduling.ts +27 -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 +51 -0
- package/src/engine/resources.ts +42 -0
- package/src/engine/scheduler.ts +67 -0
- package/src/engine/session.ts +247 -0
- package/src/eval/README.md +44 -1
- package/src/eval/kl.ts +263 -23
- package/src/eval/reference-logits.ts +207 -0
- package/src/eval/runner.ts +10 -79
- package/src/eval/tasks/bfcl.ts +2 -1
- package/src/eval/tasks/gsm8k.ts +2 -1
- package/src/eval/tasks/hashhop.ts +2 -1
- package/src/eval/tasks/humaneval.ts +5 -4
- package/src/eval/tasks/ifeval.ts +2 -1
- package/src/eval/tasks/mmlu.ts +2 -1
- package/src/expert-io.ts +3 -1
- package/src/expert-offload.ts +3 -1
- 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 +24 -43
- package/src/generate.ts +740 -337
- package/src/grammar.ts +14 -8
- package/src/harness-pi.ts +15 -34
- package/src/hub-rest.ts +4 -4
- package/src/index.ts +27 -0
- package/src/inference/denoising.ts +17 -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 +15 -14
- 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 +199 -0
- package/src/kv-store.ts +459 -234
- 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} +7 -5
- package/src/{model → lab/paged-kv}/paged-kv.ts +9 -6
- package/src/library.ts +40 -0
- package/src/lora.ts +18 -0
- package/src/media-fetch.ts +20 -4
- package/src/memory/article.ts +1 -1
- package/src/memory/chunk.ts +1 -1
- package/src/memory/model.ts +32 -170
- 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 +3 -4
- package/src/mlx/array.ts +9 -10
- package/src/mlx/compile.ts +12 -2
- package/src/mlx/ffi.ts +66 -22
- package/src/mlx/materialize.ts +23 -0
- package/src/mlx/metal-kernel.ts +10 -11
- package/src/mlx/ops.ts +64 -19
- 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/batched-mask.ts +9 -3
- package/src/model/batched-quant.ts +2 -2
- package/src/model/batched-rotating-quant.ts +45 -99
- package/src/model/batched-rotating-state.ts +73 -0
- package/src/model/batched-rotating.ts +57 -106
- package/src/model/batched-row-storage.ts +127 -0
- package/src/model/compiled-decode.ts +4 -3
- package/src/model/diffusion-gemma.ts +8 -8
- package/src/model/factory.ts +87 -49
- package/src/model/fingerprint.ts +1 -1
- package/src/model/flash-attention.ts +3 -3
- package/src/model/gemma4-base.ts +187 -17
- package/src/model/gemma4.ts +6 -6
- package/src/model/generated/gemma4-12b.ts +52 -148
- package/src/model/generated/gemma4-26b.ts +34 -94
- package/src/model/generated/gemma4-e4b.ts +28 -76
- package/src/model/glm52-cache.ts +19 -9
- package/src/model/glm52-dsa.ts +13 -9
- package/src/model/glm52-memory.ts +28 -1
- package/src/model/implementation.ts +69 -0
- package/src/model/minicpm5.ts +7 -8
- package/src/model/profile.ts +443 -0
- package/src/model/qwen-append.ts +12 -0
- package/src/model/qwen-conv.ts +52 -0
- package/src/model/qwen3-delta.ts +98 -2
- package/src/model/qwen3-mrope.ts +252 -0
- package/src/model/qwen3_5-checkpoint.ts +164 -0
- package/src/model/qwen3_5.ts +336 -60
- 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/universal/dense.ts +1 -1
- package/src/model/universal/modules.ts +8 -1
- package/src/native/frame_extract.swift +140 -0
- package/src/native-pack.ts +15 -7
- package/src/pi-provider.ts +6 -64
- package/src/pi-web.ts +14 -320
- package/src/prompt-cache.ts +97 -54
- package/src/quantize/allocator.ts +1 -1
- package/src/quantize/atomic-output.ts +38 -0
- package/src/quantize/calibration.ts +2 -1
- package/src/quantize/config-writer.ts +16 -3
- package/src/quantize/index.ts +28 -1
- package/src/quantize/job.ts +11 -0
- package/src/quantize/quantizer.ts +265 -100
- package/src/quantize/rotate.ts +603 -0
- package/src/quantize/safetensors-writer.ts +79 -1
- package/src/quantize/sensitivity.ts +41 -59
- package/src/quantize/trellis.ts +586 -0
- package/src/quantize/weight-transform.ts +292 -0
- package/src/responses.ts +130 -3
- package/src/runtime-config.ts +81 -0
- package/src/sampler.ts +276 -4
- package/src/serve/admin-routes.ts +184 -0
- package/src/serve/aux-routes.ts +132 -0
- package/src/serve/batch-scheduler.ts +8 -1558
- 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 +354 -0
- package/src/serve/completion-sink.ts +157 -0
- package/src/serve/discovery-routes.ts +204 -0
- package/src/serve/generation-gateway.ts +211 -243
- 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/kv-budget.ts +14 -0
- package/src/serve/lab-routes.ts +341 -0
- package/src/serve/lane-registry.ts +2 -1
- package/src/serve/model-admin-routes.ts +155 -0
- package/src/serve/model-binding.ts +43 -0
- package/src/serve/model-host.ts +512 -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/prompt-response-trace.ts +147 -0
- package/src/serve/request-plan.ts +162 -0
- package/src/serve/request-prep.ts +346 -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 +101 -0
- package/src/serve/text-completion-stage.ts +104 -0
- package/src/serve/token-streams.ts +519 -0
- package/src/server.ts +523 -3551
- package/src/spec/assistant-source.ts +10 -44
- package/src/spec/deepspec-source.ts +6 -6
- package/src/spec/dflash-source.ts +9 -8
- package/src/spec/dspark/ab-stats.ts +3 -3
- package/src/spec/dspark/calibration.ts +2 -2
- package/src/spec/dspark/deepspec-module.ts +2 -2
- 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 +5 -4
- 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-source.ts +9 -1
- package/src/spec/ngram-source.ts +1 -1
- package/src/spec/prefix-state.ts +45 -0
- package/src/spec/qwen-mtp-source.ts +528 -0
- package/src/spec/serve-loop.ts +179 -213
- package/src/spec/source.ts +42 -10
- package/src/spec/two-model.ts +1 -1
- package/src/ssd-cache.ts +95 -24
- package/src/ssd-durability.ts +207 -0
- package/src/tool-call.ts +51 -14
- package/src/train/flash-cce.ts +14 -13
- package/src/train/forward.ts +38 -1
- package/src/train/loss.ts +3 -2
- package/src/train/prefix-shared.ts +5 -1
- package/src/train/segmented.ts +9 -6
- package/src/train/trainer.ts +9 -8
- package/src/vision/preprocess.ts +1 -1
- package/src/vision/prompt.ts +48 -2
- package/src/vision/qwen3vl-preprocess.ts +409 -0
- package/src/vision/qwen3vl-prompt.ts +196 -0
- package/src/vision/qwen3vl-tower.ts +555 -0
- package/src/vision/video-frames.ts +148 -0
- package/src/web/app.html +1 -1
- package/src/web/app.js +15 -6
- package/src/web/src/adapters-panel.ts +3 -3
- package/src/web/src/assistant.ts +2 -36
- package/src/web/src/chat.ts +16 -9
- 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 +134 -33
- 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 -268
- 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-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 -189
- 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 -288
- 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/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/investigations/curve-runs/bisector-route.json +0 -98
- package/docs/investigations/curve-runs/bisector-trace.json +0 -1393
- package/docs/investigations/curve-runs/curve-terrain.json +0 -1179
- package/docs/investigations/curve-runs/curve-terrain.svg +0 -42
- package/docs/investigations/hlg-ab.html +0 -34
- package/docs/investigations/hlg-explorer.html +0 -238
- package/docs/investigations/hlg-figs/cliff.svg +0 -1
- package/docs/investigations/hlg-figs/cross.svg +0 -1
- package/docs/investigations/hlg-figs/edges.svg +0 -1
- package/docs/investigations/hlg-figs/k20-grids.svg +0 -1
- package/docs/investigations/hlg-figs/k20-peaks.svg +0 -1
- package/docs/investigations/hlg-figs/lw-curve.svg +0 -1
- package/docs/investigations/hlg-figs/terrain.svg +0 -1
- package/docs/investigations/hlg-report.html +0 -262
- package/docs/investigations/hlg-runs/hlg-ab.json +0 -149
- package/docs/investigations/hlg-runs/hlg-blind-prompts.md +0 -87
- package/docs/investigations/hlg-runs/hlg-blind.json +0 -107
- package/docs/investigations/hlg-runs/hlg-cliff.json +0 -197
- package/docs/investigations/hlg-runs/hlg-cross.json +0 -505
- package/docs/investigations/hlg-runs/hlg-edge.json +0 -388
- package/docs/investigations/hlg-runs/hlg-eval1.json +0 -25
- package/docs/investigations/hlg-runs/hlg-frontier.json +0 -86
- package/docs/investigations/hlg-runs/hlg-grid.json +0 -242
- package/docs/investigations/hlg-runs/hlg-grid2.json +0 -343
- package/docs/investigations/hlg-runs/hlg-lw-coarse.json +0 -110
- package/docs/investigations/hlg-runs/hlg-map.json +0 -383
- package/docs/investigations/hlg-runs/run0-original.log +0 -159
- package/docs/investigations/hlg-runs/runA-recommended.log +0 -131
- package/docs/investigations/hlg-runs/runAA-cliff-cpm5.log +0 -26
- package/docs/investigations/hlg-runs/runAB-grid2-e4b.log +0 -18
- package/docs/investigations/hlg-runs/runAC-peak-e4b-partial.log +0 -25
- package/docs/investigations/hlg-runs/runAD-ab-samples.log +0 -8
- package/docs/investigations/hlg-runs/runAE-edge-e4b.log +0 -51
- package/docs/investigations/hlg-runs/runAF-logit-calibration.log +0 -10
- package/docs/investigations/hlg-runs/runAG-eval-config2.log +0 -16
- package/docs/investigations/hlg-runs/runB-gain-variants.log +0 -192
- package/docs/investigations/hlg-runs/runC-pivots.log +0 -162
- package/docs/investigations/hlg-runs/runD-oetf.log +0 -132
- package/docs/investigations/hlg-runs/runE-eotf.log +0 -162
- package/docs/investigations/hlg-runs/runF-shaper-working.log +0 -86
- package/docs/investigations/hlg-runs/runG-shaper-sweep.log +0 -101
- package/docs/investigations/hlg-runs/runH-wsweep.log +0 -176
- package/docs/investigations/hlg-runs/runI-asweep.log +0 -176
- package/docs/investigations/hlg-runs/runJ-knobmap.log +0 -49
- package/docs/investigations/hlg-runs/runK-frontier.log +0 -19
- package/docs/investigations/hlg-runs/runL-widemap.log +0 -65
- package/docs/investigations/hlg-runs/runM-frontier-emb.log +0 -15
- package/docs/investigations/hlg-runs/runN-verify.log +0 -116
- package/docs/investigations/hlg-runs/runO-frontier-seed5000.log +0 -15
- package/docs/investigations/hlg-runs/runP-grid-AxSm.log +0 -15
- package/docs/investigations/hlg-runs/runQ-grid-tgW.log +0 -15
- package/docs/investigations/hlg-runs/runR-blind-transcript.log +0 -79
- package/docs/investigations/hlg-runs/runS-cross-coherence.log +0 -33
- package/docs/investigations/hlg-runs/runT-cross-cpm5.log +0 -33
- package/docs/investigations/hlg-runs/runU-cross-12b.log +0 -33
- package/docs/investigations/hlg-runs/runV-lw-e4b.log +0 -22
- package/docs/investigations/hlg-runs/runW-lw-12b.log +0 -22
- package/docs/investigations/hlg-runs/runX-lw-cpm5.log +0 -22
- package/docs/investigations/hlg-runs/runY-cliff-e4b.log +0 -26
- package/docs/investigations/hlg-runs/runZ-cliff-12b.log +0 -26
- package/docs/planning/IDEAS.md +0 -69
- package/docs/reference/embedding.md +0 -197
- package/docs/reference/features-matrix.md +0 -100
- package/docs/reference/orpo-quickstart.md +0 -135
- package/src/flags.ts +0 -13
- /package/docs/{investigations → archive/investigations}/chunk-finetune-experiment.md +0 -0
- /package/docs/{investigations → archive/investigations}/colibri-oracle-pin.md +0 -0
- /package/docs/{investigations → archive/investigations}/curve-bisector-routing.md +0 -0
- /package/docs/{investigations → archive/investigations}/decode-roofline-lookagain.md +0 -0
- /package/docs/{investigations → archive/investigations}/dspark-handoff.md +0 -0
- /package/docs/{investigations → archive/investigations}/expert-offload-single-user-moe.md +0 -0
- /package/docs/{investigations → archive/investigations}/indexshare-performance-spike.md +0 -0
- /package/docs/{investigations → archive/investigations}/kernel-perf-review-2026-07.md +0 -0
- /package/docs/{investigations → archive/investigations}/lab-build-journal.md +0 -0
- /package/docs/{investigations → archive/investigations}/openwiki-evaluation.md +0 -0
- /package/docs/{investigations → archive/investigations}/orpo-base-uf-experiment-and-directions.md +0 -0
- /package/docs/{investigations → archive/investigations}/orpo-flash-cce-pin-leak.md +0 -0
- /package/docs/{investigations → archive/investigations}/orpo-uf-testing-handoff.md +0 -0
- /package/docs/{investigations → archive/investigations}/pi-builtin-investigation.md +0 -0
- /package/docs/{investigations → archive/investigations}/segmented-backward-handoff.md +0 -0
- /package/docs/{investigations → archive/investigations}/starter-model-port-handoff.md +0 -0
- /package/docs/{investigations → archive/investigations}/steel-flash-cce-handoff.md +0 -0
- /package/docs/{investigations → archive/investigations}/trainer-validation-experiment.md +0 -0
- /package/docs/{planning → archive/planning}/chat-ui-vision-memory-first.md +0 -0
- /package/docs/{planning → archive/planning}/journal.md +0 -0
- /package/docs/{planning → archive/planning}/pi-integration-review.md +0 -0
- /package/docs/{planning → archive/planning}/release-notes-v0.0.10.md +0 -0
- /package/docs/{planning → archive/planning}/release-notes-v0.0.11.md +0 -0
- /package/docs/{planning → archive/planning}/release-notes-v0.0.12.md +0 -0
- /package/docs/{planning → archive/planning}/release-notes-v0.0.13.md +0 -0
- /package/docs/{planning → archive/planning}/web-ui-pass-plan.md +0 -0
- /package/{docs/investigations → src/serve/assets}/curve-terrain.html +0 -0
- /package/{docs/dag → src/serve/assets}/training-inference-map.html +0 -0
package/bin/mlx-bun.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// (a guard inside cli.ts would never run under Node — its static imports
|
|
5
5
|
// hoist and fail on the bun: scheme first).
|
|
6
6
|
|
|
7
|
-
const MIN_BUN = "1.
|
|
7
|
+
const MIN_BUN = "1.4.0"; // fixed macOS arm64 FFI stack layout (see README)
|
|
8
8
|
|
|
9
9
|
if (typeof Bun === "undefined") {
|
|
10
10
|
console.error(
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# docs/ map (generated — do not edit; `bun scripts/check-hygiene.ts --write-docs-map`)
|
|
2
|
+
|
|
3
|
+
## docs/archive/
|
|
4
|
+
|
|
5
|
+
Frozen history — read-only, never extended in place; recover raw data via git history.
|
|
6
|
+
|
|
7
|
+
- [hlg-sampling.md](../docs/archive/hlg-sampling.md) — HLG sampling — a piecewise tone curve on the logits
|
|
8
|
+
- [investigations/audio-input-plan.md](../docs/archive/investigations/audio-input-plan.md) — Audio input — design & implementation plan (gemma-4 audio tower)
|
|
9
|
+
- [investigations/chunk-finetune-experiment.md](../docs/archive/investigations/chunk-finetune-experiment.md) — Fine-tuning experiment: chunking task (2026-06-16)
|
|
10
|
+
- [investigations/colibri-glm52-port.md](../docs/archive/investigations/colibri-glm52-port.md) — GLM-5.2 on a 32 GB Mac — native MLX port of the Colibri hierarchy
|
|
11
|
+
- [investigations/colibri-oracle-pin.md](../docs/archive/investigations/colibri-oracle-pin.md) — Colibri oracle pin for the native GLM-5.2 port
|
|
12
|
+
- [investigations/curve-bisector-routing.md](../docs/archive/investigations/curve-bisector-routing.md) — Curve sampler: bisectors, routing, and the falsification
|
|
13
|
+
- [investigations/decode-roofline-lookagain.md](../docs/archive/investigations/decode-roofline-lookagain.md) — Decode perf "look again" — adversarial re-exam of the M=1 floor claim (2026-07-01)
|
|
14
|
+
- [investigations/diffusion-gemma-port.md](../docs/archive/investigations/diffusion-gemma-port.md) — DiffusionGemma port — plan & parity strategy
|
|
15
|
+
- [investigations/dspark-handoff.md](../docs/archive/investigations/dspark-handoff.md) — DSpark — handoff
|
|
16
|
+
- [investigations/expert-offload-single-user-moe.md](../docs/archive/investigations/expert-offload-single-user-moe.md) — Expert offload for single-user local MoE — findings + design sketch
|
|
17
|
+
- [investigations/faithful-l1-consolidation.md](../docs/archive/investigations/faithful-l1-consolidation.md) — Faithful → L1: consolidating the "match mlx-lm" path
|
|
18
|
+
- [investigations/hlg-sampling-investigation.md](../docs/archive/investigations/hlg-sampling-investigation.md) — Investigation: HLG sampling — a piecewise tone curve on the logits
|
|
19
|
+
- [investigations/indexshare-performance-spike.md](../docs/archive/investigations/indexshare-performance-spike.md) — IndexShare / IndexCache performance spike
|
|
20
|
+
- [investigations/kernel-perf-review-2026-07.md](../docs/archive/investigations/kernel-perf-review-2026-07.md) — Kernel/perf deep review — 2026-07-01 (condensed, tracked record)
|
|
21
|
+
- [investigations/lab-build-journal.md](../docs/archive/investigations/lab-build-journal.md) — Build journal — mlx-bun Lab (web UI + native quantize/train/dataset + pi web chat)
|
|
22
|
+
- [investigations/minicpm5-decode-megakernel.md](../docs/archive/investigations/minicpm5-decode-megakernel.md) — MiniCPM5 Decode Megakernel — end-to-end build plan (handoff)
|
|
23
|
+
- [investigations/openwiki-evaluation.md](../docs/archive/investigations/openwiki-evaluation.md) — OpenWiki — evaluation & fit analysis
|
|
24
|
+
- [investigations/optimization_plan.md](../docs/archive/investigations/optimization_plan.md) — mlx-bun: gemma4.ts decompose & optimize — action plan
|
|
25
|
+
- [investigations/orpo-base-uf-experiment-and-directions.md](../docs/archive/investigations/orpo-base-uf-experiment-and-directions.md) — ORPO from-base on UltraFeedback (mixed-5bpw) — results + research directions
|
|
26
|
+
- [investigations/orpo-flash-cce-pin-leak.md](../docs/archive/investigations/orpo-flash-cce-pin-leak.md) — flash-CCE host-buffer pin leak — post-mortem + L3 verification approach
|
|
27
|
+
- [investigations/orpo-uf-testing-handoff.md](../docs/archive/investigations/orpo-uf-testing-handoff.md) — ORPO-on-UF — results + testing-phase handoff
|
|
28
|
+
- [investigations/pareto-specialized-runtime-findings.md](../docs/archive/investigations/pareto-specialized-runtime-findings.md) — Pareto-specialized runtime findings
|
|
29
|
+
- [investigations/pi-builtin-investigation.md](../docs/archive/investigations/pi-builtin-investigation.md) — Investigation: pi as a "built-in" terminal for mlx-bun
|
|
30
|
+
- [investigations/pre-colibri-stabilization.md](../docs/archive/investigations/pre-colibri-stabilization.md) — Pre-Colibri stabilization program
|
|
31
|
+
- [investigations/segmented-backward-handoff.md](../docs/archive/investigations/segmented-backward-handoff.md) — Handoff — segmented backward training (2026-06-16)
|
|
32
|
+
- [investigations/starter-model-port-handoff.md](../docs/archive/investigations/starter-model-port-handoff.md) — Handoff: the sub-GB starter model port (publishing gate 1)
|
|
33
|
+
- [investigations/steel-flash-cce-handoff.md](../docs/archive/investigations/steel-flash-cce-handoff.md) — Steel flash-CCE — handoff
|
|
34
|
+
- [investigations/the-dreaming-handoff.md](../docs/archive/investigations/the-dreaming-handoff.md) — THE DREAMING — HANDOFF (2026-06-28)
|
|
35
|
+
- [investigations/trainer-validation-experiment.md](../docs/archive/investigations/trainer-validation-experiment.md) — Trainer validation experiment
|
|
36
|
+
- [planning/chat-ui-vision-memory-first.md](../docs/archive/planning/chat-ui-vision-memory-first.md) — Chat UI Vision: The Model That Knows You
|
|
37
|
+
- [planning/chat-ui-vision.md](../docs/archive/planning/chat-ui-vision.md) — The mlx-bun chat surface: a vision
|
|
38
|
+
- [planning/chunk-task-roadmap.md](../docs/archive/planning/chunk-task-roadmap.md) — Chunk-task quality roadmap (2026-06-17)
|
|
39
|
+
- [planning/curve-sampler-research-plan.md](../docs/archive/planning/curve-sampler-research-plan.md) — Curve sampler — preregistered research plan (distinctness track)
|
|
40
|
+
- [planning/journal.md](../docs/archive/planning/journal.md) — Engineering Journal
|
|
41
|
+
- [planning/memory-docs-and-dag-plan.md](../docs/archive/planning/memory-docs-and-dag-plan.md) — Memory docs organization + DAG-view refresh — review & plan
|
|
42
|
+
- [planning/pi-integration-review.md](../docs/archive/planning/pi-integration-review.md) — pi integration review — internal embeds + `harness pi` (2026-07-01)
|
|
43
|
+
- [planning/release-notes-v0.0.10.md](../docs/archive/planning/release-notes-v0.0.10.md) — mlx-bun v0.0.10 — batching parity, SSD KV cache, sharper serving
|
|
44
|
+
- [planning/release-notes-v0.0.11.md](../docs/archive/planning/release-notes-v0.0.11.md) — v0.0.11 release notes
|
|
45
|
+
- [planning/release-notes-v0.0.12.md](../docs/archive/planning/release-notes-v0.0.12.md) — v0.0.12 release notes
|
|
46
|
+
- [planning/release-notes-v0.0.13.md](../docs/archive/planning/release-notes-v0.0.13.md) — v0.0.13 release notes
|
|
47
|
+
- [planning/release-notes-v0.0.9.md](../docs/archive/planning/release-notes-v0.0.9.md) — v0.0.9 release notes (DRAFT — Josh edits + publishes)
|
|
48
|
+
- [planning/release-notes-v0.2.0.md](../docs/archive/planning/release-notes-v0.2.0.md) — mlx-bun v0.2.0
|
|
49
|
+
- [planning/web-ui-pass-plan.md](../docs/archive/planning/web-ui-pass-plan.md) — Web UI pass — ranked fix list (2026-07-01 audit)
|
|
50
|
+
- [planning/website-readme-pass-plan.md](../docs/archive/planning/website-readme-pass-plan.md) — Website + README pass — audit findings and fix plan (2026-07-01)
|
|
51
|
+
|
|
52
|
+
## docs/design/
|
|
53
|
+
|
|
54
|
+
Active engineering design docs — one per topic; status lives in front matter + PLAN.md.
|
|
55
|
+
|
|
56
|
+
- [batching.md](../docs/design/batching.md) — Batching — continuous scheduling for `--batch N`
|
|
57
|
+
- [decode-speed-program.md](../docs/design/decode-speed-program.md) — Inference performance program
|
|
58
|
+
- [dreaming-nightly-pipeline.md](../docs/design/dreaming-nightly-pipeline.md) — The Dreaming — memory write path + synthesis (canonical design)
|
|
59
|
+
- [generic-model-support.md](../docs/design/generic-model-support.md) — Model support — run anything mlx-lm runs, and the ports we target
|
|
60
|
+
- [kv-cache.md](../docs/design/kv-cache.md) — KV cache — residency and layout
|
|
61
|
+
- [orpo-training.md](../docs/design/orpo-training.md) — Training — design (ORPO, flash-CCE head, prefix sharing, segmented backward)
|
|
62
|
+
- [speculative-decoding.md](../docs/design/speculative-decoding.md) — Speculative decoding — one verifier, every draft source
|
|
63
|
+
- [turboquant.md](../docs/design/turboquant.md) — TurboQuant — rotation-based quantization (KV leg landed, weights leg open)
|
|
64
|
+
- [unified-engine-frontier-plan.md](../docs/design/unified-engine-frontier-plan.md) — Engine architecture — four layers, per-scheme oracles, one request path
|
|
65
|
+
- [web-chat-redesign.md](../docs/design/web-chat-redesign.md) — Web chat — the built-in chat surface (canonical design)
|
|
66
|
+
|
|
67
|
+
## docs/planning/
|
|
68
|
+
|
|
69
|
+
Living product/vision docs (USING side).
|
|
70
|
+
|
|
71
|
+
- [PRODUCT_ROADMAP.md](../docs/planning/PRODUCT_ROADMAP.md) — PRODUCT ROADMAP
|
|
72
|
+
- [ResearchTopics.md](../docs/planning/ResearchTopics.md) — Research Topics
|
|
73
|
+
- [release-notes-v0.3.0.md](../docs/planning/release-notes-v0.3.0.md) — mlx-bun v0.3.0
|
|
74
|
+
- [video-series.md](../docs/planning/video-series.md) — mlx-bun video series
|
|
75
|
+
|
|
76
|
+
## docs/reference/
|
|
77
|
+
|
|
78
|
+
User-facing reference — the ONLY home for flags, routes, models, numbers, and environment facts.
|
|
79
|
+
|
|
80
|
+
- [benchmarks.md](../docs/reference/benchmarks.md) — mlx-bun benchmark results (curated)
|
|
81
|
+
- [cli.md](../docs/reference/cli.md) — CLI reference
|
|
82
|
+
- [distribution.md](../docs/reference/distribution.md) — Distributing mlx-bun — build, sign, notarize, publish
|
|
83
|
+
- [environment.md](../docs/reference/environment.md) — Reference environment and platform facts
|
|
84
|
+
- [glossary.md](../docs/reference/glossary.md) — mlx-bun serving
|
|
85
|
+
- [library-api.md](../docs/reference/library-api.md) — Library API
|
|
86
|
+
- [memory.md](../docs/reference/memory.md) — Memory — the personal wiki
|
|
87
|
+
- [models.md](../docs/reference/models.md) — Models: supported roster + management (get / scan / ls / gc)
|
|
88
|
+
- [server-api.md](../docs/reference/server-api.md) — Server API
|
|
89
|
+
- [server-config.md](../docs/reference/server-config.md) — Server configuration
|
|
90
|
+
- [training.md](../docs/reference/training.md) — Training / fine-tuning reference
|
|
91
|
+
- [troubleshooting.md](../docs/reference/troubleshooting.md) — Troubleshooting
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# HLG sampling — a piecewise tone curve on the logits
|
|
2
2
|
|
|
3
|
-
Status: **implemented, found neutral, superseded by Curve Designer** — `applyHlg` shipped in `src/sampler.ts`; investigation found HLG a wash vs plain temperature; the Curve Designer (`src/curve-sampler.ts`) is its v2 replacement. See [docs/investigations/hlg-sampling-investigation.md](
|
|
3
|
+
Status: **implemented, found neutral, superseded by Curve Designer** — `applyHlg` shipped in `src/sampler.ts`; investigation found HLG a wash vs plain temperature; the Curve Designer (`src/curve-sampler.ts`) is its v2 replacement. See [docs/archive/investigations/hlg-sampling-investigation.md](investigations/hlg-sampling-investigation.md) for findings. This doc remains as the design rationale.
|
|
4
4
|
Owner: sampling layer (`src/sampler.ts`)
|
|
5
5
|
Default: **off** (`--hlg-sampling off` = today's temperature sampler, untouched)
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ Default: **off** (`--hlg-sampling off` = today's temperature sampler, untouched)
|
|
|
12
12
|
|
|
13
13
|
## Outcome / Retrospective
|
|
14
14
|
|
|
15
|
-
HLG was implemented through **Piece 2** (pure curve + neutrality tests + serial wiring, `applyHlg` live in `src/sampler.ts`). Evaluation found it **neutral vs plain temperature** — no measurable gain in diversity or quality at matched output entropy. As a result, HLG is **superseded by the Curve Designer** (`src/curve-sampler.ts`), which generalizes the same region-shaping idea with an editable control-point interface and cleaner UX. Full empirical findings are in [docs/investigations/hlg-sampling-investigation.md](
|
|
15
|
+
HLG was implemented through **Piece 2** (pure curve + neutrality tests + serial wiring, `applyHlg` live in `src/sampler.ts`). Evaluation found it **neutral vs plain temperature** — no measurable gain in diversity or quality at matched output entropy. As a result, HLG is **superseded by the Curve Designer** (`src/curve-sampler.ts`), which generalizes the same region-shaping idea with an editable control-point interface and cleaner UX. Full empirical findings are in [docs/archive/investigations/hlg-sampling-investigation.md](investigations/hlg-sampling-investigation.md).
|
|
16
16
|
|
|
17
17
|
The sections below (Goal through Correctness) remain as design rationale. Pieces 3–6 of Phasing and the Open Questions were never executed; see the [Phasing](#phasing-the-piece-n-increments) and [Open Questions](#open-questions--risks) sections for historical context.
|
|
18
18
|
|
|
@@ -347,4 +347,4 @@ for it. That a transfer function is standard practice in another domain says
|
|
|
347
347
|
nothing about whether it helps token sampling — that is decided only by
|
|
348
348
|
measurement (the KL characterization, the capability guardrail, and the
|
|
349
349
|
diversity lens in [Correctness](#correctness--evaluation)). The full empirical
|
|
350
|
-
write-up is in [docs/investigations/hlg-sampling-investigation.md](
|
|
350
|
+
write-up is in [docs/archive/investigations/hlg-sampling-investigation.md](investigations/hlg-sampling-investigation.md).
|
|
@@ -210,7 +210,7 @@ All under `optiq/vlm/_mlxvlm/models/gemma4/` in the oracle venv:
|
|
|
210
210
|
### 3.4 Parity strategy (tree doctrine)
|
|
211
211
|
|
|
212
212
|
Oracle = optiq internal gemma4 model in the pinned venv, driven by
|
|
213
|
-
`
|
|
213
|
+
`regen-audio-goldens.py (deleted; git history)` (modeled on their calibration loader;
|
|
214
214
|
remember `enable_thinking` pinning for any templated prompt). Tiers follow
|
|
215
215
|
the e4b vision precedent exactly:
|
|
216
216
|
|
|
@@ -238,7 +238,7 @@ Expectation (to be *measured*, not asserted): the tower is tiny —
|
|
|
238
238
|
≤750 mel frames → ~≤188 post-subsample positions × 12 layers × hidden
|
|
239
239
|
1024 bf16 — so added TTFT should be dominated by CPU feature extraction
|
|
240
240
|
plus one extra graph eval; sidecar RSS delta is the 752 bf16 tensors.
|
|
241
|
-
Every number that gets quoted comes from preflight-gated `
|
|
241
|
+
Every number that gets quoted comes from preflight-gated `scripts/bench-serve.ts all`
|
|
242
242
|
cells (tower ms, TTFT delta vs text-only, peak RSS delta) and lands in
|
|
243
243
|
`benchmarks/RESULTS.md`.
|
|
244
244
|
|
|
@@ -247,7 +247,7 @@ cells (tower ms, TTFT delta vs text-only, peak RSS delta) and lands in
|
|
|
247
247
|
**Phase A0 — groundwork**
|
|
248
248
|
- [ ] Bind `mlx_conv2d` (full header signature; CPU/GPU sanity test vs
|
|
249
249
|
oracle conv output)
|
|
250
|
-
- [ ] `
|
|
250
|
+
- [ ] `regen-audio-goldens.py (deleted; git history)` + fixtures; dump mel golden,
|
|
251
251
|
tower-output golden, spliced ids, greedy ids
|
|
252
252
|
- [ ] Resolve open questions §3.3 (write the answers into this doc)
|
|
253
253
|
- Exit: goldens on disk; masking/zeroing semantics documented.
|
|
@@ -332,7 +332,7 @@ cells (tower ms, TTFT delta vs text-only, peak RSS delta) and lands in
|
|
|
332
332
|
docs-map hygiene green. ✅ 2026-07-07
|
|
333
333
|
|
|
334
334
|
**Phase A5 — bench + coverage**
|
|
335
|
-
- [ ]
|
|
335
|
+
- [ ] scripts/bench-serve.ts all cells → RESULTS.md (tower ms, TTFT delta, RSS delta)
|
|
336
336
|
- [ ] 12B audio cell: rebuild its sidecar via optiq `build_vision_sidecar`
|
|
337
337
|
(selective download), own goldens — per-model doctrine, every
|
|
338
338
|
(model, quant) cell gets its own validation or an explicit deferral
|
|
@@ -692,7 +692,7 @@ batch.
|
|
|
692
692
|
|
|
693
693
|
G0 inventory note (2026-07-21): the exact pin, artifact/layout contract, and
|
|
694
694
|
manual checklist are recorded in
|
|
695
|
-
[`../investigations/colibri-oracle-pin.md`](../investigations/colibri-oracle-pin.md).
|
|
695
|
+
[`../archive/investigations/colibri-oracle-pin.md`](../archive/investigations/colibri-oracle-pin.md).
|
|
696
696
|
Because the pinned Makefile writes ignored build artifacts and even creates a
|
|
697
697
|
configuration stamp while parsing, model-free oracle targets must run from a
|
|
698
698
|
temporary `git archive` extraction, not in the read-only checkout. The pinned
|
|
@@ -120,7 +120,7 @@ tied 4-bit head → fp32 softcap** — is **BIT-EXACT vs the optiq golden**: arg
|
|
|
120
120
|
maxDiff 0.0, relRMSE 0.0, meanKL 0.0 (`tests/diffusion-parity.test.ts`,
|
|
121
121
|
`MLX_BUN_TEST_DIFFUSION=1`). Per-stage sub-gates (enc_hidden / dec_hidden / presoftcap /
|
|
122
122
|
per-layer / layer-0 attn·dense·MoE) all 0.0 (`scripts/experiments/diffusion-{stage,layer,l0}-diag.ts`,
|
|
123
|
-
golden dumps in `scripts/gen-diffusion-golden.py`).
|
|
123
|
+
golden dumps in `scripts/oracle/gen-diffusion-golden.py`).
|
|
124
124
|
- **The one bug found + fixed (per-model parity gotcha):** the Router pre-projection
|
|
125
125
|
norm must be the literal two-step `rms_norm(x, None, eps) * scale * hidden**-0.5`,
|
|
126
126
|
**NOT** the gemma4-style fold `rms_norm(x, scale*hidden**-0.5)`. The fold changes the
|
|
@@ -152,7 +152,7 @@ reuse, linear temp schedule, the un-mask loop, BOTH samplers (confidence-thresho
|
|
|
152
152
|
OptiQ public default, entropy-bound = engine default), self-conditioning feedback,
|
|
153
153
|
stability/EOS, canvas block loop. **Token-for-token parity vs the optiq engine at
|
|
154
154
|
temp 0 on a fixed seed for BOTH samplers** (`tests/diffusion-gen-parity.test.ts`,
|
|
155
|
-
`MLX_BUN_TEST_DIFFUSION=1`; golden `scripts/gen-diffusion-gen-golden.py`):
|
|
155
|
+
`MLX_BUN_TEST_DIFFUSION=1`; golden `scripts/oracle/gen-diffusion-gen-golden.py`):
|
|
156
156
|
confidence 17 tok / 7 steps, entropy 15 tok / 48 steps — both `.tokens`/`.steps`/
|
|
157
157
|
`.finishReason` identical.
|
|
158
158
|
- **RNG parity (the crux) SOLVED:** bound `mlx_random_randint` (+`mlx_random_seed`,
|
|
@@ -241,7 +241,7 @@ output matches optiq `generate`; HTTP test green; no regression to AR models.
|
|
|
241
241
|
|
|
242
242
|
### D4 — Performance (L3, optional, measured) `[ ]`
|
|
243
243
|
`confidence-threshold` is already the fast path (optiq: ~58 tok/s code / ~9
|
|
244
|
-
prose). Measure mlx-bun tok/s with `
|
|
244
|
+
prose). Measure mlx-bun tok/s with `scripts/bench-serve.ts all`; fuse kernels only if a number
|
|
245
245
|
says so. KV holds only the prompt (no per-step growth → no KV-quant needed).
|
|
246
246
|
**Exit:** quotable tok/s within range of optiq on this machine; any fused kernel
|
|
247
247
|
gated by KL + the 6-task quality suite (no bit-exact ancestor for novel fusions).
|
|
@@ -275,13 +275,13 @@ kernels, selected (or not) by the individual flags.
|
|
|
275
275
|
### Phase 4 — Docs + benchmark ✅ LANDED 2026-07-04 (numbers Josh-gated)
|
|
276
276
|
|
|
277
277
|
Docs updated: `features-matrix.md` (new `--compiled-activations` + `--fused-gelu`
|
|
278
|
-
rows), `server-config.md` + `cli.md` (Phase 2). Reworked `scripts/bench-faithful-matrix
|
|
279
|
-
+ `
|
|
278
|
+
rows), `server-config.md` + `cli.md` (Phase 2). Reworked `scripts/bench-levers.ts faithful-matrix`
|
|
279
|
+
+ `scripts/bench-serve.ts all` comparison 0 for the new model — since faithful is now the default,
|
|
280
280
|
the matrix measures what **removing** each faithful kernel costs and what the L3
|
|
281
281
|
custom kernels add on top (`− compiled-decode`, `− compiled activations`,
|
|
282
282
|
`+ custom fused-gelu`), all vs mlx-lm; tsc 0. **The actual numbers are Josh-gated**
|
|
283
|
-
(clean/rebooted machine —
|
|
284
|
-
`bun scripts/bench-faithful-matrix
|
|
283
|
+
(clean/rebooted machine — `bun scripts/bench-serve.ts all --redo`, or
|
|
284
|
+
`bun scripts/bench-levers.ts faithful-matrix`); loaded-machine absolutes are noise. Promote
|
|
285
285
|
quotable rows to `benchmarks/RESULTS.md` after the clean run.
|
|
286
286
|
|
|
287
287
|
## Status: consolidation complete
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*2026-06-14. Question: can the structure of a piecewise nonlinear transfer
|
|
4
4
|
function (HLG, the HDR transfer function) be transplanted onto a logit
|
|
5
5
|
distribution as a sampling method, and if so, where do you place its pivot
|
|
6
|
-
(middle grey)? Design contract: [docs/
|
|
6
|
+
(middle grey)? Design contract: [docs/archive/hlg-sampling.md](../design/hlg-sampling.md).
|
|
7
7
|
Code: `src/sampler.ts` (`applyHlg`, `makeSampler`). Harness:
|
|
8
8
|
`scripts/hlg-compare.ts`. Model under test: `gemma-4-e4b-it-OptiQ-4bit` on the
|
|
9
9
|
M4 Pro.*
|
|
@@ -108,7 +108,7 @@ a 1-token parity probe before trusting it (Phase 2 gate catches mismatch).
|
|
|
108
108
|
**Validation goldens (ALREADY EXIST, no regen needed):**
|
|
109
109
|
- L1: `goldens/minicpm5-parity.json` (prompt_ids `[0,608,4894,304,6918,357]`,
|
|
110
110
|
greedy_ids[100], vocab 130560) + `goldens/minicpm5-logits-step{0..99}.bin`
|
|
111
|
-
(f32 last-position logits). Produced by `scripts/regen
|
|
111
|
+
(f32 last-position logits). Produced by `scripts/regen.ts minicpm5`.
|
|
112
112
|
- L2: `goldens/minicpm5-kv-parity.json` + `…-kv-logits-step*.bin`.
|
|
113
113
|
|
|
114
114
|
**Reference forward to copy (the source of truth for correctness):**
|
|
@@ -132,7 +132,7 @@ All default-OFF, `bun test tests/minicpm5-*.test.ts` green. From this session:
|
|
|
132
132
|
@ M=8–256, ~1 ULP correct.** This is a working prototype of one megakernel STAGE
|
|
133
133
|
and the dequant/GEMV patterns to copy. (Note: it currently corrupts when CHAINED
|
|
134
134
|
in the lazy graph — that's the whole reason for the megakernel; the kernel math
|
|
135
|
-
itself is correct, proven by `
|
|
135
|
+
itself is correct, proven by `fused-mlp-check.ts (deleted; git history)`.)
|
|
136
136
|
- `src/model/steel-linear-kernel.ts` — `steelLinear`: plain quantized linear as our
|
|
137
137
|
dispatch (q/k/v/o/down), ~1 ULP vs `ops.quantizedMatmul`. The projection GEMV
|
|
138
138
|
pattern.
|
|
@@ -232,7 +232,7 @@ megapack-check.ts`.) This catches layout bugs before any kernel.
|
|
|
232
232
|
|
|
233
233
|
### Phase 2 — Single-threadgroup correct megakernel (G=1)
|
|
234
234
|
**Files:** `src/model/megakernel-kernel.ts` (the `MetalKernel` + dispatch),
|
|
235
|
-
`
|
|
235
|
+
`gen-minicpm5-megakernel.ts (deleted; git history)` (emits the per-layer-bits-baked SOURCE into
|
|
236
236
|
`src/model/generated/minicpm5-megakernel.ts`).
|
|
237
237
|
**Design:** ONE threadgroup (`G=1`, `TGN=256` threads). `hidden[H]` in threadgroup
|
|
238
238
|
memory (6 KB). Loop layers; each stage uses `threadgroup_barrier`. GEMVs: the 256
|
|
@@ -246,13 +246,13 @@ down). KV read/write from `KBUF`/`VBUF`. Final: finalNorm + lmHead GEMV → logi
|
|
|
246
246
|
**Transcribe** `src/model/minicpm5.ts` op-for-op; match dtypes: accumulate in f32,
|
|
247
247
|
round to bf16 at each op boundary to track the reference (`(T)` casts, as `fusedMlp`
|
|
248
248
|
does). RoPE: match `ops.rope` exactly (verify with a single-layer probe).
|
|
249
|
-
**Gate (THE correctness gate):** `
|
|
249
|
+
**Gate (THE correctness gate):** `megakernel-teacherforced.ts (deleted 2026-08-23; git history)`
|
|
250
250
|
(copy `swiglu-teacherforced.ts`): drive 100 decode steps via the megakernel,
|
|
251
251
|
teacher-forced on `goldens/minicpm5-parity.json`, KV cache in `KBUF`/`VBUF`. Require
|
|
252
252
|
**≥98/100 argmax agreement, deterministic across 3 runs, no NaN.** If an early step
|
|
253
253
|
mismatches, bisect by stage: add a debug output for `hidden` after layer L (env
|
|
254
254
|
`MLX_BUN_MEGA_DUMP_LAYER=L`) and compare to the reference model's per-layer hidden
|
|
255
|
-
(capture via the wrapper trick in `
|
|
255
|
+
(capture via the wrapper trick in `swiglu-layerN.ts (deleted; git history)`).
|
|
256
256
|
|
|
257
257
|
### Phase 3 — Persistent multi-threadgroup (G>1) for SPEED
|
|
258
258
|
**Do:** generalize Phase 2 to `G` threadgroups. Move `hidden`,`xn`,`hn`,`q/k/v/attn/
|
|
@@ -332,7 +332,7 @@ Swap `KBUF/VBUF` for the per-layer quantized-KV format. **Facts gathered:**
|
|
|
332
332
|
q = min(round((w-bias)/scale), n_bins) // dequant: scale*q+bias
|
|
333
333
|
```
|
|
334
334
|
**Implementation steps:**
|
|
335
|
-
1. ✅ **DONE — quantize formula validated** (`
|
|
335
|
+
1. ✅ **DONE — quantize formula validated** (`kv-quant-formula-check.ts (deleted 2026-08-23; git history)`):
|
|
336
336
|
the affine_quantize transcription matches `ops.quantize` to bf16 ULP (scale/bias diff
|
|
337
337
|
1.8e-3 @4-bit, 6e-5 @8-bit; dequant residual = expected bf16-storage rounding). The
|
|
338
338
|
riskiest piece is de-risked. Compute scale/bias in f32, store bf16 (as mlx does).
|
|
@@ -411,7 +411,7 @@ Guard: bf16 KV (L1) only, no adapters, no vision. Add `--megakernel` CLI flag.
|
|
|
411
411
|
of the old `tests/perf-kernel-oracle.test.ts` — deleted 2026-07-05 with its kernel,
|
|
412
412
|
unified-engine-frontier-plan.md §6; the envelope-gate methodology stands on its
|
|
413
413
|
own); paired decode tok/s A/B logged. Update
|
|
414
|
-
`STATUS.md` + `benchmarks/RESULTS.md` (preflight-gated `
|
|
414
|
+
`STATUS.md` + `benchmarks/RESULTS.md` (preflight-gated `scripts/bench-serve.ts all` for the
|
|
415
415
|
quotable number — `[[dirty-machine-numbers-are-garbage]]`).
|
|
416
416
|
|
|
417
417
|
---
|
|
@@ -462,12 +462,12 @@ so its 1-ULP/op drift is within contract — bit-exact is a focused REBUILD, not
|
|
|
462
462
|
|
|
463
463
|
```
|
|
464
464
|
src/model/megakernel-pack.ts # Phase 1: weight repack + layout table
|
|
465
|
-
|
|
465
|
+
gen-minicpm5-megakernel.ts (deleted; git history) # Phase 2: emit per-layer-baked kernel SOURCE
|
|
466
466
|
src/model/generated/minicpm5-megakernel.ts # (generated) the kernel SOURCE + bits
|
|
467
467
|
src/model/megakernel-kernel.ts # Phase 2/3: MetalKernel + decodeMegakernel()
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
468
|
+
megapack-check.ts (deleted 2026-08-23; git history) # Phase 1 gate
|
|
469
|
+
megakernel-teacherforced.ts (deleted 2026-08-23; git history) # Phase 2/3 correctness gate
|
|
470
|
+
megakernel-perf.ts (deleted 2026-08-23; git history) # Phase 3/5 paired tok/s A/B
|
|
471
471
|
tests/minicpm5-megakernel.test.ts # Phase 5 CI gate (env-gated)
|
|
472
472
|
```
|
|
473
473
|
Modify: `src/model/minicpm5.ts` (add `decodeStep` megakernel branch),
|
|
@@ -39,7 +39,7 @@ chasing host overhead that compile already removed.
|
|
|
39
39
|
|
|
40
40
|
**Steps:**
|
|
41
41
|
|
|
42
|
-
1. **Characterize before touching anything.** Run `
|
|
42
|
+
1. **Characterize before touching anything.** Run `decode-split.ts (deleted; git history)`
|
|
43
43
|
(the per-step wall-time splitter that already exists) on all three models at
|
|
44
44
|
@600 and @8k. Record GPU-blocked time vs JS-graph-build time per step. This
|
|
45
45
|
is the control measurement; everything in Phase A is judged against it. The
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Pareto-specialized runtime findings
|
|
2
|
+
|
|
3
|
+
## Question
|
|
4
|
+
|
|
5
|
+
Which parts of mlx-bun should converge on shared infrastructure, and which parts should remain deliberately specialized so cleanup does not turn the runtime into a lowest-common-denominator model host?
|
|
6
|
+
|
|
7
|
+
This note compares three mature specialization clusters: the Colibri/GLM-5.2 runtime, the Qwen3.8 27B TurboQuant and MTP work, and ORPO training. The evidence says the same thing in all three places: share lifecycle and composition policy, but keep artifact layout and numerical work close to the model or method that owns them.
|
|
8
|
+
|
|
9
|
+
## Shared control-plane infrastructure
|
|
10
|
+
|
|
11
|
+
The shared layer decides what runs, owns resources, and records what happened. It does not rewrite the selected computation.
|
|
12
|
+
|
|
13
|
+
- **Model construction.** `openModel()` recognizes the direct Colibri artifact before ordinary safetensors loading. `createModel()` prefers dedicated and fingerprint-generated model classes before the universal fallback, and explicitly says the generic path must not shadow a dedicated port. This is shared dispatch with specialized implementations, not one universal graph. [Factory dispatch](../../../src/model/factory.ts#L30-L150)
|
|
14
|
+
- **Concurrency and request composition.** The target is one concurrency-driven engine. One active request uses the B=1 pipelined or compiled fast path; concurrent requests use the general step up to `--batch N`. B=1 is an internal specialization, not a permanent public lane. Features are stackable layers, and scheduling must not replace the selected KV scheme, adapter, draft method, grammar, or sampler. [Unified engine decision](../../design/unified-engine-frontier-plan.md#L333-L403) [Composition matrix](../../design/unified-engine-frontier-plan.md#L405-L424)
|
|
15
|
+
- **Cache lifecycle and capability.** `Cache` owns update, masks, state, rollback, accounting, and disposal. `BatchableCache` adds row merge, extraction, filtering, and byte projection. The scheduler can depend on those capabilities without knowing whether a row contains ordinary KV, recurrent state, TurboQuant tensors, or compressed GLM state. [Cache interface](../../../src/model/gemma4-base.ts#L264-L303) [Batchable cache interface](../../../src/model/gemma4-base.ts#L347-L357)
|
|
16
|
+
- **Resolved KV policy.** `KvScheme` preserves bf16, uniform affine, per-layer affine, and TurboQuant as distinct immutable schemes. It centralizes names, accounting, and current batch capability checks without pretending the schemes have identical storage or kernels. [KV scheme](../../../src/kv-scheme.ts#L84-L169)
|
|
17
|
+
- **Draft lifecycle.** `DraftProvider` owns server-lifetime machinery and opens a request-scoped `DraftSource`. The source interface carries prompt mode, target taps, draft, commit, rollback-related cache state, and disposal. Assistant, DSpark, Qwen MTP, and native GLM MTP can share speculative orchestration while retaining different state transitions. [Draft source](../../../src/spec/source.ts#L31-L101) [Draft provider](../../../src/spec/source.ts#L103-L118)
|
|
18
|
+
- **Expert residency policy.** The budget equation, stable expert union, lease state, backend contract, telemetry, and pressure correction are reusable. GLM supplies artifact geometry and byte segments to that policy. [Residency planning and union](../../../src/expert-residency.ts#L17-L155) [Residency backend](../../../src/expert-residency.ts#L157-L170)
|
|
19
|
+
- **Offline transform orchestration.** `WeightTransform` separates name/config planning from lazy tensor application. Llama, the Qwen3.5 trunk, and Qwen MTP are real adapters over the same conversion seam. [Weight transform interface](../../../src/quantize/weight-transform.ts#L40-L51) [Qwen transform adapters](../../../src/quantize/weight-transform.ts#L244-L268)
|
|
20
|
+
- **Training orchestration.** `TrainConfig` names independent techniques such as segmented backward, fused or flash CCE, prefix sharing, regularization, and ORPO semantics. `orpoLoop()` composes the selected techniques and chooses the model-specific backward implementation. [Training configuration](../../../src/train/trainer.ts#L42-L150) [ORPO composition](../../../src/train/trainer.ts#L821-L948)
|
|
21
|
+
|
|
22
|
+
## Deliberately specialized data-plane code
|
|
23
|
+
|
|
24
|
+
### Colibri and GLM-5.2
|
|
25
|
+
|
|
26
|
+
GLM-5.2 is not a descriptor-table variation of a dense transformer. Its graph has MLA, DSA, shared plus routed MoE, native MTP, and compressed cache state. Its public artifact also has a dedicated container and streamed expert layout. The design therefore calls for a dedicated `Glm52Model`, direct artifact support, and a one-read routed-expert kernel rather than repacking into generic projection-major tensors. [Dedicated graph and artifact contract](../../design/colibri-glm52-port.md#L323-L357)
|
|
27
|
+
|
|
28
|
+
The memory contract is also model and artifact specific. A header-only preflight reads the container, derives expert slot layouts, counts DSA and MTP state, and refuses startup when the exact resident weights, expert slabs, compressed KV, verification transients, allocator reserve, Bun reserve, and safety margin exceed the process limit. [GLM geometry and preflight](../../../src/model/glm52-memory.ts#L340-L500) The runtime then maps Colibri segments into generic residency leases, but retains GLM-specific slot layouts, MTP slabs, signed-int8 requirements, and routed-SwiGLU executors. [GLM residency binding](../../../src/model/glm52-residency.ts#L138-L230) [GLM executor construction](../../../src/model/glm52-residency.ts#L300-L459)
|
|
29
|
+
|
|
30
|
+
That split is intentional. Bun owns residency policy and observability; the native helper owns aligned slabs, `pread`, wiring, and completion fences; the GLM model owns tensor semantics and kernels. [Ownership map](../../design/colibri-glm52-port.md#L580-L600)
|
|
31
|
+
|
|
32
|
+
### Qwen3.8 27B, TurboQuant, and MTP
|
|
33
|
+
|
|
34
|
+
Qwen3.5/3.8 keeps a dedicated graph because gated DeltaNet recurrence, full attention, MRoPE, output gates, and recurrent speculative rollback are numerical behavior, not configuration decoration. [Qwen graph](../../../src/model/qwen3_5.ts#L128-L322) [Qwen model interface](../../../src/model/qwen3_5.ts#L512-L673)
|
|
35
|
+
|
|
36
|
+
Qwen MTP preserves its own artifact and state machine behind `DraftProvider` and `DraftSource`. The provider rejects a non-Qwen target or a hidden-size mismatch. The request source uses tapped pre-final-norm target state, maintains its own KV, samples through the target sampler, and rebuilds accepted rows from verified target hiddens. Those rules must not move into generic speculative orchestration. [Qwen MTP provider](../../../src/spec/qwen-mtp-source.ts#L193-L235) [Qwen MTP state machine](../../../src/spec/qwen-mtp-source.ts#L237-L430)
|
|
37
|
+
|
|
38
|
+
TurboQuant KV demonstrates the right form of specialization. `TurboQuantKVCache` implements the shared `Cache` lifecycle, while keeping packed indices, scales, zero points, FWHT-domain values, supported head dimensions, and conversion rules inside the class. [TurboQuant cache](../../../src/model/gemma4-base.ts#L1539-L1800) The weight pipeline follows the same rule. `WeightTransform` is shared, but the Qwen corridor map preserves the output gate, recurrent internals, vision-to-residual seam, untied 27B head, and companion MTP basis. [Qwen transform seam](../../design/turboquant-weights.md#L80-L87) [Qwen corridor map](../../design/turboquant-weights.md#L125-L174)
|
|
39
|
+
|
|
40
|
+
### ORPO training
|
|
41
|
+
|
|
42
|
+
ORPO benefits from composition, not one generic backward. The trainer combines prefix sharing, segmented recomputation, fused or flash CCE, LoRA regularization, and objective semantics. The data plane remains specialized where the model topology demands it. Gemma4 segmented ORPO threads per-layer inputs and cross-segment donor KV cotangents; MiniCPM5 uses a simpler segment graph. [Composed ORPO paths](../../design/orpo-training.md#L178-L218) [Gemma4 segmented backward](../../../src/train/segmented.ts#L1137-L1471)
|
|
43
|
+
|
|
44
|
+
Flash CCE is a shared quantized-head interface with specialized Metal kernels and explicit shape guards. Its implementation selects Steel, simdgroup, or scalar kernels from actual hidden, vocabulary, group, and tile geometry, and exposes exact-gradient escape hatches. Flattening this into a generic matrix-loss helper would lose the memory and watchdog constraints that justify it. [Flash CCE head](../../../src/train/flash-cce.ts#L42-L64) [Forward dispatch](../../../src/train/flash-cce.ts#L1033-L1132) [Backward dispatch](../../../src/train/flash-cce.ts#L1134-L1234)
|
|
45
|
+
|
|
46
|
+
Dynamic lambda is not implemented. Its design belongs in the ORPO control plane: validation metrics update a live lambda source in `orpoLoop()`, while every monolithic and segmented loss reads the same value. It should not create another family of backward classes. [Dynamic-lambda status and signals](../../design/orpo-dynamic-lambda.md#L1-L27) [Proposed wiring](../../design/orpo-dynamic-lambda.md#L163-L180)
|
|
47
|
+
|
|
48
|
+
## Interfaces that already preserve specialization
|
|
49
|
+
|
|
50
|
+
| Interface | Shared invariant | Specialization retained behind it |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `RuntimeModel` plus factory dispatch | Construction and serving can hold one model type | Dedicated GLM, Qwen, Gemma, diffusion, MoE, and generated graphs |
|
|
53
|
+
| `Cache` / `BatchableCache` | Lifecycle, rollback, row operations, byte projection | Plain, rotating, quantized, TurboQuant, SSM, MLA, and DSA storage |
|
|
54
|
+
| `KvScheme` | One resolved KV choice and stable identity | Per-scheme accounting, conversion, persistence, and kernels |
|
|
55
|
+
| `DraftProvider` / `DraftSource` | Request lifecycle, target taps, draft and commit | Assistant, DSpark, Qwen MTP, and GLM MTP state machines |
|
|
56
|
+
| `ExpertResidencyBackend` | Lease and I/O lifecycle | Colibri container offsets, slot packing, expert kernels, and prediction policy inputs |
|
|
57
|
+
| `WeightTransform` | Plan first, apply lazily, record identity | Family-specific exact fold corridors and companion artifacts |
|
|
58
|
+
| ORPO trainer configuration | One run composes selected techniques | Model-specific masks, donor topology, VJPs, and Metal kernels |
|
|
59
|
+
|
|
60
|
+
## Declared profile seam (S2, 2026-08-21)
|
|
61
|
+
|
|
62
|
+
Model construction now resolves one `ResolvedModelProfile` before opening
|
|
63
|
+
weights. An exact artifact declaration binds an immutable external fingerprint,
|
|
64
|
+
config fingerprint, fidelity contract, required engine capabilities, and a
|
|
65
|
+
loader/graph/loop composition. Exact Qwen3.8 OptiQ and GLM-5.2 Colibri revisions
|
|
66
|
+
are pinned; other supported artifacts retain dedicated family resolution and
|
|
67
|
+
then the universal dense fallback.
|
|
68
|
+
|
|
69
|
+
The factory consumes the resolved composition, and the serving context retains
|
|
70
|
+
it for library callers. A matched exact declaration with a config or capability
|
|
71
|
+
mismatch refuses rather than taking another route. The profile seam does not
|
|
72
|
+
own request methods: MTP, KV schemes, adapters, grammar, and sampling remain
|
|
73
|
+
independently resolved inputs to completion execution. This keeps the control
|
|
74
|
+
plane declarative without turning a model profile into a feature preset.
|
|
75
|
+
|
|
76
|
+
These interfaces preserve specialization because they describe lifecycle or capability, not tensor algebra. They also have multiple real implementations. That is the useful test for whether an abstraction belongs.
|
|
77
|
+
|
|
78
|
+
## Rules for steady-state cleanup
|
|
79
|
+
|
|
80
|
+
1. **Unify control, not math.** Centralize admission, concurrency, cancellation, ownership, accounting, persistence, telemetry, and technique composition. Keep tensor layout, recurrence, cache encoding, model topology, and kernel selection with their owning model, artifact, or method.
|
|
81
|
+
2. **Keep one concurrency-driven engine.** B=1 and B>1 are internal step specializations in one engine. `--batch N` is a concurrency cap. Observed placement may be reported, but serial versus batch must not become a permanent public mode or feature-selection interface. Current feature-specific serial routing is capability debt.
|
|
82
|
+
3. **Never weaken a resolved composition to fit a path.** If batching lacks TurboQuant, MTP, adapters, grammar, or another selected method, close that capability gap or reject the unsupported composition. Do not silently substitute bf16 KV, disable drafting, or change sampling.
|
|
83
|
+
4. **Prefer capability interfaces over family checks.** Scheduling should ask caches whether they can merge or project bytes and draft sources what target state they require. Factory dispatch is the proper place for model identity checks.
|
|
84
|
+
5. **Let dedicated ports outrank generic fallbacks.** The universal model path is valuable for ordinary architectures. It must not absorb GLM MLA/DSA, Qwen recurrence, artifact-specific MTP, or another optimized graph merely to reduce class count.
|
|
85
|
+
6. **Treat artifacts as executable contracts.** Validate manifests, tensor families, layouts, quantization metadata, companion seeds, and memory equations before allocation. Keep artifact-specific loaders and transforms when repacking would add copies, lose reproducibility, or change arithmetic.
|
|
86
|
+
7. **Generalize only after the invariant is visible in two implementations.** Extract lifecycle and capability seams such as `DraftSource` or `WeightTransform`. Do not extract a common tensor algorithm from code that only looks similar but has different masks, state, accumulation order, or oracle.
|
|
87
|
+
8. **Compose optimizations at the orchestrator, then test the cross-product.** ORPO proves that prefix sharing, flash CCE, segmented backward, and regularization can stack while model-specific backward code remains intact. Serving needs the same discipline for model graph, KV scheme, MTP, adapters, grammar, sampling, and concurrency.
|
|
88
|
+
9. **Bind every specialized path to its own oracle and measured purpose.** A specialized module earns its place through parity, memory, quality, or throughput gates on the artifact and hardware it targets. If the benefit disappears, delete the specialization instead of preserving it as architecture folklore.
|
|
89
|
+
|
|
90
|
+
## Strongest conclusion
|
|
91
|
+
|
|
92
|
+
The steady state is not a generic engine with scattered exceptions. It is a shared control plane that carries authoritative compositions through one concurrency-driven engine, plus specialized data planes selected by model, artifact, and numerical method. That structure preserves the project's Pareto advantage: common serving and training behavior where sameness is real, and unapologetically specific code where the result depends on it.
|
|
@@ -96,7 +96,7 @@ change that state.
|
|
|
96
96
|
| LEAK-03 | P2 | fixed | `src/mlx/{autograd,checkpoint,custom-vjp}.ts` constructors | Failure out-parameter slots are initialized with live handles that may not be freed when native constructor calls fail. | Failure-injection tests for all three constructors prove slots, closures, and callbacks return to baseline with no double free. |
|
|
97
97
|
| HYG-01 | P2 | fixed | `src/train/job.ts`, empty Gemma block | A config read and stale comment claim load-bearing environment setup, but the branch is empty. | Remove the read/block/comment; job parsing and training setup tests stay green. |
|
|
98
98
|
| HYG-02 | P2 | fixed | `tsconfig.json` exclusions | Shipped web sources and tests that run in the gate are excluded from the zero-error typecheck contract. | Remove the exclusions or replace them with an explicit checked project reference; repository and web typechecks are green with no hidden files. |
|
|
99
|
-
| HYG-03 | P2 | fixed | `scripts/test.sh` test glob | `
|
|
99
|
+
| HYG-03 | P2 | fixed | `scripts/test.sh` test glob | `tests/bench-serving-load.test.ts` is model-free but outside the gate. | Gate enumerates and runs it exactly once; a sentinel/failing-case check proves it cannot silently fall out again. |
|
|
100
100
|
| SEC-01 | P0 | fixed | `src/web-tools.ts`, `web_fetch` | Model-selected URLs bypass the existing public-destination policy, follow redirects automatically, and buffer the full body. This permits SSRF into loopback/private services and unbounded response buffering. | Reuse one shared fetch-policy implementation: reject private literals and DNS resolutions, revalidate every redirect, combine caller abort with timeout, and stream to a byte cap. Tests cover loopback, private DNS, public-to-private redirect, redirect limit, chunked over-cap, and normal public text. |
|
|
101
101
|
| SEC-02 | P1 | fixed | `src/download.ts`, `blobId` | An unvalidated blob ID reaches `join()` and symlink creation, unlike the adjacent validated digest. It requires a hostile HF-compatible endpoint. | Reject any non-lowercase-40-hex SHA-1 blob ID before path construction; traversal and malformed-ID tests fail closed. |
|
|
102
102
|
| DEPLOY-01 | D | deferred | `src/server.ts`, WebSocket upgrade | No WebSocket Origin enforcement. | Deferred while bind is loopback-only. Reopen before any supported non-loopback bind, tunnel, reverse proxy, or browser origin; then add an allowlist and cross-origin rejection tests. |
|
|
@@ -127,7 +127,7 @@ change that state.
|
|
|
127
127
|
transform constructors return slots, closures, and callbacks to zero under
|
|
128
128
|
repeated failure injection. The root typecheck now includes DOM/web sources
|
|
129
129
|
and the formerly excluded web tests. `scripts/test.sh` enumerates
|
|
130
|
-
`
|
|
130
|
+
`tests/bench-serving-load.test.ts` exactly once and rejects gate drift.
|
|
131
131
|
- `bunx tsc --noEmit`, `bun scripts/check-hygiene.ts`, `bash -n
|
|
132
132
|
scripts/test.sh`, and `git diff --check` are green after Wave 3. The full
|
|
133
133
|
post-Wave-3 repository gate and both performance measurements remain open.
|
|
@@ -140,7 +140,7 @@ change that state.
|
|
|
140
140
|
Standard PEFT `use_rslora` now mounts and saves at exactly
|
|
141
141
|
`alpha / sqrt(rank)`. Custom-VJP also frees the first callback if allocation
|
|
142
142
|
of the second callback throws.
|
|
143
|
-
- **PERF-01:** `
|
|
143
|
+
- **PERF-01:** `bench-stream-decoder.ts (deleted 2026-08-23; git history)` measured the original
|
|
144
144
|
full-history decoder against the bounded exact-suffix implementation with
|
|
145
145
|
five paired repetitions. MiniCPM5 medians were 142.62 → 27.40 ms at 512
|
|
146
146
|
tokens (5.20×), 576.01 → 56.45 ms at 1,024 (10.20×), and 2,284.57 →
|
|
@@ -148,7 +148,7 @@ change that state.
|
|
|
148
148
|
113.62–116.06 ms). Every per-push chunk and final byte stream matched at
|
|
149
149
|
64–2,048 tokens; the e4b 1,024-token check was 88.62 → 10.25 ms. Raw,
|
|
150
150
|
gitignored artifacts are under `reports/perf-01-stream-decoder-*.json`.
|
|
151
|
-
- **PERF-02:** `
|
|
151
|
+
- **PERF-02:** `bench-logprobs-readback.ts (deleted 2026-08-23; git history)` confirmed the reported
|
|
152
152
|
barrier on a clean M1 Max 32 GB with Bun 1.3.14 and
|
|
153
153
|
Qwen2.5-0.5B-Instruct-4bit (256 tokens, two warmups, five measured rounds).
|
|
154
154
|
At clean base `00e597e`, off/logprobs/top-5 medians were
|
|
@@ -302,7 +302,7 @@ after any overlapping merge.
|
|
|
302
302
|
| Adapters/training | `tests/{lora,train-*,ifeval}.test.ts`; delayed writes, PEFT + mlx-lm layouts, unequal padding, optimizer LR scales, frozen scorer corpus |
|
|
303
303
|
| Grammar/Responses store | `tests/{grammar,grammar-jump,responses,server}.test.ts`; degrade forms, top-logprob alignment, fake-clock reordered LRU |
|
|
304
304
|
| MLX/resource ownership | focused diffusion/weights/autograd/checkpoint/custom-VJP failure loops with handle/allocation baselines |
|
|
305
|
-
| Repository gate | `bun scripts/check-hygiene.ts`, `bunx tsc --noEmit`, `bash scripts/test.sh`; prove `
|
|
305
|
+
| Repository gate | `bun scripts/check-hygiene.ts`, `bunx tsc --noEmit`, `bash scripts/test.sh`; prove `tests/bench-serving-load.test.ts` is included |
|
|
306
306
|
| Performance | deterministic raw artifact, paired A/B, exact output parity, quiet-machine preflight before any curated claim |
|
|
307
307
|
|
|
308
308
|
## 8. Exit gate
|
|
@@ -21,7 +21,7 @@ cross-linked, self-healing personal wiki. It **works end-to-end on real data.**
|
|
|
21
21
|
```
|
|
22
22
|
# resumable driver; continues from cursor 720. Writes to ~/.mlx-bun/wiki-full (NOT the
|
|
23
23
|
# real vault ~/.mlx-bun/wiki). ~25 min / 20-conv batch, ~50h total, SERIAL.
|
|
24
|
-
bun scripts/
|
|
24
|
+
bun scripts/memory/dreaming-full-run.ts # resume (clean-slate guarded by an init flag)
|
|
25
25
|
# state files: ~/.mlx-bun/full-run-cursor.txt, ~/.mlx-bun/full-run-initialized, ~/.mlx-bun/full-run.log
|
|
26
26
|
# after the import finishes: reindex, then connect the graph:
|
|
27
27
|
mlx-bun memory link
|
|
@@ -78,7 +78,7 @@ RECONCILE (infobox-ground-truth consistency) → LINK (cross-link) → WIKIFY (e
|
|
|
78
78
|
to the latest value; KEEPS the trajectory in a `## History` section **only for the
|
|
79
79
|
USER's evolving positions** — an AI *factual error* is silently overwritten (no
|
|
80
80
|
history). Date-aware; `reconcile.ts` is the consistency authority (infobox = ground
|
|
81
|
-
truth). Proven via a timestamp-swap demo (`scripts/
|
|
81
|
+
truth). Proven via a timestamp-swap demo (`scripts/memory/dreaming-selfheal-demo.ts`).
|
|
82
82
|
6. **Parroting (recurred 5×).** The small model copies ANY concrete example value from
|
|
83
83
|
prompts/Meta pages into unrelated articles (phantom S5IIX, "Anamorphic Video", etc.).
|
|
84
84
|
**ALL prompts + Meta pages must be SCHEMATIC** (no real names/specs/dates). Purged;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The mlx-bun chat surface: a vision
|
|
2
2
|
|
|
3
|
-
*Draft vision, product/design lead pass — 2026-07-06. Bold stance: reimagine the chat surface from scratch. Companion to the market research and current-state audit that produced it; see `docs/planning/web-ui-pass-plan.md` for the tactical bug list and `docs/design/adapters-end-to-end.md` / `docs/design/memory-system.md` for the backend contracts this vision assumes.*
|
|
3
|
+
*Draft vision, product/design lead pass — 2026-07-06. Bold stance: reimagine the chat surface from scratch. Companion to the market research and current-state audit that produced it; see `docs/archive/planning/web-ui-pass-plan.md` for the tactical bug list and `docs/design/adapters-end-to-end.md` / `docs/design/memory-system.md` for the backend contracts this vision assumes.*
|
|
4
4
|
|
|
5
5
|
## The feeling
|
|
6
6
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Where the MiniCPM5 chunking adapter stands and what raises real segmentation
|
|
4
4
|
quality. Companion to the chunk-eval metric vs. accuracy finding (score = well-formedness, not gold accuracy) and
|
|
5
|
-
[`docs/investigations/chunk-finetune-experiment.md`](../investigations/chunk-finetune-experiment.md).
|
|
5
|
+
[`docs/archive/investigations/chunk-finetune-experiment.md`](../investigations/chunk-finetune-experiment.md).
|
|
6
6
|
|
|
7
7
|
## Where we are
|
|
8
8
|
|
|
@@ -250,8 +250,8 @@ diversity; the audit below as methods material).
|
|
|
250
250
|
|
|
251
251
|
## 6. Why the old data is not trusted — audit of the prior experiments
|
|
252
252
|
|
|
253
|
-
Committed artifacts checked: `docs/investigations/curve-runs/*.json`,
|
|
254
|
-
`docs/investigations/hlg-runs/*`, harness sources. Severity: **INVALIDATES** /
|
|
253
|
+
Committed artifacts checked: `docs/archive/investigations/curve-runs/*.json`,
|
|
254
|
+
`docs/archive/investigations/hlg-runs/*`, harness sources. Severity: **INVALIDATES** /
|
|
255
255
|
**WEAKENS** / cosmetic.
|
|
256
256
|
|
|
257
257
|
- **F1 — INVALIDATES (the old distinctness claim).** The curve-temp family
|
|
@@ -327,5 +327,5 @@ Committed artifacts checked: `docs/investigations/curve-runs/*.json`,
|
|
|
327
327
|
- Witness probe: `scripts/experiments/curve-distinctness.ts`.
|
|
328
328
|
- Assessment: `reports/curve-designer-paper-assessment-2026-07-01.md`.
|
|
329
329
|
- Prior investigations (superseded on the points in §6):
|
|
330
|
-
`docs/investigations/hlg-sampling-investigation.md`,
|
|
331
|
-
`docs/investigations/curve-bisector-routing.md`.
|
|
330
|
+
`docs/archive/investigations/hlg-sampling-investigation.md`,
|
|
331
|
+
`docs/archive/investigations/curve-bisector-routing.md`.
|
|
@@ -21,7 +21,7 @@ are treated as the direction of record and untouched.
|
|
|
21
21
|
| `docs/design/bucketing-stage.md` | Classify-stage design (2026-06-26) | **No banner.** Core content (embeddings as candidate-narrower) is dead under "no embeddings anywhere"; the binary-question ladder survives inside the nightly BUCKET stage | **Needs a SUPERSEDED banner** (same shape as memory-synthesis's): dead = embedding narrower + silhouette; survives = capacity-by-decomposition, one-binary-question-at-a-time. |
|
|
22
22
|
| `docs/design/write-pipeline-entity.md` | Entity-keyed routing design (2026-06-26); itself "supersedes bucket-centric routing" | **No banner.** Half-dead: pure entity ROUTE (no bucket layer) is replaced by BUCKET→RESOLVE; the personal-notability checklist is dead. Survives: articles-are-THINGS, name/alias/category lookup, no-embeddings routing | **Needs a PARTIALLY SUPERSEDED banner** mapping survives/dead — otherwise its own "supersedes bucketing" claim inverts the actual chain for a newcomer. |
|
|
23
23
|
| `docs/design/memory-system.md` | M0 substrate design (vault, read tools, CLI, scheduling, consent) | **Status header is FALSE**: "synthesize is currently a safe no-op stub", "stage modules throw if called" — the pipeline is built and has produced 677+ articles. Directly contradicts `docs/reference/memory.md`. The four-adapter table + "Next implementation steps" describe the abandoned M1 sketch | **Fix the header + scope it down.** Retitle scope to "M0 substrate: vault + read path (landed)"; delete or banner the "Synthesis pipeline design (M1/M2)" and "Next implementation steps" sections, pointing at dreaming-nightly-pipeline. The substrate half (storage layout, tools, skill, scheduling, consent) is still the best writeup of the read side — keep it. |
|
|
24
|
-
| `docs/design/memory-inference-path.md` | Inference-path rework: design + measured verification | Accurate, self-bannered (BUILT + VERIFIED; batching measured a loss). It's really an investigation record | Fine as-is. Optional (low priority): move to `docs/investigations/` where measured-experiment records live. |
|
|
24
|
+
| `docs/design/memory-inference-path.md` | Inference-path rework: design + measured verification | Accurate, self-bannered (BUILT + VERIFIED; batching measured a loss). It's really an investigation record | Fine as-is. Optional (low priority): move to `docs/archive/investigations/` where measured-experiment records live. |
|
|
25
25
|
| `docs/reference/memory.md` | User-facing reference | Mostly current (synthesize description matches as-built stages; status truth fixed 2026-07-01). **But** the "Synthesis roadmap" section still tells the old four-named-LoRA / HF-adapter-pack story (memory-bucket/memory-synthesis/memory-editor LoRAs "distributed from Hugging Face") — not the plan of record (`memory-<stage>` convention, only `memory-chunk` exists, base+policy otherwise) | **Rewrite the roadmap section** to the as-built stage list + the `memory-<stage>` adapter convention; update stage names again when BUCKET/RESOLVE land. |
|
|
26
26
|
| `STATUS.md` § THE DREAMING | Live state | Current and correct (batch default 1, third-person fix merged, import paused at cursor 900/2096, inference-path landed) | Keep as the ONLY live-state location. |
|
|
27
27
|
|
|
@@ -117,6 +117,6 @@ overturning a load-bearing performance assumption.
|
|
|
117
117
|
"failures" were M4-Pro fixtures; all code exonerated — mlx-lm reproduces
|
|
118
118
|
mlx-bun token-for-token per machine); CI gate (typecheck + model-free tests).
|
|
119
119
|
- **Research (the lab):** decode-roofline re-measurement overturned the "at
|
|
120
|
-
the floor" assumption (docs/investigations/decode-roofline-lookagain.md);
|
|
120
|
+
the floor" assumption (docs/archive/investigations/decode-roofline-lookagain.md);
|
|
121
121
|
curve-sampler distinctness theorem + witness numbers + preregistered
|
|
122
122
|
protocol (docs/planning/curve-sampler-research-plan.md).
|