Flint for Tenstorrent Tensix
Collection
1 item • Updated
These weights from RecursiveSI/flint are quantized for Tenstorrent Tensix NPUs (Wormhole, Blackhole), with the files in bfp4/.
| Folder | Formats | Size (GB, packed) | Mean KL to BF16 |
|---|---|---|---|
bfp4/ |
Attention, MLP and routed/shared experts bfloat4_b; the rest bf16 | 23.299 | 0.374 |
| BF16, reordered reference (RecursiveSI/flint) | - | 79.57 | 0 |
| Q4_K_M (llama.cpp) | - | 24.167 | 0.3039 |
KL covers 16,320 positions of English and Korean text (WikiText-2 test and Korean Wikipedia), plain and in the chat template, with a mean-KL limit of 1.5 times the Q4_K_M reference.
hf download Xylolabs/flint-Tenstorrent-Tensix --include "bfp4/*" --local-dir flint-Tenstorrent-Tensix
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("flint-Tenstorrent-Tensix/bfp4")
model = AutoModelForCausalLM.from_pretrained("flint-Tenstorrent-Tensix/bfp4", dtype="bfloat16", device_map="auto")
messages = [{"role": "user", "content": "What is the capital of France?"}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt",
return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=64)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Use Transformers 5.22.2 or newer for the quickstart.
Pack one matrix:
import json
import torch
import ttnn
from safetensors import safe_open
d = "flint-Tenstorrent-Tensix/bfp4"
name = "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 flint-Tenstorrent-Tensix/bfp4/pack_tensix.py flint-Tenstorrent-Tensix/bfp4
python flint-Tenstorrent-Tensix/bfp4/verify_grid.py flint-Tenstorrent-Tensix/bfp4
Add --device to round-trip the packed values.
Apache 2.0, as the base model (LICENSE). The changes are listed in NOTICE. pack_tensix.py and
verify_grid.py are by Xylolabs under the same license.
Each folder carries its own LICENSE and NOTICE.
Cite RecursiveSI/flint.
Base model
RecursiveSI/flint