volvoxai 0.1.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 +21 -0
- package/README.md +145 -0
- package/bin/volvox.js +72 -0
- package/dist/v0.1.0/volvoxai.js +4664 -0
- package/dist/v0.1.0/volvoxai.min.js +1848 -0
- package/dist/v0.1.0/volvoxai.wasm +0 -0
- package/dist/volvoxai.js +4664 -0
- package/dist/volvoxai.min.js +1848 -0
- package/dist/volvoxai.wasm +0 -0
- package/docs/README.md +22 -0
- package/docs/browser-runtime.md +87 -0
- package/docs/efficientdet_tflite_vs_volvoxai.md +445 -0
- package/docs/microkernel_optimization_guide.md +153 -0
- package/docs/model-format.md +108 -0
- package/docs/models.md +103 -0
- package/docs/native-runtime.md +189 -0
- package/docs/operation_list.md +232 -0
- package/docs/operator_fusion_patterns.md +58 -0
- package/docs/quickstart.md +115 -0
- package/docs/roadmap.md +19 -0
- package/docs/testing.md +97 -0
- package/docs/textbook/01-foundations.md +233 -0
- package/docs/textbook/02-tinystories-language-model.md +300 -0
- package/docs/textbook/03-efficientdet-vision-model.md +281 -0
- package/docs/textbook/04-precision-and-quantization.md +208 -0
- package/docs/textbook/05-inside-the-engine.md +155 -0
- package/docs/textbook/06-native-engine-architecture.md +338 -0
- package/docs/textbook/07-glossary-and-next-steps.md +258 -0
- package/docs/textbook/README.md +85 -0
- package/docs/textbook/ko/01-foundations.md +231 -0
- package/docs/textbook/ko/02-tinystories-language-model.md +300 -0
- package/docs/textbook/ko/03-efficientdet-vision-model.md +277 -0
- package/docs/textbook/ko/04-precision-and-quantization.md +206 -0
- package/docs/textbook/ko/05-inside-the-engine.md +154 -0
- package/docs/textbook/ko/06-native-engine-architecture.md +333 -0
- package/docs/textbook/ko/07-glossary-and-next-steps.md +253 -0
- package/docs/textbook/ko/README.md +83 -0
- package/docs/xnnpack_optimization_guide.md +197 -0
- package/js/CPUEngine.js +241 -0
- package/js/Graph.js +49 -0
- package/js/GraphExecutor.js +1020 -0
- package/js/GraphLoader.js +282 -0
- package/js/ShaderLibrary.js +236 -0
- package/js/Tensor.js +25 -0
- package/js/Tokenizer.js +266 -0
- package/js/VolvoxAI.js +130 -0
- package/js/WasmEngine.js +378 -0
- package/js/WebNNEngine.js +169 -0
- package/js/index.js +11 -0
- package/js/ops/add.js +31 -0
- package/js/ops/argMax.js +33 -0
- package/js/ops/averagePool2D.js +38 -0
- package/js/ops/batchNorm2D.js +28 -0
- package/js/ops/cast.js +19 -0
- package/js/ops/clip.js +15 -0
- package/js/ops/concat2.js +18 -0
- package/js/ops/conv1D.js +35 -0
- package/js/ops/conv2D.js +70 -0
- package/js/ops/convTranspose2D.js +45 -0
- package/js/ops/crossAttention.js +69 -0
- package/js/ops/crossSDPA.js +41 -0
- package/js/ops/dequantizeLinear.js +9 -0
- package/js/ops/div.js +15 -0
- package/js/ops/embedding.js +14 -0
- package/js/ops/expand.js +24 -0
- package/js/ops/gELU.js +9 -0
- package/js/ops/gather.js +51 -0
- package/js/ops/gatherElements.js +33 -0
- package/js/ops/globalAveragePool.js +21 -0
- package/js/ops/hardSigmoid.js +12 -0
- package/js/ops/hardSwish.js +12 -0
- package/js/ops/interp1D.js +25 -0
- package/js/ops/layerNorm.js +25 -0
- package/js/ops/leakyReLU.js +10 -0
- package/js/ops/logSoftmax.js +15 -0
- package/js/ops/matMul.js +35 -0
- package/js/ops/maxPool2D.js +36 -0
- package/js/ops/meanHeight.js +17 -0
- package/js/ops/mul.js +31 -0
- package/js/ops/nonMaxSuppression.js +72 -0
- package/js/ops/pReLU.js +11 -0
- package/js/ops/pad.js +35 -0
- package/js/ops/profileX.js +22 -0
- package/js/ops/profileY.js +22 -0
- package/js/ops/rMSNorm.js +14 -0
- package/js/ops/reLU.js +8 -0
- package/js/ops/reduceMean.js +17 -0
- package/js/ops/reduceSum.js +19 -0
- package/js/ops/reshape.js +6 -0
- package/js/ops/resize.js +44 -0
- package/js/ops/sDPA.js +44 -0
- package/js/ops/siLU.js +8 -0
- package/js/ops/sigmoid.js +6 -0
- package/js/ops/slice.js +36 -0
- package/js/ops/softmax.js +18 -0
- package/js/ops/spatialSoftargmaxY.js +28 -0
- package/js/ops/split.js +24 -0
- package/js/ops/sub.js +11 -0
- package/js/ops/tanh.js +7 -0
- package/js/ops/transpose.js +34 -0
- package/js/ops/upsample2x.js +23 -0
- package/js/ops/where.js +15 -0
- package/package.json +33 -0
- package/shaders/add.wgsl +13 -0
- package/shaders/add3Relu.wgsl +23 -0
- package/shaders/addRelu.wgsl +22 -0
- package/shaders/averagePool2D.wgsl +24 -0
- package/shaders/batchNorm2D.wgsl +21 -0
- package/shaders/binaryBroadcast.wgsl +34 -0
- package/shaders/broadcastBinary.wgsl +26 -0
- package/shaders/clip.wgsl +10 -0
- package/shaders/concat2.wgsl +16 -0
- package/shaders/concatCopy.wgsl +10 -0
- package/shaders/concatSigmoidCopy.wgsl +16 -0
- package/shaders/conv1D.wgsl +37 -0
- package/shaders/conv2D.wgsl +80 -0
- package/shaders/conv2DDepthwise4.wgsl +74 -0
- package/shaders/conv2DDepthwise8.wgsl +66 -0
- package/shaders/conv2DPointwise16.wgsl +67 -0
- package/shaders/conv2DPointwise16Tile.wgsl +86 -0
- package/shaders/conv2DPointwise8.wgsl +85 -0
- package/shaders/conv2DPointwise8Vec2.wgsl +70 -0
- package/shaders/conv2DPointwise8Vec4.wgsl +65 -0
- package/shaders/conv2DRegularC3Out16.wgsl +75 -0
- package/shaders/convTranspose2D.wgsl +33 -0
- package/shaders/copy.wgsl +13 -0
- package/shaders/crossAttention.wgsl +140 -0
- package/shaders/crossAttentionF32.wgsl +98 -0
- package/shaders/crossSDPA.wgsl +74 -0
- package/shaders/dequantizeLinear.wgsl +14 -0
- package/shaders/div.wgsl +34 -0
- package/shaders/elementwise.wgsl +13 -0
- package/shaders/embedding.wgsl +22 -0
- package/shaders/expand.wgsl +18 -0
- package/shaders/gELU.wgsl +13 -0
- package/shaders/gather.wgsl +17 -0
- package/shaders/generalTranspose.wgsl +19 -0
- package/shaders/globalAveragePool.wgsl +19 -0
- package/shaders/hardSigmoid.wgsl +13 -0
- package/shaders/hardSwish.wgsl +13 -0
- package/shaders/interp1D.wgsl +28 -0
- package/shaders/layerNorm.wgsl +33 -0
- package/shaders/leakyReLU.wgsl +11 -0
- package/shaders/linearF32.wgsl +33 -0
- package/shaders/linearF32RowMajor.wgsl +24 -0
- package/shaders/linearInt8.wgsl +42 -0
- package/shaders/logSoftmax.wgsl +22 -0
- package/shaders/maxPool2D.wgsl +37 -0
- package/shaders/meanHeight.wgsl +18 -0
- package/shaders/mul.wgsl +32 -0
- package/shaders/nonMaxSuppression.wgsl +92 -0
- package/shaders/pReLU.wgsl +14 -0
- package/shaders/pad.wgsl +19 -0
- package/shaders/profileX.wgsl +28 -0
- package/shaders/profileY.wgsl +28 -0
- package/shaders/quantizeLinear.wgsl +69 -0
- package/shaders/rMSNorm.wgsl +21 -0
- package/shaders/reLU.wgsl +13 -0
- package/shaders/reduce.wgsl +17 -0
- package/shaders/resize.wgsl +52 -0
- package/shaders/sDPA.wgsl +71 -0
- package/shaders/siLU.wgsl +13 -0
- package/shaders/sigmoid.wgsl +13 -0
- package/shaders/slice.wgsl +26 -0
- package/shaders/softmax.wgsl +23 -0
- package/shaders/spatialSoftargmaxY.wgsl +32 -0
- package/shaders/split.wgsl +15 -0
- package/shaders/sub.wgsl +34 -0
- package/shaders/tanh.wgsl +13 -0
- package/shaders/upsample2x.wgsl +24 -0
- package/shaders/where.wgsl +12 -0
- package/volvoxai.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VolvoxAI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# VolvoxAI
|
|
2
|
+
|
|
3
|
+
**A zero-dependency, bare-metal deep learning inference engine for the browser,
|
|
4
|
+
Node.js, and native Windows/Linux/macOS/Android targets.**
|
|
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.
|
|
10
|
+
|
|
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.
|
|
14
|
+
|
|
15
|
+
## Highlights
|
|
16
|
+
|
|
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.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install volvoxai
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For local development from this repository:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install
|
|
40
|
+
npm run build:all
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The browser bundle is emitted to:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
dist/volvoxai.js
|
|
47
|
+
dist/volvoxai.min.js
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The WASM tier also needs `volvoxai.wasm`. The reproducible Docker build copies it
|
|
51
|
+
into `dist/`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
make build_web
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Browser Usage
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
import { VolvoxAI } from './volvoxai.js';
|
|
61
|
+
|
|
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 = {
|
|
67
|
+
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
|
|
79
|
+
make build_native
|
|
80
|
+
|
|
81
|
+
./native/volvoxai generate models/tinystories_1m \
|
|
82
|
+
--prompt "Once upon a time, Lily" \
|
|
83
|
+
--max-new 50
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Generic tensor execution:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
./native/volvoxai run models/tinystories_1m \
|
|
90
|
+
--input tokens=models/tinystories_1m/tokens.i32 \
|
|
91
|
+
--input positions=models/tinystories_1m/positions.i32 \
|
|
92
|
+
--output logits=out.f32 \
|
|
93
|
+
--last-token 4
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Example Models
|
|
97
|
+
|
|
98
|
+
Model weights are not committed. Regenerate the example packages from public
|
|
99
|
+
sources:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
make models_deps
|
|
103
|
+
make models_efficientdet
|
|
104
|
+
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
|
+
```
|
|
120
|
+
|
|
121
|
+
## Documentation
|
|
122
|
+
|
|
123
|
+
- [Quickstart](docs/quickstart.md)
|
|
124
|
+
- [Browser and Node runtime](docs/browser-runtime.md)
|
|
125
|
+
- [Native runtime](docs/native-runtime.md)
|
|
126
|
+
- [Model format](docs/model-format.md)
|
|
127
|
+
- [Models and exporters](docs/models.md)
|
|
128
|
+
- [Operation support matrix](docs/operation_list.md)
|
|
129
|
+
- [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.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT. See [LICENSE](LICENSE).
|
package/bin/volvox.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { VolvoxAI } from '../js/index.js';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
|
|
9
|
+
const program = new Command();
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.name('volvox')
|
|
13
|
+
.description('Volvox AI CLI for running local inference')
|
|
14
|
+
.version('0.1.0');
|
|
15
|
+
|
|
16
|
+
program
|
|
17
|
+
.command('run')
|
|
18
|
+
.description('Run inference with a given model and input')
|
|
19
|
+
.requiredOption('-m, --model <path>', 'Path to the safetensors model file')
|
|
20
|
+
.option('-b, --backend <type>', 'Backend to use (wasm, cpu)', 'wasm')
|
|
21
|
+
.action(async (options) => {
|
|
22
|
+
try {
|
|
23
|
+
installFileFetchShim();
|
|
24
|
+
console.log(`[Volvox CLI] Initializing Engine (Backend: ${options.backend})...`);
|
|
25
|
+
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);
|
|
28
|
+
|
|
29
|
+
console.log(`[Volvox CLI] Loading Model: ${options.model}`);
|
|
30
|
+
if (!fs.existsSync(options.model)) {
|
|
31
|
+
console.error(`Error: Model file not found at ${options.model}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
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);
|
|
40
|
+
|
|
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).
|
|
44
|
+
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error('[Volvox CLI] Error during execution:', err);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
program
|
|
52
|
+
.command('info')
|
|
53
|
+
.description('Print system and engine info')
|
|
54
|
+
.action(async () => {
|
|
55
|
+
console.log('Volvox AI Engine CLI');
|
|
56
|
+
console.log('Node.js:', process.version);
|
|
57
|
+
console.log('Available backends: wasm, cpu');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
program.parse();
|
|
61
|
+
|
|
62
|
+
function installFileFetchShim() {
|
|
63
|
+
const nativeFetch = globalThis.fetch;
|
|
64
|
+
globalThis.fetch = async (url, init) => {
|
|
65
|
+
const href = typeof url === 'string' ? url : url?.url;
|
|
66
|
+
if (href && href.startsWith('file://')) {
|
|
67
|
+
const data = await fs.promises.readFile(fileURLToPath(href));
|
|
68
|
+
return new Response(data, { status: 200 });
|
|
69
|
+
}
|
|
70
|
+
return nativeFetch(url, init);
|
|
71
|
+
};
|
|
72
|
+
}
|