Back
HChuggingface.co
23
·1 days ago·Official · RSS

Introducing @huggingface/kernels: 200+ WebGPU Kernels for Local AI

View original
Official announcementHugging FaceOn-device

Heat trend

Collecting trend data

The percentage is based on available heat signal, not comment count or independent people.

AI summary

Hugging Face has introduced @huggingface/kernels, a collection of over 200 WebGPU kernels designed to enhance local AI inference in browsers. This initiative by the WebAI team aims to optimize browser inference speed and user-friendliness by providing efficient GPU operations. These WebGPU kernels are integrated into the Hugging Face Hub's broader kernel ecosystem, appearing alongside kernels for CUDA, ROCm, and Metal, and can be explored and filtered like other artifacts on the Hub.

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.

Today, we are releasing the first layer of that effort: @huggingface/kernels , a minimal library for loading and running optimized WebGPU kernels from the Hugging Face Hub, together with an initial collection of 207 kernels at huggingface.co/webgpu-kernels .

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. With your consent, every run adds private evidence that can help us find failures (incorrect results, pathologically slow cases, etc.), improve kernel variants, and make better optimization decisions across real-world hardware.

TL;DR

- 207 WebGPU kernels, published as individual repositories in the webgpu-kernels organization. Apache-2.0 licensed.

- A JavaScript loader, @huggingface/kernels, which downloads, prepares, and runs kernels directly from the Hub.

- Explicit contracts and reproducible evidence for every kernel, including manifests, correctness tests, benchmark cases, and WGSL shader templates.

- Fleet, a browser-based benchmarking tool that crowdsources correctness and performance evidence across real-world GPUs to help us improve kernels and their variants.

Why start with kernels?

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.

A kernel repository, not just a shader

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.

For example, ai.onnx.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.

The ai.onnx.Add repository packages its manifest, correctness and benchmark cases, and WGSL shader templates together.

Behind the card, the repository contains the artifacts needed to understand and evaluate the implementation:

- manifest.json is the source of truth for the operation contract. It defines inputs, outputs, attributes, type constraints, and shape derivation rules.

- metadata.json records the kernel identifier, digests, and provenance.

- test.json contains correctness cases, so an implementation can be checked against expected behavior.

- bench.json contains benchmark and tuning cases that represent the workloads used to evaluate the kernel.

- *.wgsl.jinja files contain the parameterized WGSL implementations used to produce shaders for a particular request and device.

This structure turns a shader into a reusable software artifact. 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.