Hugging Face Drops 200+ WebGPU Kernels for Accelerated Browser Inference
Hugging Face released @huggingface/kernels, an Apache-2.0 library providing 207 individual, versioned WebGPU compute kernels on the Hugging Face Hub. Benchmarks show a 2.57x geometric mean speedup over ONNX Runtime Web on Apple M4 hardware.

Impact: High
Why it matters
Developers can execute browser-based machine learning models with significantly lower latency by pulling optimized WGSL shaders directly via npm.
TL;DR
- 01Install @huggingface/kernels to run optimized WebGPU operations directly in browsers.
- 02Kernels deliver a 2.57x geometric mean speedup over ORT WebGPU on Apple M4.
- 03Fleet allows hardware testing and submission of browser GPU performance telemetry.
Key facts
- Total Kernels Released
- 207 published packages
- License
- Apache-2.0
- Geometric Mean Speedup (Apple M4)
- 2.57x vs ORT WebGPU (self-reported)
- Median Speedup (Apple M4)
- 1.90x vs ORT WebGPU (self-reported)
Modular Kernel Distribution
Hugging Face has launched @huggingface/kernels, packaging 207 individual WebGPU operations on the Hugging Face Hub under Apache-2.0. Rather than embedding monolithic shader code, each kernel repository includes manifest.json for shape derivation and type constraints, test.json for correctness assertions, bench.json for tuning, and parameterized *.wgsl.jinja templates.
Benchmarks Against ONNX Runtime Web
Testing conducted on an Apple M4 GPU comparing @huggingface/kernels against ONNX Runtime Web (1.30.0-dev.20260826-b1f76d586a) across 809 matched test cases revealed:
- Geometric mean speedup: 2.57x (median 1.90x)
- Win/Loss/Tie ratio: 629 wins, 176 losses, 4 ties
- Bilinear Einsum (
size 4096): 0.136 ms vs 1,396 ms (>10,000x faster) - Row-wise CumSum (
[256, 4096]): 0.016 ms vs 4.8 ms (301x faster)
Developer Integration and Fleet Suite
Developers can load kernels using the getKernel API with explicit contract versioning (version: 1). Along with the library, Hugging Face released Fleet, a browser-based tool to crowdsource performance and correctness validation across heterogeneous client hardware.
Try it in 2 minutes
import { getKernel } from "@huggingface/kernels";
const add = await getKernel("webgpu-kernels/ai.onnx.Add", { version: 1 });
const result = await add({
a: { shape: [2, 3], data: new Float32Array([1, 2, 3, 4, 5, 6]) },
b: { shape: [3], data: new Float32Array([10, 20, 30]) }
});javascript
✓ When to use
- In-browser client-side LLM inference, embedding generation, and vision model pipelines
- Progressive Web Apps requiring offline-first, private AI compute without cloud API costs
- Custom WebGPU runtimes needing modular, benchmarked WGSL reference operators
✕ When NOT to use
- Environments or legacy web browsers without WebGPU hardware API support
- Trivial micro-tensor math where CPU-GPU memory bus transfer overhead dominates compute time
- Server-side Node.js applications with native CUDA or ROCm acceleration
What to do today
- Install the preview package with npm install @huggingface/kernels@preview
- Verify client browser WebGPU compatibility using 'gpu' in navigator
- Benchmark local browser GPU execution on the Hugging Face Fleet test suite
Sources