推論系統
Hugging Face Open-Sources 207 WebGPU Kernels, Turning Browser AI Operators Into Versioned Packages
`@huggingface/kernels` can dynamically load GPU operators from the Hub, complete with interfaces, tests, and WGSL implementations. In operator-level tests on an Apple M4, Hugging Face reported a 2.57× geometric-mean speedup, but the results exclude model loading, compilation, and data transfer costs.

Hugging Face has released a preview of `@huggingface/kernels`, whose initial collection includes 207 Apache 2.0-licensed WebGPU operators covering matrix multiplication, normalization, convolution, attention, quantization, and data layout transformations. Instead of hard-coding WGSL shaders into an inference framework, each operator is maintained as an independently versioned repository on the Hub, complete with a `manifest.json` interface contract, source and hash information, correctness cases, performance cases, and parameterized WGSL templates.
JavaScript applications can use `getKernel()` to specify a repository ID and contract version. The loader infers output shapes and data types from the input tensors, then selects an appropriate implementation variant for the current device. Contract versions are deliberately decoupled from ONNX opsets, operator `since_version` values, and model revisions, allowing the underlying shaders to be updated while keeping the higher-level calling interface stable. This separation also enables individual kernels to be tested, rolled back, and compared independently, making them easier for higher-level runtimes such as Transformers.js or ONNX Runtime Web to adopt in the future.
Using an Apple M4 and a development build of ONNX Runtime Web, Hugging Face compared 1,756 cases and retained 809 for which both implementations produced matching results and reliable timings. The new kernels recorded 629 wins, 176 losses, and four ties, with a geometric-mean speedup of 2.57× and a median speedup of 1.90×. MatMul was only 1.14× faster, while Softmax and LayerNormalization were 2.11× and 2.22× faster, respectively, showing that the gains depend heavily on the operator and tensor shape. A small number of results showing speedups of tens of thousands of times occurred because the competing implementation fell into unusually slow code paths and should not be treated as representative of typical model performance.
The concurrently released Fleet runs correctness and performance tests in users’ browsers and, with their consent, submits anonymous device evidence to help address fragmentation across combinations of browsers, drivers, and GPUs. Engineering teams should next examine end-to-end model integration, initial shader compilation and tensor transfer latency, as well as caching, supply-chain verification, and offline deployment strategies when kernels are fetched dynamically from the Hub. The current figures measure GPU work alone and cannot yet be used to infer real-world application throughput.