Instructions to use litert-community/Gemma3-1B-IT-Tensor-NPU with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use litert-community/Gemma3-1B-IT-Tensor-NPU with LiteRT-LM:
# LiteRT-LM runs on various platforms (Android, iOS, Windows, Linux, macOS, IoT, Web/WASM) # and supports many APIs (C++, Python, Kotlin, Swift, JavaScript, Flutter). # For platform-specific integration guides, please refer to the official developer website: # https://ai.google.dev/edge/litert-lm # To try LiteRT-LM, the easiest way is to use our CLI tool. # 1. Install the LiteRT-LM CLI tool: pip install -U litert-lm # 2. Download and run this model locally: # See: https://ai.google.dev/edge/litert-lm/cli # A single .litertlm file in the repo is picked automatically; otherwise the CLI asks which one to run # (or pass its name right after the repo id). litert-lm run \ --from-huggingface-repo=litert-community/Gemma3-1B-IT-Tensor-NPU \ --prompt="Write me a poem"
- Notebooks
- Google Colab
- Kaggle
Download RANK2_FC_SURGERY.md from litert-community/Gemma3-1B-IT-Tensor-NPU: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/litert-community/Gemma3-1B-IT-Tensor-NPU/resolve/main/RANK2_FC_SURGERY.md
- Command line
-
hf download hf://litert-community/Gemma3-1B-IT-Tensor-NPU/RANK2_FC_SURGERY.md
-
curl -L -o RANK2_FC_SURGERY.md https://huggingface.co/litert-community/Gemma3-1B-IT-Tensor-NPU/resolve/main/RANK2_FC_SURGERY.md
Gemma-3-1B on the Tensor G4 NPU β the rank-2 FC surgery
The compiler-bug workaround that makes Gemma-3/4 AoT-compile to the Tensor G4 edgetpu, plus working-model notes.
The rank-2 FULLY_CONNECTED surgery β the key enabler (affects G4 AND G5)
The DarwiNN AoT compiler OP_FAILEDs (file.cc:4780) on rank-3 FULLY_CONNECTED ops.
Gemma-3 (and Gemma-4) emit these ~360Γ across the model, so the AoT compile fails outright
without a fix.
Fix: wrap every rank-3 FC as RESHAPE β (rank-2) FC β RESHAPE β same math, rank the
compiler accepts. Script: recipe/fc_rank2_surgery.py (surgery(in_tflite, out_tflite)), run
after quantization, before aot_compile. ~360 FCs rewritten for gemma-3-1b. The G5 uses the same
compiler family, so the surgery carries over to G5 as well.
Profile
AoT (int4 per-channel + Hadamard): 100% NPU, prefill-monster (660 tok/s prefill),
power-efficient β best for long-input / RAG. Decode is dispatch-bound rather than
compute-bound, so it sits around 16 tok/s regardless of prefill length.
Behavior note: tone/"feel" differences vs a reference are runtime config (system prompt + sampling), not the quant β a faithful int4 copy matches the reference once system prompt and top-k / top-p / temperature match.
On quantization support tables
Don't trust a fixed "what quantization compiles" matrix, including any you find in older copies of this repo. Per-quant support is compiler-build-dependent: a result from one toolchain build does not generalize to another, and rows that read "unsupported" have repeatedly turned out to be one build's behaviour rather than a hardware or format limit.
Retest against your own target compiler rather than trusting a table.
Runtime requirement (brief)
int4 AoT DGCs require a compatible GoogleTensor dispatch library to load on-device; a stock app's dispatch may reject them as a firmware mismatch.