Repository navigation
[docs] Add a LiteRT page under community integrations - #48540
Merged
stevhliu merged 2 commits intoSep 7, 2026
Merged
Conversation
Transformers v4 documented LiteRT export through `optimum[exporters-tf]`, which was removed with the TensorFlow support in huggingface#40760. This page documents the current route: `litert-torch` converts a model from `torch.export` directly. `litert-torch export_hf` writes a `.litertlm` file for LLMs, and `litert_torch.convert` writes a `.tflite` file for other models. Also adds the toctree entry under "Local deployment" and a redirect from the removed `tflite` page to the new one.
stevhliu
approved these changes
Sep 7, 2026
|
|
||
| # LiteRT | ||
|
|
||
| [LiteRT](https://ai.google.dev/edge/litert) (formerly TensorFlow Lite) is Google's runtime for on-device inference. The model format is still `.tflite`, and language models ship as one `.litertlm` file for the [LiteRT-LM](https://ai.google.dev/edge/litert-lm) runtime. |
Member
There was a problem hiding this comment.
Suggested change
| [LiteRT](https://ai.google.dev/edge/litert) (formerly TensorFlow Lite) is Google's runtime for on-device inference. The model format is still `.tflite`, and language models ship as one `.litertlm` file for the [LiteRT-LM](https://ai.google.dev/edge/litert-lm) runtime. | |
| [LiteRT](https://ai.google.dev/edge/litert) (formerly TensorFlow Lite) is Google's runtime for on-device inference. The model format is `.tflite` and language models ship as one `.litertlm` file for the [LiteRT-LM](https://ai.google.dev/edge/litert-lm) runtime. |
|
|
||
| [LiteRT](https://ai.google.dev/edge/litert) (formerly TensorFlow Lite) is Google's runtime for on-device inference. The model format is still `.tflite`, and language models ship as one `.litertlm` file for the [LiteRT-LM](https://ai.google.dev/edge/litert-lm) runtime. | ||
|
|
||
| Export a Transformers model with [litert-torch](https://github.com/google-ai-edge/litert-torch) (formerly `ai-edge-torch`). It lowers the [torch.export](https://docs.pytorch.org/docs/stable/export.html) graph to LiteRT directly, without ONNX or TensorFlow. |
Member
There was a problem hiding this comment.
Suggested change
| Export a Transformers model with [litert-torch](https://github.com/google-ai-edge/litert-torch) (formerly `ai-edge-torch`). It lowers the [torch.export](https://docs.pytorch.org/docs/stable/export.html) graph to LiteRT directly, without ONNX or TensorFlow. | |
| Export a Transformers model with [litert-torch](https://github.com/google-ai-edge/litert-torch). It lowers the [torch.export](https://docs.pytorch.org/docs/stable/export.html) graph to LiteRT directly, and not through ONNX or a TensorFlow `SavedModel`. |
| <hfoptions id="export"> | ||
| <hfoption id="CLI (LLM)"> | ||
|
|
||
| `export_hf` loads a text-generation model from the Hub, quantizes the weights to int8 by default, and writes `model.litertlm`. |
Member
There was a problem hiding this comment.
Suggested change
| `export_hf` loads a text-generation model from the Hub, quantizes the weights to int8 by default, and writes `model.litertlm`. | |
| `export_hf` loads a language model from the Hub, quantizes the weights to int8 by default, and writes `model.litertlm`. |
| 1. [`~PreTrainedModel.from_pretrained`] loads the model weights in safetensors format. | ||
| 2. litert-torch runs [torch.export](https://docs.pytorch.org/docs/stable/export.html) and lowers the graph to LiteRT operators. `export_hf` adds the KV cache, prefill and decode signatures, and int8 quantization. | ||
| 3. [`AutoTokenizer`] loads the tokenizer. `export_hf` packs it and the chat template into the `.litertlm` file. | ||
| 4. At runtime, `.tflite` runs on LiteRT and `.litertlm` on LiteRT-LM, from Kotlin, Swift, C++, or Python (`ai-edge-litert` and `litert-lm-api`; the older `tflite-runtime` wheels stop at Python 3.11). |
Member
There was a problem hiding this comment.
Suggested change
| 4. At runtime, `.tflite` runs on LiteRT and `.litertlm` on LiteRT-LM, from Kotlin, Swift, C++, or Python (`ai-edge-litert` and `litert-lm-api`; the older `tflite-runtime` wheels stop at Python 3.11). | |
| 4. At runtime, `.tflite` runs on LiteRT and `.litertlm` on LiteRT-LM, from Kotlin, Swift, C++, or Python (`ai-edge-litert` and `litert-lm-api`). The older `tflite-runtime` wheels stop at Python 3.11. |
Contributor
Author
|
Thanks for the review, @stevhliu — applied all four suggestions as written. Nothing else changed. |
Contributor
CI recapDashboard: View test results in Grafana |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
sbucaille
pushed a commit
to sbucaille/transformers
that referenced
this pull request
Sep 16, 2026
) * [docs] Add a LiteRT page under community integrations Transformers v4 documented LiteRT export through `optimum[exporters-tf]`, which was removed with the TensorFlow support in huggingface#40760. This page documents the current route: `litert-torch` converts a model from `torch.export` directly. `litert-torch export_hf` writes a `.litertlm` file for LLMs, and `litert_torch.convert` writes a `.tflite` file for other models. Also adds the toctree entry under "Local deployment" and a redirect from the removed `tflite` page to the new one. * docs(litert): apply review wording suggestions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Since #40760 removed TensorFlow support, the docs have had no LiteRT page. The v4 page
tflite.mdwent with it, because its route (pip install optimum[exporters-tf],optimum-cli export tflite) converted through TensorFlow. The gap is still visible today: the v4 text is served at https://huggingface.co/docs/transformers/main/en/tflite, and its command no longer runs with current Optimum (2.3.0; theexporters-tfextra is absent from every 2.x release), stopping atunrecognized arguments: tflite .... Meanwhile the conversion itself no longer needs TensorFlow:litert-torchconverts fromtorch.exportdirectly, which fits a PyTorch-only Transformers. I publish LiteRT conversions of Hub models, so I ran into this from the user side.This PR adds the replacement page next to the other on-device runtimes (Candle, ExecuTorch, llama.cpp, MLX) under "Local deployment":
docs/source/en/community_integrations/litert.md, laid out likeexecutorch.md: a short intro, an<hfoptions>block with a CLI example (litert-torch export_hf, SmolLM2-135M-Instruct →model.litertlm) and a Python example (litert_torch.convert, bert-base-uncased →bert.tflite), a "Transformers integration" list, and resource links. The renamed packages (TensorFlow Lite → LiteRT,ai-edge-torch→litert-torch,tflite-runtime/ai-edge-litert) are named in the text so that searches for the old names land on the current route. The old command gets one note, nothing more._toctree.ymlentry._redirects.yml:tflite→community_integrations/litert, so the old URL lands on the new page.Everything on the page was run as written, in fresh venvs on macOS arm64 with Python 3.12.13 and 3.14.6.
pip install litert-torchresolves to litert-torch 0.9.4, ai-edge-litert 2.2.0, torch 2.13.0 and transformers 5.16.1, with no TensorFlow or ONNX in the environment.export_hfwrote a 136 MiBmodel.litertlm(int8 weights by default) thatlitert-lm-api0.17.0 loads; the reply to "What is the capital of France?" starts with "The capital of France is Paris." The BERT.tflitepredictscapitalfor the masked token, with a max logits difference of 9.5e-5 against PyTorch, and the file reloaded from disk with theai_edge_litertInterpreter gives the same output.Checks: built locally with
doc-builder(this page plusexecutorch.mdas a control);python utils/check_doc_toc.pyandpython utils/check_doctest_list.pypass. No code changes.Before submitting
Who can review?
@stevhliu