Views
No views yet
.litertlm) format for on-device inference with Google's
LiteRT-LM runtime (the engine behind the official
litert-community/* models).Qwen3ForCausalLM, 36 layers) that
operates exclusively in thinking mode — it emits a <think>…</think> chain before its answer —
so it rides the existing Qwen3 converter and runtime directly.| File | model.litertlm — int4 block 128 (~2.3 GB) |
| Quantization | int4 weights (symmetric) + OCTAV optimal-clipping; embeddings INT8 (externalized section) |
| Compute | integer |
| Context (KV cache) | 4096 |
| Base model | Qwen/Qwen3-4B-Thinking-2507 |
| Decode speed | ~14 tok/s (iPhone 17 Pro, GPU) · ~67 tok/s (Mac M-series, GPU) |
<think>…</think> reasoning chain, then the answer. Run it with
max_tokens ≥ 2048 — at a short limit it gets cut off mid-thought and never reaches the answer.
(All quality numbers below were measured at 2048.)| Configuration | GSM8K |
|---|---|
| bf16 (reference) | 90.0% |
| LiteRT int4 — block 128 | 86.0% (−4 pt) |
max_tokens ≥ 2048.<think> chains), and stays at −4 pt parity. So only the block-128 build is published.1# build litert-lm from https://github.com/google-ai-edge/litert-lm, then:
2litert_lm_main \
3 --model_path model.litertlm \
4 --backend gpu \
5 --input_prompt "A bat and a ball cost \$1.10. The bat costs \$1.00 more than the ball. How much is the ball?".litertlm bundle carries the tokenizer and prompt template (Qwen3 ChatML —
<|im_start|>role\n…<|im_end|>, stop token <|im_end|>), so no separate tokenizer files are
needed. The model produces a <think>…</think> block followed by its answer.Update (July 2026): Google AI Edge Gallery v1.0.16+ can import litert-lm models directly from Hugging Face inside the app (tap +) — no computer oradbneeded. The manual steps below are only required on older builds or for sideloading a local file.
.litertlm models on-device:com.google.ai.edge.gallery, 1.0.15+ supports .litertlm).model.litertlm and push it: adb push model.litertlm /sdcard/Download/.litertlm bundle runs on macOS / Linux / Windows with the official
LiteRT-LM CLI — including as a
local OpenAI-compatible API server:1pip install litert-lm
2litert-lm import --from-huggingface-repo litert-community/Qwen3-4B-Thinking-2507 model.litertlm qwen3-4b-thinking-2507
3litert-lm run qwen3-4b-thinking-2507 # interactive chat in the terminal
4litert-lm serve # local OpenAI-compatible API serverlitert-torch
converter — a standard Qwen3ForCausalLM, so it uses the existing Qwen3 path with no custom graph
code. Recipe: blockwise-128 int4 + OCTAV (INT4 weights, block 128, symmetric, OCTAV
optimal-clipping), embeddings INT8, KV cache 4096.1from litert_torch.generative.export_hf.export import export
2export(
3 model="Qwen/Qwen3-4B-Thinking-2507",
4 output_dir="out",
5 quantization_recipe="qwen3_int4_block128_octav.json", # blockwise-128 int4 + OCTAV, int8 embeddings
6 cache_length=4096,
7 externalize_embedder=True,
8)