Skip to content

Web runtime & typed artifacts

@arti-fit/web is an Alpha, inference-only binding. Python defines and exports the graph; the browser validates the artifact, selects an execution provider, runs named float32 tensors, and disposes resources. JavaScript does not reimplement Half, Fold, Pulse, Recall, or other ARTI mechanisms.

import arti
result = arti.web.export(
layer,
"layer-web",
example_inputs={"x": x},
)

A format-v2 export contains model.onnx, arti-web.json, arti-web.lock.json, and artifact.ts. The generated TypeScript client’s property names come from the hashed manifest. A one-input/one-output artifact exposes forward(); named multi-input graphs expose typed run().

import { loadArti } from "@arti-fit/web";
const module = await loadArti("/layer-web/", {
device: "auto",
signal: abortController.signal,
onProgress: ({ stage, loadedBytes, totalBytes }) => {
console.log(stage, loadedBytes, totalBytes);
},
});
const output = await module.predict({
x: { data: values, dims: [batch, tokens, dim] },
});
console.log(output.y.data);
await module.dispose();

predict() accepts CPU-resident float32 values and owns the temporary ONNX Runtime tensors it creates. Use the lower-level run() API when outputs must remain GPU-resident or buffers are caller-owned.

ARTI 1.7.0 and @arti-fit/web 0.1.0-alpha.5 can export selected tensor leaves from the module’s real forward(..., return_info=True) result. Python names each output and declares its dtype, logical type, role, dynamic axes, byte budget, and numerical tolerance in the hashed manifest.

result = arti.web.export(
fusion,
"fusion-web",
example_inputs={"pulses": pulses, "mask": mask, "source_mask": source_mask},
forward_kwargs={"return_info": True},
include_outputs=("fused", "survival", "workspace", "unfold_source_index"),
)
const result = await module.inspect(
{ pulses, mask, source_mask },
{ outputs: ["fused", "survival", "workspace", "unfold_source_index"] },
);
console.log(result.device, result.timings.inferenceMs);
const { workspace } = await result.download(["workspace"]);
await result.dispose();

inspect() asks ONNX Runtime to fetch only the selected, Python-declared outputs. On WebGPU, retained outputs stay device-resident until download(). OwnedRunResult must be disposed; disposing the parent module also expires every retained or in-flight result. Roles such as workspace, diagnostic, mask, and index are metadata to JavaScript—not a second implementation of ARTI semantics.

The Workspace Evidence Lab runs the repository’s locked FusionPulse fixture and checks its browser result against Python parity data.

device: "auto" attempts WebGPU and can fall back to WASM. Locking WebGPU must surface failure instead of silently changing provider. ArtiWebError exposes a stable code, stage, sanitized artifact URL, device, and tensor-contract context. Loading progress moves through manifest, lock, model, verification, initialization, and ready stages.

Stateful Recall uses paired Python-exported read/update graphs and explicit fixed-size state. The browser API supports commit, snapshot, restore, fork, async reset, and dispose, with caller-configurable state and aggregate-artifact budgets. This is bounded inference state—not browser training or unconstrained memory.

The reference Worker protocol supports load, run, inspect, dispose, and cancel, and transfers only CPU ArrayBuffer values between threads. WebGPU tensors, GPU buffers, and OwnedRunResult stay Worker-owned. Cancellation is cooperative: an in-flight ONNX call may finish, but its late result is suppressed and disposed.

Manifest and lock hashes detect drift relative to the supplied lock; they do not establish publisher identity. Host artifacts from a trusted origin, enforce size budgets, validate tensor names and shapes, and dispose every module and tensor lifecycle you own.