Parallel chains via Web Workers
sampling() runs one chain inside the page’s own Pyodide kernel worker – a single thread. StanModel.sampling_parallel(n_chains=...) instead spawns one plain-JS Web Worker per chain (no Pyodide in them, just stanwasm’s wasm module loaded fresh in each), so multiple chains can run at once across whatever cores the browser gives them. Quarto Live’s own Pyodide runs in a dedicated Web Worker too (confirmed the same way as the JupyterLite/marimo demos), so the Workers sampling_parallel spawns here aren’t nested inside another Worker – an easier case, same as the PyScript demo.
This needs nested-Worker support (a Worker spawning another Worker): current Chrome/Edge/Firefox, and Safari 16.4+ (March 2023). Where that’s unavailable it falls back to running the chains one at a time through sampling() and prints a warning – it never just fails.
Everything runs in a single block – see linear-regression.qmd for why.