Google Tensor SDK supports the following pre-compiled Small Language Models
(SLMs) on Tensor_G6 (Pixel 11) and Tensor_G5 (Pixel 10) chipsets.
Pre-compiled SLMs
The following table lists the pre-compiled models, their quantization, and links to download the pre-compiled LiteRT-LM bundles.
| Model | Quantization | LiteRT-LM Bundle |
|---|---|---|
| MedGemma2 E4B | W4A8 | Download (Tensor_G6) |
| Gemma4 E2B | W8A8 or W2A8 | Download (Tensor_G5) | Download (Tensor_G6) |
| Gemma3 1B | W8A16 | Download (Tensor_G5) | Download (Tensor_G6) |
| Mobile Actions | W8A16 | Download (Tensor_G5) | Download (Tensor_G6) |
| Embedding Gemma V1 | Mixed Precision | Download (Tensor_G5) | Download (Tensor_G6) |
| Embedding Gemma V2 | Dynamic W4AFP32 or W8A8 | Download (Tensor_G5) | Download (Tensor_G6) |
Compile SLMs from fine-tuned checkpoints
In addition to the pre-compiled models, for Tensor_G6, you can export and compile the model from their finetuned checkpoints to create TPU compatible LiteRT-LM bundles for the following models:
Get access to the compiler
Sign up for the Google Tensor SDK Beta program to get access to the compiler. You can download it after your request is approved.
Extract the compiler
Run the following command to extract it and install dependencies:
export GOOGLE_TENSOR_SDK_BETA=/<path to your local>/compiler_tar_gz
pip install ai-edge-litert-sdk-google-tensor-nightly
pip install litert-torch-nightly
Run LiteRT-LM export
Run the following command to export and compile your model:
litert-torch export-hf \
--model='<model_id or fine_tuned_safe_tensor_dir>' \
--output_dir=/tmp/ \
--split_cache \
--externalize_embedder \
--prefill_lengths=128, \
--cache_length=1280 \
--quantization_recipe='<quantization_recipe>' \
--aot_backend=GOOGLE \
--aot_soc_model=Tensor_G6 \
--aot_compilation_config_dict='<google_tensor_compiler_config>'
Use the following configurations for each model:
MedGemma2 E4B
MedGemma is a collection of open models designed for healthcare AI applications, including medical text comprehension, clinical reasoning, and medical image interpretation. Fine-tuning MedGemma2 E4B on your own medical data lets you adapt and optimize the model's performance for your specific use case. Follow the steps below to export, quantize, and AOT-compile a fine-tuned multimodal MedGemma2 E4B model (text, vision, and audio) for Tensor_G6 (Pixel 11).
- A Linux x86_64 machine (Python 3.11–3.13) connected as a local Colab runtime, with at least ~160 GB total RAM plus swap and ~150 GB free disk space.
- The Google Tensor compiler tar file (
litert_plugin_compiler.tar.gz) from the Google Tensor SDK Beta.
Step 1: Download the Tensor_G6 binary .pb compiler options files:
- Text model:
compiler_options_text_w435b.pb - Vision encoder:
compiler_options_vision_encoder.pb - Audio encoder:
compiler_options_audio_encoder.pb
Step 2: Fine-tune your MedGemma2 E4B model and save the merged BF16 Hugging Face checkpoint (including config.json and tokenizer.model—not a standalone LoRA adapter).
Step 3: Use the following quantization recipes during export. The Colab fetches the text and audio recipes automatically from models/medgemma2 in the LiteRT-LM repository (or save them locally if running outside the Colab):
- Text model: Uses a mixed 4-bit and 8-bit quantization recipe (
quantization_recipe_w435b_npu_hadamard_ple.json).Text quantization recipe
[ { "algorithm_key": "DECOMPOSED_HADAMARD_ROTATION", "op_config": { "compute_precision": "INTEGER", "weight_tensor_config": { "algorithm_params": { "max_hadamard_size": 256, "q_init_mode": "none", "randomize": false, "sizing_mode": "max_power_of_two" }, "dtype": "INT", "granularity": "CHANNELWISE", "num_bits": 4, "symmetric": true } }, "operation": "FULLY_CONNECTED", "regex": "Gemma4TextDecoderLayer_((0|1|2|4|5|6|7|8|9|10)/.*Linear_(qkv|q|k|v)_proj;|(26|29|31|32|33|34|35|36|37|38|39|40)/.*Linear_q_proj;|(0|1|2|3|4|5|6|7|8|9|10|11|12|35|38)/.*Linear_o_proj;|(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|17|18|19|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41)/.*Linear_(gate_up|gate|up)_proj;|(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|17|19|20|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40)/.*Linear_down_proj;|(22|24|25|27|28|33)/.*Linear_per_layer_input_gate;|(0|1|2|3|4|5|6|10)/.*Linear_per_layer_projection;)|decode_logits_output;|Linear_lm_head;" }, { "algorithm_key": "DECOMPOSED_HADAMARD_ROTATION", "op_config": { "compute_precision": "INTEGER", "weight_tensor_config": { "algorithm_params": { "max_hadamard_size": 256, "q_init_mode": "none", "randomize": false, "sizing_mode": "max_power_of_two" }, "dtype": "INT", "granularity": "CHANNELWISE", "num_bits": 8, "symmetric": true } }, "operation": "FULLY_CONNECTED", "regex": "Gemma4TextDecoderLayer_((3|11|12|13|14|15|16|17|18|19|20|21|22|23)/.*Linear_(qkv|q|k|v)_proj;|(24|25|27|28|30|41)/.*Linear_q_proj;|(13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|36|37|39|40|41)/.*Linear_o_proj;|(16|20|21|22|23)/.*Linear_(gate_up|gate|up)_proj;|(16|18|21|22|23|41)/.*Linear_down_proj;|(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|23|26|29|30|31|32|34|35|36|37|38|39|40|41)/.*Linear_per_layer_input_gate;|(7|8|9|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41)/.*Linear_per_layer_projection;)" }, { "algorithm_key": "OCTAV", "op_config": { "compute_precision": "INTEGER", "weight_tensor_config": { "dtype": "INT", "granularity": "CHANNELWISE", "num_bits": 8, "symmetric": true } }, "operation": "FULLY_CONNECTED", "regex": "Linear_per_layer_model_projection;" }, { "algorithm_key": "DECOMPOSED_HADAMARD_ROTATION", "op_config": { "compute_precision": "INTEGER", "weight_tensor_config": { "algorithm_params": { "max_hadamard_size": 256, "q_init_mode": "none", "randomize": false, "sizing_mode": "max_power_of_two" }, "dtype": "INT", "granularity": "CHANNELWISE", "num_bits": 4, "symmetric": true } }, "operation": "EMBEDDING_LOOKUP", "regex": ".*" }, { "algorithm_key": "DECOMPOSED_HADAMARD_ROTATION", "op_config": { "compute_precision": "INTEGER", "weight_tensor_config": { "algorithm_params": { "max_hadamard_size": 256, "q_init_mode": "none", "randomize": false, "sizing_mode": "max_power_of_two" }, "dtype": "INT", "granularity": "CHANNELWISE", "num_bits": 4, "symmetric": true } }, "operation": "EMBEDDING_LOOKUP", "regex": "per_layer_embedder|PerLayerEmbedder|embed_tokens_per_layer" } ] - Vision encoder: Uses the built-in 8-bit dynamic quantization recipe (
dynamic_wi8c_afp32); no JSON file is required. - Audio encoder: Uses an 8-bit quantization recipe tuned for
Tensor_G6NPU compilation (quantization_recipe_audio_wi8_nobmm.json).Audio quantization recipe
[ { "regex": ".*", "operation": "*", "algorithm_key": "min_max_uniform_quantize", "op_config": { "weight_tensor_config": { "num_bits": 8, "symmetric": true, "granularity": "CHANNELWISE", "dtype": "INT" }, "compute_precision": "INTEGER", "explicit_dequantize": false, "skip_checks": false, "min_weight_elements": 0 } }, { "regex": ".*", "operation": "BATCH_MATMUL", "algorithm_key": "no_quantize" } ]
Step 4: Run the MedGemma2 E4B NPU Setup Colab to export the multimodal sub-models, AOT-compile them for Tensor_G6 (using google_tensor_sharding_intensity="minimal" for the audio encoder and compiler defaults for the audio adapter), and pack the .litertlm bundle.
Gemma4 E2B
Optimize your Gemma4-E2B export by selecting a Post-Training Quantization (PTQ) configuration that balances bundle size, decode latency, and model quality. Scaling weights down to 4-bit reduces memory footprint and improves decode speed, while keeping sensitive attention and MLP layers in 8-bit precision preserves accuracy.
Step 1: Choose a quantization configuration
Select the quantization recipe that best matches your device memory budget and task complexity:
| Configuration | TPU Bundle Size | Effective Bits | Details & Trade-offs |
|---|---|---|---|
| Baseline (QAT) | 2.74 GB | 2.82 | Default QAT baseline model. |
| Config 1: High Accuracy (8-bit Transformer) W8A16 — 4-bit Per-Layer Embeddings & Embedder |
4.20 GB | 8.00 | Quantizes transformer layers to 8-bit weights while keeping Per-Layer Embeddings (PLE) and embedder layers in 4-bit. Preserves highest accuracy with a larger bundle size.Config1 |
| Config 2: Smallest Size (Full 4-bit) W4A16 — 4-bit weights across all layers |
2.84 GB | 4.00 | Applies 4-bit min-max uniform quantization across all layers. Yields the smallest footprint, suitable for simpler tasks or domain-specific fine-tuned models.Config2 |
| Config 3: Balanced (Attention-Preserving Mixed 4/8-bit) W48A16 — 8-bit Attention (Q/K/V/O) & Per-Layer Projections, 4-bit elsewhere |
3.06 GB | 4.59 | Keeps Q, K, V, and O attention projections and per-layer projections in 8-bit precision and remaining layers in 4-bit, recovering substantial accuracy over full 4-bit.Config3 |
| Config 4: Complex Reasoning (Attention & MLP Mixed 4/8-bit) W48A16 — 8-bit Attention (Q/K/V/O), Per-Layer Projections & Common MLP, 4-bit elsewhere |
3.47 GB | 5.30 | Keeps Q, K, V, and O attention projections, per-layer projections, and Common MLP layers in 8-bit across prefill and decode stages. Recommended for complex reasoning on devices with higher memory capacity.Config4 |
Step 2: Customize mixed-precision rules (Optional)
If you are creating or modifying a W48A16 JSON recipe using min_max_uniform_quantize, configure the rules as follows:
- Set 4-bit defaults: Apply 4-bit symmetric, channel-wise quantization to
EMBEDDING_LOOKUPand standardFULLY_CONNECTEDoperations. - Apply 8-bit exceptions: Keep critical layers at 8-bit symmetric, channel-wise precision—specifically per-layer fully connected ops, QKVO projections (
[qkvo]_proj), and common MLP layers (Gemma4TextDecoderLayer_([0-9]|1[0-4])/*Gemma4TextMLP_mlp).
Step 3: Install required packages
Install the required export and bundle packaging dependencies:
pip install litert-torch
pip install transformers
pip install -U litert-lm-builder-nightlyStep 4: Export and compile the model
Download the compiler options file matching your target SoC and quantization configuration:
Run litert-torch export-hf with your selected recipe and compiler options path:
litert-torch export-hf \
--model=google/gemma-4-E2B-it \
--output_dir=/tmp/ \
--split_cache \
--externalize_embedder \
--prefill_lengths=128, \
--sliding_window_ring_buffer_size=512 \
--cache_lengths=640,1024,1536,4096 \
--quantization_recipe="<quantization_recipe>" \
--jinja_chat_template_override=litert-community/gemma-4-E2B-it-litert-lm \
--aot_backend=GOOGLE \
--aot_soc_model=Tensor_G6 \
--aot_compilation_config_dict='{"google_tensor_extra_options_path": "/path/to/compiler_options.pb"}'Step 5: Inject NPU ExecutorMetadata into the .litertlm bundle
After exporting, unpack the generated .litertlm archive to enable hardware-accelerated NPU execution settings:
-
Unpack the bundle:
BUNDLE=/path/to/model.litertlm UNPACK_DIR=$(mktemp -d) litert-lm-builder unpack --input "${BUNDLE}" --output_dir "${UNPACK_DIR}" -
Add NPU executor metadata: Open
${UNPACK_DIR}/ExecutorMetadataProto.pbtext(or create it if not present). Preserve any existingllm_executor_metadata { ... }block and appendllm_npu_executor_metadataat the end:llm_npu_executor_metadata { enable_neon_for_npu_greedy_sampling: true use_hw_masking_for_npu: true use_hw_cache_update_for_npu: true use_hw_ple_for_npu: true } -
Register the section in
model.toml(only if created in Step 2): If${UNPACK_DIR}/model.tomldoes not already includesection_type = "ExecutorMetadata", append:[[section]] section_type = "ExecutorMetadata" data_path = "ExecutorMetadataProto.pbtext" -
Repack, verify, and clean up:
litert-lm-builder toml --path "${UNPACK_DIR}/model.toml" output --path "${BUNDLE}.tmp" litert-lm-peek --litertlm_file "${BUNDLE}.tmp" | grep -B 6 -A 10 "llm_npu_executor_metadata" mv -f "${BUNDLE}.tmp" "${BUNDLE}" rm -rf "${UNPACK_DIR}"
Gemma3 1B
Download the compiler options from Huggingface.
- model_id =
"google/gemma-3-1b-it"or"/path/to/your/finetuned/safetensors/directory" - quantization_recipe =
"w8a16" - google_tensor_compiler_config =
'{"google_tensor_extra_options_path": "/path/to/Gemma3-1B-IT_Google_Tensor_G6.pb"}'
For more details, see export.py.
FunctionGemma
Step 1: Download the compiler options from Huggingface.
Step 2: Fine-tune your FunctionGemma model and save this SafeTensors checkpoint as a .safetensors file.
custom_quantization_recipe.json:Custom Quantization Recipe
[ { "regex": ".*", "operation": "EMBEDDING_LOOKUP", "algorithm_key": "min_max_uniform_quantize", "op_config": { "compute_precision": "INTEGER", "explicit_dequantize": false, "weight_tensor_config": { "num_bits": 8, "symmetric": true, "granularity": "CHANNELWISE" } } }, { "regex": ".*", "operation": "FULLY_CONNECTED", "algorithm_key": "min_max_uniform_quantize", "op_config": { "compute_precision": "FLOAT", "explicit_dequantize": true, "weight_tensor_config": { "num_bits": 8, "symmetric": true, "granularity": "CHANNELWISE" } } } ]
Step 4: Add the flag --keep_temporary_files to the litert-torch export-hf command to keep the intermediate exported TFLite model.
- fine_tuned_safe_tensor_dir =
"/path/to/your/finetuned/safetensors/directory" - quantization_recipe =
/path/to/custom_quantization_recipe.json - google_tensor_compiler_config =
'{"google_tensor_extra_options_path": "/path/to/functiongemma-270m-ft-mobile-actions_Google_Tensor_G6.pb"}'
After running the export command, save llm_metadata.pbtext and pass it to the following litert-lm builder command along with the exported tflite splits. This builds a LiteRT-LM bundle compatible with Google Tensor:
litert-lm-builder
system_metadata
--str model_name "functiongemma"
tflite_model
--path /path/to/model_quantized_aot_compiled.tflite
--model_type prefill_decode
tflite_model
--path /path/to/embedder_quantized.tflite
--model_type embedder
tflite_model
--path /path/to/auxiliary.tflite
--model_type aux
hf_tokenizer
--path /path/to/tokenizer.json
llm_metadata
--path /path/to/llm_metadata.pbtext
output
--path path/to/tpu_model.litertlm
Embedding Gemma
Use the compilation path for classical ML models. Refer to the usage example for more details.