Skip to main content
Back to timeline
PyTorchSource publication:

PyTorch models now run on the browser GPU without format conversion: one .pte file, 2–10× faster decode than the CPU path

Synopsis

ExecuTorch adds a WebGPU backend that lets PyTorch models exported once with torch.export to a .pte file run on the GPU directly in WebGPU-enabled browsers, without first converting to another framework's format such as GGUF, ONNX or TFLite. Previously, running a PyTorch model in the browser usually meant doing that conversion first. On Chrome on an Apple M1 Pro, 4-bit quantized Llama 3.2 1B and Qwen3-0.6B ran 4–7× faster on prefill and 2–10× faster on decode than ExecuTorch's own Wasm CPU backend (XNNPACK).

AI-generated editorial illustration: ExecuTorch WebGPU: PyTorch Models on the GPU, in the Browser

Interpretation

PyTorch models can now stay inside the PyTorch toolchain and run on the GPU directly in the browser, without first converting to another framework's format. Previously, running a PyTorch model in the browser usually meant converting it to another framework's format such as GGUF, ONNX or TFLite. The same .pte file runs in WebGPU browsers such as Chrome and Safari, landing on Metal, Vulkan and D3D12 underneath.

A model is exported once with torch.export, and at runtime the WebGPU backend allocates GPU buffers and dispatches compute shaders into command buffers. Export is handled by torch.export() and WebGPUPartitioner, and computation is expressed as WGSL shaders. Dynamic shapes are handled with allocate-at-max buffers and per-dispatch workgroup recalculation to enable batched prefill, and the runtime routes shapes to specialized WGSL kernels.

The performance comparison ran in Chrome on an Apple M1 Pro against ExecuTorch's own Wasm CPU backend. Both backends used identical token IDs, and each data point is the median of 5 runs after 3 warmups across 128 to 8K tokens of context. WebGPU used 4-bit groupwise weights (group size 64) with fp32 activations, the CPU used XNNPACK's 4-bit weights with 8-bit dynamic activations, and both were timed by wall-clock time.

Perspective

The demonstrated scope is WebGPU-enabled desktop, laptop and mobile browsers, with models served as .pte files over CDN on a web page and inference running inside the browser sandbox; the performance comparison is limited to Chrome on an Apple M1 Pro with 4-bit quantized Llama 3.2 1B and Qwen3-0.6B.

The backend is still in early development, with further work planned on speed, stability and operator, data type and model coverage; the performance numbers come only from Chrome on an Apple M1 Pro.