WebGPU — the new web standard (W3C, finalized 2023) for working with the GPU in the browser. Replaces WebGL 2.0, adds compute shaders (ML inference, physics), maps natively to Vulkan/Metal/Direct3D 12. Shading language: WGSL (not GLSL). Support: Chrome 113+, Safari 17+ (iOS 18), Firefox 141+ (flag). Production use: WebLLM, TensorFlow.js GPU backend.
Below: details, example, related terms, FAQ.
// WebGPU — minimal compute shader
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const shader = device.createShaderModule({ code: /* WGSL */ `
@compute @workgroup_size(64)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
// parallel work here
}
`});WebGL — graphics only. WebGPU adds compute shaders + a better memory model, mirrors modern backend APIs.
For progressive enhancement — yes (Chrome 113+). For production-critical workloads — wait for Firefox stable (2026).
WebLLM runs Llama-7B on an RTX 3060 via WebGPU at 20-30 tokens/sec. Not better than server-side, but handy for private workloads.