@seantalts/stanli 0.1.0 → 0.6.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 +17 -16
- package/package.json +1 -1
- package/stanli.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# stanli
|
|
2
2
|
|
|
3
3
|
Full [Stan](https://mc-stan.org) in the browser. stanc3 (the real Stan
|
|
4
|
-
compiler, compiled to JavaScript) turns Stan source into its
|
|
5
|
-
representation; a WebAssembly build of the stanli runtime
|
|
6
|
-
op graph over precompiled stan-math kernels and samples
|
|
7
|
-
server, no C++ toolchain, everything in the tab. Live
|
|
8
|
-
<https://seantalts.github.io/stanli/>.
|
|
4
|
+
compiler, compiled to JavaScript) turns Stan source into its
|
|
5
|
+
intermediate representation; a WebAssembly build of the stanli runtime
|
|
6
|
+
lowers it to an op graph over precompiled stan-math kernels and samples
|
|
7
|
+
with NUTS. No server, no C++ toolchain, everything in the tab. Live
|
|
8
|
+
demo: <https://seantalts.github.io/stanli/>.
|
|
9
9
|
|
|
10
10
|
```js
|
|
11
11
|
import { sample } from "@seantalts/stanli";
|
|
@@ -30,17 +30,18 @@ parameters, and generated quantities (RNG draws stream from `seed`).
|
|
|
30
30
|
The heavy work runs in a worker the package owns, so the page never
|
|
31
31
|
blocks; calls queue and run one at a time.
|
|
32
32
|
|
|
33
|
-
The payload is ~9 MB installed
|
|
34
|
-
runtime plus the stanc3 compiler. The compiler loads lazily, only
|
|
35
|
-
call passes Stan source. `preload()` starts both loads in the
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
The payload is ~9 MB installed, ~1.9 MB over the wire with gzip: the
|
|
34
|
+
WASM runtime plus the stanc3 compiler. The compiler loads lazily, only
|
|
35
|
+
when a call passes Stan source. `preload()` starts both loads in the
|
|
36
|
+
background; call it at page idle so the first `sample()` skips the
|
|
37
|
+
fetch and parse. An app that ships a fixed model can precompile it at
|
|
38
|
+
build time (`stanc --debug-transformed-mir model.stan`) and pass `mir`
|
|
39
|
+
instead of `code`; the runtime alone is ~1.5 MB gzipped.
|
|
40
|
+
|
|
41
|
+
118 of 119 posteriordb corpus models verify against CmdStan's log
|
|
42
|
+
density, gradients, and write_array values from inside this WASM build;
|
|
43
|
+
see the [repository](https://github.com/seantalts/stanli) for the
|
|
44
|
+
verification policy and numbers.
|
|
44
45
|
|
|
45
46
|
Not yet here: variational inference, optimization, multi-chain
|
|
46
47
|
threading. `wasm32` caps memory at 4 GB, which one 79,000-parameter
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seantalts/stanli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Full Stan in the browser: stanc3 compiles the model in JS, a WASM runtime lowers it to an op graph and runs NUTS. No server, no C++ toolchain.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
package/stanli.wasm
CHANGED
|
Binary file
|