Key takeaways

  • One of our biggest goals on the WebAI team at Hugging Face is to make browser inference as fast and as user-friendly as possible.
  • The collection covers operations used across a wide variety of machine learning architectures and workloads.
  • Beyond the results for your own machine, Fleet gives the community a way to contribute performance and correctness evidence from devices we…

What happened

One of our biggest goals on the WebAI team at Hugging Face is to make browser inference as fast and as user-friendly as possible. Getting there is a multi-layer effort: models need browser-friendly representations, runtimes need to build efficient execution plans, and the individual GPU operations at the bottom of the stack need to make the most of many different devices and browser implementations. co/webgpu-kernels.

The interface is inspectable without reading WGSL, correctness and performance cases travel with the implementation, and published versions can be loaded explicitly rather than depending on an unversioned file URL. Our kernels can also serve as reference implementations for developers building custom WebGPU kernels or integrating these operations into their own runtimes. @huggingface/kernels provides the bridge between a kernel repository and your application.

Call getKernel with a Hub repository ID and a contract version, then invoke the returned function with typed input data and tensor shapes. Here is a small bias-add example: The second input is broadcast across the first dimension, producing an output with shape [2, 3]. The loader derives that output shape and logical data type from the manifest contract and the inputs, then allocates c automatically.

Addition on six floats is deliberately the smallest possible demo. At this size, the GPU round trip costs far more than the math. MatMul). Only the repository ID and the inputs change. Even this elementary operation illustrates why kernels need variants. Equal-shape addition can use a direct vectorized path, while broadcasted inputs need different indexing logic.

Why it matters

The collection covers operations used across a wide variety of machine learning architectures and workloads. More importantly, each kernel is published as a complete, versioned package: its interface, shader templates, correctness cases, benchmark cases, and usage instructions all live together on the Hub. We are also launching Fleet, an in-browser GPU benchmarking and testing suite that runs and scores the kernels on your hardware.

Beyond the results for your own machine, Fleet gives the community a way to contribute performance and correctness evidence from devices we could never cover in a conventional test lab. ), improve kernel variants, and make better optimization decisions across real-world hardware. 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.

WebGPU makes these operations available across modern browsers through a portable API, while WGSL provides a common language for the shaders that execute them. Portability, however, does not automatically mean performance. Two shaders can implement the same operation and produce the same output while behaving completely differently across different accelerators. Workgroup sizes, memory access patterns, vectorization, data types, and fusion strategies can all affect performance.

The best choice can also change with the input shape, device, browser, and available WebGPU features. This is why kernels form a foundational layer of fast browser inference. Higher-level runtimes can only be as efficient as the operations they dispatch. By making those operations individually discoverable, testable, benchmarkable, and versioned, we can improve the foundation independently while keeping a stable contract for the layers above it.

Each kernel in the collection has its own repository and kernel card. The card documents the operation's semantics, inputs, outputs, attributes, supported data types, source files, and a ready-to-run @huggingface/kernels example. Add implements elementwise addition with multidirectional broadcasting. It is one of the simplest operations in a neural network, used everywhere from residual connections to adding a bias.

Its card documents the two inputs, the broadcasted output shape, supported data types, and the variants available for different shapes and devices. Behind the card, the repository contains the artifacts needed to understand and evaluate the implementation: This structure turns a shader into a reusable software artifact.

What to watch

The published Add kernel includes variants for equal shapes, vectorized broadcasting, scalar processing, and general broadcasting. The runtime can select an implementation that fits the current call and device without changing the application-facing API. The version: 1 option selects version 1 of the published kernel contract. It is separate from an ONNX opset, an operator's since_version, or a model revision.

Keeping those concepts separate lets applications depend on a stable JavaScript-facing contract while kernel implementations evolve behind it. So, how much of a difference do optimized kernels actually make?