Skip to content
IJK

WebGPU Kernels: Portability Is Not Performance

By IJK ·

What a Hugging Face post says WebGPU provides, why portability does not mean performance and which factors affect a shader's performance.

What WebGPU provides

A model running in the browser eventually becomes a sequence of GPU operations: matrix multiplications, normalizations, convolutions, attention primitives, quantization operations, data-layout transformations, and many more. [1]

WebGPU makes these operations available across modern browsers through a portable API, while WGSL provides a common language for the shaders that execute them. [2]

Why portability is not performance

Portability, however, does not automatically mean performance. [3]

Two shaders can implement the same operation and produce the same output while behaving completely differently across different accelerators. [4]

What affects performance

Workgroup sizes, memory access patterns, vectorization, data types, and fusion strategies can all affect performance. [5]

The best choice can also change with the input shape, device, browser, and available WebGPU features. [6]

does not guaranteebecause ofWebGPU and WGSLa portable API and a common shader languageTwo shaders, the same outputbehave completely differently across acceleratorsWorkgroup sizes, memory access, vectorization,fusionthe best choice changes with shape, device and br...
Why do portable shaders differ?

Sources

  1. The Hugging Face source says: A model running in the browser eventually becomes a sequence of GPU operations: matrix multiplications, normalizations, convolutions, attention primitives, quantization operations, data-layout transformations, and many more. huggingface/kernels: WebGPU Kernels for Local AI
  2. The Hugging Face source says: WebGPU makes these operations available across modern browsers through a portable API, while WGSL provides a common language for the shaders that execute them. huggingface/kernels: WebGPU Kernels for Local AI
  3. The Hugging Face source says: Portability, however, does not automatically mean performance. huggingface/kernels: WebGPU Kernels for Local AI
  4. The Hugging Face source says: Two shaders can implement the same operation and produce the same output while behaving completely differently across different accelerators. huggingface/kernels: WebGPU Kernels for Local AI
  5. The Hugging Face source says: Workgroup sizes, memory access patterns, vectorization, data types, and fusion strategies can all affect performance. huggingface/kernels: WebGPU Kernels for Local AI
  6. The Hugging Face source says: The best choice can also change with the input shape, device, browser, and available WebGPU features. huggingface/kernels: WebGPU Kernels for Local AI

Editorial (AI-assisted; automatically checked, not human-reviewed). Each statement is linked to its source; check the source before relying on a detail.

  • webgpu
  • kernels
  • browser inference
  • hugging face