Skip to content

[docs] Add a LiteRT page under community integrations - #48540

Merged
stevhliu merged 2 commits into
huggingface:mainfrom
john-rocky:docs-litert-community-integration
Sep 7, 2026
Merged

stevhliu merged 2 commits into
huggingface:mainfrom
john-rocky:docs-litert-community-integration

Conversation

@john-rocky

@john-rocky john-rocky commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

CPU CI GPU run-slow

What does this PR do?

Since #40760 removed TensorFlow support, the docs have had no LiteRT page. The v4 page tflite.md went 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; the exporters-tf extra is absent from every 2.x release), stopping at unrecognized arguments: tflite .... Meanwhile the conversion itself no longer needs TensorFlow: litert-torch converts from torch.export directly, 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 like executorch.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.
  • the _toctree.yml entry.
  • _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-torch resolves 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_hf wrote a 136 MiB model.litertlm (int8 weights by default) that litert-lm-api 0.17.0 loads; the reply to "What is the capital of France?" starts with "The capital of France is Paris." The BERT .tflite predicts capital for the masked token, with a max logits difference of 9.5e-5 against PyTorch, and the file reloaded from disk with the ai_edge_litert Interpreter gives the same output.

Checks: built locally with doc-builder (this page plus executorch.md as a control); python utils/check_doc_toc.py and python utils/check_doctest_list.py pass. No code changes.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline and the Pull Request checks?
  • Was this discussed/approved via a Github issue or the forum? No related issue found.
  • Did you make sure to update the documentation with your changes according to the guidelines?
  • Did you write any new necessary tests? Docs only.

Who can review?

@stevhliu

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 stevhliu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!


# 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@john-rocky

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @stevhliu — applied all four suggestions as written. Nothing else changed.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 33944506794:2
Result: success | Jobs: 2 | Tests: 26 | Failures: 0 | Duration: 2m 43s

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@stevhliu
stevhliu added this pull request to the merge queue Sep 7, 2026
Merged via the queue into huggingface:main with commit 26600f6 Sep 7, 2026
32 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants