How to use WebGPU with Hugging Face for local AI in the browser

Hugging Face published @huggingface/kernels to load versioned WebGPU kernels from the Hub and run local AI operations in the browser with inspectable contracts.

The release came out on September 1, 2026 and comes with an initial collection of 207 WebGPU kernels published as individual repositories in huggingface.co/webgpu-kernels. It’s not just another JavaScript package to speed up a demo. It’s a way to treat in-browser inference kernels as software artifacts: with manifests, correctness cases, benchmark cases, WGSL templates, and explicit versions.

That detail matters because local in-browser inference usually hides a critical part of the stack. You download a model, call a runtime, and hope the browser does the right thing with the GPU. Hugging Face is separating a lower layer: the operations that WebGPU actually executes.

The announcement phrase sums it up well: “Today, we are releasing the first layer of that effort”. That first layer doesn’t promise to solve all local inference. It promises something more concrete: that GPU operations can be published, tested, versioned, and loaded from the Hub as reusable pieces.

How to Use WebGPU with Hugging Face?

To use WebGPU with Hugging Face in this release, you install the @huggingface/kernels@preview package and load a kernel from a Hub repository with getKernel.

The command published by Hugging Face is:

npm install @huggingface/kernels@preview

After that, the basic pattern is to import getKernel, request a kernel by its repository ID, and pin a contract version:

import { getKernel } from "@huggingface/kernels";

const add = await getKernel("webgpu-kernels/ai.onnx.Add", { version: 1 });

const { c } = await add({
  a: {
    data: new Float32Array([1, 2, 3, 4, 5, 6]),
    shape: [2, 3],
  },
  b: {
    data: new Float32Array([10, 20, 30]),
    shape: [3],
  },
});

The official example uses ai.onnx.Add, a deliberately small operation. The important part isn’t adding six numbers on the GPU. The important part is the contract: the loader receives typed tensors, input shapes, and a version; the kernel manifest derives the output shape and logical type.

For heavy operations, like matrix multiplication, the call pattern stays the same. The kernel repository, inputs, and the actual utility of moving work to WebGPU change.

There’s a base requirement: the browser must support WebGPU. Hugging Face reminds you that availability depends on the browser, operating system, GPU, and driver, and shows a minimal check with "gpu" in navigator.

What is @huggingface/kernels?

@huggingface/kernels is a JavaScript loader that downloads, prepares, and executes optimized WebGPU kernels from the Hugging Face Hub.

It shouldn’t be confused with the Python package kernels, which belongs to the broader ecosystem of kernels in Hugging Face. The public documentation for kernels already covers installation with pip, loading kernels from the Hub, versioning, and building kernels for backends like CUDA, CPU, Metal, ROCm, or XPU. The WebGPU release adds a specific piece for the browser: an npm package that can load WebGPU kernels from Hub repositories.

In practice, @huggingface/kernels works as a bridge between three things:

  • A Hub repository, for example webgpu-kernels/ai.onnx.Add.
  • A versioned contract, for example { version: 1 }.
  • A JavaScript call with typed data and tensor shapes.

That separation is healthy. A model can change, a runtime can evolve, and a browser can behave differently depending on GPU or driver. If the kernel has its own contract, upper layers can depend on a more stable interface while the implementation improves underneath.

What Exactly Did Hugging Face Publish?

Hugging Face published an initial collection of 207 WebGPU kernels as versioned repositories in the webgpu-kernels organization, along with the @huggingface/kernels npm package.

Each kernel repository includes more than a WGSL shader. According to the announcement, each operation’s package brings together:

  • manifest.json, which defines the operation contract: inputs, outputs, attributes, type constraints, and shape rules.
  • metadata.json, which records identifier, digests, and provenance.
  • test.json, with correctness cases.
  • bench.json, with benchmark cases and tuning.
  • *.wgsl.jinja files, which contain parameterized WGSL implementations.

That format turns a shader into a reviewable artifact. You can see what the operation expects without reading all the WGSL, run or compare correctness cases, understand what workloads are used to measure performance, and pin an explicit version instead of relying on a loose URL.

For developers building runtimes, local AI integrations, or their own kernels, that change in packaging might be more important than any single benchmark number.

Why Do WebGPU Kernels Matter for AI in the Browser?

WebGPU kernels matter because in-browser inference ends up being a sequence of GPU operations, not a magical entity called a “model”.

Underneath an AI application are matrix multiplications, normalizations, convolutions, attention, quantization, layout changes, and many small operations that must run efficiently. WebGPU provides a portable API for using the GPU from modern browsers, and WGSL provides the common language for writing the shaders.

But portable doesn’t automatically mean fast.

A shader can be correct and still perform poorly on a specific combination of GPU, browser, and driver. Workgroup size, memory patterns, vectorization, data types, operation fusion, and input shape can dramatically change the outcome.

That’s why Hugging Face is attacking a layer that normally stays buried inside the runtime. If the kernel is an artifact with a contract, tests, and benchmarks, it can be improved without rewriting the entire application that uses it.

Local in-browser inference needs lighter models, appropriate formats, and smart runtimes. It also needs a base of GPU operations that isn’t opaque.

How Fast Are Hugging Face’s WebGPU Kernels?

The benchmarks published by Hugging Face are self-reported results of individual operations, not a promise of speed for complete models.

In the announcement, Hugging Face compares its collection against ORT WebGPU on an Apple M4 GPU using ONNX Runtime Web 1.30.0-dev.20260826-b1f76d586a. They started with 1,756 test cases across the 207 operations and kept 809 cases where both sides produced matching outputs and reliable times.

In that sample, Hugging Face reports a 2.57x improvement by geometric mean and 1.90x at the median, with 629 wins, 176 losses, and 4 ties. It also shows extreme cases, like an Einsum that improves over 10,000x and a row-wise CumSum that improves 301x.

Those numbers are worth reading carefully.

The announcement itself clarifies that they measured the work done on the GPU, excluding overhead like kernel loading, session creation, input upload, shader compilation, and output reading. It also explains that these are operation results, not complete model results, and that actual performance varies across GPUs and browsers.

The useful takeaway isn’t “your application will be 2.57x faster”. The useful takeaway is different: Hugging Face is creating a surface where each operation can be compared, fail, improve, and be versioned visibly.

What is Fleet and Why Does It Accompany the Release?

Fleet is a benchmarking and testing suite in the browser that runs kernels on your hardware and can provide evidence of correctness and performance.

The reason is simple: WebGPU doesn’t live in a homogeneous lab. It lives on laptops, desktops, drivers, integrated GPUs, discrete GPUs, Chrome versions, Edge, Safari, Firefox, and combinations that no team can fully cover.Fleet attempts to convert that diversity into signal. With user consent, each execution can provide private evidence to detect incorrect results, pathologically slow cases, and device-specific differences.

This fits well with the decision to publish kernels as versioned artifacts. If a kernel has a contract, test cases, and variants, a real fleet of browsers can help decide which variant makes sense, which case fails, and which implementation needs adjustment.

In WebGPU, the question is not just whether a kernel is fast on the machine of the team that wrote it. The question is whether it remains correct and reasonable on the user’s machine.

How does this fit with ONNX Runtime Web and Transformers.js?

@huggingface/kernels does not automatically replace ONNX Runtime Web or Transformers.js; it aims at a lower layer that those tools can leverage directly or indirectly.

Hugging Face says it is working with the ONNX Runtime team to upstream improvements back to the ONNX Runtime Web ecosystem. That suggests a reasonable direction: these kernels can serve as a shared foundation for higher-level runtimes, not necessarily as a final API that every product developer will touch by hand.

For an end-user application, you probably still want a model abstraction. Nobody wants to manually write every MatMul or Softmax of a transformer if their goal is to add a product feature.

But for those building local inference tools, runtimes, optimization layers, or deep browser integrations, the package does open a new surface.

The comparison with open weights models also helps position the shift. At yoDEV we have already covered how open weights change costs and control in code agents, for example with Kimi K2.6. WebGPU kernels tackle another stretch of the same problem: not just what model you can download, but how inspectable and optimizable local execution is.

What should a developer try now?

A developer should try @huggingface/kernels as a piece of WebGPU infrastructure, not as an immediate guarantee of speeding up any AI app.

The reasonable test is small:

  1. Verify that your browser exposes WebGPU with "gpu" in navigator.
  2. Install the preview package with npm install @huggingface/kernels@preview.
  3. Load a simple kernel like webgpu-kernels/ai.onnx.Add with { version: 1 }.
  4. Review the kernel repository in the Hub: manifest, tests, benchmarks, and WGSL templates.
  5. Then review heavier operations, like ai.onnx.MatMul, if your real case needs that level.

That order avoids a common trap: starting with the benchmark and ending disappointed when the full application doesn’t move the same way.

The value of this release lies in understanding the contract. If your team works with local inference, WebAI, edge in the browser, or privacy through client-side execution, these repositories show where the architecture can go: downloadable models up top, versioned kernels down below, and reproducible evidence around it.

What is the caveat before adopting it?

The caveat is that @huggingface/kernels is in preview and this snapshot may change rapidly after September 1, 2026.

The install command itself uses @preview. The number of kernels, the variants, the benchmark results, the effective support per browser, and the npm package status are high-decay claims. It’s worth pinning versions, reviewing the kernel repository you will actually use, and not selling operation results as product results.

There is also an important distinction: published kernels do not by themselves turn an application into “fast local AI”. The rest of the stack is missing: model, format, runtime, execution scheduling, caches, data transfer, shader compilation, result reading, and user experience.

What does change is the transparency of a layer that until now was easy to treat as magic.

For developers in Iberoamerica, that is the strong signal. AI in the browser is not going to mature just by downloading smaller models. It also needs reproducible contracts for the operations that run on the user’s GPU. Hugging Face just put 207 of those contracts in the Hub.