Transformers.js v3: WebGPU Support, New Models & Tasks, and More…
Transformers.js v3 adds WebGPU acceleration via ONNX Runtime Web, claimed up to 100x faster than WASM and enabled by passing `device: 'webgpu'` when loading a pipeline. A new `dtype` option replaces the old boolean `quantized` flag and supports fp32, fp16, 8-bit and 4-bit variants, including per-module dtypes for quantization-sensitive encoder-decoder models like Whisper and Florence-2. The release also expands support to 120 architectures and over 1200 pre-converted Hub models, and adds Node.js, Deno and Bun compatibility under the new @huggingface/transformers npm package. WebGPU reaches only about 70% of browsers, so some users need feature flags.
Related posts
- Transformers.js v4: Now Available on NPM!
Hugging Face mediumAdeptTransformers.js v4 ships on NPM with a new C++ WebGPU runtime built with the ONNX Runtime team, enabling WebGPU-accelerated models in browsers as well as Node, Bun and Deno. Models are re-exported operation by operation using ONNX Runtime contrib operators such as GroupQueryAttention, MatMulNBits and MultiHeadAttention, giving about a 4x speedup for BERT embedding models. The release also adds Mamba, MLA and MoE architectures such as GPT-OSS 20B, which runs at about 60 tokens/s on an M4 Pro Max. Other changes include a move from Webpack to esbuild (10x faster builds, 53% smaller default bundle), a pnpm monorepo, a ModelRegistry API for inspecting and caching pipeline assets, and a standalone 8.8kB tokenizers library.
- Introducing @huggingface/kernels: 200+ WebGPU Kernels for Local AI
Hugging Face mediumAdeptHugging Face released @huggingface/kernels, a JavaScript loader for 207 Apache-2.0 WebGPU kernels published as versioned Hub repositories. Each repository bundles a manifest contract, correctness and benchmark cases, and Jinja-templated WGSL shaders with multiple variants per shape and device. On an Apple M4, 809 comparable cases ran 2.57x faster by geometric mean (1.90x median) than ONNX Runtime Web's WebGPU backend, with some outliers in Einsum and CumSum exceeding 300x. Those figures measure GPU time per operation, not full models. Fleet, an in-browser benchmarking tool, crowdsources correctness and performance results across real devices to improve variant selection.
- WebGPU now available for testing in Safari Technology Preview
WebKit mediumAdeptSafari Technology Preview 185 ships an early WebGPU implementation, enabled via the "WebGPU", "GPU Process: DOM Rendering" and "GPU Process: Canvas Rendering" feature flags. A walkthrough of the core API shows requesting an adapter and GPUDevice, configuring a GPUCanvasContext, building a GPURenderPipeline from a WGSL shader module, and encoding and submitting a draw call through a GPURenderPassEncoder. A complete WGSL vertex/fragment shader draws a colored triangle, and developers are asked to try the WebGPU samples and file bugs at bugs.webkit.org.
- Hugging Face ❤️ TorchTPU: TPUs, Natively
Hugging Face mediumAdeptTorchTPU is a native PyTorch backend that makes TPU an ordinary device, replacing the lazy-tensor torch_xla path and making Optimum TPU unnecessary for running Hugging Face models. Transformers loads models with device_map="tpu", and Diffusers pipelines run with pipe.to("tpu"), optionally with torch.compile and tensor parallelism across chips. Pallas kernels from the Kernels Hub, such as a Tokamax ragged-dot MoE kernel, speed up batch-64 decoding by 21.5× on Qwen3-30B-A3B and 12.8× on Gemma 4 26B-A4B. Of the Transformers tests that run on TPU, 96.5% pass, and 34 TorchTPU issues have been reported so far, 19 of them fixed.
- Transformers now runs llama.cpp quants
Hugging Face mediumAdeptHugging Face transformers can now load GGUF (llama.cpp) quantized checkpoints via `from_pretrained(..., gguf_file=...)` and serve them through `transformers serve` with an OpenAI-compatible API. Weights stay packed on Apple Silicon, and ggml's Metal kernels are reused via the `kernels` library for quantized matmul, fused RMSNorm, flash attention, gated delta nets and MoE top-k routing. Two `generate` changes, dropping all-ones padding masks and deferring the stopping check asynchronously, cut CPU-GPU synchronization for all models. Benchmarks on an M2 Max show throughput close to llama-bench for Qwen3.5 dense and MoE checkpoints, though llama.cpp remains the recommended engine for pure local inference. The initial packed path is MPS-only, and padded batching is still slower.