Skip to content

WebGPU

Key idea:

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.

Try it now — free →

Details

  • Compute shaders — ML inference directly in the browser (WebLLM, ONNX Runtime Web)
  • WGSL — type-safe shading language, compiled to the native shader backend
  • Async pipeline creation, explicit resource barriers
  • Command buffers are recorded once, reused
  • Limits API: request required features, otherwise runtime-fallback

Example

// 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
  }
`});

Related

Learn more

Frequently Asked Questions

WebGPU vs WebGL?

WebGL — graphics only. WebGPU adds compute shaders + a better memory model, mirrors modern backend APIs.

Can I use it already?

For progressive enhancement — yes (Chrome 113+). For production-critical workloads — wait for Firefox stable (2026).

ML in the browser?

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.