Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

google-ai-edge/litert-torch

1,076Jupyter NotebookApache-2.0

Google's tool converts PyTorch models to run directly on phones and IoT devices

litert-torch is a Python library from Google that converts PyTorch models into the .tflite format used by LiteRT, Google's on-device inference runtime. It builds on PyTorch's torch.export() feature and covers a broad set of Core ATen operators, running mainly on CPU today with early GPU and NPU support. It also includes a separate Generative API for authoring and quantizing transformer-based LLMs for on-device deployment.

What it does

  1. Converts a PyTorch model (e.g., resnet18) into a .tflite file with a few lines of code using litert_torch.convert()
  2. Works by tracing the model with PyTorch's torch.export() and mapping it to Core ATen operators, then serializing to LiteRT's flatbuffer format
  3. The converted model can run on Android, iOS, and IoT devices via LiteRT's compiled model API in C++ or Java, using CPU, GPU, or NPU acceleration
  4. A separate Generative API lets developers author and quantize transformer/LLM models natively in PyTorch, convert them, and package them with a tokenizer into a .litertlm file for deployment via LiteRT-LM
  5. The PyTorch converter is labeled Beta while the Generative API is labeled Alpha; requires Python 3.10–3.13, Linux, PyTorch >=2.4.0, and tf-nightly

Why it matters

For developers wanting to ship PyTorch-trained models to mobile or embedded devices, this removes the need to manually rewrite models in a different framework. It's especially relevant now as on-device LLM deployment becomes more common, letting teams stay in the PyTorch ecosystem while targeting edge hardware acceleration.

Terms in this repo

  • LiteRT · Google's runtime for running AI models directly on devices like phones, replacing what was formerly called TensorFlow Lite
  • .tflite · A compact file format for storing models so they can run efficiently on-device
  • torch.export() · A PyTorch feature that captures a model's computation graph so it can be converted to other formats
  • Core ATen operators · A standardized, smaller set of basic math operations that PyTorch models can be broken down into for portability
  • NPU · Neural Processing Unit, a chip specialized for running AI computations efficiently on-device
  • LiteRT-LM · A companion system for running large language models that have been converted and packaged for on-device use

Repository description (English)

Support PyTorch model conversion with LiteRT.

Owner · google-deepmind

Open on GitHub

Trending repos

All repos →

Latest from METAL MEDIA