Hugging Face has released @huggingface/kernels, a JavaScript library designed to load and run optimized WebGPU kernels from repositories on the Hugging Face Hub. The launch includes an initial collection of 207 kernels intended to strengthen the low-level infrastructure behind local AI inference in web browsers.
Published on September 1, 2026, the collection packages each operation as more than an isolated shader. Individual repositories include versioned contracts, parameterized WGSL implementations, correctness cases, benchmark workloads, metadata, and usage instructions. Hugging Face has also introduced Fleet, an in-browser testing and benchmarking suite through which users can evaluate the kernels on their own GPUs and, with consent, privately contribute evidence about performance and correctness.
What Hugging Face released
The initial release consists of four connected elements:
- 207 WebGPU kernels published as individual repositories under the
webgpu-kernelsorganization on the Hugging Face Hub. - The
@huggingface/kernelsJavaScript loader, which downloads, prepares, and executes kernels from those repositories. - Explicit contracts and reproducible supporting material for each kernel, including manifests, correctness tests, benchmark cases, and WGSL shader templates.
- Fleet, a browser-based suite for testing performance and correctness across a broader selection of real-world GPUs, browsers, and drivers.
The 207 repositories are Apache-2.0 licensed. They cover operations used across multiple machine-learning architectures and workloads rather than serving a single model family.
Why kernels matter for browser inference
A model executed in a browser ultimately becomes a sequence of lower-level GPU operations. Those operations can include matrix multiplication, convolution, normalization, attention primitives, quantization, and transformations between data layouts. WebGPU supplies a portable browser API for accessing GPU capabilities, while WGSL supplies a shared language for the shaders performing the computation.
Portability alone does not guarantee that an operation will run efficiently. Two shaders may calculate the same result but perform very differently depending on their workgroup sizes, memory-access patterns, vectorization, data types, and fusion strategies. The fastest choice can also vary with input shape, GPU, browser implementation, and the WebGPU features available on a device.
Hugging Face is therefore treating kernels as a distinct foundation for its browser inference work. Separating the operations into discoverable and versioned artifacts allows developers to test and improve them without changing the stable interfaces used by higher-level runtimes. It also creates a place to compare multiple implementation variants for the same logical operation.
Each repository contains a complete kernel package
Every kernel has its own Hub repository and a kernel card describing the operation’s semantics, inputs, outputs, attributes, supported data types, source files, and example usage. Hugging Face highlights ai.onnx.Add, an elementwise addition operation supporting multidirectional broadcasting, as a straightforward example.
The underlying repository structure assigns a specific role to each artifact:
manifest.jsondefines the operation contract, including inputs, outputs, attributes, type constraints, and rules for deriving shapes.metadata.jsonstores the kernel identifier, digests, and provenance.test.jsoncontains correctness cases against which an implementation can be checked.bench.jsonsupplies benchmark and tuning cases representing evaluation workloads.*.wgsl.jinjafiles hold parameterized WGSL implementations used to generate shaders for a particular request and device.
This packaging makes the interface inspectable without requiring a developer to begin by reading shader code. Tests and benchmarks travel with the implementation, and applications can request published versions instead of relying on an unversioned shader URL. Hugging Face also presents the repositories as possible reference implementations for teams writing their own WebGPU kernels or integrating equivalent operations into other runtimes.
Loading and running a kernel from JavaScript
The preview package can be installed with npm install @huggingface/kernels@preview. It requires a browser environment with WebGPU support, whose availability depends on the browser, operating system, GPU, and driver. Applications can perform a basic JavaScript availability check using "gpu" in navigator.
The library exposes getKernel. A caller supplies a Hub repository identifier and a contract version, then invokes the resulting function with typed data and tensor shapes. In Hugging Face’s addition example, the first input is a Float32Array containing six values with shape [2, 3]. The second contains three values with shape [3]. The loader broadcasts that second input across the first dimension, derives the output’s logical type and shape from the manifest, and allocates an output named c with shape [2, 3].
The tiny six-float operation is meant to demonstrate the interface, not GPU efficiency: at that size, the GPU round trip costs considerably more than the arithmetic. The same calling pattern, however, can be used for heavier operations such as ai.onnx.MatMul by changing the repository identifier and inputs.
Stable contracts and implementation variants
The addition kernel demonstrates why a single operation may need several implementations. Equal-shape tensors can use a direct vectorized path, while broadcasting requires different indexing. The published Add repository includes variants for equal shapes, vectorized broadcasting, scalar processing, and general broadcasting. The runtime can choose a suitable variant for the request and device without altering the application-facing API.
The option version: 1 specifically selects version 1 of the published kernel contract. It does not refer to an ONNX opset, an operator’s since_version, or a model revision. That distinction is intended to let the JavaScript interface remain stable while the implementations behind it evolve.
Hugging Face reports faster operation-level benchmarks
Hugging Face compared its collection with ORT WebGPU on an Apple M4 GPU using ONNX Runtime Web version 1.30.0-dev.20260826-b1f76d586a. The evaluation began with 1,756 test cases across all 207 operations. It retained 809 cases in which both systems produced matching outputs and timings considered reliable.
Across those retained comparisons, Hugging Face reports a 2.57-times geometric-mean speedup and a 1.90-times median speedup. Its kernels recorded 629 wins, 176 losses, and four ties.
| Operation | Cases | Hugging Face kernel | ORT WebGPU | Reported speedup |
|---|---|---|---|---|
| Add | 5 | 0.064 ms | 0.227 ms | 3.52x |
| MatMul | 29 | 0.115 ms | 0.131 ms | 1.14x |
| Softmax | 12 | 0.114 ms | 0.240 ms | 2.11x |
| LayerNormalization | 6 | 0.061 ms | 0.135 ms | 2.22x |
The source also identifies two unusually large wins. A bilinear Einsum case expressed as i,ij,j at size 4096 took 0.136 ms with the Hugging Face kernel and 1,396 ms with ORT WebGPU, a reported speedup greater than 10,000 times. A row-wise CumSum over shape [256, 4096] took 0.016 ms rather than 4.784 ms, yielding a reported 301-times speedup.
What the benchmark does not establish
Those headline results require careful interpretation. Hugging Face describes the extreme Einsum and CumSum cases as unusual examples, not representative expectations for every operation. The test measured GPU work while excluding kernel loading, session creation, input uploads, shader compilation, and output readback. Very short workloads are difficult to measure reliably, and small cases may benefit from GPU caching.
The figures also compare individual operations rather than complete model inference. They come from one Apple M4 GPU and have not been independently substantiated in the supplied evidence. Results may differ across GPUs, browsers, drivers, model graphs, input shapes, and end-to-end application workflows. Hugging Face says it is working with the ONNX Runtime team to upstream the improvements for the wider ONNX Runtime Web ecosystem.
Fleet expands testing beyond one device
Fleet addresses the problem that a single-machine benchmark cannot represent WebGPU’s hardware and software diversity. It runs correctness and performance checks inside the browser, letting participants see how the kernels behave on their hardware.
When a participant consents, a run privately contributes evidence that Hugging Face says can reveal incorrect results, pathologically slow cases, and device-specific failures. The data can also support comparisons between variants and improvements to the rules used to select an implementation. The stated aim is to gather coverage across more real-world devices than a conventional test laboratory could maintain.
A shared, extensible foundation for WebAI
Hugging Face characterizes the first 207 kernels as a starting point. Publishing operations independently on the Hub creates a shared location for inspecting contracts, comparing implementations, reproducing correctness checks, and tuning performance without embedding every shader directly into every runtime.
The WebGPU collection also joins the Hub’s broader kernel ecosystem alongside artifacts targeting CUDA, ROCm, Metal, and other platforms. The Hub allows users to filter, sort, and explore the kernels as standalone artifacts.
The architecture connects four layers of work: repositories provide transparent and versioned operation contracts; @huggingface/kernels loads those operations from JavaScript; Fleet gathers evidence from a wider range of hardware; and contributed runs can expose failures, guide tuning, improve variant selection, and help validate later kernel versions.
Hugging Face plans to connect this low-level layer to higher-level model tooling, broaden operation coverage, and continue improving local inference across its WebAI stack. For developers, the immediate release provides both executable kernels and the supporting contracts, tests, benchmarks, and templates needed to inspect how those operations are defined and evaluated.
Source: This article is based on Hugging Face’s September 1, 2026 announcement, “Introducing @huggingface/kernels: 200+ WebGPU Kernels for Local AI.”
