Live data from Hacker News

MNIST training: Showdown between JavaScript and WebAssembly

ai.danruta.co.uk

11–20 of 34 posts

Re: MNIST training: Showdown between JavaScript and WebAssembly

#11
post #10

My browser at least seems to struggle to download the file at https://ai.danruta.co.uk/webassembly/mnist.js - how big is this file in total?

It is 20 Megabytes, transmitted gzipped at 2.4 Megabytes. It is super slow to grab though, due to the other end.

Re: MNIST training: Showdown between JavaScript and WebAssembly

#12
post #7
post #6

It would be a more fair comparison to https://deeplearnjs.org/ , since CPU training is not standard practice for neural nets these days.

We've done some initial tests ourselves. WASM doesn't yet support SIMD so WebGL tends to be 5-10x faster. SIMD is actively being worked on by many smart people in Chromium / other browsers, so I would expect to see huge wins in the near term future. When that happens, deeplearn.js will have a WASM backend. WASM has a much better memory management story (destructors on the C++ side) so I'm super excited about its futu…

Is SIMD going to close that performance gap for a problem that otherwise fits well on a GPU? Wouldn't the ideal by WASM support for GPU access?

Re: MNIST training: Showdown between JavaScript and WebAssembly

#17
post #7

Earlier quoted context omitted.

We've done some initial tests ourselves. WASM doesn't yet support SIMD so WebGL tends to be 5-10x faster. SIMD is actively being worked on by many smart people in Chromium / other browsers, so I would expect to see huge wins in the near term future. When that happens, deeplearn.js will have a WASM backend. WASM has a much better memory management story (destructors on the C++ side) so I'm super excited about its futu…

Is SIMD going to close that performance gap for a problem that otherwise fits well on a GPU? Wouldn't the ideal by WASM support for GPU access?

Indeed WASM supports GPU access through the normal JS WebGL API. Many asm.js/WebAssembly apps use the GPU in this way.

Though compiling WebAssembly to GPU code would be a very interesting thing to explore, too.

Re: MNIST training: Showdown between JavaScript and WebAssembly

#19
post #18

So what's the explanation for the 20x difference? Is the JS implementation untuned? edit: seems the JS is written in the straightforward, idiomatic JS way without employing speed hacks or typed arrays. So that I guess explains some of it.

You tell me, https://github.com/DanRuta/jsNet/tree/master/dev/js

Ran in Chrome profiler, spent most time in these forward/backward functions https://github.com/DanRuta/jsNet/blob/master/dev/js/ConvLaye...

Re: MNIST training: Showdown between JavaScript and WebAssembly

#20
post #17

Earlier quoted context omitted.

Is SIMD going to close that performance gap for a problem that otherwise fits well on a GPU? Wouldn't the ideal by WASM support for GPU access?

Indeed WASM supports GPU access through the normal JS WebGL API. Many asm.js/WebAssembly apps use the GPU in this way. Though compiling WebAssembly to GPU code would be a very interesting thing to explore, too.

This probably won't buy you anything. The API you still have is WebGL, and JS is not the bottleneck.
Post reply on HN