Deploying edge AI models onto Google Tensor TPUs introduces friction into your development cycle. The manual process of compiling models, validating performance, and packaging dependencies can potentially slow down iteration.
Introduction
The litert-google-tensor agent skill automates ahead-of-time
(AOT) compilation, on-device benchmarking, Play AI packaging, and Gradle
integration directly from natural language prompts in your agent
workspace. You can use it for optimizing models on custom Google
Tensor TPUs: Tensor G5 (Pixel 10) and Tensor G6 (Pixel 11).
Core capabilities and agent workflows
Here is a breakdown of what the litert-google-tensor skill offers, what you
can ask the agent, and how the skill responds for each workflow stage:
Check
- What it does: Checks whether a
.tflitemodel is already compiled for Google Tensor and for which chip. - What you can ask:
- "Is
model.tflitecompiled for the Pixel TPU?"
- "Is
- What the skill does: Says compiled or not, for which chip, and with which compile flags when known.
Compile
- What it does: Compiles a plain
.tflitemodel ahead of time (AOT) forTensor_G5(Pixel 10 family) orTensor_G6(Pixel 11 family) using the public LiteRT Python API — either locally on a Linuxx86_64machine or remotely on a Google Colab VM (--colabusinggoogle-colab-cli). - What you can ask:
- "Compile
model.tflitefor Pixel 10" (or Pixel 11) - "Compile
model.tflitefor Pixel 10 using Colab" / "I'm on a Mac, compile this model" - "Compile it with these flags" (passes Tensor compiler options: precision, sharding, int64 to int32, models over 2 GB, 4-bit weights)
- "Compile
- What the skill does:
- Writes
compiled/model_Google_Tensor_G5.tflite(or..._G6) plus a.compile.jsonrecord of flags, ops placed on the TPU, and versions. - If using Colab, spins up a remote Google Colab Linux
x86_64VM, installs the SDK with your Beta tar file, compiles the model, downloads the.tfliteand.compile.jsonsidecar locally, and stops the Colab VM.
- Writes
Compile and benchmark can run on different machines, for example,
compile on a Linux workstation or cloud VM, or on a remote Google
Colab VM (--colab), and benchmark where the phone is plugged in
(or over a forwarded adb connection).
Benchmark
- What it does: Benchmarks a compiled model on the device TPU (latency, peak memory, TPU tile time, and energy per inference), optionally comparing against CPU execution.
- What you can ask:
- "Benchmark this compiled model on my phone"
- "How long does the TPU itself take?" (returns TPU tile time)
- "How much energy does the TPU use per inference?" (from phone's power monitor)
- "How fast is
model.tfliteon the TPU versus the CPU?"
- What the skill does: Runs TPU-only benchmarks on the attached Pixel (reporting latency statistics, memory, TPU tile time, and energy), or runs both TPU and CPU variants to calculate speed-ups.
Compile and benchmark can run on different machines, for example,
compile on a Linux workstation or cloud VM, or on a remote Google
Colab VM (--colab), and benchmark where the phone is plugged in
(or over a forwarded adb connection).
Report
- What it does: Generates a ready-to-paste Markdown table,
results.json, and raw logs. Every number comes from the run itself. - What you can ask:
- "Give me the benchmark results / report" (automatically produced as part of benchmark and package runs).
Package
- What it does: Packages compiled models for your Android
Gradle app (Google Play AI pack, NPU runtime feature module,
CPU fallback, Kotlin loader, and
INTEGRATION.md). - What you can ask:
- "Package my compiled model for my app" / "Deploy it to my Android app"
- What the skill does: Writes
app_package/<name>/containing the AI pack, NPU runtime module, CPU fallback model,TensorModelLoader.kt, and anINTEGRATION.mdfile filled in with your names and versions. It also asks when Google Play should deliver the model and offers to apply the plan to your project.
Update
- What it does: Updates an existing Google Tensor app build by inspecting your project and preparing replacement files.
- What you can ask:
- "My app already runs a Tensor build; swap in the new one"
- What the skill does: Reads your project without changing it, writes
app_update/<name>/with only the files to replace, provides anUPDATE.mdguide, and offers to safely apply the changes with file backups.
Apply
- What it does: Applies packages or updates to your project safely with a review plan and user confirmation.
- What you can ask:
- "Yes, apply it to my app" / "Add it to my app at
/path/to/MyApp"
- "Yes, apply it to my app" / "Add it to my app at
- What the skill does: Checks your project against the package, shows
a single explicit plan (files to copy and code edits), asks separate
confirmation questions for risky changes (such as upgrading the
Android Gradle plugin/Kotlin, raising
minSdk, or changing LiteRT versions), and builds the app once at the end.
Install
- What it does: Installs and validates the app on a Pixel device, confirming whether execution ran on the TPU or CPU.
- What you can ask:
- "Install my app on my Pixel and check it uses the TPU"
- "I just want to try it on my Pixel quickly" (adds
--quick-testfor quick debug builds without bundletool)
- What the skill does: Builds your app bundle, installs it using
bundletool local testingthe way Google Play would, starts the app, and reports"path":"npu"or"path":"cpu"with the reason. It also asks before uninstalling any existing app copy.
Troubleshoot
- "The compile crashed" / "some ops stayed on the CPU": Retries with documented fallback flags or offers a run allowing CPU fallback with labeled results.
- "This computer has no internet": Benchmarks using local copies of the runtime files.
- "I don't have Beta access yet": Checks files, computer, and phone now, providing exact install commands for when access arrives.
The litert-google-tensor skill doesn't overwrite an existing compiled
model without asking, change your app's project until you approve
the plan, touch signing settings, or leave background processes.
It removes files it pushes to your phone, asks before uninstalling
your app, and installs nothing on your computer without telling you.
Set up the skill
The source files to the litert-google-tensor skill are available in the
google-ai-edge/litert-samples/skills/litert-google-tensor
directory on GitHub.
Follow these steps to set up, install, and use the skill:
Request Beta access (Required for compiling): Sign up for Beta access. You might need to wait for Google to approve your access and provide you the tar file. Compilation cannot be done without the tar file but benchmarking an already-compiled model does not need it.
Set up the compiler (Required for compiling): Choose one of the following:
Local Linux x86_64
Ask the agent to set it up, or print the commands yourself:
python3 <skill dir>/scripts/compile_model.py --print-installRun the printed commands with the path to your Beta tar file.
They create a virtualenv (
~/.venvs/litert-tensor) and installai-edge-litertandai-edge-litert-sdk-google-tensorat the version the skill pins; the output also says whether your Python version is supported.GOOGLE_TENSOR_SDK_BETAmust point at the tar file during pip install, because that is when the compiler is unpacked. If your system is missing packages, see troubleshooting.Remote Google Colab
If you are on macOS or Windows, or don't want to set up a local Linux environment, print the Colab CLI setup commands:
python3 <skill dir>/scripts/compile_model.py --print-install --colabThis installs
google-colab-cliand runs colab sessions once, to sign in with your Google Account in the browser.When you compile with
--colab --sdk-tarball /abs/path/litert_plugin_compiler.tar.gz, the script uploads your model and tar file to a Colab VM, installs the pinned LiteRT SDK there, downloads the compiled.tfliteand.compile.jsonsidecar, and stops the Colab VM.If you prefer clicking through a notebook in the browser instead of the CLI, see the LiteRT AOT Compilation Tutorial Colab
Install adb (Required for benchmark and app check): Download from Android SDK platform-tools and put it on your PATH.
Prepare the phone (Required for benchmark and app check): Turn on Developer options > USB debugging, plug the phone in, and accept the "Allow USB debugging" prompt.
adb devicesmust list the phone as device.Install the skill (Required for all workflows):
Copy the
litert-google-tensorskill folder into your agent's skills directory.Start a new agent session and verify that the agent recognizes the skill (for example, by checking its loaded skills list or using the
/litert-google-tensorcommand). If it doesn't appear, check the folder path and restart your agent.Use the skill: Ask the agent to compile, benchmark, package, or perform another associated task in plain words. Have the following ready:
- The absolute path of the
.tflite; - For a compile: the target phone (Pixel 10 or Pixel 11);
- For a CPU comparison: the original, uncompiled model;
- If several phones are connected: the serial from
adb devices.
Example prompts
- "Is
/path/to/model.tflitecompiled for Google Tensor?" - "Compile
/path/to/model.tflitefor Pixel 10." - "Compile
/path/to/model.tflitefor Pixel 10 on Colab using/path/to/litert_plugin_compiler.tar.gz." - "Benchmark
/path/to/compiled/model_Google_Tensor_G5.tfliteon my phone, with a CPU baseline from/path/to/model.tflite." - "How fast is
/path/to/model.tfliteon the Pixel 10 TPU compared with the CPU?" - "Package
/path/to/compiled/model_Google_Tensor_G5.tflitefor my Android app (original:/path/to/model.tflite)." - "Update the Tensor model in my app at
/path/to/MyAppwith/path/to/compiled/model_Google_Tensor_G5.tflite(original:/path/to/model.tflite)." - "Apply the integration plan to my app at
/path/to/MyApp." - "Install my app at
/path/to/MyAppon my Pixel and check that the model runs on the TPU."
Where the results go
- Compile:
, with a/compiled/ _Google_ .tflite .compile.jsonfile next to it. - Benchmark:
./litert_benchmark_results/with/ report.md,results.json,logsand per-op profiles. - Package:
with/app_package/ / INTEGRATION.md(your next steps), the Gradle modules, the models andpack.json(where every file came from). - Update:
with/app_update/ / UPDATE.md(your next steps),files/(the new files, at your project's paths) andupdate.json. When the agent applies it, a copy of each project file it replaces goes tofirst./app_update/ -backup/ - App check on a Pixel:
./litert_app_verify/with/ report.md,results.jsonand the build and install logs.
- The absolute path of the
Additional resources
For more details, see the skill's source in google-ai-edge/litert-samples/skills/litert-google-tensor on GitHub.