mlx-bun 0.0.4 → 0.0.6
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 +175 -93
- package/docs/dag/training-inference-map.html +575 -0
- package/docs/design/adapters-end-to-end.md +50 -46
- package/docs/design/compat-cli-surface-design.md +10 -8
- package/docs/design/docs-reorg-plan.md +14 -1
- package/docs/design/hlg-sampling.md +12 -2
- package/docs/design/memory-system.md +193 -295
- package/docs/design/optimization_plan.md +4 -2
- package/docs/design/orpo-dynamic-lambda.md +179 -0
- package/docs/design/orpo-future-enhancements.md +340 -0
- package/docs/design/orpo-training.md +1212 -0
- package/docs/design/parallel-slots.md +34 -26
- package/docs/design/parity-tier-dag.md +143 -0
- package/docs/design/runtime-isolation.md +1 -1
- package/docs/design/segmented-backward-training.md +58 -39
- package/docs/design/tauri-desktop-app.md +127 -0
- package/docs/design/w4a16-compute-precision-spike.md +232 -0
- package/docs/investigations/orpo-base-uf-experiment-and-directions.md +120 -0
- package/docs/investigations/orpo-flash-cce-pin-leak.md +167 -0
- package/docs/investigations/orpo-uf-testing-handoff.md +126 -0
- package/docs/{segmented-backward-handoff.md → investigations/segmented-backward-handoff.md} +1 -1
- package/docs/investigations/starter-model-port-handoff.md +32 -13
- package/docs/investigations/steel-flash-cce-handoff.md +489 -0
- package/docs/investigations/trainer-validation-experiment.md +173 -0
- package/docs/planning/IDEAS.md +29 -0
- package/docs/planning/PRODUCT_ROADMAP.md +147 -27
- package/docs/planning/chunk-task-roadmap.md +1 -1
- package/docs/planning/journal.md +161 -0
- package/docs/reference/distribution.md +61 -5
- package/docs/reference/library-api.md +29 -14
- package/docs/reference/memory.md +77 -0
- package/docs/reference/orpo-quickstart.md +130 -0
- package/docs/reference/server-api.md +105 -7
- package/docs/reference/server-config.md +12 -5
- package/docs/reference/training.md +296 -0
- package/package.json +1 -1
- package/src/cli.ts +651 -18
- package/src/eval/ifeval.ts +138 -0
- package/src/eval/runner.ts +76 -6
- package/src/eval/tasks/bfcl.ts +49 -15
- package/src/eval/tasks/gsm8k.ts +21 -9
- package/src/eval/tasks/hashhop.ts +33 -4
- package/src/eval/tasks/humaneval.ts +30 -8
- package/src/eval/tasks/ifeval.ts +52 -18
- package/src/eval/tasks/mmlu.ts +85 -74
- package/src/eval/ultrafeedback.ts +60 -0
- package/src/jobs/runner.ts +6 -0
- package/src/lora.ts +12 -7
- package/src/memory/chunk.ts +25 -0
- package/src/memory/cluster.ts +24 -0
- package/src/memory/db.ts +114 -0
- package/src/memory/ingest.ts +22 -0
- package/src/memory/pipeline.ts +63 -0
- package/src/memory/prompts.ts +23 -0
- package/src/memory/schedule.ts +163 -0
- package/src/memory/synthesize.ts +29 -0
- package/src/memory/tools.ts +399 -0
- package/src/memory/vault.ts +694 -0
- package/src/memory/wikify.ts +23 -0
- package/src/mlx/metal-kernel.ts +31 -4
- package/src/model/flash-attention.ts +37 -19
- package/src/model/fused-geglu-kernel.ts +111 -0
- package/src/model/gemma4-base.ts +39 -1
- package/src/model/gemma4.ts +196 -21
- package/src/model/minicpm5.ts +44 -3
- package/src/pi-provider.ts +29 -13
- package/src/pi-session.ts +81 -0
- package/src/pi-terminal.ts +13 -24
- package/src/pi-web.ts +246 -166
- package/src/quantize/job.ts +17 -2
- package/src/quantize/quantizer.ts +26 -2
- package/src/server.ts +216 -47
- package/src/tokenizer.ts +6 -2
- package/src/train/dataset.ts +29 -6
- package/src/train/flash-cce.ts +1175 -0
- package/src/train/job.ts +64 -3
- package/src/train/lora-params.ts +53 -4
- package/src/train/loss.ts +947 -0
- package/src/train/optimizer.ts +10 -3
- package/src/train/prefix-shared.ts +435 -0
- package/src/train/rank.ts +36 -0
- package/src/train/segmented.ts +1148 -3
- package/src/train/steel-qmm-header.ts +1461 -0
- package/src/train/trainer.ts +570 -54
- package/src/train/watch.ts +542 -0
- package/src/web/app.html +285 -19
- package/src/web/skills/memory/SKILL.md +97 -0
- package/src/web/skills/web-research/SKILL.md +3 -1
- package/src/web/skills.ts +46 -8
- /package/{docs → src/assets}/curve-designer.html +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# ORPO-on-UF — results + testing-phase handoff
|
|
2
|
+
|
|
3
|
+
**Status:** training done (2026-06-20); **testing phase = next.** This doc is the
|
|
4
|
+
"where we are + what to run" so anyone (or a fresh session) can execute the measurements.
|
|
5
|
+
Companion: [trainer-validation-experiment.md](trainer-validation-experiment.md) (the
|
|
6
|
+
validation that got us here).
|
|
7
|
+
|
|
8
|
+
## The run that just finished
|
|
9
|
+
|
|
10
|
+
From-**base** ORPO on UltraFeedback, MiniCPM5-1B.
|
|
11
|
+
- **Base:** `mlx-community/MiniCPM5-1B-OptiQ-4bit` (the full post-trained model; optiq quant).
|
|
12
|
+
- **Data:** `~/.cache/mlx-bun/eval-data/uf-cpm5` — 14,691 train / 148 val, `{prompt,chosen,rejected}`.
|
|
13
|
+
- **Config:** ORPO, **1 epoch (14,691 iters)**, B=1, seq 2048, rank 16, **λ=0.1**, cosine LR
|
|
14
|
+
1e-5, **no-segment**. From base (no warm-start).
|
|
15
|
+
- **Command:** `SEQ=2048 EVAL_EVERY=500 RANK=16 SCHED=cosine LAMBDA=0.1
|
|
16
|
+
ADAPTER_DIR=./adapters/cpm5-uf-frombase bun scripts/experiments/pref-control.ts orpo
|
|
17
|
+
~/.cache/mlx-bun/eval-data/uf-cpm5 uf-frombase 14691 1e-5`
|
|
18
|
+
|
|
19
|
+
## Key result — the two ORPO halves decoupled
|
|
20
|
+
|
|
21
|
+
| half | metric | best | at step | final (14690) |
|
|
22
|
+
|---|---|---|---|---|
|
|
23
|
+
| **SFT** | loss (NLL+λOR) ↓ | **1.5057** | **14500** (the end) | 1.506 |
|
|
24
|
+
| **DPO** | margin ↑ | **0.143** | **6000** | 0.127 |
|
|
25
|
+
| — | accuracy | **81/148** | ~5500 | 80/148 |
|
|
26
|
+
|
|
27
|
+
- **SFT improved across the *whole* run** (loss bottomed at the end) → **final adapter = best SFT.**
|
|
28
|
+
- **DPO peaked at ~6000 and faded** → **step ~6000 = best DPO**, slightly worse SFT (loss 1.5077).
|
|
29
|
+
- **No single checkpoint has both.** Honest summary: a **small, early-peaking preference
|
|
30
|
+
signal** (~+6 questions, chance 74 → peak 81/148) that **drifted down in the tail**, while
|
|
31
|
+
SFT kept inching to its ~1.506 floor. Whether even that small lift **converts** on an
|
|
32
|
+
independent test is the open question the testing phase answers.
|
|
33
|
+
|
|
34
|
+
## Artifacts + baselines
|
|
35
|
+
|
|
36
|
+
- **Final adapter:** `./adapters/cpm5-uf-frombase/` (mountable: `eval.ts --adapter`).
|
|
37
|
+
- **Trajectory:** `runs/uf-frombase.{json,csv}`; **plot:** `runs/uf-frombase.png` via
|
|
38
|
+
`scripts/experiments/plot-runs.py` (panels: loss=val+train-EMA; questions-correct/148;
|
|
39
|
+
margin — each zoomed to its band).
|
|
40
|
+
- **x1 baseline** (base CPM5, full capability suite): **28.69** (in the eval DB; needs the
|
|
41
|
+
MMLU-argmax + HumanEval-python fixes — see Gotchas). optiq published is 30.28.
|
|
42
|
+
- **⚠ No intermediate checkpoints this run** — `pref-control.ts` lacked `saveCheckpoints`
|
|
43
|
+
(now **fixed**; future runs checkpoint every val eval + track best-margin). The ~6k peak
|
|
44
|
+
is recoverable by **deterministic replay** (same seed/order → same adapter).
|
|
45
|
+
|
|
46
|
+
## Testing plan
|
|
47
|
+
|
|
48
|
+
**PRIMARY — the headline (READY TO RUN):**
|
|
49
|
+
- **A. final adapter vs base** on x2 (capability) + Exp 2 (judge win-rate). Answers "did a
|
|
50
|
+
full epoch of ORPO-on-UF move a 1B, on an *independent* test?"
|
|
51
|
+
|
|
52
|
+
**SWEEP / SYNTHESIS:**
|
|
53
|
+
- **B. recover the ~6k peak** — re-run from base to ~7k (checkpoints now on), grab the
|
|
54
|
+
step-6000 (and neighbors, pick best-val). The early-stop peak arm.
|
|
55
|
+
- **C. four-way** — base / 6k-peak / final / final+6k on x2 + Exp 2 → traces the
|
|
56
|
+
early-stopping curve on an independent test.
|
|
57
|
+
- **D. DPO-boost (the day's synthesis) — keep best SFT, re-pressure the DPO.** Warm-start
|
|
58
|
+
from the **final** adapter (best SFT, NLL at floor), re-apply the **DPO-helpful examples
|
|
59
|
+
with HIGH λ** (or DPO-only). = dynamic-λ (ramp preference at SFT-saturation) + data-curation
|
|
60
|
+
in one move. Tests the fork: DPO stalled because of a **capacity ceiling** (won't help) or
|
|
61
|
+
**dilution / λ-too-gentle** (margin recovers past 0.143 while loss holds ~1.506 → better on
|
|
62
|
+
*both* axes than any single checkpoint).
|
|
63
|
+
- **E. data-valuation control** — `final + (0–6000)` vs `final + (6000–14691)`, same size.
|
|
64
|
+
First-half wins → those examples carry the DPO signal; tie → it's "more preference training,"
|
|
65
|
+
not *which* examples. (We control which pairs go in, so this generalizes to **curating** the
|
|
66
|
+
data with the model as the probe.)
|
|
67
|
+
|
|
68
|
+
## Commands
|
|
69
|
+
|
|
70
|
+
`ORC=/Users/joshrossi/Code/mlx-lm-example/.venv/bin/python` (HumanEval interpreter, this machine).
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# A — x2 capability (final vs base; base x1=28.69 already recorded)
|
|
74
|
+
MLX_BUN_ORACLE_PYTHON=$ORC bun scripts/eval.ts capability --candidate MiniCPM5 --adapter ./adapters/cpm5-uf-frombase
|
|
75
|
+
# A — Exp 2 (gen base+trained responses, then judge head-to-head)
|
|
76
|
+
bun scripts/experiments/prefbench.ts gen mtbench ./adapters/cpm5-uf-frombase mtbench-uf # GPU
|
|
77
|
+
bun scripts/experiments/prefbench.ts judge mtbench-uf # codex
|
|
78
|
+
# B — replay base→7k to recover the ~6k checkpoint (now checkpoints)
|
|
79
|
+
SEQ=2048 EVAL_EVERY=500 RANK=16 SCHED=cosine LAMBDA=0.1 ADAPTER_DIR=./adapters/cpm5-uf-replay \
|
|
80
|
+
bun scripts/experiments/pref-control.ts orpo ~/.cache/mlx-bun/eval-data/uf-cpm5 uf-replay 7000 1e-5
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Harness gaps to close for D / E
|
|
84
|
+
|
|
85
|
+
`pref-control.ts` does **not yet** support (needed for the DPO-boost + control arms):
|
|
86
|
+
1. **Warm-start from an adapter** (`--resume` / load a non-zero adapter before training) —
|
|
87
|
+
the trainer has `warm_start_adapter` (see `trainer.ts`); just not wired into pref-control.
|
|
88
|
+
2. **Data-subset selection** (feed a chosen subset / order of pairs, e.g. rows 0–6000) —
|
|
89
|
+
pref-control feeds the whole `train.jsonl`; needs a row-range / id-list option.
|
|
90
|
+
3. λ is already env-controllable (`LAMBDA=`), so high-λ is ready once 1+2 exist.
|
|
91
|
+
|
|
92
|
+
## Validated infrastructure (all green — see trainer-validation-experiment.md)
|
|
93
|
+
|
|
94
|
+
- **Trainer:** positive controls pass — DPO & ORPO drive prefer-uppercase val acc → 1.0;
|
|
95
|
+
grads match autograd. `scripts/experiments/pref-control.ts`.
|
|
96
|
+
- **Capability harness:** reproduces optiq across 6 tasks after two fixes (below).
|
|
97
|
+
`eval.ts capability --adapter` wired.
|
|
98
|
+
- **Judge:** `gpt-5.4-mini` via `codex exec`, **keyless**, structured, order-swapped,
|
|
99
|
+
3/3 positive control. `scripts/experiments/llm-judge.ts`.
|
|
100
|
+
- **Exp 2 harness:** `scripts/experiments/prefbench.ts` (gen/judge); prompts downloaded
|
|
101
|
+
(`mt_bench.jsonl` 80, `alpaca_eval.json` 805).
|
|
102
|
+
- **MMLU frozen set:** optiq's exact 969 questions + dev exemplars captured
|
|
103
|
+
(`mmlu_optiq_frozen.jsonl` / `mmlu_optiq_dev.jsonl`) for parity work.
|
|
104
|
+
|
|
105
|
+
## Gotchas / load-bearing facts
|
|
106
|
+
|
|
107
|
+
- **`AdapterManager.mount` affects the *serving* forward** (eval generation, chat) **but NOT
|
|
108
|
+
the *training* `branchLogpMean`.** Measure training metrics via the trainLora emit, not mount.
|
|
109
|
+
- **Eval env:** `MLX_BUN_ORACLE_PYTHON=$ORC` (HumanEval code-exec — wrong default path on this
|
|
110
|
+
machine); evals default to **non-thinking** (optiq parity; `MLX_BUN_EVAL_THINK=1` to re-enable).
|
|
111
|
+
- **MMLU parity:** our number (47.7 old / ~50 argmax) vs optiq 52.4 is **sampling + forward
|
|
112
|
+
parity**, not noise (both deterministic argmax). Use the frozen set; remaining gap = our
|
|
113
|
+
forward vs `mlx_lm` (logit-diff test on the frozen prompts — **queued, GPU**).
|
|
114
|
+
- **Determinism:** same seed/order → same adapter. Replay recovers any checkpoint.
|
|
115
|
+
- **Server adapter API** (`POST /v1/adapters` + per-request `"adapter":"id"`) is the clean way
|
|
116
|
+
to compare *many* adapters via chat; **raw eval (`--adapter`) is required for capability**
|
|
117
|
+
(MMLU is logit-argmax, not chat generation).
|
|
118
|
+
|
|
119
|
+
## Recommended order
|
|
120
|
+
|
|
121
|
+
1. **A** (final vs base) — the headline, READY. Run x2, then Exp 2.
|
|
122
|
+
2. **B** — replay to recover the 6k peak (cheap, ~45 min).
|
|
123
|
+
3. **C** — eval base/6k/final on the suite (four-way needs D for the +6k arm).
|
|
124
|
+
4. Close the **pref-control harness gaps** (warm-start + subset), then **D** (DPO-boost) and
|
|
125
|
+
**E** (data-valuation control) — the synthesis experiments.
|
|
126
|
+
5. (Parallel/queued) **MMLU forward-parity** logit-diff to nail x1 ≈ 30.28.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Handoff — segmented backward training (2026-06-16)
|
|
2
2
|
|
|
3
3
|
Current-state report for the segmented-backward LoRA training work. Deep dossier
|
|
4
|
-
(design, proofs, every measurement): [`docs/design/segmented-backward-training.md`](design/segmented-backward-training.md)
|
|
4
|
+
(design, proofs, every measurement): [`docs/design/segmented-backward-training.md`](../design/segmented-backward-training.md)
|
|
5
5
|
§9 (MiniCPM5) and §10 (e4b). Branch: `segmented-backward-training`,
|
|
6
6
|
PR [#9](https://github.com/joshuarossi/mlx-bun/pull/9).
|
|
7
7
|
|
|
@@ -52,6 +52,22 @@ QK-norm against the oracle, llama has none).
|
|
|
52
52
|
Josh decides; both tracks are specified below. The shared recipe
|
|
53
53
|
(§2) applies to either.
|
|
54
54
|
|
|
55
|
+
> **Outcome (2026-06-17, resolved).** Both tracks proceeded as
|
|
56
|
+
> recommended. **Track A (MiniCPM5-1B) was chosen as the publishing
|
|
57
|
+
> gate and shipped** (open question 1 confirmed): `src/model/minicpm5.ts`
|
|
58
|
+
> is live, parity suite green, PLAN.md updated. The starter runs
|
|
59
|
+
> non-thinking (open question 2 confirmed). Weights are kept on disk as a
|
|
60
|
+
> permanent fallback and tour-guide model — not deleted after the big model
|
|
61
|
+
> lands (open question 3 confirmed). Publishing mechanics resolved
|
|
62
|
+
> (open question 4 green-lit): the package is published as
|
|
63
|
+
> `mlx-bun@0.0.4` on npm, installable via `bunx mlx-bun`, and a
|
|
64
|
+
> Homebrew release pipeline (sign/notarize/tap, default tap
|
|
65
|
+
> `joshuarossi/homebrew-tap`) is in place. First-run onboarding
|
|
66
|
+
> (auto-download + browser open) shipped alongside. **Track B
|
|
67
|
+
> (Qwen3.5-0.8B) is underway** as Phase 14 proper on its own clock,
|
|
68
|
+
> with reasoning fixes already merged. All four open questions are
|
|
69
|
+
> resolved; see §6.
|
|
70
|
+
|
|
55
71
|
---
|
|
56
72
|
|
|
57
73
|
## 1. Machine + reference environment logistics
|
|
@@ -308,16 +324,19 @@ isolates the novel machinery so parity bisects cleanly.
|
|
|
308
324
|
- PLAN.md updated with findings (negative results included — e.g.
|
|
309
325
|
any oracle deviations discovered, like the Phase 11 ones).
|
|
310
326
|
|
|
311
|
-
## 6.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
327
|
+
## 6. Resolved questions
|
|
328
|
+
|
|
329
|
+
All four questions were resolved by 2026-06-17 (see outcome box above).
|
|
330
|
+
|
|
331
|
+
1. **Track A vs B for the gate** — **Track A (MiniCPM5-1B) chosen.**
|
|
332
|
+
`src/model/minicpm5.ts` shipped as the publishing gate; Track B
|
|
333
|
+
(Qwen3.5-0.8B) is underway as Phase 14 proper on its own clock.
|
|
334
|
+
2. **Thinking mode for the starter** — **Non-thinking confirmed.**
|
|
335
|
+
The starter runs with thinking disabled; no `<think>` tokens in the
|
|
336
|
+
first-run flow.
|
|
337
|
+
3. **Keep weights on disk?** — **Yes, kept as permanent fallback + tour
|
|
338
|
+
guide.** The ~1 GB artifact is not deleted once the big model lands.
|
|
339
|
+
4. **Publishing mechanics green-lit?** — **Yes, shipped.**
|
|
340
|
+
Package published as `mlx-bun@0.0.4` on npm; installable via
|
|
341
|
+
`bunx mlx-bun`; Homebrew release pipeline (sign/notarize/tap,
|
|
342
|
+
default tap `joshuarossi/homebrew-tap`) is in place.
|