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.
Files changed (90) hide show
  1. package/README.md +175 -93
  2. package/docs/dag/training-inference-map.html +575 -0
  3. package/docs/design/adapters-end-to-end.md +50 -46
  4. package/docs/design/compat-cli-surface-design.md +10 -8
  5. package/docs/design/docs-reorg-plan.md +14 -1
  6. package/docs/design/hlg-sampling.md +12 -2
  7. package/docs/design/memory-system.md +193 -295
  8. package/docs/design/optimization_plan.md +4 -2
  9. package/docs/design/orpo-dynamic-lambda.md +179 -0
  10. package/docs/design/orpo-future-enhancements.md +340 -0
  11. package/docs/design/orpo-training.md +1212 -0
  12. package/docs/design/parallel-slots.md +34 -26
  13. package/docs/design/parity-tier-dag.md +143 -0
  14. package/docs/design/runtime-isolation.md +1 -1
  15. package/docs/design/segmented-backward-training.md +58 -39
  16. package/docs/design/tauri-desktop-app.md +127 -0
  17. package/docs/design/w4a16-compute-precision-spike.md +232 -0
  18. package/docs/investigations/orpo-base-uf-experiment-and-directions.md +120 -0
  19. package/docs/investigations/orpo-flash-cce-pin-leak.md +167 -0
  20. package/docs/investigations/orpo-uf-testing-handoff.md +126 -0
  21. package/docs/{segmented-backward-handoff.md → investigations/segmented-backward-handoff.md} +1 -1
  22. package/docs/investigations/starter-model-port-handoff.md +32 -13
  23. package/docs/investigations/steel-flash-cce-handoff.md +489 -0
  24. package/docs/investigations/trainer-validation-experiment.md +173 -0
  25. package/docs/planning/IDEAS.md +29 -0
  26. package/docs/planning/PRODUCT_ROADMAP.md +147 -27
  27. package/docs/planning/chunk-task-roadmap.md +1 -1
  28. package/docs/planning/journal.md +161 -0
  29. package/docs/reference/distribution.md +61 -5
  30. package/docs/reference/library-api.md +29 -14
  31. package/docs/reference/memory.md +77 -0
  32. package/docs/reference/orpo-quickstart.md +130 -0
  33. package/docs/reference/server-api.md +105 -7
  34. package/docs/reference/server-config.md +12 -5
  35. package/docs/reference/training.md +296 -0
  36. package/package.json +1 -1
  37. package/src/cli.ts +651 -18
  38. package/src/eval/ifeval.ts +138 -0
  39. package/src/eval/runner.ts +76 -6
  40. package/src/eval/tasks/bfcl.ts +49 -15
  41. package/src/eval/tasks/gsm8k.ts +21 -9
  42. package/src/eval/tasks/hashhop.ts +33 -4
  43. package/src/eval/tasks/humaneval.ts +30 -8
  44. package/src/eval/tasks/ifeval.ts +52 -18
  45. package/src/eval/tasks/mmlu.ts +85 -74
  46. package/src/eval/ultrafeedback.ts +60 -0
  47. package/src/jobs/runner.ts +6 -0
  48. package/src/lora.ts +12 -7
  49. package/src/memory/chunk.ts +25 -0
  50. package/src/memory/cluster.ts +24 -0
  51. package/src/memory/db.ts +114 -0
  52. package/src/memory/ingest.ts +22 -0
  53. package/src/memory/pipeline.ts +63 -0
  54. package/src/memory/prompts.ts +23 -0
  55. package/src/memory/schedule.ts +163 -0
  56. package/src/memory/synthesize.ts +29 -0
  57. package/src/memory/tools.ts +399 -0
  58. package/src/memory/vault.ts +694 -0
  59. package/src/memory/wikify.ts +23 -0
  60. package/src/mlx/metal-kernel.ts +31 -4
  61. package/src/model/flash-attention.ts +37 -19
  62. package/src/model/fused-geglu-kernel.ts +111 -0
  63. package/src/model/gemma4-base.ts +39 -1
  64. package/src/model/gemma4.ts +196 -21
  65. package/src/model/minicpm5.ts +44 -3
  66. package/src/pi-provider.ts +29 -13
  67. package/src/pi-session.ts +81 -0
  68. package/src/pi-terminal.ts +13 -24
  69. package/src/pi-web.ts +246 -166
  70. package/src/quantize/job.ts +17 -2
  71. package/src/quantize/quantizer.ts +26 -2
  72. package/src/server.ts +216 -47
  73. package/src/tokenizer.ts +6 -2
  74. package/src/train/dataset.ts +29 -6
  75. package/src/train/flash-cce.ts +1175 -0
  76. package/src/train/job.ts +64 -3
  77. package/src/train/lora-params.ts +53 -4
  78. package/src/train/loss.ts +947 -0
  79. package/src/train/optimizer.ts +10 -3
  80. package/src/train/prefix-shared.ts +435 -0
  81. package/src/train/rank.ts +36 -0
  82. package/src/train/segmented.ts +1148 -3
  83. package/src/train/steel-qmm-header.ts +1461 -0
  84. package/src/train/trainer.ts +570 -54
  85. package/src/train/watch.ts +542 -0
  86. package/src/web/app.html +285 -19
  87. package/src/web/skills/memory/SKILL.md +97 -0
  88. package/src/web/skills/web-research/SKILL.md +3 -1
  89. package/src/web/skills.ts +46 -8
  90. /package/{docs → src/assets}/curve-designer.html +0 -0
@@ -1,5 +1,16 @@
1
1
  # Adapters end-to-end — notes / TODO (2026-06-16)
2
2
 
3
+ **Status legend:** ✅ DONE — shipped and verified in code | ⏳ PENDING — not yet implemented
4
+
5
+ | Section | Status |
6
+ | --- | --- |
7
+ | §A Pi CLI extension (`extensions/mlx-bun-adapter.ts`) | ✅ DONE |
8
+ | §B Web chat adapter selector (`src/web/app.html` + `before_provider_request` hook in `pi-web.ts`) | ✅ DONE |
9
+ | §C `/v1/adapters/available` discovery (`src/server.ts:1182`, `src/lora.ts:139`) | ✅ DONE |
10
+ | §D Overnight training from the web UI — monitor/stream endpoint + UI | ⏳ PENDING |
11
+ | §E `--force-adapter` CLI flag (absent from `src/cli.ts`) | ⏳ PENDING |
12
+ | Repo-id keying written into adapter configs at save time | ⏳ PENDING |
13
+
3
14
  Working notes for wiring trained LoRA adapters through the whole stack: Pi (CLI +
4
15
  web), the web Chat page UI, and the server's discovery surface. Captured from the
5
16
  2026-06-16 session (serving verified working; pi-extension mechanism confirmed from
@@ -31,16 +42,16 @@ API should let you move an adapter between these states explicitly.
31
42
  So **loaded** and **selected** are done. The gap is **available** (discovery) plus
32
43
  the two front-ends (Pi extension, web Chat selector).
33
44
 
34
- ## TODO
45
+ ## Shipped (§A–§C) ✅
35
46
 
36
- ### A. Pi CLI/terminal — adapter via extension *(default none)*
47
+ ### A. Pi CLI/terminal — adapter via extension *(default none)* ✅ DONE
37
48
 
38
- Mechanism (confirmed from the pi docs in-session): a Pi extension using the
39
- `before_provider_request` hook to inject the field into the outgoing
40
- OpenAI-compatible payload. `models.json` can't add arbitrary body fields — the hook
41
- is the right tool.
49
+ Wired a Pi extension using the `before_provider_request` hook to inject the `adapter`
50
+ field into the outgoing OpenAI-compatible payload. `models.json` can't add arbitrary
51
+ body fields — the hook was the right tool.
42
52
 
43
- Create `~/.pi/agent/extensions/mlx-bun-adapter.ts`:
53
+ Shipped as `~/.pi/agent/extensions/mlx-bun-adapter.ts` (copy in-repo + one-liner
54
+ installer):
44
55
 
45
56
  ```ts
46
57
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
@@ -60,53 +71,44 @@ export default function (pi: ExtensionAPI) {
60
71
  - Selection via `PI_MLX_ADAPTER=chunk pi --provider mlx-bun --model local -p "..."`
61
72
  (no native `-p --adapter` flag; unknown CLI flags get rejected). Optional shell
62
73
  helper: `pi-chunk() { PI_MLX_ADAPTER=chunk pi --provider mlx-bun --model local -p "$@"; }`.
63
- - Put it in the global `~/.pi/agent/extensions/` dir so it loads for non-interactive
64
- `-p` too. `/reload` to pick it up.
65
- - **Ship this** as part of mlx-bun (a copy in-repo + a one-liner installer), so users
66
- don't hand-write it. Consider also reading the *selected* adapter from a small
67
- state file the web UI / a `mlx-bun adapter use <id>` command writes, so CLI and web
68
- share one selection.
74
+ - Lives in the global `~/.pi/agent/extensions/` dir so it loads for non-interactive
75
+ `-p` too. `/reload` picks it up.
76
+ - Also reads the *selected* adapter from a small state file the web UI / a
77
+ `mlx-bun adapter use <id>` command writes, so CLI and web share one selection.
69
78
 
70
- ### B. Web Chat page — selector + load/unload *(default none)*
79
+ ### B. Web Chat page — selector + load/unload *(default none)* ✅ DONE
71
80
 
72
81
  Path: `src/web/app.html` (UI) ↔ `/ws/chat` (`src/pi-web.ts`) ↔ in-process Pi ↔ model.
73
82
 
74
83
  - **Selector** in `app.html`: a dropdown of *available* adapters with **"none"
75
84
  selected by default**. Changing it sets the active selection for subsequent
76
- messages. Allow multi-select → `"a+b"` (resolveSpec already supports stacking).
85
+ messages. Multi-select → `"a+b"` (resolveSpec already supports stacking).
77
86
  - **Load / unload controls**: buttons that call `POST /v1/adapters` (load) and
78
- `DELETE /v1/adapters/:id` (unload). Show each adapter's state (available / loaded /
79
- selected) so the three concepts are visible. An adapter must be **loaded** before
80
- it can be **selected** (selecting an unloaded id errors) — UI should either
81
- auto-load on select or gate selection to loaded ones.
82
- - **Inject via the `before_provider_request` hook — the primary mechanism, identical
83
- to the CLI (§A).** `pi-web.ts` ALREADY registers an inline extension this way
84
- (`pi.on("tool_call", …)` wired into `createAgentSession`, pi-web.ts:469/605), so
85
- `pi.on("before_provider_request", (e) => ({ ...e.payload, adapter }))` drops in the
86
- same way and reads the current selection from the WS session state. **No custom
87
+ `DELETE /v1/adapters/:id` (unload). Each adapter's state (available / loaded /
88
+ selected) is shown so the three concepts are visible. Selecting an unloaded adapter
89
+ auto-loads it (fires `POST /v1/adapters`) before injecting the id.
90
+ - **Injected via the `before_provider_request` hook — identical mechanism to the CLI
91
+ (§A).** `pi-web.ts` registers the inline extension in `createAgentSession`
92
+ (pi-web.ts:469/605), so `pi.on("before_provider_request", (e) => ({ ...e.payload,
93
+ adapter }))` reads the current selection from WS session state. **No custom
87
94
  provider plumbing, no new model-call wiring.** The hook is the spine for BOTH UIs.
88
- - **Selection → hook**: the dropdown just updates the session's selected-adapter value
89
- that the hook reads — a tiny client→server message (or reuse the `set_thinking`-style
90
- toggle path), NOT a heavyweight protocol. Default none → hook returns the payload
91
- unchanged → base model.
92
- - **Mounting is the only thing the hook can't do**: the injected id must be mounted
93
- server-side or `resolveSpec` rejects it. Auto-load-on-select handles it — selecting
94
- fires one `POST /v1/adapters`, then the hook injects the id. Discovery (§C) and a
95
- richer protocol are optional polish; the dropdown can start from `GET /v1/adapters`.
96
-
97
- ### C. Server — adapter **discovery** (the missing "available" list)
98
-
99
- - Add a store the server scans for available adapters:
100
- - `~/.cache/mlx-bun/adapters/` (the trainer already defaults saves here —
101
- `src/server.ts:1653`) and/or a **sidecar next to the model dir**.
102
- - New endpoint, e.g. `GET /v1/adapters/available` →
95
+ - **Selection → hook**: the dropdown updates the session's selected-adapter value via
96
+ a small client→server message (reusing the `set_thinking`-style toggle path). Default
97
+ none → hook returns the payload unchanged → base model.
98
+
99
+ ### C. Server — adapter **discovery** (`GET /v1/adapters/available`) ✅ DONE
100
+
101
+ - Scans `~/.cache/mlx-bun-finetunes/` and `~/.cache/mlx-bun/adapters/`
102
+ (`src/server.ts:1192`) and any sidecar next to the model dir.
103
+ - `GET /v1/adapters/available` (`src/server.ts:1182`, `src/lora.ts:139`) →
103
104
  `[{ id, path, source_repo, rank, scale, compatible }]`, where each entry is read
104
105
  from the adapter's `optiq_lora_config.json` (`source_model`, `rank`, `scale`).
105
- - **Filter by the served model.** Today `source_model` is a *machine/snapshot-specific
106
- path* (`/Users/joshrossi/.cache/huggingface/.../snapshots/<hash>`), which won't
107
- match across machines/snapshots. Key compatibility on the **repo id**
108
- (`mlx-community/MiniCPM5-1B-OptiQ-4bit`) instead — see "repo-id keying" below. The
109
- server already tracks `repoId` per model; `compatible = adapter.source_repo === served.repoId`.
106
+ - **Filters by the served model** on **repo id**
107
+ (`mlx-community/MiniCPM5-1B-OptiQ-4bit`) rather than the fragile
108
+ machine/snapshot-specific path. The server already tracks `repoId` per model;
109
+ `compatible = adapter.source_repo === served.repoId`.
110
+
111
+ ## TODO (§D–§E)
110
112
 
111
113
  ### D. Overnight training from the web UI
112
114
 
@@ -117,8 +119,10 @@ Training must be fully drivable from the web UI — not just a script.
117
119
  (rank / scale / num_layers / LR / dropout / iters / seq / segmentSize — the
118
120
  configurable-params task, mlx-lm defaults), **start**, and leave it running.
119
121
  - **Monitor**: live loss / iter / ETA, and survives the browser closing (the run is
120
- server-side; the page reconnects). `POST /v1/fit` already exists
121
- (`src/server.ts:1652`) — needs a status/stream endpoint + a UI.
122
+ server-side; the page reconnects). The training backend already exists:
123
+ `POST /api/finetune/submit` (`src/server.ts:1781`). What §D still needs is a
124
+ status/stream endpoint + the overnight-monitoring UI. (Note: `GET /fit` is the
125
+ unrelated memory-fit solver in `src/fit.ts` — not a training endpoint.)
122
126
  - **Completion**: the finished adapter lands in the store and shows up as *available*
123
127
  (state A in the three-state model), ready to load/select or auto-serve.
124
128
  - This closes the loop with the chunk-task roadmap: iterate data → train overnight →
@@ -6,6 +6,8 @@ modes"). This doc is the surface contract: every verb, the flag
6
6
  vocabulary, how optiq is absorbed, the parity harness, and **the
7
7
  matrix of what we still lack**.
8
8
 
9
+ **Update 2026-06-17:** Several items have shipped since the 2026-06-12 snapshot: **LoRA training** is live (`src/train/`, `scripts/chunk-finetune.ts`, segmented-backward Phase A MiniCPM5 + Phase B e4b both merged); the **web UI fine-tune tab** (`src/web/app.html`) is live with SFT/DPO workflow, loss curve, merge, and export; the **chat adapter selector** (web UI) is live; and **adapters end-to-end** (web selector + CLI `/adapter`) are done — the matrix below reflects these as ✅. The **Phase 17 compat parity harness itself** (the verb router, dotted aliases, flag-surface parity tests) remains **unbuilt**.
10
+
9
11
  ## Goal
10
12
 
11
13
  Design mlx-bun's entire CLI/flag surface from scratch (nothing is
@@ -54,7 +56,7 @@ shared subset; optiq-only features are additive (marked ⊕).
54
56
  | `chat` | mlx_lm.chat | engine ✅, web chat ✅; no terminal REPL (`tui.ts` is help-formatting) | build REPL frontend over `generate` |
55
57
  | `server` | mlx_lm.server / optiq serve | ✅ `serve` | rename flags; ⊕ `--kv-config`, `--anthropic` honored (default on) |
56
58
  | `convert` | mlx_lm.convert + optiq convert | ❌ | quant pipeline; ⊕ `--target-bpw/--candidate-bits/--reference` |
57
- | `lora` | mlx_lm.lora + optiq lora | serve/hot-swap ✅, train ❌ | `--train/--test`; ⊕ `--rank-scaling by_bits\|by_kl`; `lora info` |
59
+ | `lora` | mlx_lm.lora + optiq lora | serve/hot-swap ✅, train ✅ | `--train/--test`; ⊕ `--rank-scaling by_bits\|by_kl`; `lora info` |
58
60
  | `fuse` | mlx_lm.fuse | ❌ | fuse adapters, dequant, GGUF export, upload |
59
61
  | `cache_prompt` | mlx_lm.cache_prompt | runtime ✅, CLI ❌ | precompute + save reusable KV cache file |
60
62
  | `benchmark` | mlx_lm.benchmark / optiq benchmark | ✅ `benchmark` | flag-name parity (`-p/-g/-b/-n`); ppl half ❌ |
@@ -83,7 +85,7 @@ mlx-lm" half.
83
85
 
84
86
  ### pi — the built-in agentic coding CLI
85
87
 
86
- (Phase 16; full plan in **docs/pi-builtin-investigation.md**.) pi is an
88
+ (Phase 16; full plan in **docs/investigations/pi-builtin-investigation.md**.) pi is an
87
89
  MIT, Bun-native (`bun build --compile`) coding agent — the "CLI
88
90
  experience inside our package" that neither Python package has. Two
89
91
  commands, one for each audience:
@@ -111,8 +113,8 @@ split.
111
113
  The web UI's agent backbone is pi's RPC / `AgentSession.subscribe()`
112
114
  event stream (investigation Option 4) — the SAME events drive the
113
115
  embedded TUI and the browser, so tool calls / steering / progress come
114
- for free. Tiles: chat ✅; quantize / fine-tune / training-data gate on
115
- the capability matrix.
116
+ for free. Tiles: chat ✅; fine-tune ✅ (shipped: SFT/DPO workflow, loss curve, merge,
117
+ export); quantize / training-data gate on the capability matrix.
116
118
 
117
119
  ## Flag-vocabulary reconciliation (where we currently diverge)
118
120
 
@@ -150,7 +152,7 @@ column; the 🟥 column is the capability matrix that fills in behind it.
150
152
  | KV-cache quant: bf16 / uniform / **mixed per-layer** (kv_config.json) | `server` (`off`/`N`/`config`) | ✅ | done (Phase 9/10; config.ts reads, generate.ts applies per-layer) |
151
153
  | KV sensitivity *profiler* (authors a NEW kv_config.json) | `kv-cache` | 🟥 | model-prep, low pri (shipped artifacts already include one) |
152
154
  | TurboQuant — optional extra quant *method* (rotation VQ) | scheme, not a verb | 🟥 | Phase 13 (KV plumbing already exists) |
153
- | **LoRA / DoRA / full training** | `lora --train` | 🟥 | Training (new phase) |
155
+ | **LoRA / DoRA / full training** | `lora --train` | ✅ | Training (done: Phase A MiniCPM5 + Phase B e4b) |
154
156
  | **Sensitivity-aware rank scaling** | `lora --rank-scaling` | 🟥 | Training |
155
157
  | **Fuse adapters (+GGUF/upload)** | `fuse` | 🟥 | Training |
156
158
  | **lm-eval-harness tasks** | `evaluate` | 🟥 | Eval (new phase) |
@@ -159,7 +161,7 @@ column; the 🟥 column is the capability matrix that fills in behind it.
159
161
  | **HF upload** | `upload` | 🟥 | Distribution |
160
162
  | **Distributed share** | `share` | 🟥 | Distribution (lowest pri) |
161
163
  | **Web UI: quantize** | `lab`/UI | 🟥 | gated on Quantize |
162
- | **Web UI: fine-tune** | `lab`/UI | 🟥 | gated on Training |
164
+ | **Web UI: fine-tune** | `lab`/UI | ✅ | done (SFT/DPO workflow, loss curve, merge, export) |
163
165
  | **Web UI: training-data template + gen** | `lab`/UI | 🟥 | new (no engine dep) |
164
166
  | Web UI: chat | `/chat` | ✅ | done (publishing gate 2) |
165
167
  | **Native: pi embedded** (`mlx-bun pi`, in-process TUI) | — | ✅ (P3/P4) | Phase 16 (flagship) |
@@ -177,7 +179,7 @@ does. The real capability work splits along two axes:
177
179
  optional and not inference plumbing: a *profiler* to author a new
178
180
  kv_config.json (model-prep, low pri) and extra methods like TurboQuant
179
181
  (Phase 13).
180
- - **Training**: LoRA/DoRA/full + `fuse`.
182
+ - **Training**: LoRA/DoRA/full training ✅ (shipped); `fuse` verb (adapter merge, GGUF export, upload) 🟥 remaining.
181
183
  - **Eval**: harness + `perplexity`.
182
184
  - **Distribution**: `upload`/`share`.
183
185
 
@@ -221,7 +223,7 @@ correctness diffs need no clean machine.
221
223
  3. Inference-time KV quant → already done (bf16 / uniform / mixed
222
224
  per-layer via kv_config.json, Phase 9/10). Optional later: a profiler
223
225
  to author new configs (low pri) + the TurboQuant method (Phase 13).
224
- 4. Training → `lora --train`/`fuse` + web-UI fine-tune tile.
226
+ 4. Training → ✅ `lora --train` + web-UI fine-tune tile (both shipped); remaining: `fuse` verb (adapter merge, GGUF export, upload).
225
227
  5. Eval → `evaluate`/`perplexity`.
226
228
  6. Distribution → `upload`/`share`.
227
229
  7. Web UI training-data tile (independent of engine work).
@@ -4,6 +4,19 @@
4
4
  (src/ and scripts/ moves — they change import paths / script references
5
5
  and need a test run, so deferred to their own pass). Authored 2026-06-14.
6
6
 
7
+ **Execution state (verified 2026-06-17):**
8
+ - P0 #1 — **DONE**: `AGENTS.md` is a symlink → `CLAUDE.md`; drift risk resolved.
9
+ - P0 #2 — **DONE**: `benchmarks/RESULTS.md` created; old committed benchmark artifacts `git rm`'d. Root untracked spew (`benchmarks-h2h-2026-06-13-*` etc.) is now cleaned — no untracked report files found at root.
10
+ - P0 #3 — **DONE**: root HTML/md spew cleared (no `benchmarks-h2h-*.md`, `benchmark-report-*.html`, `kernel-fusion-report-*.html`, or `project-review.html` at root).
11
+ - P0 #4 — **DONE**: hardcoded test count removed from CLAUDE.md (no "All 72 tests" present).
12
+ - P1 #5 — **DONE**: `STATUS.md` exists at root.
13
+ - P1 #6 — **DONE**: `docs/planning/` exists with `IDEAS.md`, `PRODUCT_ROADMAP.md`, `ResearchTopics.md`, `journal.md`.
14
+ - P1 #7 — open (optimization_plan.md still lives in docs/design/ as a standalone).
15
+ - P1 #8 — status unknown (archive/ not verified in this pass).
16
+ - P2 #9 — **NOT DONE**: `harness-pi.ts`, `pi-provider.ts`, `pi-terminal.ts`, `pi-web.ts` still live flat in `src/` root (no `src/pi/` subdirectory).
17
+ - P2 #10 — **PARTIALLY DONE**: ~57 one-off research/debug scripts moved to `scripts/experiments/`; production + tooling + bench-* + regen-* + parity-* + gen-model + eval/serve remain at `scripts/` root (the full bench/regen/build split was not applied).
18
+ - P2 #11 — **DONE**: CLI vocabulary reconciled.
19
+
7
20
  **Scope & ethos.** Private repo, single author + agents, MLX-by-identity.
8
21
  No OSS/community scaffolding (CONTRIBUTING, issue templates, badges) —
9
22
  out of scope by design. **Prefer move / consolidate over delete.** The
@@ -127,7 +140,7 @@ files, not benchmark output. Leave entirely alone.
127
140
  | 5 | Add `STATUS.md` (or a pinned top section in PLAN.md) holding only live handoff: current state + next action + blockers. Move PLAN.md's `NEXT UP` / `NEXT SESSION PICKUP` / `SESSION SWEEP` blocks into it. | Separates transient "do this next" from 2,475 lines of durable phase history; gives agents one entry point. |
128
141
  | 6 | Create `docs/planning/` and move `PRODUCT_ROADMAP.md`, `IDEAS.md`, `ResearchTopics.md`, `journal.md` under it. Leave only README + PLAN.md (+ STATUS.md) at root. Add a ~6-line "doc map" to README. | Root is currently a 6-file planning thicket; extends the taxonomy that already works in `docs/`. |
129
142
  | 7 | Pick one home for the optimization plan: fold `docs/design/optimization_plan.md` into PLAN.md Phase A–E, or have PLAN.md link out to it as canonical. | Two homes for the same plan = drift. |
130
- | 8 | Resolve the archive overlap: `archive/pi-builtin-investigation.html` duplicates [docs/investigations/pi-builtin-investigation.md](../investigations/pi-builtin-investigation.md). Decide whether `archive/` (tracked; 8 generated HTML files incl. a 374 KB pi-session transcript) should be tracked at all, or moved to an ignored location. Keep the `.md`, drop the duplicate. | Stops committing heavyweight generated HTML; one source per investigation. |
143
+ | 8 | Resolve the archive overlap: `archive/pi-builtin-investigation.html` duplicates [docs/investigations/pi-builtin-investigation.md](../investigations/pi-builtin-investigation.md). Decide whether `archive/` (tracked; 2 HTML files: `mlx-bun-lab-report.html` + `wwdc-mlx-bun.html`) should be tracked at all, or moved to an ignored location. Keep the `.md`, drop the duplicate. | Stops committing heavyweight generated HTML; one source per investigation. |
131
144
 
132
145
  ## P2 — Polish (optional)
133
146
 
@@ -1,6 +1,6 @@
1
1
  # HLG sampling — a piecewise tone curve on the logits
2
2
 
3
- Status: **design + phasing** (no code yet; this doc is the contract)
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](../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
 
@@ -10,6 +10,12 @@ Default: **off** (`--hlg-sampling off` = today's temperature sampler, untouched)
10
10
  > [docs/reference/server-config.md](../reference/server-config.md) and
11
11
  > [docs/reference/server-api.md](../reference/server-api.md) once shipped.
12
12
 
13
+ ## Outcome / Retrospective
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](../investigations/hlg-sampling-investigation.md).
16
+
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
+
13
19
  ## Goal
14
20
 
15
21
  Add a sampling transform — gated entirely behind `--hlg-sampling on` and a
@@ -290,6 +296,8 @@ quality + diversity rather than parity — except for the degeneracy gates, whic
290
296
 
291
297
  ## Phasing (the "piece N" increments)
292
298
 
299
+ > **Historical / superseded.** Pieces 1–2 shipped. Pieces 3–6 were never executed — HLG was evaluated after Piece 2 and found neutral; the feature was superseded by the Curve Designer before Piece 3 began.
300
+
293
301
  1. **Pure curve + neutrality tests** — `applyHlg(lp, params)` in `sampler.ts`,
294
302
  top-anchored pivot only; degeneracy + monotonicity tests green across all
295
303
  four models. (No flag wired yet — pure, fully-tested function.)
@@ -305,6 +313,8 @@ quality + diversity rather than parity — except for the degeneracy gates, whic
305
313
 
306
314
  ## Open questions / risks
307
315
 
316
+ > **Historical / superseded.** These questions were open at the time of design. HLG evaluation concluded with a neutral verdict before they were answered; the Curve Designer supersedes this path. Questions are preserved as design context.
317
+
308
318
  - **Default knob values** are calibration-pending — set empirically by the
309
319
  Piece 5 sweep, not guessed. Initial exploration points: `c ≈ 6`, `w ≈ 4`,
310
320
  `β_h ≈ 4`, `β_t ≈ 6` nats; confirm or replace with measured values.
@@ -337,4 +347,4 @@ for it. That a transfer function is standard practice in another domain says
337
347
  nothing about whether it helps token sampling — that is decided only by
338
348
  measurement (the KL characterization, the capability guardrail, and the
339
349
  diversity lens in [Correctness](#correctness--evaluation)). The full empirical
340
- write-up goes in `docs/investigations/hlg-sampling-investigation.md` once run.
350
+ write-up is in [docs/investigations/hlg-sampling-investigation.md](../investigations/hlg-sampling-investigation.md).