volvoxai 0.1.0 → 0.3.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.
Files changed (179) hide show
  1. package/README.md +274 -97
  2. package/bin/volvox.js +27 -12
  3. package/dist/0.3.0/volvoxai.full.js +33136 -0
  4. package/dist/0.3.0/volvoxai.full.min.js +9806 -0
  5. package/dist/0.3.0/volvoxai.full.wasm +0 -0
  6. package/dist/0.3.0/volvoxai.js +23410 -0
  7. package/dist/0.3.0/volvoxai.min.js +6848 -0
  8. package/dist/0.3.0/volvoxai.wasm +0 -0
  9. package/dist/0.3.0/volvoxai.wasm.js +13231 -0
  10. package/dist/0.3.0/volvoxai.wasm.min.js +2 -0
  11. package/package.json +26 -12
  12. package/dist/v0.1.0/volvoxai.js +0 -4664
  13. package/dist/v0.1.0/volvoxai.min.js +0 -1848
  14. package/dist/v0.1.0/volvoxai.wasm +0 -0
  15. package/dist/volvoxai.js +0 -4664
  16. package/dist/volvoxai.min.js +0 -1848
  17. package/dist/volvoxai.wasm +0 -0
  18. package/docs/README.md +0 -22
  19. package/docs/browser-runtime.md +0 -87
  20. package/docs/efficientdet_tflite_vs_volvoxai.md +0 -445
  21. package/docs/microkernel_optimization_guide.md +0 -153
  22. package/docs/model-format.md +0 -108
  23. package/docs/models.md +0 -103
  24. package/docs/native-runtime.md +0 -189
  25. package/docs/operation_list.md +0 -232
  26. package/docs/operator_fusion_patterns.md +0 -58
  27. package/docs/quickstart.md +0 -115
  28. package/docs/roadmap.md +0 -19
  29. package/docs/testing.md +0 -97
  30. package/docs/textbook/01-foundations.md +0 -233
  31. package/docs/textbook/02-tinystories-language-model.md +0 -300
  32. package/docs/textbook/03-efficientdet-vision-model.md +0 -281
  33. package/docs/textbook/04-precision-and-quantization.md +0 -208
  34. package/docs/textbook/05-inside-the-engine.md +0 -155
  35. package/docs/textbook/06-native-engine-architecture.md +0 -338
  36. package/docs/textbook/07-glossary-and-next-steps.md +0 -258
  37. package/docs/textbook/README.md +0 -85
  38. package/docs/textbook/ko/01-foundations.md +0 -231
  39. package/docs/textbook/ko/02-tinystories-language-model.md +0 -300
  40. package/docs/textbook/ko/03-efficientdet-vision-model.md +0 -277
  41. package/docs/textbook/ko/04-precision-and-quantization.md +0 -206
  42. package/docs/textbook/ko/05-inside-the-engine.md +0 -154
  43. package/docs/textbook/ko/06-native-engine-architecture.md +0 -333
  44. package/docs/textbook/ko/07-glossary-and-next-steps.md +0 -253
  45. package/docs/textbook/ko/README.md +0 -83
  46. package/docs/xnnpack_optimization_guide.md +0 -197
  47. package/js/CPUEngine.js +0 -241
  48. package/js/Graph.js +0 -49
  49. package/js/GraphExecutor.js +0 -1020
  50. package/js/GraphLoader.js +0 -282
  51. package/js/ShaderLibrary.js +0 -236
  52. package/js/Tensor.js +0 -25
  53. package/js/Tokenizer.js +0 -266
  54. package/js/VolvoxAI.js +0 -130
  55. package/js/WasmEngine.js +0 -378
  56. package/js/WebNNEngine.js +0 -169
  57. package/js/index.js +0 -11
  58. package/js/ops/add.js +0 -31
  59. package/js/ops/argMax.js +0 -33
  60. package/js/ops/averagePool2D.js +0 -38
  61. package/js/ops/batchNorm2D.js +0 -28
  62. package/js/ops/cast.js +0 -19
  63. package/js/ops/clip.js +0 -15
  64. package/js/ops/concat2.js +0 -18
  65. package/js/ops/conv1D.js +0 -35
  66. package/js/ops/conv2D.js +0 -70
  67. package/js/ops/convTranspose2D.js +0 -45
  68. package/js/ops/crossAttention.js +0 -69
  69. package/js/ops/crossSDPA.js +0 -41
  70. package/js/ops/dequantizeLinear.js +0 -9
  71. package/js/ops/div.js +0 -15
  72. package/js/ops/embedding.js +0 -14
  73. package/js/ops/expand.js +0 -24
  74. package/js/ops/gELU.js +0 -9
  75. package/js/ops/gather.js +0 -51
  76. package/js/ops/gatherElements.js +0 -33
  77. package/js/ops/globalAveragePool.js +0 -21
  78. package/js/ops/hardSigmoid.js +0 -12
  79. package/js/ops/hardSwish.js +0 -12
  80. package/js/ops/interp1D.js +0 -25
  81. package/js/ops/layerNorm.js +0 -25
  82. package/js/ops/leakyReLU.js +0 -10
  83. package/js/ops/logSoftmax.js +0 -15
  84. package/js/ops/matMul.js +0 -35
  85. package/js/ops/maxPool2D.js +0 -36
  86. package/js/ops/meanHeight.js +0 -17
  87. package/js/ops/mul.js +0 -31
  88. package/js/ops/nonMaxSuppression.js +0 -72
  89. package/js/ops/pReLU.js +0 -11
  90. package/js/ops/pad.js +0 -35
  91. package/js/ops/profileX.js +0 -22
  92. package/js/ops/profileY.js +0 -22
  93. package/js/ops/rMSNorm.js +0 -14
  94. package/js/ops/reLU.js +0 -8
  95. package/js/ops/reduceMean.js +0 -17
  96. package/js/ops/reduceSum.js +0 -19
  97. package/js/ops/reshape.js +0 -6
  98. package/js/ops/resize.js +0 -44
  99. package/js/ops/sDPA.js +0 -44
  100. package/js/ops/siLU.js +0 -8
  101. package/js/ops/sigmoid.js +0 -6
  102. package/js/ops/slice.js +0 -36
  103. package/js/ops/softmax.js +0 -18
  104. package/js/ops/spatialSoftargmaxY.js +0 -28
  105. package/js/ops/split.js +0 -24
  106. package/js/ops/sub.js +0 -11
  107. package/js/ops/tanh.js +0 -7
  108. package/js/ops/transpose.js +0 -34
  109. package/js/ops/upsample2x.js +0 -23
  110. package/js/ops/where.js +0 -15
  111. package/shaders/add.wgsl +0 -13
  112. package/shaders/add3Relu.wgsl +0 -23
  113. package/shaders/addRelu.wgsl +0 -22
  114. package/shaders/averagePool2D.wgsl +0 -24
  115. package/shaders/batchNorm2D.wgsl +0 -21
  116. package/shaders/binaryBroadcast.wgsl +0 -34
  117. package/shaders/broadcastBinary.wgsl +0 -26
  118. package/shaders/clip.wgsl +0 -10
  119. package/shaders/concat2.wgsl +0 -16
  120. package/shaders/concatCopy.wgsl +0 -10
  121. package/shaders/concatSigmoidCopy.wgsl +0 -16
  122. package/shaders/conv1D.wgsl +0 -37
  123. package/shaders/conv2D.wgsl +0 -80
  124. package/shaders/conv2DDepthwise4.wgsl +0 -74
  125. package/shaders/conv2DDepthwise8.wgsl +0 -66
  126. package/shaders/conv2DPointwise16.wgsl +0 -67
  127. package/shaders/conv2DPointwise16Tile.wgsl +0 -86
  128. package/shaders/conv2DPointwise8.wgsl +0 -85
  129. package/shaders/conv2DPointwise8Vec2.wgsl +0 -70
  130. package/shaders/conv2DPointwise8Vec4.wgsl +0 -65
  131. package/shaders/conv2DRegularC3Out16.wgsl +0 -75
  132. package/shaders/convTranspose2D.wgsl +0 -33
  133. package/shaders/copy.wgsl +0 -13
  134. package/shaders/crossAttention.wgsl +0 -140
  135. package/shaders/crossAttentionF32.wgsl +0 -98
  136. package/shaders/crossSDPA.wgsl +0 -74
  137. package/shaders/dequantizeLinear.wgsl +0 -14
  138. package/shaders/div.wgsl +0 -34
  139. package/shaders/elementwise.wgsl +0 -13
  140. package/shaders/embedding.wgsl +0 -22
  141. package/shaders/expand.wgsl +0 -18
  142. package/shaders/gELU.wgsl +0 -13
  143. package/shaders/gather.wgsl +0 -17
  144. package/shaders/generalTranspose.wgsl +0 -19
  145. package/shaders/globalAveragePool.wgsl +0 -19
  146. package/shaders/hardSigmoid.wgsl +0 -13
  147. package/shaders/hardSwish.wgsl +0 -13
  148. package/shaders/interp1D.wgsl +0 -28
  149. package/shaders/layerNorm.wgsl +0 -33
  150. package/shaders/leakyReLU.wgsl +0 -11
  151. package/shaders/linearF32.wgsl +0 -33
  152. package/shaders/linearF32RowMajor.wgsl +0 -24
  153. package/shaders/linearInt8.wgsl +0 -42
  154. package/shaders/logSoftmax.wgsl +0 -22
  155. package/shaders/maxPool2D.wgsl +0 -37
  156. package/shaders/meanHeight.wgsl +0 -18
  157. package/shaders/mul.wgsl +0 -32
  158. package/shaders/nonMaxSuppression.wgsl +0 -92
  159. package/shaders/pReLU.wgsl +0 -14
  160. package/shaders/pad.wgsl +0 -19
  161. package/shaders/profileX.wgsl +0 -28
  162. package/shaders/profileY.wgsl +0 -28
  163. package/shaders/quantizeLinear.wgsl +0 -69
  164. package/shaders/rMSNorm.wgsl +0 -21
  165. package/shaders/reLU.wgsl +0 -13
  166. package/shaders/reduce.wgsl +0 -17
  167. package/shaders/resize.wgsl +0 -52
  168. package/shaders/sDPA.wgsl +0 -71
  169. package/shaders/siLU.wgsl +0 -13
  170. package/shaders/sigmoid.wgsl +0 -13
  171. package/shaders/slice.wgsl +0 -26
  172. package/shaders/softmax.wgsl +0 -23
  173. package/shaders/spatialSoftargmaxY.wgsl +0 -32
  174. package/shaders/split.wgsl +0 -15
  175. package/shaders/sub.wgsl +0 -34
  176. package/shaders/tanh.wgsl +0 -13
  177. package/shaders/upsample2x.wgsl +0 -24
  178. package/shaders/where.wgsl +0 -12
  179. package/volvoxai.wasm +0 -0
package/README.md CHANGED
@@ -1,144 +1,321 @@
1
1
  # VolvoxAI
2
2
 
3
- **A zero-dependency, bare-metal deep learning inference engine for the browser,
4
- Node.js, and native Windows/Linux/macOS/Android targets.**
3
+ **A zero-dependency deep-learning runtime for browsers, Node.js, and native
4
+ Windows, Linux, macOS, and Android targets.**
5
5
 
6
- VolvoxAI runs exported neural-network graphs without shipping a full ML runtime.
7
- Train in PyTorch or another framework, export to a small Volvox blueprint plus
8
- safetensors weights, and run inference through WebNN, WebGPU, WASM SIMD, pure JS,
9
- or a freestanding native C binary.
6
+ VolvoxAI runs compact graph packages without embedding a general-purpose ML
7
+ framework. It supports WebNN, WebGPU, WASM SIMD, JavaScript CPU, native CPU,
8
+ Vulkan, OpenGL, optional CUDA, Metal, and NNAPI integrations.
10
9
 
11
- The project is inference-only. It is built for small, inspectable model packages,
12
- constrained web apps, extensions, local tools, and edge devices where heavyweight
13
- runtimes such as ONNX Runtime Web or TensorFlow.js are too large or too opaque.
10
+ The repository is also a from-scratch textbook:
11
+
12
+ - [Idea, Build, and Deep tracks](docs/textbook/README.md)
13
+ - [Architecture](ARCHITECTURE.md)
14
+ - [Runtime design](REFACTORING.md)
14
15
 
15
16
  ## Highlights
16
17
 
17
- - Browser tiers: WebNN, WebGPU, WASM SIMD, and pure-JS CPU fallback.
18
- - Zero runtime dependency path: vanilla JS plus WGSL with optional freestanding WASM.
19
- - Small runtime artifacts: about 167 KiB minified JS, 55 KiB WASM, and a
20
- roughly 695 KiB native Linux executable in current builds.
21
- - Native runtime: freestanding C with dynamic Vulkan, OpenGL, Metal, and Android
22
- NNAPI loading.
23
- - Optimization-focused internals: operator fusion, weight packing, quantized CPU
24
- islands, vectorized WGSL/C kernels, and backend-specific dispatch.
25
- - Model format: `config.json` graph blueprint plus `model.safetensors` weights.
26
- - Shader source: WGSL for browser WebGPU and native shader generation.
27
- - Examples: EfficientDet Lite0 object detection and TinyStories-1M text generation.
28
- - License: MIT.
18
+ - One explicit inference lifecycle: Runtime Model CompiledModel
19
+ ExecutionContext ExecutionResult.
20
+ - Stable named outputs on every backend. Host reads return caller-owned arrays;
21
+ WebGPU results may also expose result-owned device buffers.
22
+ - Independent execution and decode contexts with immutable compiled model and
23
+ weight revisions.
24
+ - Required or preferred backend policy with independent operator-fallback
25
+ control and machine-readable reports.
26
+ - A single context-aware provider contract for built-in and external devices.
27
+ - A full profile with a retained Trainer for CPU, WebGPU, or strict WASM
28
+ training.
29
+ - Inspectable model packages using graph.json and safetensors.
30
+ - Strict inference/training composition boundaries in JavaScript, WASM, and
31
+ native builds.
29
32
 
30
33
  ## Install
31
34
 
32
- ```bash
35
+ ~~~bash
33
36
  npm install volvoxai
34
- ```
37
+ ~~~
35
38
 
36
- For local development from this repository:
39
+ For repository development:
37
40
 
38
- ```bash
41
+ ~~~bash
39
42
  npm install
43
+ npm run typecheck
40
44
  npm run build:all
41
- ```
42
-
43
- The browser bundle is emitted to:
45
+ ~~~
44
46
 
45
- ```text
46
- dist/volvoxai.js
47
- dist/volvoxai.min.js
48
- ```
47
+ ## Release artifacts
49
48
 
50
- The WASM tier also needs `volvoxai.wasm`. The reproducible Docker build copies it
51
- into `dist/`:
49
+ The fixed browser release files for package version 0.3.0 are:
52
50
 
53
- ```bash
54
- make build_web
55
- ```
51
+ ~~~text
52
+ dist/0.3.0/volvoxai.js
53
+ dist/0.3.0/volvoxai.min.js
54
+ dist/0.3.0/volvoxai.full.js
55
+ dist/0.3.0/volvoxai.full.min.js
56
+ dist/0.3.0/volvoxai.wasm.js
57
+ dist/0.3.0/volvoxai.wasm.min.js
58
+ dist/0.3.0/volvoxai.wasm
59
+ dist/0.3.0/volvoxai.full.wasm
60
+ ~~~
56
61
 
57
- ## Browser Usage
62
+ The standard JavaScript entry is inference-only and resolves the forward-only
63
+ WASM sidecar. The full entry adds training and resolves volvoxai.full.wasm.
64
+ The WASM-only JavaScript entry contains strict WASM inference and training but
65
+ no CPU, WebNN, WebGPU, WGSL, or Node filesystem implementation.
58
66
 
59
- ```javascript
60
- import { VolvoxAI } from './volvoxai.js';
67
+ Build all browser artifacts reproducibly with:
61
68
 
62
- const engine = await VolvoxAI.init(); // auto: WebNN, WebGPU, WASM, CPU
63
- const graph = await engine.loadGraph('./models/my-model/model.safetensors');
64
- const executor = await engine.compile(graph);
65
-
66
- const inputs = {
69
+ ~~~bash
70
+ make build_web
71
+ ~~~
72
+
73
+ ## Model packages
74
+
75
+ An inference package contains:
76
+
77
+ ~~~text
78
+ graph.json
79
+ model.safetensors
80
+ ~~~
81
+
82
+ Every graph root, including named subgraphs, must carry the exact
83
+ case-sensitive discriminator:
84
+
85
+ ~~~json
86
+ {
87
+ "format": "volvox-graph/v1"
88
+ }
89
+ ~~~
90
+
91
+ The loader rejects a missing or different discriminator before allocating
92
+ weights or backend resources. Every node input must resolve to a declared graph
93
+ input, a named weight, or an earlier node output.
94
+
95
+ ## Inference
96
+
97
+ ~~~javascript
98
+ import { VolvoxAI } from 'volvoxai';
99
+
100
+ const runtime = await VolvoxAI.createRuntime({
101
+ backends: ['webnn', 'webgpu', 'wasm', 'cpu'],
102
+ onDiagnostic(event) {
103
+ console.debug(event.kind, event.report ?? event);
104
+ },
105
+ });
106
+
107
+ const model = await runtime.loadModel(
108
+ './models/my-model/model.safetensors',
109
+ );
110
+ const compiled = await model.compile({
111
+ backend: {
112
+ mode: 'prefer',
113
+ order: ['webgpu', 'wasm', 'cpu'],
114
+ operatorFallback: 'allow',
115
+ },
116
+ });
117
+ const context = await compiled.createContext();
118
+
119
+ const result = await context.execute({
67
120
  images: new Float32Array(1 * 224 * 224 * 3),
68
- };
69
-
70
- const output = await executor.execute(inputs);
71
- ```
72
-
73
- On WebGPU, `execute()` currently returns a `GPUBuffer` for the final node's first
74
- output. WASM and CPU return a map keyed by `graph.outputNames`.
75
-
76
- ## Native Usage
77
-
78
- ```bash
121
+ });
122
+ const scores = await result.output('scores').read();
123
+
124
+ await result.close();
125
+ await context.close();
126
+ await compiled.close();
127
+ await model.close();
128
+ await runtime.close();
129
+ ~~~
130
+
131
+ Runtime loading resolves graph.json beside the first safetensors URL. Pass
132
+ graphUrl in the loader options when the graph is stored elsewhere; its basename
133
+ must be `graph.json` or a named `*.graph.json` document.
134
+
135
+ Compilation pins an immutable topology and weight revision. Create multiple
136
+ contexts from one compiled model for independent request or decode state. Each
137
+ context serializes its own accepted operations, while different contexts may
138
+ progress concurrently.
139
+
140
+ ExecutionResult owns a stable snapshot of every declared graph output. A result
141
+ remains usable after later executions and after its context closes. Each read()
142
+ returns a fresh typed array. A device result may expose deviceBuffer; that
143
+ buffer remains owned by the result and must not be destroyed by the caller.
144
+
145
+ Use a strict policy when execution must stay on one provider:
146
+
147
+ ~~~javascript
148
+ const compiled = await model.compile({
149
+ backend: {
150
+ mode: 'require',
151
+ backend: 'webgpu',
152
+ operatorFallback: 'forbid',
153
+ },
154
+ });
155
+ ~~~
156
+
157
+ Backend selection finishes during compilation. Execution failure is reported
158
+ and is never retried on another provider.
159
+
160
+ ## Training
161
+
162
+ Training is available only from the full and WASM-only profiles. Trainer owns
163
+ gradients, optimizer slots, accumulation, and a private working
164
+ revision. `trainStep()` mutates only that private revision. `commit()` atomically
165
+ publishes it as a new Model weight revision; already compiled models and
166
+ contexts remain pinned to their original revision.
167
+
168
+ ~~~javascript
169
+ import {
170
+ ModelBuilder,
171
+ VolvoxAI,
172
+ } from 'volvoxai/full';
173
+
174
+ const builder = new ModelBuilder();
175
+ const x = builder.input('x', [1, 4]);
176
+ const weight = builder.weight('projection', [4, 8], 'float32', {
177
+ initializer: { type: 'xavierUniform', seed: 17 },
178
+ });
179
+ const logits = builder.addOp(
180
+ 'MatMul',
181
+ { input: x, weight },
182
+ { out: { name: 'logits', shape: [1, 8] } },
183
+ {},
184
+ { id: 'projection', wLayout: 'din' },
185
+ ).out;
186
+ builder.outputs(logits);
187
+ const graph = builder.build();
188
+
189
+ const runtime = await VolvoxAI.createRuntime({ backends: ['cpu'] });
190
+ const model = runtime.createModel(graph);
191
+ const trainer = await VolvoxAI.createTrainer(model, {
192
+ backend: 'cpu',
193
+ });
194
+
195
+ const step = await trainer.trainStep({
196
+ inputs: { x: new Float32Array([1, 2, 3, 4]) },
197
+ logitsTensor: 'logits',
198
+ targets: new Int32Array([3]),
199
+ trainableTensors: ['projection'],
200
+ updateMode: 'adamw',
201
+ optimizer: { learningRate: 1e-3, maxGradNorm: 1 },
202
+ });
203
+ await trainer.commit();
204
+
205
+ await trainer.close();
206
+ await model.close();
207
+ await runtime.close();
208
+ ~~~
209
+
210
+ The same Trainer contract accepts backend: 'webgpu' or backend: 'wasm'. WASM
211
+ training is strict and rejects an unsupported graph before mutating weights.
212
+ There is no implicit publication: call `commit()` before compiling inference
213
+ against the update, or `rollback()` to restore the last committed baseline.
214
+ The full profile also exports training builders, checkpoints, gradient
215
+ accumulation controls, LoRA helpers, and PTQ authoring tools. See
216
+ [model construction and training](docs/model_builder_training.md) and the
217
+ [operation matrix](docs/operation_list.md).
218
+
219
+ ## WASM-only browser extensions
220
+
221
+ For a Manifest V3 extension, package one WASM-only JavaScript variant, the full
222
+ sidecar, and the model:
223
+
224
+ ~~~text
225
+ vendor/volvoxai.wasm.min.js
226
+ vendor/volvoxai.full.wasm
227
+ model/graph.json
228
+ model/model.safetensors
229
+ ~~~
230
+
231
+ ~~~javascript
232
+ import { VolvoxAI } from './vendor/volvoxai.wasm.min.js';
233
+
234
+ const runtime = await VolvoxAI.createRuntime({
235
+ wasmUrl: chrome.runtime.getURL('vendor/volvoxai.full.wasm'),
236
+ });
237
+ const model = await runtime.loadModel(
238
+ chrome.runtime.getURL('model/model.safetensors'),
239
+ { graphUrl: chrome.runtime.getURL('model/graph.json') },
240
+ );
241
+ ~~~
242
+
243
+ Extension pages need wasm-unsafe-eval in their content security policy. The
244
+ WASM-only release has no dynamic import and contains no alternate backend.
245
+ See [Browser and Node runtime](docs/browser-runtime.md).
246
+
247
+ ## Native use
248
+
249
+ ~~~bash
79
250
  make build_native
80
251
 
81
- ./native/volvoxai generate models/tinystories_1m \
82
- --prompt "Once upon a time, Lily" \
83
- --max-new 50
84
- ```
252
+ ./native/volvoxai --help
253
+ ./native/volvoxai-full --help
254
+ ~~~
85
255
 
86
- Generic tensor execution:
256
+ The inference executable provides model-agnostic tensor execution. The full
257
+ executable additionally provides training:
87
258
 
88
- ```bash
259
+ ~~~bash
89
260
  ./native/volvoxai run models/tinystories_1m \
90
261
  --input tokens=models/tinystories_1m/tokens.i32 \
91
262
  --input positions=models/tinystories_1m/positions.i32 \
92
- --output logits=out.f32 \
93
- --last-token 4
94
- ```
263
+ --output logits=out.f32
264
+ ~~~
265
+
266
+ Raw files use a storage suffix matching their declared dtype: .f32, .i32,
267
+ .i8, or .u8. Outputs contain the complete declared tensor; applications
268
+ select task-specific rows or slices. Model-specific tokenization, image
269
+ decoding, generation, and postprocessing live under examples/.
95
270
 
96
- ## Example Models
271
+ Native releases use embedded shaders. For shader development,
272
+ VOLVOXAI_SHADER_DIR may point to generated spv/, glsl/, gles/, and metal/
273
+ directories; VolvoxAI logs once when that external override is actually used.
97
274
 
98
- Model weights are not committed. Regenerate the example packages from public
99
- sources:
275
+ ## Example models
100
276
 
101
- ```bash
277
+ Weights are not committed. Recreate the example packages from public sources:
278
+
279
+ ~~~bash
102
280
  make models_deps
103
281
  make models_efficientdet
104
282
  make models_tinystories
105
- ```
106
-
107
- See [docs/models.md](docs/models.md) for export details.
108
-
109
- ## Repository Layout
110
-
111
- ```text
112
- js/ Browser and Node engine implementation
113
- shaders/ WGSL compute shaders
114
- native/ Freestanding C engine and native backends
115
- runtime/ Rust service wrapper around the C engine
116
- examples/ Browser examples
117
- tools/ Export, shader, and test utilities
118
- docs/ Detailed documentation
119
- ```
283
+ make validate_model_packages
284
+ ~~~
285
+
286
+ See [Models and exporters](docs/models.md).
287
+
288
+ ## Repository layout
289
+
290
+ ~~~text
291
+ ts/core/ graph/data objects and runtime ownership
292
+ ts/ops/ operators, validation, and normalization
293
+ ts/backends/ backend providers and device resources
294
+ ts/training/ Trainer, autograd, optimizers, checkpoints, and PTQ
295
+ examples/ model-specific applications and integrations
296
+ shaders/ authoritative WGSL source
297
+ native/include/ public opaque inference/provider and full Trainer/PTQ C APIs
298
+ native/src/runtime/ runtime/model/context/result implementation
299
+ native/src/kernels/ portable and optimized CPU/WASM kernels
300
+ native/src/backends/ native device integrations
301
+ native/src/training/ full-profile training implementation
302
+ runtime/ optional in-process Synurang FFI plugin
303
+ ~~~
120
304
 
121
305
  ## Documentation
122
306
 
123
307
  - [Quickstart](docs/quickstart.md)
124
308
  - [Browser and Node runtime](docs/browser-runtime.md)
125
309
  - [Native runtime](docs/native-runtime.md)
310
+ - [Backend SDK](docs/backend-sdk.md)
126
311
  - [Model format](docs/model-format.md)
127
- - [Models and exporters](docs/models.md)
312
+ - [Graph exporter and optimizer design](docs/graph-optimizer-design.md)
313
+ - [Typed PTQ](docs/typed-ptq.md)
314
+ - [Model construction and training](docs/model_builder_training.md)
128
315
  - [Operation support matrix](docs/operation_list.md)
129
316
  - [Testing and validation](docs/testing.md)
130
- - [Roadmap](docs/roadmap.md)
131
- - [Textbook walkthrough](docs/textbook/README.md) ([한국어](docs/textbook/ko/README.md))
132
- - [EfficientDet benchmark notes](docs/efficientdet_tflite_vs_volvoxai.md)
133
-
134
- ## Current Status
135
-
136
- VolvoxAI can run real browser and native inference paths, but it is still early.
137
- Known gaps include WebGPU multi-output readback, broader WebNN coverage, additional
138
- native/WebGPU shaders for a few fallback ops, browser-side generation helpers, and
139
- formal CI wiring for the existing smoke tests.
140
-
141
- See [docs/roadmap.md](docs/roadmap.md) for the detailed list.
317
+ - [Models and exporters](docs/models.md)
318
+ - [Textbook](docs/textbook/README.md)
142
319
 
143
320
  ## License
144
321
 
package/bin/volvox.js CHANGED
@@ -1,17 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { Command } from 'commander';
4
- import { VolvoxAI } from '../js/index.js';
5
4
  import fs from 'fs';
6
5
  import path from 'path';
7
6
  import { fileURLToPath } from 'url';
8
7
 
8
+ const packageVersion = JSON.parse(
9
+ fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
10
+ ).version;
11
+ const { VolvoxAI } = await import(
12
+ new URL(`../dist/${packageVersion}/volvoxai.js`, import.meta.url)
13
+ );
14
+
9
15
  const program = new Command();
10
16
 
11
17
  program
12
18
  .name('volvox')
13
19
  .description('Volvox AI CLI for running local inference')
14
- .version('0.1.0');
20
+ .version(packageVersion);
15
21
 
16
22
  program
17
23
  .command('run')
@@ -21,10 +27,13 @@ program
21
27
  .action(async (options) => {
22
28
  try {
23
29
  installFileFetchShim();
24
- console.log(`[Volvox CLI] Initializing Engine (Backend: ${options.backend})...`);
30
+ console.log(`[Volvox CLI] Initializing runtime (backend: ${options.backend})...`);
25
31
  const cliDir = path.dirname(fileURLToPath(import.meta.url));
26
- const wasmPath = path.resolve(cliDir, '..', 'volvoxai.wasm');
27
- const engine = await VolvoxAI.init(options.backend, wasmPath);
32
+ const wasmPath = path.resolve(cliDir, '..', 'dist', packageVersion, 'volvoxai.wasm');
33
+ const runtime = await VolvoxAI.createRuntime({
34
+ backends: [options.backend],
35
+ wasmUrl: wasmPath,
36
+ });
28
37
 
29
38
  console.log(`[Volvox CLI] Loading Model: ${options.model}`);
30
39
  if (!fs.existsSync(options.model)) {
@@ -33,14 +42,20 @@ program
33
42
  }
34
43
 
35
44
  const modelUrl = 'file://' + path.resolve(options.model);
36
- const graph = await engine.loadGraph(modelUrl);
37
-
38
- console.log(`[Volvox CLI] Compiling Model...`);
39
- const executor = await engine.compile(graph, modelUrl);
45
+ const model = await runtime.loadModel(modelUrl);
40
46
 
41
- console.log(`[Volvox CLI] Model Ready! Provide input data via scripts for full inference.`);
42
- // TODO: In a real CLI, we would parse JSON inputs or specific tensors,
43
- // and call executor.execute(inputs).
47
+ console.log('[Volvox CLI] Compiling model...');
48
+ const compiled = await model.compile({
49
+ backend: {
50
+ mode: 'require',
51
+ backend: options.backend,
52
+ operatorFallback: 'forbid',
53
+ },
54
+ });
55
+ console.log(`[Volvox CLI] Model ready on ${compiled.backend}.`);
56
+ await compiled.close();
57
+ await model.close();
58
+ await runtime.close();
44
59
 
45
60
  } catch (err) {
46
61
  console.error('[Volvox CLI] Error during execution:', err);