volvoxai 0.2.0 → 0.5.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 CHANGED
@@ -1,447 +1,285 @@
1
1
  # VolvoxAI
2
2
 
3
- **A zero-dependency, bare-metal deep learning engine for the
4
- browser, Node.js, and native Windows/Linux/macOS/Android targets.**
5
-
6
- > 🧭 **New here — want to *understand* how AI actually works, not just use a library?**
7
- > This repo doubles as a from-scratch **textbook** built on its own real code. Pick your path:
8
- >
9
- > - 🌱 **Just curious what AI really is?** → [Start the **Idea track**](docs/textbook/README.md) — plain words, analogies, **no code or math required**. A motivated 11-year-old can follow it.
10
- > - 🔧 **Can code a little and want to see it run?** → [The **Build track**](docs/textbook/README.md) — the same ideas in graphs, JavaScript, and operators.
11
- > - 🔬 **A developer who wants the engine?** → [The **Deep track**](docs/textbook/README.md) + [ARCHITECTURE.md](ARCHITECTURE.md) — quantization, native, optimization, and training internals.
12
- >
13
- > One book, three depths. Everything below this line is the **product / release reference** for people who just want to install and ship.
14
-
15
- ---
16
-
17
- VolvoxAI runs and trains neural-network graphs without shipping a full ML
18
- runtime. Load a small Volvox blueprint plus safetensors weights, or use the full
19
- entry to create an empty model, initialize its parameters, and build it entirely
20
- through the API.
21
- The resulting graph can run through WebNN, WebGPU, WASM SIMD, pure JS, or a
22
- freestanding native C binary.
23
-
24
- The project is built for small, inspectable model packages, constrained web
25
- apps, extensions, local tools, and edge devices where heavyweight runtimes such
26
- as ONNX Runtime Web or TensorFlow.js are too large or too opaque. Training is an
27
- explicit path: inference does not allocate gradients, optimizer state, or
28
- backward pipelines. The inference bundle has no training dependency; the full
29
- bundle adds training as a separate public entry.
3
+ **A deep-learning runtime for browsers, Node.js, and native desktop, phone,
4
+ and robot applications.**
30
5
 
31
- ## Highlights
32
-
33
- - Runs in browsers, Node.js, and native applications through WebNN, WebGPU,
34
- WASM, JavaScript CPU, native CPU, Vulkan, OpenGL, and Metal.
35
- - Compact current Linux x86-64 artifacts: 360 KiB WASM-only JS, 683 KiB
36
- multi-backend inference JS, 174 KiB inference WASM, and 936 KiB native
37
- inference; full training builds remain about 1–1.4 MiB.
38
- - No external ML runtime: models use inspectable `config.json` graphs and
39
- safetensors weights.
40
- - Clean inference/training separation: inference builds contain no autograd,
41
- optimizer state, backward shaders, or public training symbols.
42
- - Built-in model construction, training, LoRA, checkpointing, PTQ, and portable
43
- W8A8 execution.
44
- - Extensible browser and native backend APIs with embedded native shaders and
45
- portable CPU fallback.
46
- - Includes EfficientDet, TinyStories, multimodal examples, and a three-level
47
- textbook.
48
-
49
- ## Install
50
-
51
- ```bash
52
- npm install volvoxai
53
- ```
54
-
55
- For local development from this repository:
6
+ VolvoxAI runs compact model packages without embedding a general-purpose ML
7
+ framework. The JavaScript package has no runtime npm dependencies. Use it to recognize objects, process text, or adapt a small model on
8
+ the device where the data is produced. The same graph and weights can run in a
9
+ browser through WebAssembly or in a native C application.
56
10
 
57
- ```bash
58
- npm install
59
- npm run typecheck
60
- npm run build:all
61
- ```
11
+ The engine supports both inference and training. A browser application can
12
+ coordinate concurrent requests in one runtime; an edge service can schedule
13
+ vision and language workloads with explicit request and result-memory budgets.
14
+ Model-specific preprocessing, generation policy, and evaluation stay in the
15
+ application.
62
16
 
63
- The TypeScript sources are checked before esbuild emits the six fixed-name
64
- JavaScript bundles; the build preserves an existing WASM sidecar. For version
65
- 0.2.0, the complete browser release consists of:
17
+ This repository is also a from-scratch textbook. Start with
18
+ [How AI Actually Works](docs/textbook/README.md) ([한국어](docs/textbook/ko/README.md))
19
+ to learn tensors, attention, training, quantization, and the engine itself.
20
+ For a first run, follow the [quickstart](docs/quickstart.md).
66
21
 
67
- ```text
68
- dist/0.2.0/volvoxai.js # readable inference
69
- dist/0.2.0/volvoxai.min.js # minified inference
70
- dist/0.2.0/volvoxai.full.js # readable inference + training
71
- dist/0.2.0/volvoxai.full.min.js # minified inference + training
72
- dist/0.2.0/volvoxai.wasm.js # readable WASM-only inference + training/PTQ
73
- dist/0.2.0/volvoxai.wasm.min.js # minified WASM-only inference + training/PTQ
74
- dist/0.2.0/volvoxai.wasm # forward kernels used by the WASM backend
75
- dist/0.2.0/volvoxai.full.wasm # forward kernels plus C training/PTQ ABIs
76
- ```
77
-
78
- `volvoxai.wasm` deliberately exports no training symbol. `volvoxai.full.wasm`
79
- keeps every forward export and adds C loss, backward, gradient utility, SGD, and
80
- AdamW operators plus generic PTQ observation, affine quantization, weight
81
- packing, and bias packing. Quantized LoRA synchronization is one higher-level
82
- use of those reusable kernels. From a clean checkout, the reproducible Docker
83
- build creates all eight files:
22
+ ## Highlights
84
23
 
85
- ```bash
86
- make build_web
24
+ - **One model package across platforms.** Inspectable `graph.json` and
25
+ SafeTensors weights describe the computation and its data.
26
+ - **CPU and GPU execution.** Browser/Node WASM SIMD, browser WebGPU, and native
27
+ CPU with optional Vulkan, OpenGL/OpenGL ES, CUDA, and Metal backends.
28
+ - **Bounded dynamic shapes.** Name a dimension such as sequence length and give
29
+ it finite bounds. The compiler checks the supported domain; each request
30
+ supplies its actual shape without rebuilding the model.
31
+ - **Independent sessions and stable results.** Reuse a compiled model across
32
+ execution contexts. Each context owns its shape and decode state, and each
33
+ result retains its own named output snapshot until released.
34
+ - **Scheduling and batching.** Run a single request directly, or use bounded
35
+ queues, priorities, deadlines, and compatible-request batching. Decode
36
+ contexts support row execution and paged KV caches on qualified routes.
37
+ - **On-device training.** The full profile provides SGD/AdamW, gradient
38
+ accumulation, checkpoints, and LoRA authoring. Training updates private
39
+ weights; an explicit commit publishes them for new inference compilations.
40
+ - **Post-training quantization.** Calibrate a float model and produce an explicit
41
+ W8A8 package, then measure its accuracy and latency against the original.
42
+ - **Separate inference and full builds.** Inference artifacts exclude compiled
43
+ training code, optimizer state, and training shaders.
44
+
45
+ Support depends on the operator, dtype, shape, and selected backend. See the
46
+ [operator guide](docs/operation_list.md) and [validation coverage](docs/c-runtime-validation.md)
47
+ for the tested domains.
48
+
49
+ ## Install and choose a profile
50
+
51
+ ```sh
52
+ npm install volvoxai
87
53
  ```
88
54
 
89
- The npm `prepack` check rejects a missing sidecar or stale extra artifact.
90
- `npm run build:all` bundles JavaScript but cannot compile C/WASM from a clean
91
- checkout; use `make build_web` before `npm pack` or `npm publish`.
92
-
93
- ## Browser Usage
94
-
95
- ```javascript
96
- import { VolvoxAI } from './dist/0.2.0/volvoxai.js';
55
+ | Your application needs | JavaScript entry | WASM companion |
56
+ | --- | --- | --- |
57
+ | CPU inference, text processing, graph construction, scheduling | `volvoxai/lite` | `volvoxai.lite.wasm` |
58
+ | WebGPU inference, training, or PTQ | `volvoxai` | `volvoxai.wasm` |
97
59
 
98
- const engine = await VolvoxAI.init(); // auto: WebNN, WebGPU, WASM, CPU
99
- const graph = await engine.loadGraph('./models/my-model/model.safetensors');
100
- const executor = await engine.compile(graph);
60
+ Both entries run WASM CPU inference. WebGPU belongs to the **full** entry (`volvoxai`).
61
+ Serve the matching WASM file beside the JavaScript bundle, or supply `wasmUrl`
62
+ when your bundler or CDN puts it elsewhere. See [browser and Node deployment](docs/browser-runtime.md).
101
63
 
102
- const inputs = {
103
- images: new Float32Array(1 * 224 * 224 * 3),
104
- };
64
+ For repository development, build both JavaScript entries and their companions:
105
65
 
106
- const output = await executor.execute(inputs);
66
+ ```sh
67
+ make build_web
107
68
  ```
108
69
 
109
- Every input referenced by a blueprint node must be declared in `config.inputs`,
110
- loaded as a named weight, or produced by an earlier node. The loader does not
111
- invent a default image input or shape for an undeclared name.
112
-
113
- On WebGPU, `execute()` currently returns a `GPUBuffer` for the final node's first
114
- output. The executor owns GPU buffers; core `Tensor` objects contain portable
115
- descriptors and optional CPU storage, not device handles. WASM and CPU return a
116
- map keyed by `graph.outputNames`. All four browser engines share the versioned
117
- backend lifecycle, named registration hook, and decode-session facade described
118
- in [Browser and Node runtime](docs/browser-runtime.md#javascript-backend-contract).
70
+ This uses the repository's Docker toolchain. [Quickstart](docs/quickstart.md)
71
+ explains prerequisites, local builds, and the first runnable example.
119
72
 
120
- ### WASM-only Chrome extensions, training, and PTQ
73
+ ## Model packages
121
74
 
122
- For a Manifest V3 extension that needs no CPU, WebNN, WebGPU, or shader code,
123
- ship exactly one JavaScript variant, the full WASM sidecar, and the model:
75
+ A typical package contains:
124
76
 
125
77
  ```text
126
- vendor/volvoxai.wasm.min.js
127
- vendor/volvoxai.full.wasm
128
- model/config.json
129
- model/model.safetensors
78
+ graph.json
79
+ model.safetensors
130
80
  ```
131
81
 
132
- `volvoxai.wasm.min.js` names the only selectable backend, not a forward-only
133
- capability set. It uses `volvoxai.full.wasm` because updating LoRA A/B still
134
- requires backward propagation through the surrounding graph. The ordinary
135
- `volvoxai.wasm` sidecar remains forward-only for the standard inference entry.
136
- The `./wasm` and `./wasm/min` package subpaths are browser-only and deliberately
137
- omit Node's filesystem loader; Node applications should use `.` or `./full`
138
- and select the WASM backend.
82
+ The graph describes named inputs, operations, output tensors, and dimension
83
+ bounds. SafeTensors stores the weights; larger packages may use several shards.
84
+ Every graph has the exact `"format": "volvox-graph/v1"` discriminator.
85
+ A static graph uses an empty `dimensions` object; a dynamic graph declares each
86
+ symbol's finite range. See the [model format](docs/model-format.md).
139
87
 
140
- ```javascript
141
- import { VolvoxAI } from './vendor/volvoxai.wasm.min.js';
142
-
143
- const runtime = await VolvoxAI.init(
144
- 'wasm',
145
- chrome.runtime.getURL('vendor/volvoxai.full.wasm'),
146
- );
147
- const graph = await runtime.loadGraph(
148
- chrome.runtime.getURL('model/model.safetensors'),
149
- );
150
- const executor = await runtime.compile(graph);
151
-
152
- const step = await runtime.trainLoRAStep(graph, {
153
- inputs: teacherForcedInputs,
154
- logitsTensor: 'logits',
155
- targets: correctedTokenIds,
156
- trainableTensors: ['decoder.lora_a', 'decoder.lora_b'],
157
- updateMode: 'adamw',
158
- optimizer: { learningRate: 1e-4 },
159
- });
160
-
161
- // Applied updates refresh packed WASM weights, so this executor observes A/B.
162
- const corrected = await executor.execute(nextInputs);
88
+ Recreate the example models from their public sources:
89
+
90
+ ```sh
91
+ make models_deps
92
+ make models_efficientdet
93
+ make models_tinystories
94
+ make validate_model_packages
163
95
  ```
164
96
 
165
- The same runtime exposes the existing stateless C PTQ implementation as a
166
- generic typed toolkit, independent of LoRA:
97
+ Weights are not committed. [Models and exporters](docs/models.md) explains the
98
+ sources and export options. The browser demos are
99
+ [EfficientDet](examples/efficientdet_lite0.html) and [TinyStories](examples/tinystories.html).
167
100
 
168
- ```javascript
169
- const ptq = await runtime.createPTQ();
170
- try {
171
- const observer = ptq.createObserver();
172
- observer.observe(calibrationValues); // Float32Array; repeat for more samples
173
-
174
- const parameters = observer.parameters({
175
- dtype: 'int8',
176
- scheme: 'symmetric',
177
- });
178
- const activation = ptq.quantize(values, parameters);
179
- const weight = ptq.packWeight(weightValues, [outputSize, inputSize], { axis: 0 });
180
- const bias = ptq.packBias(biasValues, parameters.scale, weight.scales);
181
- } finally {
182
- ptq.dispose();
183
- }
184
- ```
101
+ ## Web inference
185
102
 
186
- These calls run in a private scratch WASM instance and return caller-owned
187
- typed arrays. They do not rewrite a graph or choose how an application stores
188
- or deploys the result. Reuse one toolkit across related operations and call
189
- `dispose()` when finished so its isolated WASM memory can be garbage-collected.
190
- Developers may use it for calibration, conversion, custom model builders, or
191
- their own update workflow. Browser safetensors and graph/package authoring
192
- remain JavaScript orchestration rather than C file I/O.
193
-
194
- The model must represent LoRA A/B as explicit initialized F32 graph weights and
195
- wire them through its low-rank MatMul/Add branch. Listing only those names in
196
- `trainableTensors` freezes the base model. A corrected answer string is
197
- application policy: tokenize it and construct teacher-forced model inputs,
198
- target token IDs, and any loss mask before calling `trainLoRAStep()`.
199
- Immutable staged adapter snapshots are deployment/routing objects, not
200
- autograd parameters; checkpoint or export the updated explicit graph factors
201
- after training.
202
-
203
- To retain an existing W8A8 inference topology, use a separate supported F32
204
- training graph as the persistent master and bind its A/B factors to the I8
205
- factor weights already present in the inference graph:
103
+ The lifecycle is **create a runtime load a model compile → run → read outputs**.
104
+ This small ReLU graph needs no downloaded weights. Save the example as an `.mjs`
105
+ file in an installed project or this repository and run it with Node:
206
106
 
207
107
  ```javascript
208
- const trainer = await runtime.createQuantizedLoRATrainer(
209
- f32TrainingGraph,
210
- w8InferenceGraph,
211
- {
212
- bindings: [
213
- { master: 'decoder.lora_a', target: 'decoder.lora_a.i8', transpose: true },
214
- { master: 'decoder.lora_b', target: 'decoder.lora_b.i8', transpose: true },
215
- ],
216
- },
217
- );
108
+ import { EngineHost, VxInferenceServiceClient, pb } from 'volvoxai';
218
109
 
110
+ const host = new EngineHost();
111
+ const inference = new VxInferenceServiceClient(host);
219
112
  try {
220
- // Use this once only when starting from a W8 snapshot without an F32
221
- // checkpoint. Do not dequantize again after training begins.
222
- await trainer.initializeMastersFromQuantized();
223
-
224
- await trainer.trainStep({
225
- inputs: teacherForcedInputs,
226
- logitsTensor: 'logits',
227
- targets: correctedTokenIds,
228
- trainableTensors: ['decoder.lora_a', 'decoder.lora_b'],
229
- updateMode: 'adamw',
230
- optimizer: { learningRate: 1e-4 },
231
- });
232
-
233
- const corrected = await trainer.engine.execute(nextQuantizedInputs);
113
+ const runtime = await inference.createRuntime(new pb.CreateRuntimeRequest());
114
+ const graphDocument = new TextEncoder().encode(JSON.stringify({
115
+ format: 'volvox-graph/v1', dimensions: {},
116
+ inputs: { x: { dtype: 'float32', shape: [2] } },
117
+ nodes: [{
118
+ id: 'relu', opType: 'ReLU', inputs: { input: 'x' },
119
+ outputs: { out: { tensor: 'y', dtype: 'float32', shape: [2] } },
120
+ params: {},
121
+ }],
122
+ outputs: ['y'],
123
+ }));
124
+ const model = await inference.loadModel(new pb.LoadModelRequest({
125
+ runtimeId: runtime.runtimeId,
126
+ package: new pb.ModelPackage({ graphDocument }),
127
+ }));
128
+ const compiled = await inference.compileModel(new pb.CompileModelRequest({
129
+ modelId: model.modelId,
130
+ }));
131
+ const values = Float32Array.of(-2, 3);
132
+ const result = await inference.run(new pb.RunRequest({
133
+ compiledModelId: compiled.compiledModelId,
134
+ inputs: [new pb.Tensor({
135
+ name: 'x', dtype: pb.DataType.DATA_TYPE_F32, shape: [2n],
136
+ inline: new Uint8Array(values.buffer, values.byteOffset, values.byteLength),
137
+ })],
138
+ }));
139
+ const output = await inference.readOutput(new pb.ReadOutputRequest({
140
+ resultId: result.resultId, name: 'y',
141
+ }));
142
+ console.log(Array.from(new Float32Array(output.tensor.inline.slice().buffer)));
143
+ // [0, 3]
234
144
  } finally {
235
- await trainer.dispose();
145
+ await host.close();
236
146
  }
237
147
  ```
238
148
 
239
- The C conversion helper transposes the builder's IN_OUT factors into canonical
240
- OUT_IN I8 weights and recomputes symmetric axis-0 scales. The JavaScript trainer
241
- stages every converted factor before atomically updating the graph, then
242
- refreshes the WASM raw bytes, scale metadata, and packed Q8 caches without
243
- changing nodes or activation descriptors. Version 0.2.0 requires I8 targets
244
- with zero points of zero and all-zero I32 LoRA biases. Persist the F32
245
- checkpoint and optimizer state as the resumable authority; the W8 graph is an
246
- inference snapshot. After restoring an F32 checkpoint, call `trainer.sync()`
247
- instead of `initializeMastersFromQuantized()`.
248
-
249
- This is F32-master LoRA requantization, not QAT or backward support for a deep
250
- W8A8 graph. `QLinear`/`QGemm` are still rejected by strict WASM training, so
251
- the separate training graph must provide the supported F32 backward path. The
252
- inference graph must already contain its quantized LoRA branch; this API does
253
- not rewrite graph topology.
254
-
255
- The extension must package all executable code locally and enable WebAssembly
256
- for extension pages. Use an ES-module service worker and this CSP:
257
-
258
- ```json
259
- {
260
- "manifest_version": 3,
261
- "background": { "service_worker": "service-worker.js", "type": "module" },
262
- "content_security_policy": {
263
- "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
264
- }
265
- }
266
- ```
149
+ `pb` contains the request, response, and enum types. Tensor shapes use `bigint`
150
+ values such as `2n`; tensor data is an exact byte view. Inputs always state their
151
+ name, dtype, and concrete shape so the engine can validate the whole batch.
267
152
 
268
- The WASM-only release bundle contains no dynamic `import()`, which Chrome
269
- extension service workers do not support. `web_accessible_resources` is not
270
- needed when only extension-owned pages/workers fetch the packaged model and
271
- sidecar; declare the narrow resources explicitly if a normal web page must
272
- fetch them. See [Browser and Node runtime](docs/browser-runtime.md#wasm-only-manifest-v3-extensions)
273
- for complete packaging notes.
153
+ For a downloaded model, supply `graphPath` and `weightPaths`, or load their bytes
154
+ into `ModelPackage`. `GetModelInfo` reports the required inputs and outputs.
155
+ The [browser runtime guide](docs/browser-runtime.md) shows both forms, WebGPU
156
+ selection, result polling, and session cleanup. The repository also includes
157
+ [a minimal inference script](examples/call_inference.mjs).
274
158
 
275
- ## Training from APIs
159
+ ## Scheduling and generation
276
160
 
277
- Use the full entry when calling training, checkpoint, or gradient-accumulation
278
- APIs:
161
+ DIRECT is the default for one-shot inference. Choose SCHEDULED explicitly when
162
+ several producers need queue admission and arbitration in the same Runtime.
163
+ Only requests for a compatible compiled route can share a physical batch;
164
+ batching is useful when the graph preserves each request's independence.
279
165
 
280
- ```javascript
281
- import { VolvoxAI } from './dist/0.2.0/volvoxai.full.js';
282
- ```
166
+ For text generation, prefill a context with a prompt and then advance it one
167
+ step at a time. Its KV cache retains previous attention state. Paged caches can
168
+ share prefixes and retire individual lanes. `DecodeGenerate` handles a supported
169
+ fixed-count greedy feedback loop; sampling, stop conditions, and task policy
170
+ remain application decisions. See [scheduling and dynamic batching](docs/scheduling-and-dynamic-batching-design.md).
283
171
 
284
- In this module, the familiar `VolvoxAI`, `Graph`, and `ModelBuilder` exports are
285
- the training-capable variants; the explicit `TrainingVolvoxAI`,
286
- `TrainingGraph`, and `TrainingModelBuilder` names are also available.
287
- Initializers, optimizer state, and training-only builder helpers are deliberately
288
- absent from the inference entry.
289
-
290
- Models can start from an empty graph and initialized weights; no PyTorch export
291
- or seed safetensors file is required. The JavaScript builder provides generic
292
- GroupNorm, MoE and routed bottleneck adapters, deterministic Dropout, and
293
- explicit trainable-tensor selection. The repository's
294
- `examples/seq2seq_training/Seq2SeqBuilder.js` composes those primitives into an
295
- encoder-decoder with multimodal source features and teacher forcing; that
296
- model-family policy is not exported by either package entry.
297
-
298
- `trainStep()` accepts either the legacy single cross-entropy target or a
299
- `losses` list with independent logits, targets, weights, masks, and normalizers.
300
- Repeated logits tensors are allowed and their gradients add. Accumulation has
301
- reset/flush controls, and `maxGradNorm` clips one global norm over all trainable
302
- tensors. JavaScript CPU and WebGPU regenerate the same SDPA/CrossSDPA
303
- attention-dropout mask in forward and backward; inference never applies it.
304
-
305
- For an explicit C-backed browser training path, initialize the full entry with
306
- the full sidecar and set `backend: "wasm"`. It is strict: its current portable
307
- contracts are listed in [the operation status reference](docs/operation_list.md).
308
- Unsupported or non-canonical layouts are rejected before any model state
309
- changes, including ambiguous square linear layouts.
310
-
311
- Native CPU, Vulkan, OpenGL compute, and Metal support deterministic standalone
312
- Dropout training while keeping inference as an identity. Their SDPA/CrossSDPA
313
- training paths also implement after-softmax attention-probability dropout and
314
- regenerate the mask during backward; unsupported GPU layouts fall back to the
315
- matching complete native CPU path. See
316
- [model construction, routing, and training](docs/model_builder_training.md) and
317
- the [operation matrix](docs/operation_list.md) for exact backend limits.
318
-
319
- ## Native Usage
320
-
321
- ```bash
322
- make build_native
323
-
324
- # inference-only executable
325
- ./native/volvoxai --help
172
+ ## Full-profile training
326
173
 
327
- # inference + training executable
328
- ./native/volvoxai-full --help
329
- ```
174
+ Training follows **construct/load train → evaluate → commit or roll back → save**.
175
+ The Trainer owns private parameters, gradients, and optimizer state. Existing
176
+ compiled inference models keep their earlier weights after a commit; compile
177
+ again when you want to serve the new revision.
330
178
 
331
- The fixed release executables stay model-agnostic: both expose `run`, and only
332
- `volvoxai-full` additionally exposes `train`. They do not choose vocabulary
333
- files, decode images, or implement generation and task postprocessing.
179
+ Use `FullEngineHost` and `VxTrainingServiceClient` from `volvoxai/full`.
180
+ The [training guide](docs/model_builder_training.md) walks through building a
181
+ small classifier, running AdamW, saving a checkpoint, and resuming it.
182
+ It also covers multiple losses, accumulation, shape-cache limits, and LoRA.
334
183
 
335
- Generic tensor execution:
184
+ The [quantization guide](docs/quantization.md) continues from a float package to
185
+ calibration and W8A8 export. Full WASM supports the complete PTQ workflow using
186
+ bytes; your browser application chooses how to save them.
336
187
 
337
- ```bash
338
- ./native/volvoxai run models/tinystories_1m \
339
- --input tokens=models/tinystories_1m/tokens.i32 \
340
- --input positions=models/tinystories_1m/positions.i32 \
341
- --output logits=out.f32 \
342
- --row 4
343
- ```
188
+ ## Native use
344
189
 
345
- Raw input and output filenames must end in the declared storage dtype suffix:
346
- `.f32`, `.f16`, `.i32`, `.i8`, or `.u8`. Row output is currently F32-only.
347
-
348
- Generic cross-entropy training is available only in the full executable:
349
-
350
- ```bash
351
- ./native/volvoxai-full train models/my_model \
352
- --input input=batch.f32 \
353
- --targets targets.i32 \
354
- --logits logits \
355
- --trainable classifier.weight \
356
- --trainable classifier.bias \
357
- --steps 10 \
358
- --learning-rate 0.001 \
359
- --output-weights trained.safetensors \
360
- --output-optimizer optimizer.safetensors
190
+ ```sh
191
+ make build_native_profiles
192
+ ./native/volvoxai-lite --help
193
+ ./native/volvoxai --help
361
194
  ```
362
195
 
363
- Use `--input-optimizer` to resume saved optimizer state. Run
364
- `./native/volvoxai-full train --help` for all optimizer and backend options.
365
-
366
- Model-facing native task wrappers are an opt-in example:
196
+ Both executables run named raw tensors. Full additionally provides `train`.
197
+ For example, after the [quickstart](docs/quickstart.md#4-run-tinystories-from-native-c)
198
+ prepares a TinyStories package and six I32 tokens and positions:
367
199
 
368
- ```bash
369
- make -C examples native_task_cli
370
-
371
- examples/target/bin/volvoxai-tasks generate models/tinystories_1m \
372
- --prompt "Once upon a time, Lily" \
373
- --max-new 50
200
+ ```sh
201
+ ./native/volvoxai-lite run models/tinystories_1m \
202
+ --input 'tokens[1,6]=build/quickstart/tokens.i32' \
203
+ --input 'positions[1,6]=build/quickstart/positions.i32' \
204
+ --output logits=build/quickstart/logits.f32
374
205
  ```
375
206
 
376
- That example owns image decoding, vocabulary-file selection, generation loops,
377
- and the `generate`, `classify`, `detect`, `ctc`, `seq2seq`, and `chat` commands.
378
-
379
- Native executables do not need a shader directory. For shader development,
380
- point `VOLVOXAI_SHADER_DIR` at a generated directory containing `spv/`,
381
- `glsl/`, `gles/`, and `metal/`; VolvoxAI logs once when that override is used.
207
+ Use the [native guide](docs/native-runtime.md) for input preparation, CPU threads,
208
+ backend selection, embedding, and macOS/Android builds. The
209
+ [task CLI](examples/native_task_cli/README.md) adds image decoding and detection.
210
+ Native releases embed shaders; `VOLVOXAI_SHADER_DIR` provides a development
211
+ override and logs once when used.
382
212
 
383
- ## Example Models
213
+ ## Python
384
214
 
385
- Model weights are not committed. Regenerate the example packages from public
386
- sources:
215
+ The [Python package](python/README.md) provides native CPU/GPU inference,
216
+ training, quantization, tokenization, graph planning and scheduling through the
217
+ same generated API. Linux x86_64 wheels bundle inference/full libraries and the
218
+ loader, with CUDA, Vulkan and OpenGL backends. They also include ONNX conversion
219
+ and a PTQ command-line workflow.
387
220
 
388
- ```bash
389
- make models_deps
390
- make models_efficientdet
391
- make models_tinystories
221
+ ```sh
222
+ make build_wheel
223
+ python3 -m pip install dist/python/0.5.0/*.whl
392
224
  ```
393
225
 
394
- See [docs/models.md](docs/models.md) for export details.
226
+ For an exported model with one input, `InferenceSession` handles loading,
227
+ compilation, NumPy input/output and cleanup. CPU and automatic thread selection
228
+ are the defaults; FP32/INT8 precision comes from the model:
395
229
 
396
- ## Repository Layout
230
+ ```python
231
+ import numpy as np
232
+ import volvoxai as vx
397
233
 
398
- ```text
399
- ts/core/ TypeScript inference graph/data objects and model-agnostic orchestration
400
- ts/ops/ TypeScript operators plus graph validation and normalization
401
- ts/backends/ TypeScript CPU, WASM, WebGPU, and WebNN execution/device resources
402
- ts/training/ TypeScript training graphs/builders, autograd, optimizers, checkpoints
403
- examples/ Model-specific applications and reference integrations
404
- shaders/inference/ Forward WGSL sources
405
- shaders/training/ Backward and training WGSL sources
406
- native/include/ Public C APIs
407
- native/src/shader_store.* Lazy embedded-shader asset loader
408
- native/src/runtime/ Model state, graph, memory, and execution
409
- native/src/kernels/ Portable and optimized CPU/WASM kernels
410
- native/src/backends/ Vulkan, OpenGL, Metal, and NNAPI integrations
411
- native/src/training/ Training-specific orchestration
412
- native/cli/ Fixed model-agnostic command-line applications
413
- native/tests/ Native tests
414
- runtime/ Rust service wrapper around the C engine
234
+ with vx.InferenceSession("path/to/model") as session:
235
+ outputs = session.run(np.load("input.npy"))
236
+ ```
237
+
238
+ Use `AsyncInferenceSession` for asyncio, `vx.quantize` for streaming NumPy
239
+ calibration, and `TrainingSession` for training, saving and checkpoint resumption.
240
+ These workflows select the appropriate library and raise Python exceptions.
241
+ `InferenceSession.run_tensors()` retains CPU/CUDA results, reuses them as
242
+ inputs, and shares compatible buffers with PyTorch through DLPack.
243
+ `run()` continues to return NumPy arrays; GPU array libraries remain optional.
244
+ See the Python guide for full workflows, supported environments and PyPI
245
+ publishing. Python artifacts live outside the fixed npm release directory.
246
+
247
+ ## Documentation and API reference
248
+
249
+ The [documentation index](docs/README.md) separates learning material from
250
+ integration and engine-development guides. Useful starting points:
251
+
252
+ - [Quickstart](docs/quickstart.md) and [textbook](docs/textbook/README.md)
253
+ - [Model format](docs/model-format.md) and [operator support](docs/operation_list.md)
254
+ - [Architecture](ARCHITECTURE.md) and [backend development](docs/backend-sdk.md)
255
+ - [Testing](docs/testing.md) and [profiling](docs/profiling.md)
256
+
257
+ The schema in [volvoxai.proto](proto/volvoxai.proto) defines the shared API for
258
+ applications and AI agents. For field-level lookup and programmatic discovery,
259
+ use [API discovery](docs/api-discovery.md) and the generated
260
+ [inference](docs/generated/api-contract.inference.md) / [full](docs/generated/api-contract.full.md)
261
+ references. [Runtime integration](runtime/README.md) covers C/Python bindings
262
+ and regeneration. These references complement the task-oriented guides above.
263
+
264
+ ## Build and verify
265
+
266
+ ```sh
267
+ npm ci
268
+ npm run build:all # build JS first; this removes stale WASM companions
269
+ make build_wasm # both WASM profiles
270
+ make build_native_profiles # both native profiles
271
+ npm run test:proto-api
272
+ npm run test:wasm-ptq
273
+ npm run test:wasm-training-smoke
274
+ make test_native
275
+ npm run check:release
415
276
  ```
416
277
 
417
- See [ARCHITECTURE.md](ARCHITECTURE.md) for dependency and build-composition
418
- rules.
419
-
420
- ## Documentation
421
-
422
- - [Quickstart](docs/quickstart.md)
423
- - [Browser and Node runtime](docs/browser-runtime.md)
424
- - [Native runtime](docs/native-runtime.md)
425
- - [Custom backend SDK](docs/backend-sdk.md)
426
- - [Model format](docs/model-format.md)
427
- - [W8A8 safetensors companion scales](docs/w8a8-safetensors.md)
428
- - [Post-training quantization](docs/quantization.md)
429
- - [Model construction, routing, and training](docs/model_builder_training.md)
430
- - [Models and exporters](docs/models.md)
431
- - [Operation support matrix](docs/operation_list.md)
432
- - [Testing and validation](docs/testing.md)
433
- - [Roadmap](docs/roadmap.md)
434
- - [Textbook walkthrough](docs/textbook/README.md) ([한국어](docs/textbook/ko/README.md))
435
- - [EfficientDet benchmark notes](docs/efficientdet_tflite_vs_volvoxai.md)
436
-
437
- ## Current Status
438
-
439
- VolvoxAI can run real browser and native inference paths, but it is still early.
440
- Known gaps include WebGPU multi-output readback, broader WebNN coverage, additional
441
- native/WebGPU shaders for a few fallback ops, browser-side generation helpers,
442
- and formal CI wiring for the existing smoke tests.
443
-
444
- See [docs/roadmap.md](docs/roadmap.md) for the detailed list.
278
+ The fixed release inventory is four JS files (`volvoxai.lite.js`, `volvoxai.lite.min.js`,
279
+ `volvoxai.js`, `volvoxai.min.js`) and two WASM files (`volvoxai.lite.wasm`,
280
+ `volvoxai.wasm`) under `dist/<package-version>/`, plus `native/volvoxai-lite`
281
+ and `native/volvoxai`. See [testing](docs/testing.md) for release gates and
282
+ [deployment](docs/browser-runtime.md#packaging-and-browser-extensions) for runtime ZIPs and extensions.
445
283
 
446
284
  ## License
447
285