mlx-bun 0.0.8 → 0.0.9
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-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/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/spec-decode-larger-targets.md +229 -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 +262 -0
- package/docs/investigations/dspark-handoff.md +58 -0
- package/docs/investigations/kernel-perf-review-2026-07.md +92 -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.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 +40 -9
- package/docs/reference/training.md +25 -11
- 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 +1029 -86
- 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 +141 -18
- package/src/harness-pi.ts +43 -17
- package/src/index.ts +2 -0
- 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/ffi.ts +3 -0
- package/src/mlx/ops.ts +46 -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 +62 -6
- package/src/model/gemma4.ts +33 -2
- package/src/model/minicpm5.ts +106 -8
- package/src/model/qwen3.ts +276 -0
- 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/quantize/config-writer.ts +1 -1
- package/src/registry.ts +215 -7
- package/src/responses.ts +23 -0
- package/src/sampler.ts +220 -9
- package/src/serve/batch-scheduler.ts +272 -80
- package/src/serve/generation-gateway.ts +86 -18
- package/src/server.ts +612 -49
- 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/status-page.html +1 -1
- package/src/tokenizer.ts +7 -0
- package/src/train/flash-cce.ts +70 -15
- 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 +289 -30
- package/src/train/prefix-shared.ts +33 -5
- package/src/train/segmented.ts +67 -11
- package/src/train/trainer.ts +92 -28
- package/src/web/skills/memory/SKILL.md +40 -17
package/package.json
CHANGED
package/src/anthropic.ts
CHANGED
|
@@ -50,6 +50,18 @@ export interface AnthropicRequest {
|
|
|
50
50
|
top_k?: number;
|
|
51
51
|
stop_sequences?: string[];
|
|
52
52
|
stream?: boolean;
|
|
53
|
+
/** mlx-lm sampler/penalty extensions — not part of the Anthropic protocol,
|
|
54
|
+
* accepted as pass-through extras with the same names as our /v1 chat
|
|
55
|
+
* surface. Anthropic has NO logit_bias, so none is accepted here. */
|
|
56
|
+
min_p?: number;
|
|
57
|
+
xtc_probability?: number;
|
|
58
|
+
xtc_threshold?: number;
|
|
59
|
+
repetition_penalty?: number;
|
|
60
|
+
repetition_context_size?: number;
|
|
61
|
+
presence_penalty?: number;
|
|
62
|
+
presence_context_size?: number;
|
|
63
|
+
frequency_penalty?: number;
|
|
64
|
+
frequency_context_size?: number;
|
|
53
65
|
tools?: Array<{
|
|
54
66
|
name?: string;
|
|
55
67
|
description?: string;
|
|
@@ -167,6 +179,16 @@ export function anthropicToChatBody(body: AnthropicRequest): Record<string, unkn
|
|
|
167
179
|
if (body.top_k != null) oai.top_k = body.top_k;
|
|
168
180
|
if (body.stop_sequences?.length) oai.stop = body.stop_sequences;
|
|
169
181
|
if (body.stream) oai.stream = true;
|
|
182
|
+
// mlx-lm sampler/penalty extensions: straight pass-through (same wire names
|
|
183
|
+
// on the chat surface). No logit_bias — it doesn't exist in this protocol.
|
|
184
|
+
for (const k of [
|
|
185
|
+
"min_p", "xtc_probability", "xtc_threshold",
|
|
186
|
+
"repetition_penalty", "repetition_context_size",
|
|
187
|
+
"presence_penalty", "presence_context_size",
|
|
188
|
+
"frequency_penalty", "frequency_context_size",
|
|
189
|
+
] as const) {
|
|
190
|
+
if (body[k] != null) oai[k] = body[k];
|
|
191
|
+
}
|
|
170
192
|
|
|
171
193
|
// Client tools only (entries with name + input_schema); server-tool
|
|
172
194
|
// types (web_search etc.) have no local meaning and are dropped.
|
|
@@ -89,7 +89,7 @@ button.ghost{background:var(--card);border:1px solid var(--bd);border-radius:8px
|
|
|
89
89
|
<script>
|
|
90
90
|
const ln=Math.log;
|
|
91
91
|
const UMIN=ln(1e-6); // bottom-left / plot floor (matches src/curve-sampler.ts CURVE_UMIN)
|
|
92
|
-
const ENGINE_BASE = location.protocol.startsWith("http") ? location.origin : "http://localhost:
|
|
92
|
+
const ENGINE_BASE = location.protocol.startsWith("http") ? location.origin : "http://localhost:8080";
|
|
93
93
|
// ---- curve state: 5 movable control points, sorted ascending in p_in ----
|
|
94
94
|
function identityPoints(){ return [{x_pct:1e-4,y_pct:1e-4},{x_pct:0.1,y_pct:0.1},{x_pct:1,y_pct:1},{x_pct:9,y_pct:9},{x_pct:100,y_pct:100}]; }
|
|
95
95
|
let C = { space:"logprob", points:identityPoints(), monotonic:true };
|
package/src/chat-template.ts
CHANGED
|
@@ -131,20 +131,38 @@ export class ChatTemplate {
|
|
|
131
131
|
/** True when the model has a switchable reasoning channel we can parse. */
|
|
132
132
|
readonly supportsThinking: boolean;
|
|
133
133
|
|
|
134
|
-
private constructor(
|
|
134
|
+
private constructor(
|
|
135
|
+
source: string,
|
|
136
|
+
bosToken: string | null,
|
|
137
|
+
eosToken: string | null,
|
|
138
|
+
forceNoThinking = false,
|
|
139
|
+
) {
|
|
135
140
|
this.#template = new Template(source);
|
|
136
141
|
this.#bosToken = bosToken;
|
|
137
142
|
this.#eosToken = eosToken;
|
|
138
143
|
const gatesThinking = source.includes("enable_thinking");
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
// `forceNoThinking` suppresses the switchable channel even when the template
|
|
145
|
+
// carries the gemma markers. DiffusionGemma ships the shared gemma-family
|
|
146
|
+
// template (with the `<|channel>thought…<channel|>` reasoning channel), but
|
|
147
|
+
// its non-autoregressive canvas decode cannot reliably emit the `<channel|>`
|
|
148
|
+
// close, so an enabled channel never ends (everything is captured as
|
|
149
|
+
// reasoning, no answer). The OptiQ reference never enables thinking for this
|
|
150
|
+
// model — it always renders the template's `default(false)` pre-closed empty
|
|
151
|
+
// channel and decodes the whole canvas as plain text. We match that.
|
|
152
|
+
this.thinkingFormat = forceNoThinking
|
|
153
|
+
? null
|
|
154
|
+
: gatesThinking && source.includes("<think>")
|
|
155
|
+
? "think-tag"
|
|
156
|
+
: gatesThinking && source.includes("<|channel>")
|
|
157
|
+
? "gemma-channel"
|
|
158
|
+
: null;
|
|
144
159
|
this.supportsThinking = this.thinkingFormat !== null;
|
|
145
160
|
}
|
|
146
161
|
|
|
147
|
-
static async load(
|
|
162
|
+
static async load(
|
|
163
|
+
modelDir: string,
|
|
164
|
+
opts: { disableThinking?: boolean } = {},
|
|
165
|
+
): Promise<ChatTemplate> {
|
|
148
166
|
const config = (await Bun.file(`${modelDir}/tokenizer_config.json`).json()) as Record<string, any>;
|
|
149
167
|
let source: string | undefined = config.chat_template;
|
|
150
168
|
if (!source) {
|