4 December 2026

AI and agents, every day. Straight to it.

ToolsQuick notes

The @huggingface/kernels library loads versioned WebGPU operations from the Hub

The library runs browser GPU operations for integration into web applications.

Diego Sato

· 1 min read

Read in Portuguese

Hugging Face’s @huggingface/kernels library retrieves GPU operation implementations from the Hub and runs them in a browser. Each operation exposes a versioned contract specifying its inputs, outputs and accepted data types. The collection carries an Apache-2.0 license.

A kernel is the GPU program behind an operation. Here, its repository also carries correctness cases, performance workloads and usage instructions. Developers can inspect the interface without first reading the shader implementation.

The official example adds a vector across the rows of a matrix:

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 loader determines the output shape and allocates c. The version: 1 setting selects the operation contract, independently of a model revision.

Nico Martin and Xenova document the mechanism in Introducing @huggingface/kernels: 200+ WebGPU Kernels for Local AI. It serves developers integrating GPU operations into web applications; WebGPU support depends on the browser, operating system, GPU and driver.

Report an error

Use 10–1,000 characters; a reply email shares this space.

Next in your reading list