# WebGPU A modern W3C web standard for accessing GPU compute and graphics capabilities directly from JavaScript. Successor to WebGL. Designed for both 3D graphics and general-purpose GPU compute (GPGPU), making it foundational for browser-based ML, simulations, and visualization. Spec: https://www.w3.org/TR/webgpu/ ## What it does - **Compute shaders**: arbitrary GPU computation (matrix multiplication, neural net ops) - **Modern graphics**: 3D rendering matching capabilities of Vulkan/Metal/D3D12 - **Cross-platform**: one API across Windows, macOS, Linux, and ChromeOS - **Native performance**: maps directly to native GPU APIs ## Why It Matters for ML Before WebGPU, browser ML libraries had to use WebGL (a graphics API) hacks to access GPU compute. WebGPU provides first-class compute shader support, enabling: - [[Transformers.js]] runs models faster on GPU - [[ONNX Runtime Web]] uses WebGPU as a high-performance execution provider - TensorFlow.js delegates ops to WebGPU ## Relationship to WebNN | | [[WebNN API]] | WebGPU | |---|---|---| | Abstraction | ML-specific (neural net ops) | General-purpose GPU | | Hardware | GPU + NPU + CPU | GPU only | | Optimization | Browser optimizes per-hardware | Developer writes shaders | | Intended user | App developer using ML | ML library author, graphics dev | WebNN sits at a higher level; WebGPU is the substrate that ML libraries can target directly. ## Status Shipping in Chrome and Edge. Available in Firefox Nightly. Safari implementing. ## References - https://www.w3.org/TR/webgpu/ - https://gpuweb.github.io/gpuweb/ ## Related - [[WebNN API]] - [[Web Assembly (WASM)]] - [[WebMachineLearning]] - [[Transformers.js]] - [[ONNX Runtime Web]] - [[On-Device Machine Learning]] - [[Neural Processing Unit (NPU)]]