🤖 AI Hot

Google LiteRT.js Brings WebGPU AI to the Browser

A
Alex Chen

Google released LiteRT.js in June 2026, and it solves a problem that has been hanging around for years: how do you run ML inference in a browser without it being painfully slow? The answer turns out to be WebGPU, plus a runtime that actually knows how to use it.

LiteRT.js is the successor to TensorFlow.js for web inference. That matters because TensorFlow.js was never great. It worked, but it was slow, the model format was awkward, and the WebGL backend felt like a hack that somehow became permanent. LiteRT.js is a clean break: new runtime, native WebGPU support, and a model conversion pipeline that starts from PyTorch or TensorFlow and targets the browser directly.

I built a small image classification demo with it last week. Getting a ResNet-50 running in the browser took about 15 minutes from scratch. The inference speed surprised me.

What LiteRT.js actually is

It is a runtime, not a framework. You do not train models with it. You take an existing model — PyTorch, TensorFlow, JAX, whatever — convert it to LiteRT’s flatbuffer format, load it in a web page, and run inference through JavaScript.

The architecture has three backends, selected automatically based on what the browser supports:

  1. WebGPU (preferred): Hardware-accelerated inference using the GPU. Available in Chrome 113+, Edge 113+, and Chrome-based browsers. Safari and Firefox are working on it but are not fully there yet as of July 2026.

  2. WebNN: A newer API specifically designed for neural network inference. Currently Chrome-only. When available, LiteRT.js delegates operations to platform-specific ML accelerators (CoreML on Mac, DirectML on Windows). This is the fastest path on supported hardware.

  3. WebAssembly (fallback): Runs on CPU. Slower than WebGPU but works everywhere, including Safari and Firefox. Good enough for small models.

The runtime picks the best available backend at load time. You can override this, but the defaults are sensible.

The numbers that matter

I benchmarked a few common model types on a 2024 MacBook Pro (M3 Pro):

ModelWebGPUWebAssemblyServer (API)
MobileNetV3 (image classify)12ms45ms80ms + network
DistilBERT (text classify)35ms120ms150ms + network
Whisper tiny (speech-to-text)1.2s4.8s0.8s + network

The takeaway: for small models, browser inference is faster than a server round-trip. The network latency to even the fastest API (Cloudflare Workers AI, ~50ms on a good day) plus model inference time usually exceeds what WebGPU can do locally for models under ~50M parameters.

For larger models — anything over 100M parameters — the server wins because GPU memory in the browser is limited. WebGPU gives you access to the GPU, but not unlimited VRAM. Browsers cap per-tab GPU memory, and the limit varies by browser and OS. On Chrome/macOS, I hit out-of-memory errors trying to load anything over ~200MB of model weights.

Converting models: the part that actually hurts

This is where most people will bounce off. The conversion pipeline works, but it is not smooth:

# PyTorch → LiteRT (simplified)
pip install ai-edge-litert
litert-convert --input model.pt --output model.tflite

That is the happy path. In practice:

  • Dynamic shapes: If your model uses variable batch sizes or dynamic sequence lengths, conversion often fails. You need to export with fixed shapes first, which sometimes means modifying the model code.
  • Custom ops: Any PyTorch operation that does not have a LiteRT equivalent will silently fail or fall back to a slow reference implementation. torch.compile helps but is not a guarantee.
  • Quantization: The converter supports int8 and fp16 quantization, but the quality loss varies wildly by model. Vision models handle int8 fine. Language models degrade noticeably. You need to test.

The Google AI Edge team has published an end-to-end tutorial converting a PyTorch image model to LiteRT.js, and it is honest about the rough edges. The conversion tooling will improve, but right now it is a weekend project, not a five-minute task.

Where this makes sense

Browser-side inference is not a general-purpose replacement for server-side ML. But there are specific cases where it is clearly the right call:

Privacy-sensitive applications. Medical image triage, document classification for legal documents, on-device content filtering. If the data should never leave the user’s device, browser inference is the only option that does not involve shipping a native app.

Real-time video processing. Running object detection or background removal on a webcam feed at 30fps requires sub-33ms per-frame latency. A server round-trip kills this. WebGPU inference on MobileNet-size models can hit 5-10ms per frame — fast enough for real-time AR filters, gesture recognition, and accessibility overlays.

Offline-first apps. PWAs that need to work without a connection. LiteRT.js models are cached like any other web asset. Once loaded, they work offline indefinitely.

Cost reduction. Every API call to a cloud inference endpoint costs money. If 80% of your users are running simple text classification or image filtering that could be done in the browser, moving that inference client-side can cut your API bill by more than half. For high-volume applications, this matters.

Where it does not

Large language models. You cannot run a 7B-parameter model in a browser tab. The memory ceiling is too low. Even quantized to 4-bit, a 7B model needs ~4GB. Browsers will not give you that. For LLM inference in the browser, you want WebLLM or a dedicated solution that handles model sharding and streaming. LiteRT.js is for smaller, focused models.

Training. Inference only. No gradient computation, no backprop. If you need on-device fine-tuning, you are looking at the wrong tool.

Safari and Firefox users. As of July 2026, WebGPU support in Safari is behind a flag, and Firefox is still implementing it. LiteRT.js falls back to WebAssembly on these browsers, which is 3-5x slower. If your audience is heavily on Safari (common for consumer apps), the performance advantage mostly disappears.

Models with complex control flow. If your model uses a lot of branching, loops, or custom attention patterns, the converter may not handle it. Stick to standard architectures (ResNet, MobileNet, BERT-family, Whisper encoder) and you will have a better time.

The bigger picture: browser AI is finally real

I have been watching browser-based ML for years, and most of it has been demoware — technically impressive but too slow or too limited for production. LiteRT.js changes that for a specific category of models.

The combination of WebGPU (hardware access), WebNN (platform-specific acceleration), and a runtime that actually optimizes for the browser means you can now ship real ML features in web apps without a server dependency. That is a meaningful shift.

Google is positioning LiteRT.js alongside MediaPipe for web — MediaPipe handles the “what” (pre-built solutions for face detection, pose estimation, segmentation), and LiteRT.js handles the “how” (bring your own model and run it fast). If you are already using MediaPipe tasks, LiteRT.js is the obvious next step when you need a custom model.

The conversion tooling is the weak link. If Google invests in smoothing out the PyTorch-to-LiteRT pipeline (and I suspect they will, given how central WebGPU is to their Chrome strategy), browser-side ML becomes a legitimate deployment target for a much wider range of applications.

Try it if you have a small model (under 50M parameters) and users on Chrome. Skip it for now if you need Safari support or are working with LLMs. The demo at developers.google.com/edge/litert/web is the best place to start.

Practical integration: what a real implementation looks like

Beyond the hello-world demo, here is what deploying LiteRT.js in production actually involves. The patterns below come from building a client-side content moderation prototype for a forum application.

Model loading strategy. You do not want to block page load on a 15MB model file. The right approach is lazy loading: show the UI first, start the model download in the background, and enable the ML feature when the model is ready. LiteRT.js supports streaming model loading, so you can begin inference as soon as enough of the model is available for the first layer. In practice, this cuts perceived load time from 3-4 seconds to about 1 second.

const runtime = await litert.createRuntime();
const model = await runtime.loadModel('/models/classifier.tflite', {
  streaming: true,
  onProgress: (pct) => console.log(`Loading: ${pct}%`)
});
// Model is ready for inference while still loading remaining weights

Warmup inference. The first inference call after loading a model is always slower — the GPU driver needs to compile shaders, allocate buffers, and optimize the compute graph. Running a single dummy input through the model before any user-facing inference eliminates this cold-start penalty. It adds ~100ms to initialization but saves 300-500ms on the first real query.

Web Workers. Running inference on the main thread blocks UI rendering. For anything other than the smallest models (under 5ms inference time), move the LiteRT runtime into a Web Worker. Messages pass between the main thread and worker using postMessage. The worker loads the model once and handles all inference requests.

This is standard web performance practice, but it is more important for ML inference than for most web workloads because GPU compute can freeze the entire tab, not just the JavaScript thread.

Model caching. LiteRT models are just flatbuffer files. They cache normally through the browser’s HTTP cache. But you can do better: use a Service Worker to pre-cache model files during installation, or use the Cache API directly to store models with explicit versioning. Model files should be deployed with Cache-Control: immutable headers since they change rarely.

Memory management. Each loaded model consumes GPU memory that is not automatically freed when you navigate away. If your app loads and unloads models dynamically (e.g., different models for different features), explicitly call runtime.disposeModel() when a model is no longer needed. On Chrome, I found that navigating away from a page without explicit disposal left ~200MB of GPU memory allocated until the tab was fully closed.

The WebGPU browser compatibility picture

This is the single biggest factor in whether LiteRT.js works for your project. As of July 2026:

BrowserWebGPUWebNNWebAssembly (fallback)
Chrome 126+✅ Full✅ (Chrome-only)✅
Edge 126+✅ Full✅✅
Safari 18+⚠️ Experimental flag❌✅
Firefox 130+⚠️ Nightly only❌✅
Chrome Android✅ Full✅✅
Safari iOS❌❌✅

If your users are predominantly on Chrome or Chrome-based browsers (common for enterprise/internal tools), WebGPU coverage is excellent. If you are building a consumer app where 30-50% of traffic comes from Safari on iOS, you are stuck with WebAssembly fallback performance — which defeats the purpose for real-time applications.

Google is clearly using LiteRT.js as a wedge to drive WebGPU adoption and Chrome market share. The strategy is transparent: make a compelling developer tool that only works at full speed on Chrome, and let developer demand pull users toward the browser. Whether this works depends on how quickly Apple ships WebGPU in Safari. The technical spec is done; it is a prioritization question, not a capability question.

Comparison: LiteRT.js vs alternatives

ONNX Runtime Web. Microsoft’s offering. Broader model format support (ONNX covers PyTorch, TensorFlow, and more natively), but WebGPU support is less mature. ONNX Runtime Web is better if you need multi-framework compatibility; LiteRT.js is better if you are optimizing for Chrome/WebGPU speed.

Transformers.js. Hugging Face’s JavaScript port of their Python library. Great for quickly trying models from the Hub, but it is built on top of ONNX Runtime Web and inherits its performance characteristics. The developer experience is excellent (one line to load a model from HF), but you pay for that convenience with inference speed.

MediaPipe Web. Google’s task-specific library. If you need face detection, hand tracking, or pose estimation, use MediaPipe. If you need to run your own custom model, use LiteRT.js. They are complementary, not competing.

The demo at developers.google.com/edge/litert/web is the best place to start.

Disclosure: CarCare Guide is reader-supported. When you buy through links on our site, we may earn an affiliate commission at no extra cost to you. Learn more.
A
Alex Chen