
In the last post I argued that Python in the browser still has a job: running existing Python, compiled libraries included, where you have no server. This post tests that argument on something heavy. Training a neural network on the user's GPU, inside a tab.
On November 23, Anutosh Bhat of QuantStack published "Train in Your Tab". It shows PyTorch, JAX and their compilers running inside JupyterLite.
Short version: In one reported run, an MNIST training loop ran about 12.6x faster on WebGPU than on the same stack's CPU path, with the same accuracy. The speedup depends on how much work you give the GPU, and much of the stack still lives in forks.
What was built
Everything runs in the page. The server delivers the app, the packages, the datasets and the model weights. The computation happens on your machine.
This is not Pyodide. The example environment file in the post (for its depth-estimation notebooks) uses the emscripten-forge package set with a xeus-python kernel, Python 3.14.3 and a PyTorch 2.15.0a0 build for the emscripten-wasm64 target. JupyterLite can run more than one kind of Python kernel, and this work uses a different one from the Pyodide kernel I described last time.
Four ways to run a model
Route | How it works | Runs on |
|---|---|---|
Eager PyTorch | Operations execute as Python reaches them | CPU, in WebAssembly |
TorchInductor |
| CPU, in WebAssembly |
TorchAX | PyTorch computations go to JAX and XLA, then LLVM to WebAssembly | CPU, in WebAssembly |
IREE | PyTorch goes through Turbine and Torch-MLIR into the IREE compiler, which emits WGSL shaders | GPU, through WebGPU |
The GPU route looks like this:
flowchart LR
A["PyTorch model and training step"] --> B["Turbine and Torch-MLIR"]
B --> C["IREE compiler"]
C --> D["SPIR-V, then WGSL shaders"]
D --> E["IREE runtime in WebAssembly"]
E --> F["Browser GPU through WebGPU"]The compilers live in the tab too. You can change a model in a cell, compile it again and run it, and the generated C++ is there to inspect. That is the part of the design I find most interesting.
The benchmark
The CPU and WebGPU notebooks use the same model, initial weights, minibatch order and optimizer settings. The notebooks also check the first update against eager PyTorch, and parameters and optimizer state stay on the GPU between updates.
Benchmark setup in full
A 3.25-million-parameter model in FP32
49,152 training examples, three epochs, batch size 256
SGD with learning rate 0.05 and momentum 0.9
The first update is checked against eager PyTorch: loss, gradients, updated weights and momentum
One local run on an Apple M5 system with 16 GiB of memory, Chrome 157 and the wasm64 packages
The CPU build runs without pthreads
Measurement | IREE CPU | IREE WebGPU |
|---|---|---|
Three training epochs | 86.60 s | 6.86 s |
32 warmed updates, inputs already on the device | 4.570 s | 0.370 s |
Test accuracy | 96.8% | 96.8% |
That works out to about 12.6x for the full loop and 12.4x for the resident-update measurement. Matching accuracy is the check that matters here, because a fast GPU path that trains a different model proves nothing.
What the number does and doesn't tell you
The baseline is the same stack on CPU
The post says the CPU build runs without pthreads, so it is most likely using a single core. It is not native PyTorch and not a multi-core CPU. The author is explicit that this is not a general comparison of browser ML backends.
It is one run on one machine
The post describes a single run on an Apple M5 system with Chrome 157. I did not see other browsers or GPUs reported.
The GPU only wins with enough work
The author's inference numbers show the crossover:
Inference | CPU | WebGPU |
|---|---|---|
One image | 1.23 ms | 1.63 ms |
Batch of 256 | 71.5 ms | 3.85 ms |
For a single image the CPU is faster. At batch size 256 the GPU is roughly 19 times faster.
The first step is a different cost
The first update has to trace, compile and run, and the post times it separately from the warmed numbers. How long you wait before anything happens is a big part of whether this feels usable.
How it compares with ExecuTorch
The PyTorch team announced a WebGPU backend for ExecuTorch on November 10. You export a model once to a .pte file and it runs in any WebGPU browser. Their reported speedups are 4 to 7 times over ExecuTorch's own CPU path (WebAssembly plus XNNPACK) for prefill, and 2 to 10 times for decode.
The goals differ. ExecuTorch is a deployment route for exported models. The notebook approach is an interactive Python environment where the framework, the compiler and the runtime sit together.
The author calls the two complementary, and ported five of ExecuTorch's playground demos as editable notebooks: super-resolution, background removal, depth estimation, object detection and speech to text.
What it rests on
Much of this lives in forks, and parts of it are marked experimental. Slow down before building anything on it.
A lot of it is downstream. The browser IREE integration and the Turbine device adapter are maintained in forks. IREE marks its WebAssembly and WebGPU support as experimental. The XLA maintainers said WebAssembly is outside their CPU roadmap, so those changes stay in forks too.
The scope is narrow. The GPU path covers compiled dense-tensor workflows. General eager WebGPU operations and distributed execution are listed as future work.
It needs a sponsor. The author is open about wanting funding and collaborators to keep the ports maintained and get the larger changes upstream.
There is a good side too. The GPU path runs Python and WebGPU in the same worker and needs no SharedArrayBuffer, no extra GPU worker, no cross-origin isolation headers, and no JSPI or Asyncify. Threaded WebAssembly usually needs some of those, so this should be easy to host on plain static hosting.
Reproduce it
Everything above comes from the author's post. I have not reproduced these numbers myself, so treat them as one reported run.
If you want to check them:
Open the MNIST CPU/WebGPU notebook pair on notebook.link and run both to the end
Record your browser and version, OS and GPU, and confirm the browser is using a real GPU adapter rather than a software fallback
Note the first-update time, the three-epoch time, the 32-update time and the test accuracy
Time inference for one image and for a batch of 256
Change the batch size or model width and watch where the CPU and GPU lines cross
Try a second browser and, if you can, a non-Apple GPU
Look at download size and memory in the browser's developer tools
That last item matters most to me. Download size and memory are the costs I flagged in the Pyodide post, and I did not see them reported here.
Where this leaves the Pyodide argument
Translating a framework and a compiler like this into JavaScript is not a realistic option. It is exactly the case where the Python has to come along.
The costs from the first post still apply, and some may grow: large packages, an alpha PyTorch build, a stack that depends on forks. What you get in return is no install, no server, and data that stays on the device.
Whether that trade is worth it depends on the project. For teaching, demos and small experiments it already looks tempting. For production, I would wait for the upstream pieces to land.
Sources
Anutosh Bhat, Train in Your Tab: PyTorch, JAX and ML Compilers in the Browser (QuantStack, November 23, 2026): the stack, benchmark setup and results, caveats
The post's MNIST CPU/WebGPU notebooks and PyTorch CPU notebooks
PyTorch blog, ExecuTorch WebGPU: PyTorch Models on the GPU, in the Browser (November 10, 2026)
Comments0
Log in to join the discussion.
No comments yet.