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
package/src/web/skills.ts CHANGED
@@ -13,6 +13,10 @@
13
13
  // the user's personal ~/.pi and project .pi skills, so the chat stays
14
14
  // isolated while still getting our curated set (resource-loader.js:277).
15
15
  //
16
+ // Memory is deliberately gated by vault existence. If memory is not enabled,
17
+ // we do not expose its skill at all; otherwise small local models can fixate on
18
+ // the skill description even when the user asks unrelated things like weather.
19
+ //
16
20
  // To add a skill: drop a folder under ./skills/<name>/SKILL.md, add a text
17
21
  // import for it, and append it to BUNDLED_SKILLS.
18
22
 
@@ -20,6 +24,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
20
24
  import { homedir } from "node:os";
21
25
  import { join } from "node:path";
22
26
  import webResearchMd from "./skills/web-research/SKILL.md" with { type: "text" };
27
+ import memoryMd from "./skills/memory/SKILL.md" with { type: "text" };
23
28
 
24
29
  interface BundledSkill {
25
30
  /** Directory name under the skills root; should match the SKILL.md `name`. */
@@ -30,15 +35,23 @@ interface BundledSkill {
30
35
 
31
36
  const BUNDLED_SKILLS: readonly BundledSkill[] = [
32
37
  { name: "web-research", md: webResearchMd },
38
+ { name: "memory", md: memoryMd },
33
39
  ];
34
40
 
41
+ export interface BundledSkillOptions {
42
+ /** Include the web-research workflow skill. Default false: tool schemas are enough, and small local models can over-apply workflow skills. */
43
+ includeWebResearch?: boolean;
44
+ /** Include the personal-memory skill. Default true for backward compatibility. */
45
+ includeMemory?: boolean;
46
+ }
47
+
35
48
  /** Where the bundled skills are written; also pi's per-session scratch root. */
36
49
  export function bundledSkillsRoot(): string {
37
50
  return join(homedir(), ".mlx-bun", "skills");
38
51
  }
39
52
 
40
53
  /** Memoize: the embedded content can't change within a process run. */
41
- let materialized = false;
54
+ const materialized = new Set<string>();
42
55
 
43
56
  /**
44
57
  * Write the embedded skills to disk (overwriting, so updates propagate) and
@@ -46,14 +59,39 @@ let materialized = false;
46
59
  * pi scans it for per-skill SKILL.md files. Runs its disk writes once per
47
60
  * process even when called per browser connection.
48
61
  */
49
- export function materializeBundledSkills(): string {
62
+ function selectedSkills(opts: BundledSkillOptions = {}): readonly BundledSkill[] {
63
+ const includeMemory = opts.includeMemory ?? true;
64
+ const includeWebResearch = opts.includeWebResearch ?? false;
65
+ return BUNDLED_SKILLS.filter((skill) => {
66
+ if (!includeMemory && skill.name === "memory") return false;
67
+ if (!includeWebResearch && skill.name === "web-research") return false;
68
+ return true;
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Materialize selected bundled skills and return exact skill directories. Use
74
+ * these paths in DefaultResourceLoader.additionalSkillPaths. Returning exact
75
+ * directories (rather than the shared root) prevents an old on-disk memory
76
+ * skill from being discovered when memory is disabled for the current session.
77
+ */
78
+ export function materializeBundledSkillPaths(opts: BundledSkillOptions = {}): string[] {
50
79
  const root = bundledSkillsRoot();
51
- if (materialized) return root;
52
- for (const skill of BUNDLED_SKILLS) {
80
+ const paths: string[] = [];
81
+ for (const skill of selectedSkills(opts)) {
53
82
  const dir = join(root, skill.name);
54
- mkdirSync(dir, { recursive: true });
55
- writeFileSync(join(dir, "SKILL.md"), skill.md);
83
+ if (!materialized.has(skill.name)) {
84
+ mkdirSync(dir, { recursive: true });
85
+ writeFileSync(join(dir, "SKILL.md"), skill.md);
86
+ materialized.add(skill.name);
87
+ }
88
+ paths.push(dir);
56
89
  }
57
- materialized = true;
58
- return root;
90
+ return paths;
91
+ }
92
+
93
+ /** Backward-compatible root materializer for older call sites. Prefer materializeBundledSkillPaths(). */
94
+ export function materializeBundledSkills(): string {
95
+ materializeBundledSkillPaths({ includeMemory: true, includeWebResearch: true });
96
+ return bundledSkillsRoot();
59
97
  }
File without changes