@openfluke/welvet 0.3.0 → 0.75.0
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/LICENSE +200 -200
- package/README.md +64 -353
- package/dist/benchmark_tiling.html +244 -0
- package/dist/benchmark_training.html +249 -0
- package/dist/benchmark_training_comparison.html +230 -0
- package/dist/cabi_verify.html +360 -0
- package/dist/coverage_check.html +298 -0
- package/dist/dna_evo_benchmark.html +420 -0
- package/dist/example.html +283 -0
- package/dist/index.d.ts +152 -31
- package/dist/index.js +170 -60
- package/dist/loader.browser.d.ts +2 -2
- package/dist/loader.browser.js +7 -8
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +12 -25
- package/dist/main.wasm +0 -0
- package/dist/src/index.d.ts +182 -0
- package/dist/src/index.js +207 -0
- package/dist/src/loader.browser.d.ts +5 -0
- package/dist/src/loader.browser.js +24 -0
- package/dist/src/loader.d.ts +5 -0
- package/dist/src/loader.js +26 -0
- package/dist/src/types.d.ts +354 -0
- package/dist/src/types.js +65 -0
- package/dist/tests/benchmark.d.ts +5 -0
- package/dist/tests/benchmark.js +139 -0
- package/dist/tests/benchmark.ts +148 -0
- package/dist/tests/cabi_verify.d.ts +5 -0
- package/dist/tests/cabi_verify.js +181 -0
- package/dist/tests/cabi_verify.ts +192 -0
- package/dist/tests/coverage.ts +113 -0
- package/dist/types.d.ts +326 -169
- package/dist/types.js +63 -2
- package/dist/wasm_exec.js +575 -575
- package/package.json +87 -88
- package/dist/index.browser.d.ts +0 -32
- package/dist/index.browser.js +0 -39
package/dist/index.js
CHANGED
|
@@ -1,110 +1,220 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @openfluke/welvet -
|
|
2
|
+
* @openfluke/welvet — M-POLY-VTD AI Engine
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Isomorphic TypeScript wrapper for the Loom v0.75.0 WASM module.
|
|
5
|
+
* Supports Node.js and browser environments.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { init, createNetwork, DType } from "@openfluke/welvet";
|
|
10
|
+
*
|
|
11
|
+
* await init();
|
|
12
|
+
*
|
|
13
|
+
* const net = createNetwork({
|
|
14
|
+
* layers: [
|
|
15
|
+
* { type: "dense", input_height: 4, output_height: 8 },
|
|
16
|
+
* { type: "dense", input_height: 8, output_height: 2 },
|
|
17
|
+
* ]
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const output = net.sequentialForward(new Float32Array([1, 0, 0, 1]));
|
|
21
|
+
* console.log(output); // Float32Array [...]
|
|
22
|
+
* ```
|
|
6
23
|
*/
|
|
24
|
+
import { DType, LayerType, Activation } from "./types.js";
|
|
7
25
|
import { loadLoomWASMBrowser } from "./loader.browser.js";
|
|
26
|
+
// Re-export all types and constants
|
|
8
27
|
export * from "./types.js";
|
|
9
28
|
export { loadLoomWASMBrowser };
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
29
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
30
|
+
// Initialization
|
|
31
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
14
32
|
/**
|
|
15
|
-
* Initialize WASM
|
|
16
|
-
* Auto-detects
|
|
33
|
+
* Initialize the welvet WASM module.
|
|
34
|
+
* Auto-detects Node.js vs browser environment.
|
|
35
|
+
*
|
|
36
|
+
* @param wasmUrl Optional custom URL for browser WASM loading (default: /dist/main.wasm)
|
|
17
37
|
*/
|
|
18
38
|
export async function init(wasmUrl) {
|
|
19
|
-
// Check for browser environment (needs window and document for loader.browser.ts)
|
|
20
39
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
21
|
-
return
|
|
40
|
+
return loadLoomWASMBrowser(wasmUrl);
|
|
22
41
|
}
|
|
23
|
-
|
|
42
|
+
const mod = await import("./loader.js");
|
|
43
|
+
return mod.loadLoomWASM();
|
|
24
44
|
}
|
|
25
45
|
/**
|
|
26
|
-
* Initialize
|
|
46
|
+
* Initialize explicitly for browser environments.
|
|
47
|
+
* @param wasmUrl Optional custom URL for WASM binary
|
|
27
48
|
*/
|
|
28
49
|
export async function initBrowser(wasmUrl) {
|
|
29
|
-
|
|
50
|
+
return loadLoomWASMBrowser(wasmUrl);
|
|
30
51
|
}
|
|
52
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
53
|
+
// Network Lifecycle
|
|
54
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
31
55
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
56
|
+
* Build a VolumetricNetwork from a JSON configuration object or string.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const net = createNetwork({
|
|
61
|
+
* layers: [
|
|
62
|
+
* { type: "dense", input_height: 784, output_height: 256 },
|
|
63
|
+
* { type: "dense", input_height: 256, output_height: 10, activation: "silu" },
|
|
64
|
+
* ]
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
34
67
|
*/
|
|
35
68
|
export function createNetwork(config) {
|
|
36
|
-
const jsonConfig = typeof config === "string"
|
|
37
|
-
? config
|
|
38
|
-
: JSON.stringify(config);
|
|
69
|
+
const jsonConfig = typeof config === "string" ? config : JSON.stringify(config);
|
|
39
70
|
return createLoomNetwork(jsonConfig);
|
|
40
71
|
}
|
|
41
72
|
/**
|
|
42
|
-
*
|
|
73
|
+
* Build a network from a JSON string.
|
|
43
74
|
*/
|
|
44
|
-
export function
|
|
45
|
-
return
|
|
75
|
+
export function buildNetworkFromJSON(json) {
|
|
76
|
+
return globalThis["BuildNetworkFromJSON"](json);
|
|
46
77
|
}
|
|
78
|
+
/** Alias for buildNetworkFromJSON to match engine symbol */
|
|
79
|
+
export const BuildNetworkFromJSON = buildNetworkFromJSON;
|
|
47
80
|
/**
|
|
48
|
-
*
|
|
81
|
+
* Load a pre-trained network from a SafeTensors file path.
|
|
49
82
|
*/
|
|
50
|
-
export function
|
|
51
|
-
|
|
52
|
-
|
|
83
|
+
export function loadNetwork(path) {
|
|
84
|
+
return loadLoomNetwork(path);
|
|
85
|
+
}
|
|
86
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
87
|
+
// WebGPU
|
|
88
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
89
|
+
/**
|
|
90
|
+
* Initialize WebGPU (browser only).
|
|
91
|
+
* Sets window.webgpuAdapter, window.webgpuDevice, window.webgpuQueue.
|
|
92
|
+
*/
|
|
93
|
+
export async function setupWebGPU() {
|
|
94
|
+
// @ts-ignore — setupWebGPU is injected by the WASM module
|
|
95
|
+
return setupWebGPU();
|
|
96
|
+
}
|
|
97
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
98
|
+
// DNA / Introspection
|
|
99
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
100
|
+
/**
|
|
101
|
+
* Compare the architectural DNA of two networks.
|
|
102
|
+
*
|
|
103
|
+
* @param dnaA JSON string from network.extractDNA()
|
|
104
|
+
* @param dnaB JSON string from network.extractDNA()
|
|
105
|
+
* @returns DNACompareResult
|
|
106
|
+
*/
|
|
107
|
+
export function compareDNA(dnaA, dnaB) {
|
|
108
|
+
return JSON.parse(compareLoomDNA(dnaA, dnaB));
|
|
53
109
|
}
|
|
54
110
|
/**
|
|
55
|
-
*
|
|
111
|
+
* Get the default TargetPropConfig.
|
|
56
112
|
*/
|
|
57
|
-
export function
|
|
58
|
-
|
|
59
|
-
const resJSON = graftNetworks(idsJSON, combineMode);
|
|
60
|
-
return JSON.parse(resJSON);
|
|
113
|
+
export function defaultTargetPropConfig() {
|
|
114
|
+
return JSON.parse(getDefaultTargetPropConfig());
|
|
61
115
|
}
|
|
62
116
|
/**
|
|
63
|
-
*
|
|
117
|
+
* Get the internal parity symbol list from Go.
|
|
118
|
+
* Used for audits and verification.
|
|
64
119
|
*/
|
|
65
|
-
export function
|
|
66
|
-
|
|
67
|
-
|
|
120
|
+
export function getInternalParity() {
|
|
121
|
+
if (typeof getLoomInternalParity === "function") {
|
|
122
|
+
return getLoomInternalParity();
|
|
123
|
+
}
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
/** Global accessor for extractNetworkBlueprint (engine parity) */
|
|
127
|
+
export function ExtractNetworkBlueprint(network, modelID) {
|
|
128
|
+
return network.extractNetworkBlueprint(modelID);
|
|
68
129
|
}
|
|
130
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
131
|
+
// Training Helpers
|
|
132
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
69
133
|
/**
|
|
70
|
-
*
|
|
134
|
+
* Convenience wrapper for network.train() that handles JSON serialization.
|
|
135
|
+
*
|
|
136
|
+
* @param network The network to train
|
|
137
|
+
* @param batches Array of {input, target} training pairs
|
|
138
|
+
* @param epochs Number of training epochs
|
|
139
|
+
* @param lr Learning rate
|
|
71
140
|
*/
|
|
72
|
-
export function
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
141
|
+
export function trainNetwork(network, batches, epochs, lr) {
|
|
142
|
+
const serialized = batches.map((b) => {
|
|
143
|
+
const inp = b.input instanceof Float32Array ? b.input : new Float32Array(b.input);
|
|
144
|
+
const tgt = b.target instanceof Float32Array ? b.target : new Float32Array(b.target);
|
|
145
|
+
const inShape = b.inputShape ?? [1, inp.length];
|
|
146
|
+
const tgtShape = b.targetShape ?? [1, tgt.length];
|
|
147
|
+
return {
|
|
148
|
+
input: { shape: inShape, data: Array.from(inp) },
|
|
149
|
+
target: { shape: tgtShape, data: Array.from(tgt) },
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
return JSON.parse(network.train(JSON.stringify(serialized), epochs, lr));
|
|
153
|
+
}
|
|
154
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
155
|
+
// Evolution / DNA
|
|
156
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
157
|
+
/** Get the default SpliceConfig as a plain object. */
|
|
158
|
+
export function getSpliceConfig() {
|
|
159
|
+
return JSON.parse(globalThis["defaultSpliceConfig"]());
|
|
160
|
+
}
|
|
161
|
+
/** Get the default NEATConfig as a plain object. */
|
|
162
|
+
export function getNEATConfig(dModel) {
|
|
163
|
+
return JSON.parse(globalThis["defaultNEATConfig"](dModel));
|
|
82
164
|
}
|
|
83
165
|
/**
|
|
84
|
-
*
|
|
166
|
+
* Create a NEAT population from a seed network.
|
|
167
|
+
* @param network Seed network (its _id is used)
|
|
168
|
+
* @param size Population size
|
|
169
|
+
* @param cfg NEATConfig object or JSON string (defaults to getNEATConfig(64))
|
|
85
170
|
*/
|
|
86
|
-
export function
|
|
87
|
-
const
|
|
88
|
-
|
|
171
|
+
export function createNEATPopulation(network, size, cfg) {
|
|
172
|
+
const cfgJSON = cfg
|
|
173
|
+
? (typeof cfg === "string" ? cfg : JSON.stringify(cfg))
|
|
174
|
+
: globalThis["defaultNEATConfig"](64);
|
|
175
|
+
return globalThis["createLoomNEATPopulation"](network._id, size, cfgJSON);
|
|
89
176
|
}
|
|
90
177
|
/**
|
|
91
|
-
* Create
|
|
178
|
+
* Create a Transformer wrapper.
|
|
179
|
+
* @param network Network to use as the base
|
|
180
|
+
* @param embeddings Float32Array of embedding weights
|
|
181
|
+
* @param lmHead Float32Array of LM head weights
|
|
182
|
+
* @param finalNorm Float32Array of final norm weights
|
|
92
183
|
*/
|
|
93
|
-
export function
|
|
94
|
-
return
|
|
184
|
+
export function createTransformer(network, embeddings, lmHead, finalNorm) {
|
|
185
|
+
return createLoomTransformer(network._id, embeddings, lmHead, finalNorm);
|
|
95
186
|
}
|
|
96
187
|
/**
|
|
97
|
-
*
|
|
188
|
+
* Save a network to a SafeTensors byte array.
|
|
98
189
|
*/
|
|
190
|
+
export function saveNetwork(network) {
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
return network.saveSafetensors();
|
|
193
|
+
}
|
|
194
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
195
|
+
// Default export
|
|
196
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
99
197
|
export default {
|
|
100
198
|
init,
|
|
101
199
|
initBrowser,
|
|
102
200
|
createNetwork,
|
|
201
|
+
buildNetworkFromJSON,
|
|
103
202
|
loadNetwork,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
203
|
+
saveNetwork,
|
|
204
|
+
setupWebGPU,
|
|
205
|
+
compareDNA,
|
|
206
|
+
defaultTargetPropConfig,
|
|
207
|
+
getInternalParity,
|
|
208
|
+
trainNetwork,
|
|
209
|
+
getSpliceConfig,
|
|
210
|
+
getNEATConfig,
|
|
211
|
+
createNEATPopulation,
|
|
212
|
+
createTransformer,
|
|
213
|
+
// Parity aliases
|
|
214
|
+
BuildNetworkFromJSON,
|
|
215
|
+
ExtractNetworkBlueprint,
|
|
216
|
+
// Re-export constants for convenience
|
|
217
|
+
DType,
|
|
218
|
+
LayerType,
|
|
219
|
+
Activation,
|
|
110
220
|
};
|
package/dist/loader.browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* welvet WASM Browser Loader
|
|
3
|
+
* Loads the Go runtime and WASM module in a browser environment.
|
|
4
4
|
*/
|
|
5
5
|
export declare function loadLoomWASMBrowser(wasmUrl?: string): Promise<void>;
|
package/dist/loader.browser.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* welvet WASM Browser Loader
|
|
3
|
+
* Loads the Go runtime and WASM module in a browser environment.
|
|
4
4
|
*/
|
|
5
5
|
export async function loadLoomWASMBrowser(wasmUrl) {
|
|
6
|
-
//
|
|
7
|
-
if (typeof globalThis
|
|
8
|
-
// Load wasm_exec.js dynamically from /dist/
|
|
6
|
+
// Inject wasm_exec.js if the Go runtime is not yet available
|
|
7
|
+
if (typeof globalThis["Go"] === "undefined") {
|
|
9
8
|
const script = document.createElement("script");
|
|
10
9
|
script.src = "/dist/wasm_exec.js";
|
|
11
10
|
await new Promise((resolve, reject) => {
|
|
@@ -14,12 +13,12 @@ export async function loadLoomWASMBrowser(wasmUrl) {
|
|
|
14
13
|
document.head.appendChild(script);
|
|
15
14
|
});
|
|
16
15
|
}
|
|
17
|
-
const response = await fetch(wasmUrl
|
|
16
|
+
const response = await fetch(wasmUrl ?? "/dist/main.wasm");
|
|
18
17
|
const wasmBuffer = await response.arrayBuffer();
|
|
19
|
-
// @ts-ignore
|
|
18
|
+
// @ts-ignore — Go is injected by wasm_exec.js
|
|
20
19
|
const go = new Go();
|
|
21
20
|
const { instance } = await WebAssembly.instantiate(wasmBuffer, go.importObject);
|
|
22
21
|
go.run(instance);
|
|
23
|
-
//
|
|
22
|
+
// Allow Go goroutines to settle
|
|
24
23
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
25
24
|
}
|
package/dist/loader.d.ts
CHANGED
package/dist/loader.js
CHANGED
|
@@ -1,39 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Loads and initializes the
|
|
2
|
+
* welvet WASM Loader — Node.js
|
|
3
|
+
* Loads and initializes the welvet WebAssembly module.
|
|
4
4
|
*/
|
|
5
|
-
// Node.js only loader - using dynamic imports to allow bundling for browser (where this file is not used but might be analyzed)
|
|
6
5
|
export async function loadLoomWASM() {
|
|
7
6
|
const fs = await import("fs");
|
|
8
7
|
const url = await import("url");
|
|
9
8
|
const path = await import("path");
|
|
10
9
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
11
10
|
const __dirname = path.dirname(__filename);
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
root = __dirname;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// Running from src/ or example/
|
|
22
|
-
// Point to project’s dist/ directory
|
|
23
|
-
root = path.join(__dirname, "..", "dist");
|
|
24
|
-
}
|
|
25
|
-
// Load wasm_exec.js
|
|
26
|
-
const wasmExecPath = path.join(root, "wasm_exec.js");
|
|
27
|
-
const wasmExecCode = fs.readFileSync(wasmExecPath, "utf-8");
|
|
28
|
-
// Execute wasm_exec.js to get the Go runtime
|
|
11
|
+
// Resolve root: dist/ in production, or one level up from src/
|
|
12
|
+
const root = __dirname.endsWith("dist")
|
|
13
|
+
? __dirname
|
|
14
|
+
: path.join(__dirname, "..", "dist");
|
|
15
|
+
// Bootstrap Go runtime
|
|
16
|
+
const wasmExecCode = fs.readFileSync(path.join(root, "wasm_exec.js"), "utf-8");
|
|
29
17
|
eval(wasmExecCode);
|
|
30
|
-
// Load
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
// @ts-ignore - Go runtime from wasm_exec.js
|
|
18
|
+
// Load and instantiate the WASM module
|
|
19
|
+
const wasmBuffer = fs.readFileSync(path.join(root, "main.wasm"));
|
|
20
|
+
// @ts-ignore — Go is injected by wasm_exec.js
|
|
34
21
|
const go = new Go();
|
|
35
22
|
const { instance } = await WebAssembly.instantiate(wasmBuffer, go.importObject);
|
|
36
23
|
go.run(instance);
|
|
37
|
-
//
|
|
24
|
+
// Allow Go goroutines to settle
|
|
38
25
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
39
26
|
}
|
package/dist/main.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @openfluke/welvet — M-POLY-VTD AI Engine
|
|
3
|
+
*
|
|
4
|
+
* Isomorphic TypeScript wrapper for the Loom v0.73.0 WASM module.
|
|
5
|
+
* Supports Node.js and browser environments.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { init, createNetwork, DType } from "@openfluke/welvet";
|
|
10
|
+
*
|
|
11
|
+
* await init();
|
|
12
|
+
*
|
|
13
|
+
* const net = createNetwork({
|
|
14
|
+
* layers: [
|
|
15
|
+
* { type: "dense", input_height: 4, output_height: 8 },
|
|
16
|
+
* { type: "dense", input_height: 8, output_height: 2 },
|
|
17
|
+
* ]
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const output = net.sequentialForward(new Float32Array([1, 0, 0, 1]));
|
|
21
|
+
* console.log(output); // Float32Array [...]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import type { Network, NEATPopulation, SystolicState, TargetPropState, TrainingBatch, TrainingResult, DNACompareResult, Transformer } from "./types.js";
|
|
25
|
+
import { loadLoomWASMBrowser } from "./loader.browser.js";
|
|
26
|
+
export * from "./types.js";
|
|
27
|
+
export { loadLoomWASMBrowser };
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the welvet WASM module.
|
|
30
|
+
* Auto-detects Node.js vs browser environment.
|
|
31
|
+
*
|
|
32
|
+
* @param wasmUrl Optional custom URL for browser WASM loading (default: /dist/main.wasm)
|
|
33
|
+
*/
|
|
34
|
+
export declare function init(wasmUrl?: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Initialize explicitly for browser environments.
|
|
37
|
+
* @param wasmUrl Optional custom URL for WASM binary
|
|
38
|
+
*/
|
|
39
|
+
export declare function initBrowser(wasmUrl?: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Build a VolumetricNetwork from a JSON configuration object or string.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const net = createNetwork({
|
|
46
|
+
* layers: [
|
|
47
|
+
* { type: "dense", input_height: 784, output_height: 256 },
|
|
48
|
+
* { type: "dense", input_height: 256, output_height: 10, activation: "silu" },
|
|
49
|
+
* ]
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function createNetwork(config: object | string): Network;
|
|
54
|
+
/**
|
|
55
|
+
* Load a pre-trained network from a SafeTensors file path.
|
|
56
|
+
* (Node.js only — requires file system access)
|
|
57
|
+
*
|
|
58
|
+
* @param path Absolute or relative path to a .safetensors file
|
|
59
|
+
*/
|
|
60
|
+
export declare function loadNetwork(path: string): Network;
|
|
61
|
+
/**
|
|
62
|
+
* Initialize WebGPU (browser only).
|
|
63
|
+
* Sets window.webgpuAdapter, window.webgpuDevice, window.webgpuQueue.
|
|
64
|
+
*/
|
|
65
|
+
export declare function setupWebGPU(): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Compare the architectural DNA of two networks.
|
|
68
|
+
*
|
|
69
|
+
* @param dnaA JSON string from network.extractDNA()
|
|
70
|
+
* @param dnaB JSON string from network.extractDNA()
|
|
71
|
+
* @returns DNACompareResult
|
|
72
|
+
*/
|
|
73
|
+
export declare function compareDNA(dnaA: string, dnaB: string): DNACompareResult;
|
|
74
|
+
/**
|
|
75
|
+
* Get the default TargetPropConfig.
|
|
76
|
+
*/
|
|
77
|
+
export declare function defaultTargetPropConfig(): object;
|
|
78
|
+
/**
|
|
79
|
+
* Get the internal parity symbol list from Go.
|
|
80
|
+
* Used for audits and verification.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getInternalParity(): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Convenience wrapper for network.train() that handles JSON serialization.
|
|
85
|
+
*
|
|
86
|
+
* @param network The network to train
|
|
87
|
+
* @param batches Array of {input, target} training pairs
|
|
88
|
+
* @param epochs Number of training epochs
|
|
89
|
+
* @param lr Learning rate
|
|
90
|
+
*/
|
|
91
|
+
export declare function trainNetwork(network: Network, batches: TrainingBatch[], epochs: number, lr: number): TrainingResult;
|
|
92
|
+
/** Get the default SpliceConfig as a plain object. */
|
|
93
|
+
export declare function getSpliceConfig(): object;
|
|
94
|
+
/** Get the default NEATConfig as a plain object. */
|
|
95
|
+
export declare function getNEATConfig(dModel: number): object;
|
|
96
|
+
/**
|
|
97
|
+
* Create a NEAT population from a seed network.
|
|
98
|
+
* @param network Seed network (its _id is used)
|
|
99
|
+
* @param size Population size
|
|
100
|
+
* @param cfg NEATConfig object or JSON string (defaults to getNEATConfig(64))
|
|
101
|
+
*/
|
|
102
|
+
export declare function createNEATPopulation(network: Network, size: number, cfg?: object | string): NEATPopulation;
|
|
103
|
+
/**
|
|
104
|
+
* Create a Transformer wrapper.
|
|
105
|
+
* @param network Network to use as the base
|
|
106
|
+
* @param embeddings Float32Array of embedding weights
|
|
107
|
+
* @param lmHead Float32Array of LM head weights
|
|
108
|
+
* @param finalNorm Float32Array of final norm weights
|
|
109
|
+
*/
|
|
110
|
+
export declare function createTransformer(network: Network, embeddings: Float32Array | number[], lmHead: Float32Array | number[], finalNorm: Float32Array | number[]): Transformer;
|
|
111
|
+
/**
|
|
112
|
+
* Save a network to a SafeTensors byte array.
|
|
113
|
+
*/
|
|
114
|
+
export declare function saveNetwork(network: Network): Uint8Array;
|
|
115
|
+
declare const _default: {
|
|
116
|
+
init: typeof init;
|
|
117
|
+
initBrowser: typeof initBrowser;
|
|
118
|
+
createNetwork: typeof createNetwork;
|
|
119
|
+
loadNetwork: typeof loadNetwork;
|
|
120
|
+
saveNetwork: typeof saveNetwork;
|
|
121
|
+
setupWebGPU: typeof setupWebGPU;
|
|
122
|
+
compareDNA: typeof compareDNA;
|
|
123
|
+
defaultTargetPropConfig: typeof defaultTargetPropConfig;
|
|
124
|
+
getInternalParity: typeof getInternalParity;
|
|
125
|
+
trainNetwork: typeof trainNetwork;
|
|
126
|
+
getSpliceConfig: typeof getSpliceConfig;
|
|
127
|
+
getNEATConfig: typeof getNEATConfig;
|
|
128
|
+
createNEATPopulation: typeof createNEATPopulation;
|
|
129
|
+
createTransformer: typeof createTransformer;
|
|
130
|
+
DType: {
|
|
131
|
+
readonly FLOAT64: 0;
|
|
132
|
+
readonly FLOAT32: 1;
|
|
133
|
+
readonly FLOAT16: 2;
|
|
134
|
+
readonly BFLOAT16: 3;
|
|
135
|
+
readonly FP8_E4M3: 4;
|
|
136
|
+
readonly FP8_E5M2: 5;
|
|
137
|
+
readonly INT64: 6;
|
|
138
|
+
readonly INT32: 7;
|
|
139
|
+
readonly INT16: 8;
|
|
140
|
+
readonly INT8: 9;
|
|
141
|
+
readonly UINT64: 10;
|
|
142
|
+
readonly UINT32: 11;
|
|
143
|
+
readonly UINT16: 12;
|
|
144
|
+
readonly UINT8: 13;
|
|
145
|
+
readonly INT4: 14;
|
|
146
|
+
readonly UINT4: 15;
|
|
147
|
+
readonly FP4: 16;
|
|
148
|
+
readonly INT2: 17;
|
|
149
|
+
readonly UINT2: 18;
|
|
150
|
+
readonly TERNARY: 19;
|
|
151
|
+
readonly BINARY: 20;
|
|
152
|
+
};
|
|
153
|
+
LayerType: {
|
|
154
|
+
readonly DENSE: 0;
|
|
155
|
+
readonly RMS_NORM: 1;
|
|
156
|
+
readonly LAYER_NORM: 2;
|
|
157
|
+
readonly MHA: 3;
|
|
158
|
+
readonly SOFTMAX: 4;
|
|
159
|
+
readonly SWIGLU: 5;
|
|
160
|
+
readonly EMBEDDING: 6;
|
|
161
|
+
readonly RESIDUAL: 7;
|
|
162
|
+
readonly KMEANS: 8;
|
|
163
|
+
readonly RNN: 9;
|
|
164
|
+
readonly LSTM: 10;
|
|
165
|
+
readonly CNN1: 11;
|
|
166
|
+
readonly CNN2: 12;
|
|
167
|
+
readonly CNN3: 13;
|
|
168
|
+
readonly CONV_TRANSPOSED_1D: 14;
|
|
169
|
+
readonly CONV_TRANSPOSED_2D: 15;
|
|
170
|
+
readonly CONV_TRANSPOSED_3D: 16;
|
|
171
|
+
};
|
|
172
|
+
Activation: {
|
|
173
|
+
readonly RELU: 0;
|
|
174
|
+
readonly SILU: 1;
|
|
175
|
+
readonly GELU: 2;
|
|
176
|
+
readonly TANH: 3;
|
|
177
|
+
readonly SIGMOID: 4;
|
|
178
|
+
readonly LINEAR: 5;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export default _default;
|
|
182
|
+
export type { Network, NEATPopulation, SystolicState, TargetPropState, TrainingBatch, TrainingResult, DNACompareResult };
|