NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DistML.js: Installation-free Distributed Deep Learning Framework for Web Browsers

Masatoshi Hidaka, Tomohiro Hashimoto, Yuto Nishizawa, Tatsuya HaradaarXiv 2024

Abstract

We present "DistML.js", a library designed for training and inference of machine learning models within web browsers. Not only does DistML.js facilitate model training on local devices, but it also supports distributed learning through communication with servers. Its design and define-by-run API for deep learning model construction resemble PyTorch, thereby reducing the learning curve for prototyping. Matrix computations involved in model training and inference are executed on the backend utilizing WebGL, enabling high-speed calculations. We provide a comprehensive explanation of DistML.js's design, API, and implementation, alongside practical applications including data parallelism in learning.

Introduction

Deep learning typically requires high-end GPUs and complex software environments. While volunteer computing and federated learning offer ways to utilize edge devices, the barrier to entry is often high due to the need for specific software installations. DistML.js addresses this friction by using the web browser as a universal execution platform, enabling "installation-free" distributed training across heterogeneous devices like smartphones and PCs.

Methods

DistML.js is implemented in TypeScript and focuses on several technical pillars:

  • PyTorch-like API: Adopts a "define-by-run" approach. Because JavaScript lacks Python’s __call__ magic method, the library uses model.c() to invoke the forward pass.
  • WebGL Backend: Matrix computations are offloaded to the GPU via WebGL to achieve competitive speeds.
  • Manual Memory Management: To prevent memory leaks on the GPU, the library implements a K.tidy function (inspired by TensorFlow.js) to manually release tensors.
  • Hybrid Distributed Architecture: A Python server handles coordination and weight averaging, while web browsers act as worker clients communicating via HTTP and WebSockets.

Experimental Evaluation

The framework was evaluated using the CIFAR-10 dataset and a ResNet-18 architecture (11M parameters). Testing spanned diverse hardware, including an iPhone 13 Mini (Safari), a MacBook Air M1 (Chrome), and a high-end Windows Desktop (Edge).

Single-Device Performance

Processing efficiency improved significantly with larger batch sizes as the overhead of matrix operations was amortized. On desktop systems, throughput continued to scale up to a batch size of 512. However, mobile devices like the iPhone 13 Mini faced stability issues beyond a batch size of 128 due to limited GPU memory.

Throughput performance across different operating systems and batch sizes.

Distributed Scaling

In a data-parallel setup, the framework achieved a 2.4x speedup with 16 workers. However, the experiments revealed a performance plateau at 16 devices. With an average communication speed of 606 Mbps, network bandwidth became the primary bottleneck, as the time spent transmitting gradients began to outweigh the computational gains.

Scaling performance of distributed training with increasing device counts.

Conclusion

DistML.js demonstrates the feasibility of browser-based distributed deep learning. While communication overhead remains a challenge for web protocols, the transition to WebGPU and the implementation of gradient compression offer promising paths forward for large-scale, installation-free volunteer computing.

Source Code: https://github.com/mil-tokyo/distmljs

Summary updated

BibTeX
@misc{hidaka2024distml,
  author = {Masatoshi Hidaka and Tomohiro Hashimoto and Yuto Nishizawa and Tatsuya Harada},
  title = {{DistML.js: Installation-free Distributed Deep Learning Framework for Web Browsers}},
  year = {2024},
  eprint = {2407.01023},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.01023},
}
Figure