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.
- package/README.md +274 -97
- package/bin/volvox.js +27 -12
- package/dist/0.3.0/volvoxai.full.js +33136 -0
- package/dist/0.3.0/volvoxai.full.min.js +9806 -0
- package/dist/0.3.0/volvoxai.full.wasm +0 -0
- package/dist/0.3.0/volvoxai.js +23410 -0
- package/dist/0.3.0/volvoxai.min.js +6848 -0
- package/dist/0.3.0/volvoxai.wasm +0 -0
- package/dist/0.3.0/volvoxai.wasm.js +13231 -0
- package/dist/0.3.0/volvoxai.wasm.min.js +2 -0
- package/package.json +26 -12
- package/dist/v0.1.0/volvoxai.js +0 -4664
- package/dist/v0.1.0/volvoxai.min.js +0 -1848
- package/dist/v0.1.0/volvoxai.wasm +0 -0
- package/dist/volvoxai.js +0 -4664
- package/dist/volvoxai.min.js +0 -1848
- package/dist/volvoxai.wasm +0 -0
- package/docs/README.md +0 -22
- package/docs/browser-runtime.md +0 -87
- package/docs/efficientdet_tflite_vs_volvoxai.md +0 -445
- package/docs/microkernel_optimization_guide.md +0 -153
- package/docs/model-format.md +0 -108
- package/docs/models.md +0 -103
- package/docs/native-runtime.md +0 -189
- package/docs/operation_list.md +0 -232
- package/docs/operator_fusion_patterns.md +0 -58
- package/docs/quickstart.md +0 -115
- package/docs/roadmap.md +0 -19
- package/docs/testing.md +0 -97
- package/docs/textbook/01-foundations.md +0 -233
- package/docs/textbook/02-tinystories-language-model.md +0 -300
- package/docs/textbook/03-efficientdet-vision-model.md +0 -281
- package/docs/textbook/04-precision-and-quantization.md +0 -208
- package/docs/textbook/05-inside-the-engine.md +0 -155
- package/docs/textbook/06-native-engine-architecture.md +0 -338
- package/docs/textbook/07-glossary-and-next-steps.md +0 -258
- package/docs/textbook/README.md +0 -85
- package/docs/textbook/ko/01-foundations.md +0 -231
- package/docs/textbook/ko/02-tinystories-language-model.md +0 -300
- package/docs/textbook/ko/03-efficientdet-vision-model.md +0 -277
- package/docs/textbook/ko/04-precision-and-quantization.md +0 -206
- package/docs/textbook/ko/05-inside-the-engine.md +0 -154
- package/docs/textbook/ko/06-native-engine-architecture.md +0 -333
- package/docs/textbook/ko/07-glossary-and-next-steps.md +0 -253
- package/docs/textbook/ko/README.md +0 -83
- package/docs/xnnpack_optimization_guide.md +0 -197
- package/js/CPUEngine.js +0 -241
- package/js/Graph.js +0 -49
- package/js/GraphExecutor.js +0 -1020
- package/js/GraphLoader.js +0 -282
- package/js/ShaderLibrary.js +0 -236
- package/js/Tensor.js +0 -25
- package/js/Tokenizer.js +0 -266
- package/js/VolvoxAI.js +0 -130
- package/js/WasmEngine.js +0 -378
- package/js/WebNNEngine.js +0 -169
- package/js/index.js +0 -11
- package/js/ops/add.js +0 -31
- package/js/ops/argMax.js +0 -33
- package/js/ops/averagePool2D.js +0 -38
- package/js/ops/batchNorm2D.js +0 -28
- package/js/ops/cast.js +0 -19
- package/js/ops/clip.js +0 -15
- package/js/ops/concat2.js +0 -18
- package/js/ops/conv1D.js +0 -35
- package/js/ops/conv2D.js +0 -70
- package/js/ops/convTranspose2D.js +0 -45
- package/js/ops/crossAttention.js +0 -69
- package/js/ops/crossSDPA.js +0 -41
- package/js/ops/dequantizeLinear.js +0 -9
- package/js/ops/div.js +0 -15
- package/js/ops/embedding.js +0 -14
- package/js/ops/expand.js +0 -24
- package/js/ops/gELU.js +0 -9
- package/js/ops/gather.js +0 -51
- package/js/ops/gatherElements.js +0 -33
- package/js/ops/globalAveragePool.js +0 -21
- package/js/ops/hardSigmoid.js +0 -12
- package/js/ops/hardSwish.js +0 -12
- package/js/ops/interp1D.js +0 -25
- package/js/ops/layerNorm.js +0 -25
- package/js/ops/leakyReLU.js +0 -10
- package/js/ops/logSoftmax.js +0 -15
- package/js/ops/matMul.js +0 -35
- package/js/ops/maxPool2D.js +0 -36
- package/js/ops/meanHeight.js +0 -17
- package/js/ops/mul.js +0 -31
- package/js/ops/nonMaxSuppression.js +0 -72
- package/js/ops/pReLU.js +0 -11
- package/js/ops/pad.js +0 -35
- package/js/ops/profileX.js +0 -22
- package/js/ops/profileY.js +0 -22
- package/js/ops/rMSNorm.js +0 -14
- package/js/ops/reLU.js +0 -8
- package/js/ops/reduceMean.js +0 -17
- package/js/ops/reduceSum.js +0 -19
- package/js/ops/reshape.js +0 -6
- package/js/ops/resize.js +0 -44
- package/js/ops/sDPA.js +0 -44
- package/js/ops/siLU.js +0 -8
- package/js/ops/sigmoid.js +0 -6
- package/js/ops/slice.js +0 -36
- package/js/ops/softmax.js +0 -18
- package/js/ops/spatialSoftargmaxY.js +0 -28
- package/js/ops/split.js +0 -24
- package/js/ops/sub.js +0 -11
- package/js/ops/tanh.js +0 -7
- package/js/ops/transpose.js +0 -34
- package/js/ops/upsample2x.js +0 -23
- package/js/ops/where.js +0 -15
- package/shaders/add.wgsl +0 -13
- package/shaders/add3Relu.wgsl +0 -23
- package/shaders/addRelu.wgsl +0 -22
- package/shaders/averagePool2D.wgsl +0 -24
- package/shaders/batchNorm2D.wgsl +0 -21
- package/shaders/binaryBroadcast.wgsl +0 -34
- package/shaders/broadcastBinary.wgsl +0 -26
- package/shaders/clip.wgsl +0 -10
- package/shaders/concat2.wgsl +0 -16
- package/shaders/concatCopy.wgsl +0 -10
- package/shaders/concatSigmoidCopy.wgsl +0 -16
- package/shaders/conv1D.wgsl +0 -37
- package/shaders/conv2D.wgsl +0 -80
- package/shaders/conv2DDepthwise4.wgsl +0 -74
- package/shaders/conv2DDepthwise8.wgsl +0 -66
- package/shaders/conv2DPointwise16.wgsl +0 -67
- package/shaders/conv2DPointwise16Tile.wgsl +0 -86
- package/shaders/conv2DPointwise8.wgsl +0 -85
- package/shaders/conv2DPointwise8Vec2.wgsl +0 -70
- package/shaders/conv2DPointwise8Vec4.wgsl +0 -65
- package/shaders/conv2DRegularC3Out16.wgsl +0 -75
- package/shaders/convTranspose2D.wgsl +0 -33
- package/shaders/copy.wgsl +0 -13
- package/shaders/crossAttention.wgsl +0 -140
- package/shaders/crossAttentionF32.wgsl +0 -98
- package/shaders/crossSDPA.wgsl +0 -74
- package/shaders/dequantizeLinear.wgsl +0 -14
- package/shaders/div.wgsl +0 -34
- package/shaders/elementwise.wgsl +0 -13
- package/shaders/embedding.wgsl +0 -22
- package/shaders/expand.wgsl +0 -18
- package/shaders/gELU.wgsl +0 -13
- package/shaders/gather.wgsl +0 -17
- package/shaders/generalTranspose.wgsl +0 -19
- package/shaders/globalAveragePool.wgsl +0 -19
- package/shaders/hardSigmoid.wgsl +0 -13
- package/shaders/hardSwish.wgsl +0 -13
- package/shaders/interp1D.wgsl +0 -28
- package/shaders/layerNorm.wgsl +0 -33
- package/shaders/leakyReLU.wgsl +0 -11
- package/shaders/linearF32.wgsl +0 -33
- package/shaders/linearF32RowMajor.wgsl +0 -24
- package/shaders/linearInt8.wgsl +0 -42
- package/shaders/logSoftmax.wgsl +0 -22
- package/shaders/maxPool2D.wgsl +0 -37
- package/shaders/meanHeight.wgsl +0 -18
- package/shaders/mul.wgsl +0 -32
- package/shaders/nonMaxSuppression.wgsl +0 -92
- package/shaders/pReLU.wgsl +0 -14
- package/shaders/pad.wgsl +0 -19
- package/shaders/profileX.wgsl +0 -28
- package/shaders/profileY.wgsl +0 -28
- package/shaders/quantizeLinear.wgsl +0 -69
- package/shaders/rMSNorm.wgsl +0 -21
- package/shaders/reLU.wgsl +0 -13
- package/shaders/reduce.wgsl +0 -17
- package/shaders/resize.wgsl +0 -52
- package/shaders/sDPA.wgsl +0 -71
- package/shaders/siLU.wgsl +0 -13
- package/shaders/sigmoid.wgsl +0 -13
- package/shaders/slice.wgsl +0 -26
- package/shaders/softmax.wgsl +0 -23
- package/shaders/spatialSoftargmaxY.wgsl +0 -32
- package/shaders/split.wgsl +0 -15
- package/shaders/sub.wgsl +0 -34
- package/shaders/tanh.wgsl +0 -13
- package/shaders/upsample2x.wgsl +0 -24
- package/shaders/where.wgsl +0 -12
- package/volvoxai.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,144 +1,321 @@
|
|
|
1
1
|
# VolvoxAI
|
|
2
2
|
|
|
3
|
-
**A zero-dependency
|
|
4
|
-
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
-
|
|
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
|
-
|
|
35
|
+
~~~bash
|
|
33
36
|
npm install volvoxai
|
|
34
|
-
|
|
37
|
+
~~~
|
|
35
38
|
|
|
36
|
-
For
|
|
39
|
+
For repository development:
|
|
37
40
|
|
|
38
|
-
|
|
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
|
-
|
|
46
|
-
dist/volvoxai.js
|
|
47
|
-
dist/volvoxai.min.js
|
|
48
|
-
```
|
|
47
|
+
## Release artifacts
|
|
49
48
|
|
|
50
|
-
The
|
|
51
|
-
into `dist/`:
|
|
49
|
+
The fixed browser release files for package version 0.3.0 are:
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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
|
-
|
|
60
|
-
import { VolvoxAI } from './volvoxai.js';
|
|
67
|
+
Build all browser artifacts reproducibly with:
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```
|
|
252
|
+
./native/volvoxai --help
|
|
253
|
+
./native/volvoxai-full --help
|
|
254
|
+
~~~
|
|
85
255
|
|
|
86
|
-
|
|
256
|
+
The inference executable provides model-agnostic tensor execution. The full
|
|
257
|
+
executable additionally provides training:
|
|
87
258
|
|
|
88
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
-
sources:
|
|
275
|
+
## Example models
|
|
100
276
|
|
|
101
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
- [
|
|
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
|
-
- [
|
|
131
|
-
- [Textbook
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
42
|
-
|
|
43
|
-
|
|
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);
|