mlx-bun 0.0.8 → 0.0.10
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 +112 -20
- package/docs/design/batching-perf-path.md +232 -0
- package/docs/design/batching-v2-plan.md +515 -0
- package/docs/design/bucketing-stage.md +196 -0
- package/docs/design/compat-cli-surface-design.md +11 -11
- package/docs/design/docs-reorg-plan.md +1 -1
- package/docs/design/dreaming-nightly-pipeline.md +291 -0
- package/docs/design/dspark-speculative-decoding.md +106 -0
- package/docs/design/generic-model-support.md +381 -0
- package/docs/design/memory-inference-path.md +422 -0
- package/docs/design/memory-synthesis.md +287 -0
- package/docs/design/minicpm5-decode-megakernel.md +484 -0
- package/docs/design/mlx-lm-tool-parity-plan.md +535 -0
- package/docs/design/omlx-adoption-map.md +90 -0
- package/docs/design/orpo-dynamic-lambda.md +41 -0
- package/docs/design/orpo-training.md +35 -5
- package/docs/design/parallel-slots.md +12 -1
- package/docs/design/parity-tier-dag.md +13 -5
- package/docs/design/segmented-backward-training.md +15 -0
- package/docs/design/spec-decode-larger-targets.md +229 -0
- package/docs/design/ssd-kv-cold-tier.md +158 -0
- package/docs/design/tauri-desktop-app.md +2 -2
- package/docs/design/the-dreaming-handoff.md +141 -0
- package/docs/design/the-dreaming-master-plan.md +446 -0
- package/docs/design/write-pipeline-entity.md +468 -0
- package/docs/investigations/curve-bisector-routing.md +1 -1
- package/docs/investigations/decode-roofline-lookagain.md +348 -0
- package/docs/investigations/dspark-handoff.md +58 -0
- package/docs/investigations/kernel-perf-review-2026-07.md +171 -0
- package/docs/planning/PRODUCT_ROADMAP.md +2 -2
- package/docs/planning/curve-sampler-research-plan.md +331 -0
- package/docs/planning/memory-docs-and-dag-plan.md +185 -0
- package/docs/planning/pi-integration-review.md +178 -0
- package/docs/planning/release-notes-v0.0.10.md +57 -0
- package/docs/planning/release-notes-v0.0.9.md +122 -0
- package/docs/planning/web-ui-pass-plan.md +213 -0
- package/docs/planning/website-readme-pass-plan.md +224 -0
- package/docs/reference/cli.md +255 -0
- package/docs/reference/embedding.md +7 -2
- package/docs/reference/library-api.md +22 -3
- package/docs/reference/memory.md +5 -5
- package/docs/reference/models.md +137 -0
- package/docs/reference/orpo-quickstart.md +6 -0
- package/docs/reference/server-api.md +187 -9
- package/docs/reference/server-config.md +43 -9
- package/docs/reference/training.md +31 -12
- package/package.json +1 -1
- package/src/anthropic.ts +22 -0
- package/src/assets/curve-designer.html +1 -1
- package/src/chat-template.ts +25 -7
- package/src/cli.ts +1077 -90
- package/src/config.ts +4 -1
- package/src/download.ts +99 -8
- package/src/embed.ts +77 -0
- package/src/eval/perplexity.ts +164 -0
- package/src/eval/runner.ts +15 -6
- package/src/eval/tasks/bfcl.ts +1 -1
- package/src/generate.ts +149 -18
- package/src/harness-pi.ts +43 -17
- package/src/index.ts +2 -0
- package/src/kv-store.ts +240 -98
- package/src/lora.ts +2 -2
- package/src/memory/article.ts +558 -0
- package/src/memory/chunk-validation.ts +150 -0
- package/src/memory/chunk.ts +305 -12
- package/src/memory/cluster.ts +344 -17
- package/src/memory/coverage.ts +134 -0
- package/src/memory/crosslink.ts +0 -0
- package/src/memory/db.ts +184 -45
- package/src/memory/entity.ts +203 -0
- package/src/memory/gate.ts +187 -0
- package/src/memory/history.ts +152 -0
- package/src/memory/ingest.ts +324 -11
- package/src/memory/model.ts +321 -0
- package/src/memory/normalize.ts +671 -0
- package/src/memory/parse.ts +22 -0
- package/src/memory/pipeline.ts +242 -30
- package/src/memory/prompts.ts +42 -0
- package/src/memory/query.ts +334 -0
- package/src/memory/reconcile.ts +734 -0
- package/src/memory/redirect.ts +108 -0
- package/src/memory/reindex.ts +325 -0
- package/src/memory/resolve.ts +307 -0
- package/src/memory/route.ts +272 -0
- package/src/memory/schedule.ts +6 -4
- package/src/memory/stages.ts +774 -0
- package/src/memory/synthesize.ts +1629 -20
- package/src/memory/tools.ts +446 -96
- package/src/memory/vault.ts +462 -35
- package/src/memory/wikify.ts +1057 -16
- package/src/mlx/array.ts +21 -0
- package/src/mlx/ffi.ts +3 -0
- package/src/mlx/ops.ts +72 -0
- package/src/model/compiled-decode.ts +43 -8
- package/src/model/factory.ts +29 -8
- package/src/model/flash-attention.ts +4 -2
- package/src/model/fused-decode-kernel.ts +14 -7
- package/src/model/fused-mlp-kernel.ts +169 -0
- package/src/model/fused-swiglu-kernel.ts +240 -0
- package/src/model/gemma4-base.ts +96 -7
- package/src/model/gemma4.ts +33 -2
- package/src/model/minicpm5.ts +106 -8
- package/src/model/qwen3-delta.ts +48 -1
- package/src/model/qwen3.ts +276 -0
- package/src/model/qwen3_5.ts +11 -2
- package/src/model/steel-linear-kernel.ts +96 -0
- package/src/model/support.ts +38 -8
- package/src/model/universal/archs.ts +332 -0
- package/src/model/universal/dense.ts +576 -0
- package/src/model/universal/modules.ts +163 -0
- package/src/model/universal/rope.ts +366 -0
- package/src/pi-provider.ts +1 -1
- package/src/pi-terminal.ts +29 -8
- package/src/pi-web.ts +19 -2
- package/src/prompt-cache.ts +55 -9
- package/src/quantize/config-writer.ts +1 -1
- package/src/registry.ts +219 -8
- package/src/responses.ts +23 -0
- package/src/sampler.ts +220 -9
- package/src/serve/batch-scheduler.ts +307 -83
- package/src/serve/generation-gateway.ts +156 -29
- package/src/server.ts +746 -73
- package/src/spec/drafter.ts +81 -49
- package/src/spec/dspark/data-dflash.ts +156 -0
- package/src/spec/dspark/data.ts +201 -0
- package/src/spec/dspark/generate-dflash.ts +193 -0
- package/src/spec/dspark/generate.ts +290 -0
- package/src/spec/dspark/loss.ts +213 -0
- package/src/spec/dspark/module-dflash.ts +361 -0
- package/src/spec/dspark/module.ts +540 -0
- package/src/spec/dspark/sample.ts +112 -0
- package/src/spec/generate.ts +40 -19
- package/src/ssd-cache.ts +213 -0
- package/src/status-page.html +1 -1
- package/src/tokenizer.ts +7 -0
- package/src/train/flash-cce.ts +81 -23
- package/src/train/fuse.ts +243 -0
- package/src/train/index.ts +3 -0
- package/src/train/job.ts +8 -0
- package/src/train/loss.ts +341 -40
- package/src/train/prefix-shared.ts +62 -11
- package/src/train/segmented.ts +215 -55
- package/src/train/trainer.ts +112 -38
- package/src/web/skills/memory/SKILL.md +40 -17
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# THE DREAMING — HANDOFF (2026-06-28)
|
|
2
|
+
|
|
3
|
+
Live handoff for the local personal-wiki memory system (`src/memory/`). A fresh
|
|
4
|
+
session can resume from this doc. **Companion docs:** `research-journal.md` (dated
|
|
5
|
+
findings), `docs/design/memory-inference-path.md` (the in-progress templating/batching
|
|
6
|
+
rework), and the per-phase `p*-judge.md` reports.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## TL;DR — where we are
|
|
11
|
+
|
|
12
|
+
The Dreaming turns conversations → chunks → entities → **subject articles** →
|
|
13
|
+
cross-linked, self-healing personal wiki. It **works end-to-end on real data.**
|
|
14
|
+
|
|
15
|
+
- **Full-corpus import RESUMED from cursor 720/2096** into `~/.mlx-bun/wiki-full`, on the
|
|
16
|
+
corrected templating, batching off (serial, ~50h).
|
|
17
|
+
- **Committed + merged to `main`** (the Dreaming pipeline + inference-path rework). tsc 0.
|
|
18
|
+
- Templating fix **VERIFIED live** on real convs (bare prompt + a 40-msg conv → valid chunks).
|
|
19
|
+
|
|
20
|
+
## Resume the import
|
|
21
|
+
```
|
|
22
|
+
# resumable driver; continues from cursor 720. Writes to ~/.mlx-bun/wiki-full (NOT the
|
|
23
|
+
# real vault ~/.mlx-bun/wiki). ~25 min / 20-conv batch, ~50h total, SERIAL.
|
|
24
|
+
bun scripts/experiments/dreaming-full-run.ts # resume (clean-slate guarded by an init flag)
|
|
25
|
+
# state files: ~/.mlx-bun/full-run-cursor.txt, ~/.mlx-bun/full-run-initialized, ~/.mlx-bun/full-run.log
|
|
26
|
+
# after the import finishes: reindex, then connect the graph:
|
|
27
|
+
mlx-bun memory link
|
|
28
|
+
```
|
|
29
|
+
**Gotcha:** background bash + detached processes get **reaped across turns** in this
|
|
30
|
+
harness. Drive long GPU runs as foreground bounded batches, or `nohup … & disown` (still
|
|
31
|
+
iffy). The pipeline is resumable, so just re-launch to continue.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Architecture (as-built, after this session's corrections)
|
|
36
|
+
|
|
37
|
+
**Staged, chronological, resumable pipeline** (`src/memory/stages.ts`). Each stage is an
|
|
38
|
+
independent DB-state-keyed worker, ordered `updated_at ASC` (chronological), resumable
|
|
39
|
+
(skips done work). CLI: `mlx-bun memory segment|extract|route|synthesize-stage|link` (run
|
|
40
|
+
separately/concurrently) — and `mlx-bun memory synthesize` runs the full DAG.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
ingest → SEGMENT (our e4b-chunk-300 chunker) → EXTRACT (entities) → ROUTE (subject-based,
|
|
44
|
+
surface-everything) → CREATE/PATCH (per-section bounded synthesis; self-healing) →
|
|
45
|
+
RECONCILE (infobox-ground-truth consistency) → LINK (cross-link) → WIKIFY (editorial) → commit
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- **Vault = truth** (markdown files in `articles/`); **DB = derived cache** (`reindex`
|
|
49
|
+
rebuilds it). The article FILES are the real artifacts. The `entities.article_stem`
|
|
50
|
+
column being unset mid-run is cosmetic (file-presence is the source of truth).
|
|
51
|
+
- **Vaults:** `~/.mlx-bun/wiki` (the REAL vault — untouched), `~/.mlx-bun/wiki-full`
|
|
52
|
+
(import target), `wiki-smoke|slice|pattern|pattern2|link-test` (scratch).
|
|
53
|
+
- **Model:** ONE base **Gemma-4-e4b** (`SNAPSHOT_E4B`). **Only ONE adapter trained so far:
|
|
54
|
+
`e4b-chunk-300`** (the chunker), symlinked `~/.cache/mlx-bun/adapters/memory-chunk`.
|
|
55
|
+
`callLocal(stage,…)` picks `memory-<stage>` adapter iff it exists, else base.
|
|
56
|
+
- **Lucien is a READ-ONLY oracle/data-source** (`~/Code/lucien/.lucien/lucien.db` opened
|
|
57
|
+
readonly; `~/Dreaming`). We reuse NONE of its derived chunks/buckets — only the raw
|
|
58
|
+
conversation text (≡ a JSONL export / scraper). Never write there.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## What we LEARNED / CORRECTED this session (load-bearing — don't re-derive)
|
|
63
|
+
|
|
64
|
+
1. **NO notability/ownership filter.** Surface everything; notable = "anything that recurs
|
|
65
|
+
in your thinking" (Lucien `Editorial_Guidelines.md`). The plan's "owned/decided/≥3
|
|
66
|
+
chunks → PARK as trivia" was **fabricated by a prior agent and ripped out.** ROUTE now:
|
|
67
|
+
surface everything, strongly prefer an existing article, mint a new one only for a
|
|
68
|
+
substantive/recurring subject, `_captured` bucket (searchable) for the rest — **nothing
|
|
69
|
+
dropped.**
|
|
70
|
+
2. **Subject-based articles = the one deliberate improvement over Lucien** (which drifted
|
|
71
|
+
into `X_and_Y` topic-bins). Verified: frameworks (Kaizen, TPS, LessWrong, Free energy
|
|
72
|
+
principle) get good articles; coverage resolves (`resolve("Kaizen")` → article).
|
|
73
|
+
3. **Our chunker must be used.** The pipeline's `segment` was a no-op reusing Lucien's
|
|
74
|
+
chunks; fixed — `e4b-chunk-300` segments the raw conversations (better, topic-coherent).
|
|
75
|
+
4. **Chronological ordering.** Was `ORDER BY id` (= conv UUID, random); fixed to
|
|
76
|
+
`updated_at ASC` everywhere. Load-bearing for self-healing.
|
|
77
|
+
5. **Self-healing.** A later-dated correction flips the LEAD + INFOBOX + every body section
|
|
78
|
+
to the latest value; KEEPS the trajectory in a `## History` section **only for the
|
|
79
|
+
USER's evolving positions** — an AI *factual error* is silently overwritten (no
|
|
80
|
+
history). Date-aware; `reconcile.ts` is the consistency authority (infobox = ground
|
|
81
|
+
truth). Proven via a timestamp-swap demo (`scripts/experiments/dreaming-selfheal-demo.ts`).
|
|
82
|
+
6. **Parroting (recurred 5×).** The small model copies ANY concrete example value from
|
|
83
|
+
prompts/Meta pages into unrelated articles (phantom S5IIX, "Anamorphic Video", etc.).
|
|
84
|
+
**ALL prompts + Meta pages must be SCHEMATIC** (no real names/specs/dates). Purged;
|
|
85
|
+
defensive strips added. Keep this rule for any new prompt.
|
|
86
|
+
7. **Cross-linking is WIKIFY's job, NOT synthesis** (synthesis updates ONE article, can't
|
|
87
|
+
know others). Built a dedicated `link` stage (`crosslink.ts`): mention-based (prose
|
|
88
|
+
names another article → `[[link]]`) + co-occurrence (shared folded chunks → See also).
|
|
89
|
+
Result on a 587-article snapshot: See-also 18%→96%, resolved edges 309→**7026 (22.7×)**.
|
|
90
|
+
Idempotent; fence-fix handles malformed input.
|
|
91
|
+
8. **Metrics.** Do NOT measure articles-per-conversation (there is no conv→article link).
|
|
92
|
+
Measure **topic aggregation** (e.g. `El_Salvador` ← 30 conversations → 1 article).
|
|
93
|
+
Quality is judged by a **CLOUD JUDGE on real output**, never Lucien bucket-F1 (that's the
|
|
94
|
+
bin taxonomy we replace).
|
|
95
|
+
9. **Inference path (IN PROGRESS — see `docs/design/memory-inference-path.md`):**
|
|
96
|
+
- **Template mismatch (fixed in working tree):** the chunk adapter was SFT'd with a
|
|
97
|
+
**system role** (Gemma-4 renders `<|turn>system…<turn|>` distinctly), but inference
|
|
98
|
+
dropped it (one user message). `callLocal` now passes `{system, user}` matching
|
|
99
|
+
training; the chunk stage uses `CHUNK_SYSTEM` (its exact trained system prompt). Also
|
|
100
|
+
noted: the live `CHUNK_PROMPT` drifted from training (only 2 of 8 Meta pages; abstracted
|
|
101
|
+
examples) — adapter still generalizes, so quality delta is **modest**.
|
|
102
|
+
- **Batching = DEAD END.** Measured ~**1.7× SLOWER** (warm, uniform: 0.607 vs 0.357
|
|
103
|
+
s/chunk). The `BatchScheduler` pads heterogeneous prefills and doesn't amortize
|
|
104
|
+
weight-loads. Default OFF (`MLX_BUN_MEMORY_BATCH=1`). Import is genuinely ~50h serial;
|
|
105
|
+
batching is NOT the lever (a *better* batched-decode that amortizes weights could help
|
|
106
|
+
in principle, but that's a real perf project, not worth it for a one-time import).
|
|
107
|
+
- **Load-once / persistent server = the REAL efficiency win, for DAILY use.** Each CLI
|
|
108
|
+
invocation today reloads the model + pays warmup; routing memory generation through the
|
|
109
|
+
**resident server** (model loaded once) kills that. Within the single-process import
|
|
110
|
+
the model is already loaded once, so it doesn't speed the import.
|
|
111
|
+
|
|
112
|
+
## Product framing (from the user)
|
|
113
|
+
- **Daily local conversations (pi sessions) folding in is the product** — watermark-gated
|
|
114
|
+
ingest, minutes/day, self-healing. The 4-year Claude/ChatGPT import is a one-time
|
|
115
|
+
**onboarding feature + stress test**. Throughput only matters for the import.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## NEXT STEPS (prioritized)
|
|
120
|
+
|
|
121
|
+
1. **Finish the inference-path rework.** Templating fix is in the working tree (verify it
|
|
122
|
+
end-to-end). **Wire memory generation through the persistent server (load-once)** — the
|
|
123
|
+
user's actual ask — keeping a no-server fallback; default batching OFF. Verify the chunk
|
|
124
|
+
stage decodes on-distribution (system role present).
|
|
125
|
+
2. **Import is RUNNING** (resumed from 720, serial, corrected templating). Just let it finish.
|
|
126
|
+
Re-segmenting the first 720 is **low-urgency** (old chunks were valid).
|
|
127
|
+
3. **After import:** `reindex` → `mlx-bun memory link` → browse `wiki-full` in Obsidian;
|
|
128
|
+
cloud-judge a broad, diverse sample (not just frameworks/gear).
|
|
129
|
+
4. **Promote to the real vault** when satisfied: point `~/.mlx-bun/wiki` at the bootstrapped
|
|
130
|
+
content; wire the **nightly daily fold-in** from pi sessions (`schedule.ts` exists).
|
|
131
|
+
5. **Open quality items** (low priority): ~<1% articles leak a prompt fragment; some leads
|
|
132
|
+
run on; the `owned/used/chosen` framing in `Article_Conventions` lead spec can put
|
|
133
|
+
`owned: yes` on abstract concepts (reframe).
|
|
134
|
+
6. **Commit when ready** — everything is uncommitted; the user has not asked to commit.
|
|
135
|
+
|
|
136
|
+
## Gotchas / facts
|
|
137
|
+
- `bunx tsc` sometimes can't resolve typescript in this checkout; use global `tsc`. Repo = 0 errors.
|
|
138
|
+
- The `mlx-bun train-watch orpo-e4b-chunk` process is a **stale idle daemon, not training** — GPU is free.
|
|
139
|
+
- e4b training still OOMs on this 32GB M1 Max; P10 adapter training stays USER-ACTION (segmented-backward).
|
|
140
|
+
- The `Reference/` folder in vaults symlinks the mlx-bun repo docs (`setupVault`) — non-portable; fine for now, drop for the real personal vault.
|
|
141
|
+
- Methodology memories: cloud-judge not bucket-F1; Lucien read-only; surface-everything notability.
|