Google Play services 中的 LiteRT 升级:GPU 推理提速约 1.4x,应用体积减小约 8 MB
Smaller apps and faster GPU inference with LiteRT in Google Play services
Google 宣布 Google Play services 中的 LiteRT 端侧推理运行时迎来最大升级:基于 ML Drift 的 GPU 推理比旧版 GPU delegate 快约 1.4x,并通过新的 CompiledModel API 提供。
原文给出 GPU 推理提速约 1.4x 和应用体积减小约 8 MB 的具体数据,读者可据此评估迁移到 Play services 运行时的收益。
OCT. 28, 2026
LiteRT in Google Play services is Android's on-device inference runtime for custom models, handling more than a trillion inferences a day across billions of devices. Today, it gets its biggest upgrade yet: GPU inference that runs about 1.4x faster than the legacy GPU delegate, powered by ML Drift and available through the new CompiledModel API, LiteRT’s modern successor to the legacy Interpreter API.
Until now, taking advantage of this faster GPU stack required bundling LiteRT in your app. In our testing, apps that switched to LiteRT in Google Play services are about 8 MB smaller, making them faster to download and lighter on users' devices, because the runtime, including the GPU accelerator, ships once with Play services rather than inside every app. More than 100K Android apps bundle their own copy of LiteRT or TensorFlow Lite today, so the savings add up quickly as apps switch.
If your Android app runs custom ML models on CPU or GPU, we encourage you to switch to LiteRT in Google Play services. You can see it in action in the Google AI Edge Gallery app, where the Scrapbook feature's image segmentation runs on LiteRT in Google Play services.
Why use LiteRT in Google Play services
Developers that adopt LiteRT in Google Play Services enjoy immediate benefits:
- Smaller apps, more free storage: As no ML runtime is bundled into your APK, your app is smaller and faster to download. In addition, as apps share one runtime, the storage and memory savings grow with each app that switches.
- Automatic updates: performance improvements, bug fixes, and security patches arrive through Play services in staged rollouts that catch device-specific issues early, without you having to ship an app update.
- More places to run: LiteRT in Play services runs on phones back to Android 7 (API level 24), and now also on Wear OS 4+ and Android Automotive OS (Android 11+).
- Tested at scale: ML Kit's Vision and Text APIs, like Subject Segmentation and Document Scanner, are already powered by LiteRT in Google Play services at scale across billions of Android devices. By adopting LiteRT in Google Play Services you are using the same, battle-tested infrastructure in your own app.
CompiledModel API
LiteRT is the evolution of TensorFlow Lite. It keeps the same .tflite model format you rely on and adds the CompiledModel API, which makes acceleration across fragmented hardware reliable:
- Simpler: one workflow for CPU and GPU acceleration instead of a different delegate and setup path for each accelerator. LiteRT uses OpenCL where available and OpenGL otherwise. If you request both GPU and CPU, it falls back to CPU on devices without a usable GPU.
- Faster: powered by ML Drift, LiteRT's latest, open-source GPU engine already used by Google apps on millions of devices daily. GPU inference runs about 1.4x faster than the legacy TensorFlow Lite GPU delegate.
- Portable: cross-platform support, so the same
.tflitemodel runs on Android, iOS, desktop, and web. - Flexible: the legacy Interpreter API is still supported on CPU, so you can migrate in phases.
Getting started and upgrading
Whether you're starting fresh or switching from bundled LiteRT, using LiteRT in Google Play services takes a few lines of code:
- Add
com.google.android.gms:play-services-litert:17.0.0(or a later version). If you bundle LiteRT today, remove thelitertdependency. - Get the
LiteRTenvironment from Play services:
val liteRtEnvironment =
LiteRt.initialize(
context,
LiteRtDsl.initializationOptions { setEnableGpu(true) }
).await()Kotlin
Copied
- Pass the LiteRT
environmentin when you create yourCompiledModel. The rest of your code stays the same.
If you're already using the legacy Interpreter API in Google Play services, your Interpreter code keeps working on CPU when you switch to play-services-litert. To run on the GPU, move to the CompiledModel API.
Let your coding agent do the work. In Agent Mode, the new LiteRT skill for Android Studio automates the move to LiteRT in Google Play services and the CompiledModel API. Ask it to “migrate my TFLite code to CompiledModel,” or type @litert-runtime, and it switches your app to play-services-litert, rewrites your Interpreter calls, and sets up GPU acceleration with CPU fallback. It can also scaffold a new LiteRT app. Treat it as a strong first pass: review the diff, build, and compare outputs on a real device. Get the skill on GitHub.
Upgrading from legacy APIs? The legacy GPU delegate and custom delegate APIs are deprecated in favor of CompiledModel GPU acceleration and the Compiler Plugin and Dispatch APIs, and NNAPI will be removed starting in 2027. Older SDKs now receive critical security fixes only. Apps you've already shipped keep working, but plan your move to the CompiledModel API now: code that uses deprecated APIs won't compile against the latest SDK, and staying on an older SDK can cause conflicts as your other dependencies move forward. See the release notes for details.
What's next
Looking ahead, LiteRT in Google Play services is our foundation for running your own task-specific models on Android, with CPU and GPU acceleration.
- LiteRT will keep getting regular updates, including better GPU acceleration and wider model coverage.
- NPU support in Play services is actively being worked on.
Ready to start?
- Read the LiteRT in Google Play services docs
- Try the LiteRT skill for Android Studio
- Try Scrapbook in the Google AI Edge Gallery app
- Something stopping you from switching, or need help? Reach out on GitHub Discussions or file an issue.
We can't wait to see what you build.
Previous
Next
来源:Google Developers Blog · developers.googleblog.com