Instructions to use Xylolabs/gemma-4-12B-it-Tenstorrent-Tensix with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Xylolabs/gemma-4-12B-it-Tenstorrent-Tensix with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Xylolabs/gemma-4-12B-it-Tenstorrent-Tensix", device_map="auto") - Notebooks
- Google Colab
- Kaggle
These weights from google/gemma-4-12B-it are quantized for Tenstorrent Tensix NPUs, with each format in its own folder.
Folders
| Folder | Formats | Size (GB, packed) | Mean KL to BF16 | Top-1 (%) |
|---|---|---|---|---|
bfp4/ |
Attention and MLP bfloat4_b, with the tied LM head and embedding, norms, audio, vision, and all other tensors in bf16 | 8.146 | 0.12030 | 87.96 |
bfp8/ |
Attention and MLP bfloat8_b, with the tied LM head and embedding, norms, audio, vision, and all other tensors in bf16 | 13.596 | 0.00183 | 98.35 |
| BF16 (google/gemma-4-12B-it) | - | 23.81 | 0 | 100 |
| Q4_K_M (llama.cpp) | - | 7.381 | 0.16924 | 85.52 |
KL and top-1 cover 8,048 positions of English and Korean text (WikiText-2 test, Korean Wikipedia), in the chat template. Q4_K_M was made from the same checkpoint with llama.cpp v0.9.0 (cd959bae) and no importance matrix. Its sha256 is 94baa8b5f0f9601ebeb7e961be3dd7d39b3fb15f316902c914f890c966570046.
How to run
Use Transformers 5.10.0 or later with PyTorch and accelerate.
hf download Xylolabs/gemma-4-12B-it-Tenstorrent-Tensix --include "bfp4/*" --local-dir gemma-4-12B-it-Tenstorrent-Tensix
hf download Xylolabs/gemma-4-12B-it-Tenstorrent-Tensix --include "bfp8/*" --local-dir gemma-4-12B-it-Tenstorrent-Tensix
from transformers import AutoProcessor, Gemma4UnifiedForConditionalGeneration
d = "gemma-4-12B-it-Tenstorrent-Tensix/bfp4"
processor = AutoProcessor.from_pretrained(d)
model = Gemma4UnifiedForConditionalGeneration.from_pretrained(d, dtype="bfloat16", device_map="auto")
messages = [{"role": "user", "content": [{"type": "text", "text": "What is the capital of France?"}]}]
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True,
return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=64)
print(processor.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Run on Tensix
Pack one matrix.
import json
import torch
import ttnn
from safetensors import safe_open
d = "gemma-4-12B-it-Tenstorrent-Tensix/bfp4"
name = "model.language_model.layers.0.mlp.down_proj.weight"
fmt = json.load(open(f"{d}/quant4.json"))["layers"]["0"]["mlp.down_proj"]["format"]
dtype = {"bfp4": ttnn.bfloat4_b, "bfp8": ttnn.bfloat8_b}[fmt]
shard = json.load(open(f"{d}/model.safetensors.index.json"))["weight_map"][name]
with safe_open(f"{d}/{shard}", "pt") as f:
w = f.get_tensor(name).t().contiguous()
device = ttnn.open_device(device_id=0)
w_tt = ttnn.as_tensor(w, dtype=dtype, layout=ttnn.TILE_LAYOUT,
device=device, memory_config=ttnn.DRAM_MEMORY_CONFIG)
assert torch.equal(ttnn.to_torch(w_tt).float(), w.float())
ttnn.close_device(device)
python gemma-4-12B-it-Tenstorrent-Tensix/bfp4/pack_tensix.py gemma-4-12B-it-Tenstorrent-Tensix/bfp4
python gemma-4-12B-it-Tenstorrent-Tensix/bfp4/verify_grid.py gemma-4-12B-it-Tenstorrent-Tensix/bfp4
Add --device to pack_tensix.py to round-trip the packed values. For BFP8, replace bfp4 with bfp8 in every path above.
Updates
- 2026-11-29: Merged the BFP4 and BFP8 repos into one repo with a folder per format.
- 2026-11-22:
bfp4/andbfp8/: Corrected the bf16 size in the summary to match the evaluation table. - 2026-11-11:
bfp4/andbfp8/: First release.
License
Apache 2.0, as declared by the base model. LICENSE contains the standard text, and NOTICE lists the changes. Each folder carries both files.
pack_tensix.py and verify_grid.py are by Xylolabs under the same license and ship unchanged from tensix-bfp-gptq commit 5c52065.
Citation
@misc{gemmateam2026gemma4,
title={Gemma 4 Technical Report},
author={Gemma Team},
year={2026},
eprint={2607.02770},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2607.02770},
}