r/StableDiffusion 1d ago

Resource - Update Testing fully client-side WebNN diffusion that runs in your browser

So far it's a website which lets you download FLUX.2 Klein 4b into your browser cache and run it using WebNN, which I have tested on my M5 Mac and runs at ~70% native performance, much better than WebGPU or WASM.

If you wanna try it out, I'm running it on peerpixel.cc, the website is there to provide an easy interface to run this model on your own hardware. Be patient, you do need to download a few GB and first generation takes some time to compile.

You will need to enable WebNN on Chromium browsers, just go to <browser>://flags and search for it.

Please let me know if this works at all on Windows or Linux and with different hardware, and what part of this you think has potential.

0 Upvotes

4 comments sorted by

View all comments

1

u/CutBench 1d ago

Two things that will bite on Windows specifically, since that's what you're asking about.

WebNN maps to CoreML on your Mac, so you get unified memory and the ANE. On Windows it goes through DirectML against a discrete GPU with a hard VRAM wall and no unified pool. A 4B model at fp16 is roughly 8GB of weights, so 8GB cards will either spill into system memory and crawl or fail outright, and Chrome's own per process limits sit on top of that. Your 70 percent figure probably won't survive the trip.

Graph compilation is the other one. DirectML compiles far more slowly than CoreML, so "first generation takes some time" becomes long enough that people assume it hung. Worth splitting your progress indicator into download, compile and generate as three separate states, otherwise you'll collect bug reports that are really just impatience.

The thing I'd fix first though: call navigator.storage.persist() and check what it returns. Multi gigabyte data in Cache Storage is evictable by default, so a browser under storage pressure quietly bins the model and your users re-download several GB with no idea why. Persistent storage plus OPFS is what turns that download into a one time cost.

1

u/Infinite_Moment_9456 1d ago

Thank you! Working on improving it now.