@seanhogg/builderforce-memory-engine 2026.7.12 → 2026.9.27

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 (196) hide show
  1. package/README.md +14 -0
  2. package/dist/bench/adaptation.d.ts +57 -0
  3. package/dist/bench/adaptation.d.ts.map +1 -0
  4. package/dist/bench/adaptation.js +167 -0
  5. package/dist/bench/adaptation.js.map +1 -0
  6. package/dist/bench/harness.d.ts +2 -0
  7. package/dist/bench/harness.d.ts.map +1 -1
  8. package/dist/bench/harness.js +1 -1
  9. package/dist/bench/harness.js.map +1 -1
  10. package/dist/bench/index.d.ts +5 -3
  11. package/dist/bench/index.d.ts.map +1 -1
  12. package/dist/bench/index.js +4 -2
  13. package/dist/bench/index.js.map +1 -1
  14. package/dist/bench/types.d.ts +88 -0
  15. package/dist/bench/types.d.ts.map +1 -1
  16. package/dist/evermind/adapt.d.ts +40 -0
  17. package/dist/evermind/adapt.d.ts.map +1 -0
  18. package/dist/evermind/adapt.js +25 -0
  19. package/dist/evermind/adapt.js.map +1 -0
  20. package/dist/evermind/delta_wire.d.ts +43 -0
  21. package/dist/evermind/delta_wire.d.ts.map +1 -0
  22. package/dist/evermind/delta_wire.js +94 -0
  23. package/dist/evermind/delta_wire.js.map +1 -0
  24. package/dist/evermind/eval.d.ts +31 -0
  25. package/dist/evermind/eval.d.ts.map +1 -0
  26. package/dist/evermind/eval.js +36 -0
  27. package/dist/evermind/eval.js.map +1 -0
  28. package/dist/evermind/index.d.ts +16 -0
  29. package/dist/evermind/index.d.ts.map +1 -0
  30. package/dist/evermind/index.js +11 -0
  31. package/dist/evermind/index.js.map +1 -0
  32. package/dist/evermind/merge.d.ts +21 -0
  33. package/dist/evermind/merge.d.ts.map +1 -0
  34. package/dist/evermind/merge.js +79 -0
  35. package/dist/evermind/merge.js.map +1 -0
  36. package/dist/{moe/moe_package.d.ts → evermind/package.d.ts} +55 -5
  37. package/dist/evermind/package.d.ts.map +1 -0
  38. package/dist/{moe/moe_package.js → evermind/package.js} +118 -19
  39. package/dist/evermind/package.js.map +1 -0
  40. package/dist/import/foreign/adapter.d.ts +59 -0
  41. package/dist/import/foreign/adapter.d.ts.map +1 -0
  42. package/dist/import/foreign/adapter.js +76 -0
  43. package/dist/import/foreign/adapter.js.map +1 -0
  44. package/dist/import/foreign/apply.d.ts +23 -0
  45. package/dist/import/foreign/apply.d.ts.map +1 -0
  46. package/dist/import/foreign/apply.js +43 -0
  47. package/dist/import/foreign/apply.js.map +1 -0
  48. package/dist/import/foreign/codestral_mamba.d.ts +57 -0
  49. package/dist/import/foreign/codestral_mamba.d.ts.map +1 -0
  50. package/dist/import/foreign/codestral_mamba.js +174 -0
  51. package/dist/import/foreign/codestral_mamba.js.map +1 -0
  52. package/dist/import/foreign/falcon_mamba.d.ts +51 -0
  53. package/dist/import/foreign/falcon_mamba.d.ts.map +1 -0
  54. package/dist/import/foreign/falcon_mamba.js +131 -0
  55. package/dist/import/foreign/falcon_mamba.js.map +1 -0
  56. package/dist/import/foreign/index.d.ts +21 -0
  57. package/dist/import/foreign/index.d.ts.map +1 -0
  58. package/dist/import/foreign/index.js +18 -0
  59. package/dist/import/foreign/index.js.map +1 -0
  60. package/dist/import/foreign/plan.d.ts +122 -0
  61. package/dist/import/foreign/plan.d.ts.map +1 -0
  62. package/dist/import/foreign/plan.js +171 -0
  63. package/dist/import/foreign/plan.js.map +1 -0
  64. package/dist/import/foreign/registry.d.ts +35 -0
  65. package/dist/import/foreign/registry.d.ts.map +1 -0
  66. package/dist/import/foreign/registry.js +89 -0
  67. package/dist/import/foreign/registry.js.map +1 -0
  68. package/dist/import/index.d.ts +7 -0
  69. package/dist/import/index.d.ts.map +1 -1
  70. package/dist/import/index.js +7 -0
  71. package/dist/import/index.js.map +1 -1
  72. package/dist/index.d.ts +29 -12
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +24 -9
  75. package/dist/index.js.map +1 -1
  76. package/dist/kernels/selective_scan.d.ts.map +1 -1
  77. package/dist/kernels/selective_scan.js +15 -9
  78. package/dist/kernels/selective_scan.js.map +1 -1
  79. package/dist/kernels/slice.d.ts +26 -0
  80. package/dist/kernels/slice.d.ts.map +1 -0
  81. package/dist/kernels/slice.js +52 -0
  82. package/dist/kernels/slice.js.map +1 -0
  83. package/dist/kernels/weight_update.d.ts.map +1 -1
  84. package/dist/kernels/weight_update.js +30 -4
  85. package/dist/kernels/weight_update.js.map +1 -1
  86. package/dist/lm/evermind_lm.d.ts +180 -4
  87. package/dist/lm/evermind_lm.d.ts.map +1 -1
  88. package/dist/lm/evermind_lm.js +433 -116
  89. package/dist/lm/evermind_lm.js.map +1 -1
  90. package/dist/lm/index.d.ts +8 -2
  91. package/dist/lm/index.d.ts.map +1 -1
  92. package/dist/lm/index.js +6 -1
  93. package/dist/lm/index.js.map +1 -1
  94. package/dist/lm/text_embedder.d.ts +55 -0
  95. package/dist/lm/text_embedder.d.ts.map +1 -0
  96. package/dist/lm/text_embedder.js +62 -0
  97. package/dist/lm/text_embedder.js.map +1 -0
  98. package/dist/model/attention_block.d.ts.map +1 -1
  99. package/dist/model/attention_block.js +9 -5
  100. package/dist/model/attention_block.js.map +1 -1
  101. package/dist/model/mamba1_block.d.ts.map +1 -1
  102. package/dist/model/mamba1_block.js +28 -12
  103. package/dist/model/mamba1_block.js.map +1 -1
  104. package/dist/model/mamba2_block.d.ts.map +1 -1
  105. package/dist/model/mamba2_block.js +14 -9
  106. package/dist/model/mamba2_block.js.map +1 -1
  107. package/dist/model/mamba3_block.d.ts.map +1 -1
  108. package/dist/model/mamba3_block.js +14 -9
  109. package/dist/model/mamba3_block.js.map +1 -1
  110. package/dist/moe/index.d.ts +0 -2
  111. package/dist/moe/index.d.ts.map +1 -1
  112. package/dist/moe/index.js +0 -1
  113. package/dist/moe/index.js.map +1 -1
  114. package/dist/optim/adamw.d.ts +58 -1
  115. package/dist/optim/adamw.d.ts.map +1 -1
  116. package/dist/optim/adamw.js +69 -4
  117. package/dist/optim/adamw.js.map +1 -1
  118. package/dist/tokenizer/bpe.d.ts +28 -0
  119. package/dist/tokenizer/bpe.d.ts.map +1 -1
  120. package/dist/tokenizer/bpe.js +47 -0
  121. package/dist/tokenizer/bpe.js.map +1 -1
  122. package/dist/training/cpu_ops.d.ts +44 -0
  123. package/dist/training/cpu_ops.d.ts.map +1 -0
  124. package/dist/training/cpu_ops.js +111 -0
  125. package/dist/training/cpu_ops.js.map +1 -0
  126. package/dist/training/lora.d.ts +153 -0
  127. package/dist/training/lora.d.ts.map +1 -0
  128. package/dist/training/lora.js +324 -0
  129. package/dist/training/lora.js.map +1 -0
  130. package/dist/training/mamba1_cpu.d.ts +109 -0
  131. package/dist/training/mamba1_cpu.d.ts.map +1 -0
  132. package/dist/training/mamba1_cpu.js +316 -0
  133. package/dist/training/mamba1_cpu.js.map +1 -0
  134. package/dist/training/mixed_precision.d.ts +67 -0
  135. package/dist/training/mixed_precision.d.ts.map +1 -0
  136. package/dist/training/mixed_precision.js +101 -0
  137. package/dist/training/mixed_precision.js.map +1 -0
  138. package/dist/training/model_cpu.d.ts +100 -0
  139. package/dist/training/model_cpu.d.ts.map +1 -0
  140. package/dist/training/model_cpu.js +252 -0
  141. package/dist/training/model_cpu.js.map +1 -0
  142. package/dist/training/trainer.d.ts +156 -16
  143. package/dist/training/trainer.d.ts.map +1 -1
  144. package/dist/training/trainer.js +327 -101
  145. package/dist/training/trainer.js.map +1 -1
  146. package/dist/utils/base64.d.ts +12 -0
  147. package/dist/utils/base64.d.ts.map +1 -0
  148. package/dist/utils/base64.js +27 -0
  149. package/dist/utils/base64.js.map +1 -0
  150. package/package.json +3 -1
  151. package/src/bench/adaptation.ts +180 -0
  152. package/src/bench/harness.ts +1 -1
  153. package/src/bench/index.ts +13 -2
  154. package/src/bench/types.ts +93 -0
  155. package/src/evermind/adapt.ts +61 -0
  156. package/src/evermind/delta_wire.ts +114 -0
  157. package/src/evermind/eval.ts +62 -0
  158. package/src/evermind/index.ts +33 -0
  159. package/src/evermind/merge.ts +106 -0
  160. package/src/{moe/moe_package.ts → evermind/package.ts} +148 -17
  161. package/src/import/foreign/adapter.ts +106 -0
  162. package/src/import/foreign/apply.ts +54 -0
  163. package/src/import/foreign/codestral_mamba.ts +224 -0
  164. package/src/import/foreign/falcon_mamba.ts +173 -0
  165. package/src/import/foreign/index.ts +37 -0
  166. package/src/import/foreign/plan.ts +294 -0
  167. package/src/import/foreign/registry.ts +126 -0
  168. package/src/import/index.ts +30 -0
  169. package/src/index.ts +104 -13
  170. package/src/kernels/selective_scan.ts +15 -9
  171. package/src/kernels/slice.ts +64 -0
  172. package/src/kernels/weight_update.ts +30 -4
  173. package/src/lm/evermind_lm.ts +470 -116
  174. package/src/lm/index.ts +12 -2
  175. package/src/lm/text_embedder.ts +84 -0
  176. package/src/model/attention_block.ts +9 -5
  177. package/src/model/mamba1_block.ts +28 -12
  178. package/src/model/mamba2_block.ts +14 -9
  179. package/src/model/mamba3_block.ts +14 -9
  180. package/src/moe/index.ts +0 -9
  181. package/src/optim/adamw.ts +115 -7
  182. package/src/tokenizer/bpe.ts +55 -0
  183. package/src/training/cpu_ops.ts +127 -0
  184. package/src/training/lora.ts +365 -0
  185. package/src/training/mamba1_cpu.ts +421 -0
  186. package/src/training/mixed_precision.ts +119 -0
  187. package/src/training/model_cpu.ts +360 -0
  188. package/src/training/trainer.ts +397 -154
  189. package/src/utils/base64.ts +28 -0
  190. package/dist/model/mamba_block.d.ts +0 -64
  191. package/dist/model/mamba_block.d.ts.map +0 -1
  192. package/dist/model/mamba_block.js +0 -303
  193. package/dist/model/mamba_block.js.map +0 -1
  194. package/dist/moe/moe_package.d.ts.map +0 -1
  195. package/dist/moe/moe_package.js.map +0 -1
  196. package/src/model/mamba_block.ts +0 -401
@@ -1 +1 @@
1
- {"version":3,"file":"selective_scan.js","sourceRoot":"","sources":["../../src/kernels/selective_scan.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,qEAAqE;AACrE,4EAA4E;AA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M,CAAC,MAAM,4BAA4B,GAAW,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6H7D,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * slice.ts — strided COLUMN slice of a row-major (rows, stride) tensor.
3
+ *
4
+ * Every block in this engine projects into one fused tensor and then splits it:
5
+ * Mamba-1 into (x, z) and (Δ, B, C), Mamba-2/3 into (x, Δ) and (x, B, C),
6
+ * attention into (Q, K, V). `LINEAR_FORWARD_WGSL` writes its output `(M, N)`
7
+ * ROW-major, so each of those parts is a contiguous range of COLUMNS **within
8
+ * every row** — not a contiguous range of the buffer.
9
+ *
10
+ * Splitting them with `copyBufferToBuffer` therefore took whole ROWS instead: it
11
+ * is only the right answer when `M == 1` (batch × seq_len), and for any real
12
+ * sequence it silently handed the block the wrong tensor. This kernel is the one
13
+ * correct implementation; every block uses it.
14
+ */
15
+ export declare const COL_SLICE_WGSL: string;
16
+ /** Entry point name of {@link COL_SLICE_WGSL}. */
17
+ export declare const COL_SLICE_ENTRY = "col_slice";
18
+ /**
19
+ * `dst[r, 0..width) = src[r, offset..offset+width)` for every row.
20
+ *
21
+ * @param pipeline a pipeline built from {@link COL_SLICE_WGSL} / {@link COL_SLICE_ENTRY}
22
+ * @param rows batch * seqLen
23
+ * @param stride source row width (the fused projection's output features)
24
+ */
25
+ export declare function dispatchColumnSlice(device: GPUDevice, pipeline: GPUComputePipeline, src: GPUBuffer, dst: GPUBuffer, rows: number, stride: number, offset: number, width: number): void;
26
+ //# sourceMappingURL=slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../../src/kernels/slice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,eAAO,MAAM,cAAc,EAAE,MAoB5B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,kBAAkB,EAC5B,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACd,IAAI,CAKN"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * slice.ts — strided COLUMN slice of a row-major (rows, stride) tensor.
3
+ *
4
+ * Every block in this engine projects into one fused tensor and then splits it:
5
+ * Mamba-1 into (x, z) and (Δ, B, C), Mamba-2/3 into (x, Δ) and (x, B, C),
6
+ * attention into (Q, K, V). `LINEAR_FORWARD_WGSL` writes its output `(M, N)`
7
+ * ROW-major, so each of those parts is a contiguous range of COLUMNS **within
8
+ * every row** — not a contiguous range of the buffer.
9
+ *
10
+ * Splitting them with `copyBufferToBuffer` therefore took whole ROWS instead: it
11
+ * is only the right answer when `M == 1` (batch × seq_len), and for any real
12
+ * sequence it silently handed the block the wrong tensor. This kernel is the one
13
+ * correct implementation; every block uses it.
14
+ */
15
+ import { createBindGroup, createUniformBuffer, dispatchKernel, cdiv } from '../utils/gpu_utils.js';
16
+ export const COL_SLICE_WGSL = /* wgsl */ `
17
+ struct SliceParams {
18
+ rows : u32,
19
+ stride : u32, // source row width
20
+ offset : u32, // first column to take
21
+ width : u32, // number of columns to take
22
+ };
23
+ @group(0) @binding(0) var<uniform> p : SliceParams;
24
+ @group(0) @binding(1) var<storage, read> src : array<f32>;
25
+ @group(0) @binding(2) var<storage, read_write> dst : array<f32>;
26
+
27
+ // Dispatch: (ceil(rows * width / 256), 1, 1)
28
+ @compute @workgroup_size(256)
29
+ fn col_slice(@builtin(global_invocation_id) gid: vec3<u32>) {
30
+ let i = gid.x;
31
+ if (i >= p.rows * p.width) { return; }
32
+ let r = i / p.width;
33
+ let c = i % p.width;
34
+ dst[i] = src[r * p.stride + p.offset + c];
35
+ }
36
+ `;
37
+ /** Entry point name of {@link COL_SLICE_WGSL}. */
38
+ export const COL_SLICE_ENTRY = 'col_slice';
39
+ /**
40
+ * `dst[r, 0..width) = src[r, offset..offset+width)` for every row.
41
+ *
42
+ * @param pipeline a pipeline built from {@link COL_SLICE_WGSL} / {@link COL_SLICE_ENTRY}
43
+ * @param rows batch * seqLen
44
+ * @param stride source row width (the fused projection's output features)
45
+ */
46
+ export function dispatchColumnSlice(device, pipeline, src, dst, rows, stride, offset, width) {
47
+ const pBuf = createUniformBuffer(device, new Uint32Array([rows, stride, offset, width]).buffer);
48
+ const bg = createBindGroup(device, pipeline, [pBuf, src, dst]);
49
+ dispatchKernel(device, pipeline, bg, [cdiv(rows * width, 256), 1, 1]);
50
+ pBuf.destroy();
51
+ }
52
+ //# sourceMappingURL=slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice.js","sourceRoot":"","sources":["../../src/kernels/slice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEnG,MAAM,CAAC,MAAM,cAAc,GAAW,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;CAoB/C,CAAC;AAEF,kDAAkD;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAC/B,MAAiB,EACjB,QAA4B,EAC5B,GAAc,EACd,GAAc,EACd,IAAY,EACZ,MAAc,EACd,MAAc,EACd,KAAa;IAEb,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAChG,MAAM,EAAE,GAAG,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/D,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"weight_update.d.ts","sourceRoot":"","sources":["../../src/kernels/weight_update.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,EAAE,MAmEhC,CAAC;AAIF,eAAO,MAAM,cAAc,EAAE,MAyD5B,CAAC"}
1
+ {"version":3,"file":"weight_update.d.ts","sourceRoot":"","sources":["../../src/kernels/weight_update.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,EAAE,MAmEhC,CAAC;AAkBF,eAAO,MAAM,cAAc,EAAE,MAqE5B,CAAC"}
@@ -77,6 +77,20 @@ fn adamw_update(
77
77
  `;
78
78
  // Gradient clipping kernel – clips global gradient norm to max_norm.
79
79
  // Run before weight updates. Two-pass: first compute squared norm, then scale.
80
+ //
81
+ // The accumulator is a REAL atomic. It used to be a plain `array<f32>` written as
82
+ // `norm_sq[0] = norm_sq[0] + local_sq[0]` by the lane-0 invocation of every
83
+ // workgroup — a read-modify-write with no synchronisation, so with more than one
84
+ // workgroup (i.e. any tensor above 256 elements) concurrent workgroups lost each
85
+ // other's contributions and the norm came out too SMALL, under-clipping exactly
86
+ // when clipping matters most. WGSL has no `atomic<f32>`, so the accumulator is an
87
+ // `atomic<u32>` holding the f32 bit pattern and updated with a
88
+ // compare-exchange loop — the standard portable float-atomic-add.
89
+ //
90
+ // Summation ORDER across workgroups is not deterministic (floating-point addition
91
+ // is not associative), so the norm can differ in the last ulp or two between runs.
92
+ // That is fine for a clip threshold and is the accepted trade for correctness;
93
+ // nothing downstream depends on a bit-exact norm.
80
94
  export const GRAD_CLIP_WGSL = /* wgsl */ `
81
95
 
82
96
  struct ClipParams {
@@ -86,10 +100,23 @@ struct ClipParams {
86
100
 
87
101
  @group(0) @binding(0) var<uniform> clip_p : ClipParams;
88
102
  @group(0) @binding(1) var<storage, read_write> grad : array<f32>;
89
- @group(0) @binding(2) var<storage, read_write> norm_sq : array<f32>; // size 1, atomic accumulator
103
+ // size 1 – the f32 bit pattern of the accumulated sum of squares, updated
104
+ // atomically. Zero-initialise it by writing 0.0f (bit pattern 0x00000000).
105
+ @group(0) @binding(2) var<storage, read_write> norm_sq : array<atomic<u32>>;
90
106
 
91
107
  var<workgroup> local_sq : array<f32, 256>;
92
108
 
109
+ // Portable atomic add on an f32 stored as its u32 bit pattern.
110
+ fn atomic_add_f32(value: f32) {
111
+ var old_bits : u32 = atomicLoad(&norm_sq[0]);
112
+ loop {
113
+ let new_bits = bitcast<u32>(bitcast<f32>(old_bits) + value);
114
+ let res = atomicCompareExchangeWeak(&norm_sq[0], old_bits, new_bits);
115
+ if (res.exchanged) { break; }
116
+ old_bits = res.old_value;
117
+ }
118
+ }
119
+
93
120
  // Pass 1: reduce sum of squares into norm_sq[0]
94
121
  @compute @workgroup_size(256, 1, 1)
95
122
  fn grad_norm_reduce(
@@ -115,8 +142,7 @@ fn grad_norm_reduce(
115
142
  }
116
143
 
117
144
  if (lid == 0u) {
118
- // Non-atomic accumulation (single workgroup assumption for small models)
119
- norm_sq[0] = norm_sq[0] + local_sq[0];
145
+ atomic_add_f32(local_sq[0]);
120
146
  }
121
147
  }
122
148
 
@@ -128,7 +154,7 @@ fn grad_clip_scale(
128
154
  let i = gid.x;
129
155
  if (i >= clip_p.num_elements) { return; }
130
156
 
131
- let ns = norm_sq[0];
157
+ let ns = bitcast<f32>(atomicLoad(&norm_sq[0]));
132
158
  if (ns > clip_p.max_norm_sq) {
133
159
  let scale = sqrt(clip_p.max_norm_sq / ns);
134
160
  grad[i] = grad[i] * scale;
@@ -1 +1 @@
1
- {"version":3,"file":"weight_update.js","sourceRoot":"","sources":["../../src/kernels/weight_update.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,sDAAsD;AACtD,EAAE;AACF,qBAAqB;AACrB,8CAA8C;AAC9C,gDAAgD;AAChD,gCAAgC;AAChC,gCAAgC;AAChC,uFAAuF;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAW,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEnD,CAAC;AAEF,qEAAqE;AACrE,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAW,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyD/C,CAAC"}
1
+ {"version":3,"file":"weight_update.js","sourceRoot":"","sources":["../../src/kernels/weight_update.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,sDAAsD;AACtD,EAAE;AACF,qBAAqB;AACrB,8CAA8C;AAC9C,gDAAgD;AAChD,gCAAgC;AAChC,gCAAgC;AAChC,uFAAuF;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAW,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEnD,CAAC;AAEF,qEAAqE;AACrE,gFAAgF;AAChF,EAAE;AACF,kFAAkF;AAClF,4EAA4E;AAC5E,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,kFAAkF;AAClF,+DAA+D;AAC/D,kEAAkE;AAClE,EAAE;AACF,kFAAkF;AAClF,mFAAmF;AACnF,+EAA+E;AAC/E,kDAAkD;AAClD,MAAM,CAAC,MAAM,cAAc,GAAW,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqE/C,CAAC"}
@@ -21,6 +21,7 @@
21
21
  * acceleration with the same shapes.
22
22
  */
23
23
  import { type AdamWOptions } from "../optim/adamw.js";
24
+ import { DynamicLossScaler, type LossScalerOptions } from "../training/mixed_precision.js";
24
25
  export interface EvermindLMConfig {
25
26
  /** Vocabulary size (the only required field; everything else has a default). */
26
27
  vocabSize: number;
@@ -81,8 +82,34 @@ export interface LMGenerateOptions {
81
82
  /** Stop generating when this token id is produced. */
82
83
  stopToken?: number;
83
84
  }
85
+ /**
86
+ * Incremental decode state — everything a continuation needs from the prefix.
87
+ *
88
+ * The model's only cross-position dependency is the depthwise causal conv, whose
89
+ * receptive field is `convKernel` positions, so the entire "KV cache" is the
90
+ * trailing `convKernel - 1` normalised conv inputs per layer. That makes an exact
91
+ * prefix cache cheap: process a prompt once, then extend it with each candidate
92
+ * continuation for the cost of the candidate alone.
93
+ */
94
+ export interface EvermindLMDecodeState {
95
+ /** [layer][slot] the trailing `convKernel - 1` RMSNormed conv inputs, oldest first. */
96
+ convWindow: Float32Array[][];
97
+ /** Positions consumed so far. */
98
+ length: number;
99
+ /** Logits at the LAST consumed position — what predicts the next token. */
100
+ lastLogits: Float32Array | null;
101
+ }
84
102
  export declare class EvermindLM {
85
103
  readonly config: Required<Omit<EvermindLMConfig, "seed">>;
104
+ /**
105
+ * Token-positions pushed through a block since the last {@link resetStats}.
106
+ *
107
+ * The cost metric that matters for the tool-calling path: scoring N candidate
108
+ * tool names used to replay the WHOLE prompt N times, so this counted
109
+ * N x (prompt + candidate) x layers. With {@link stepDecode} the prompt is paid
110
+ * for once. Exposed so a benchmark can assert the saving rather than assume it.
111
+ */
112
+ private _positionsEvaluated;
86
113
  /** Tied token embedding / output head: vocabSize × dModel (row-major). */
87
114
  emb: Float32Array;
88
115
  private gEmb;
@@ -97,17 +124,124 @@ export declare class EvermindLM {
97
124
  /** Per-layer channel mixer. */
98
125
  private readonly moe;
99
126
  constructor(config: EvermindLMConfig);
127
+ /** Embed a token sequence into per-position channel vectors. */
128
+ private _embed;
129
+ /**
130
+ * One (conv + MoE) block: pre-norm → depthwise causal conv → residual, then
131
+ * pre-norm → MoE channel mixer → residual. Returns the block output and the
132
+ * activation cache its backward needs. Isolating this is what lets
133
+ * {@link lossAndBackwardCheckpointed} recompute a layer's activations on demand
134
+ * instead of retaining every layer's cache at once.
135
+ */
136
+ private _forwardLayer;
137
+ /**
138
+ * ONE position through one (conv + MoE) block, given the trailing conv window.
139
+ *
140
+ * The single place the block's maths lives: the batch path
141
+ * ({@link _forwardLayer}, which needs the full activation cache for backward)
142
+ * and the incremental path ({@link stepDecode}, which needs none of it) both
143
+ * run this, so they cannot drift apart. `window` holds the previous
144
+ * `convKernel - 1` RMSNormed conv inputs, OLDEST FIRST, and is advanced in
145
+ * place — a shorter window is exactly the causal zero-padding at the start of
146
+ * a sequence.
147
+ */
148
+ private _stepLayerPosition;
149
+ /** One token's embedding row (a copy — callers write into it). */
150
+ private _embedOne;
151
+ /** Tied output head: logits_t[v] = x_t · emb[v]. */
152
+ private _head;
100
153
  /** Run the model over a token sequence; returns per-position logits + a cache. */
101
154
  forward(tokens: number[]): {
102
155
  logits: Float32Array[];
103
156
  cache: ForwardCache;
104
157
  };
158
+ /**
159
+ * Produces a single fixed-length embedding vector for a token sequence — the
160
+ * CPU counterpart of `HybridMambaModel.embed()`, to the same contract.
161
+ *
162
+ * Runs the full block stack and takes the final hidden state — i.e. exactly the
163
+ * state the tied LM head consumes in {@link forward} — then mean-pools across
164
+ * sequence positions and L2-normalises. The result has length `dModel`, so
165
+ * cosine similarity between two embeddings reduces to a dot product.
166
+ *
167
+ * Like the GPU path it skips the (expensive) head projection: it only needs the
168
+ * `dModel`-wide hidden state, not `vocabSize` logits. Unlike the GPU path it
169
+ * needs no WebGPU device at all, which is what lets a headless host (the stdio
170
+ * MCP server) rank recall by SSM embedding instead of word overlap.
171
+ *
172
+ * Streamed one position at a time through the SHARED block implementation
173
+ * ({@link _stepLayerPosition}, the same routine {@link forward} and
174
+ * {@link stepDecode} run), so it can never drift from them and it retains no
175
+ * per-position activation cache.
176
+ *
177
+ * The embedding reflects whatever the model currently knows — an untrained
178
+ * model behaves like a random projection of the token embeddings (still
179
+ * lexically discriminative), and the representation sharpens as the model is
180
+ * adapted/distilled.
181
+ */
182
+ embed(tokenIds: number[] | Uint32Array): Float32Array;
183
+ /** Text-level embedding: encode with `codec`, then {@link embed}. */
184
+ embedText(text: string, codec: TextCodec): Float32Array;
185
+ /**
186
+ * Head + tied-embedding gradient. Accumulates dL/d(head→emb) into gEmb and
187
+ * returns the mean next-token loss plus dL/d(finalX). Shared by the full and
188
+ * checkpointed backward paths so the head maths lives in one place.
189
+ */
190
+ private _headBackward;
191
+ /**
192
+ * Backward through one (conv + MoE) block given dL/d(block output) and the
193
+ * block's activation cache. Accumulates conv/norm/MoE gradients and returns
194
+ * dL/d(block input). The inverse of {@link _forwardLayer}.
195
+ */
196
+ private _backwardLayer;
197
+ /** Embedding lookup: dL/d(layer-0 input) flows into the row for each token. */
198
+ private _embedBackward;
105
199
  /**
106
200
  * Next-token cross-entropy over the sequence (predict tokens[t+1] from
107
201
  * position t), accumulating exact gradients. Returns the mean loss. Call
108
202
  * {@link zeroGrad} before and an optimiser step after.
109
203
  */
110
204
  lossAndBackward(tokens: number[]): number;
205
+ /**
206
+ * Activation-checkpointed backward — numerically identical gradients to
207
+ * {@link lossAndBackward}, but retains only the per-LAYER inputs during the
208
+ * forward instead of every layer's full activation cache. Each layer's
209
+ * activations are RECOMPUTED (a cheap extra forward) when its backward runs,
210
+ * so peak activation memory is one layer's cache, not all of them. This is the
211
+ * memory-for-compute trade the cookbook pairs with FSDP to fit longer
212
+ * sequences / bigger models on a constrained device.
213
+ */
214
+ lossAndBackwardCheckpointed(tokens: number[]): number;
215
+ /** Positions pushed through a block since the last {@link resetStats}. */
216
+ get positionsEvaluated(): number;
217
+ resetStats(): void;
218
+ /** An empty decode state — the start of a sequence. */
219
+ newDecodeState(): EvermindLMDecodeState;
220
+ /** Deep copy, so one prefix state can seed many independent continuations. */
221
+ cloneDecodeState(state: EvermindLMDecodeState): EvermindLMDecodeState;
222
+ /**
223
+ * Consume `tokens` from `state`, returning the per-position logits and the
224
+ * ADVANCED state. `state` is not mutated — pass {@link cloneDecodeState} output
225
+ * or a fresh state; this clones internally so the caller's prefix stays reusable.
226
+ *
227
+ * Numerically identical to {@link forward} over the concatenated sequence: the
228
+ * shared {@link _stepLayerPosition} is the only implementation of the block.
229
+ */
230
+ stepDecode(state: EvermindLMDecodeState, tokens: number[]): {
231
+ logits: Float32Array[];
232
+ state: EvermindLMDecodeState;
233
+ };
234
+ /** Run a prompt once and keep the state, so continuations are cheap. */
235
+ prefixState(tokens: number[]): EvermindLMDecodeState;
236
+ /**
237
+ * Mean log-probability the model assigns to `continuation` following a cached
238
+ * prefix — the tool-decision vote, without replaying the prompt.
239
+ *
240
+ * Returns `-Infinity` for an empty continuation, and requires a prefix with at
241
+ * least one position (there must be a position to predict the first
242
+ * continuation token FROM).
243
+ */
244
+ scoreContinuation(prefix: EvermindLMDecodeState, continuation: number[]): number;
111
245
  /**
112
246
  * Text-level generation: encode the prompt, generate, decode. `codec` is any
113
247
  * tokenizer exposing encode/decode (the engine's `BPETokenizer` satisfies it),
@@ -115,7 +249,13 @@ export declare class EvermindLM {
115
249
  * `vocabSize` must match the codec's vocabulary.
116
250
  */
117
251
  generateText(prompt: string, codec: TextCodec, opts: LMGenerateOptions): string;
118
- /** Greedy / temperature-sampled autoregressive generation. Returns NEW token ids. */
252
+ /**
253
+ * Greedy / temperature-sampled autoregressive generation. Returns NEW token ids.
254
+ *
255
+ * Carries an incremental decode state, so the prompt is processed ONCE and each
256
+ * new token costs one position. The previous implementation re-ran the whole
257
+ * sequence per token, making generation quadratic in the prompt length.
258
+ */
119
259
  generate(prompt: number[], opts: LMGenerateOptions): number[];
120
260
  /** All trainable parameters as {data} (AdamW-compatible), canonical order. */
121
261
  parameters(): {
@@ -149,16 +289,52 @@ export declare class EvermindLM {
149
289
  /** Reconstruct weights from a base EVL0 checkpoint + a delta (EVM-6). */
150
290
  loadDelta(baseCheckpoint: ArrayBuffer, delta: ArrayBuffer): void;
151
291
  }
292
+ export interface EvermindLMTrainOptions extends AdamWOptions {
293
+ epochs?: number;
294
+ /**
295
+ * Gradient accumulation: average gradients over this many sequences (micro-
296
+ * batches) before each optimiser step, for a larger effective batch on a
297
+ * memory-constrained device. Default 1.
298
+ */
299
+ accumSteps?: number;
300
+ /**
301
+ * Use activation checkpointing (recompute layer activations in backward) to
302
+ * cap peak activation memory. Identical gradients, a little extra compute.
303
+ * Default false.
304
+ */
305
+ checkpoint?: boolean;
306
+ /**
307
+ * Mixed-precision training: fp16-rounded gradients with dynamic loss scaling
308
+ * over fp32 master weights (the model params). Overflowing steps are skipped
309
+ * and the scale backs off. Default false.
310
+ */
311
+ mixedPrecision?: boolean | LossScalerOptions;
312
+ }
152
313
  /** Minimal sequence trainer: AdamW over next-token cross-entropy. */
153
314
  export declare class EvermindLMTrainer {
154
315
  private readonly model;
155
316
  private readonly opts;
156
317
  private readonly adam;
157
- constructor(model: EvermindLM, opts?: AdamWOptions & {
158
- epochs?: number;
159
- });
318
+ private readonly scaler;
319
+ private readonly grads;
320
+ constructor(model: EvermindLM, opts?: EvermindLMTrainOptions);
321
+ /** The dynamic loss scaler (mixed-precision mode only) — exposes scale/overflow stats. */
322
+ get lossScaler(): DynamicLossScaler | null;
323
+ private _backward;
324
+ /** Divide accumulated gradients by `n` (accumulation averaging), in place. */
325
+ private _scaleGrads;
326
+ /** Round accumulated gradients to fp16 precision (mixed-precision simulation), in place. */
327
+ private _fp16Grads;
328
+ /** Multiply accumulated gradients by `s`, in place. */
329
+ private _mulGrads;
160
330
  /** Train on a set of token sequences; returns per-epoch mean loss. */
161
331
  fit(sequences: number[][]): number[];
162
332
  }
333
+ /**
334
+ * Log-probability the model assigned to `id` at a position, from that position's
335
+ * raw logits. Log-softmax computed max-shifted so a long-tail logit cannot
336
+ * overflow `exp`.
337
+ */
338
+ export declare function logProbOfToken(row: Float32Array, id: number): number;
163
339
  export {};
164
340
  //# sourceMappingURL=evermind_lm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"evermind_lm.d.ts","sourceRoot":"","sources":["../../src/lm/evermind_lm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAM7D,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,CAOpF,CAAC;AAEF,eAAO,MAAM,eAAe,aAAa,CAAC;AAG1C,UAAU,YAAY;IACpB,CAAC,EAAE,YAAY,CAAC;IAChB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IACnE,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAC;CACz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