baretile is a userspace driver, runtime and tensor compiler for Tenstorrent Blackhole.
It doesn't need a kernel driver or any Tenstorrent libraries. baretile talks to the card through its PCIe BAR, loads its own firmware onto the Tensix cores and compiles tensor code into Tensix instructions. The compiler was written from the ISA docs.
Code is on GitHub.
from baretile import pci
from baretile.chip import Chip
from baretile.runtime import Runtime
from baretile.tensor import Tensor
chip = Chip(pci.open_device()) # the card, or ttsim if TTSIM is set
rt = Runtime(chip) # loads firmware onto every Tensix core
x = Tensor.of(rt, [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
w = Tensor.of(rt, [[0.5, -1.0], [2.0, 0.25], [-1.0, 1.0]])
# nothing runs until you read the result, then it's one fused kernel
print((x @ w).relu().softmax(-1).tolist())
You need Python, clang, lld, and ttsim built for Blackhole. The tests also need numpy.
If TTSIM isn't set, baretile looks for a real card on the PCI bus and you'll need to be root for that.
export TTSIM=/path/to/libttsim.so
python3 -m baretile.hello # every worker core computes fib(30)
python3 -m pytest test # the tests, on the simulator
python3 models/llama.py SmolLM-135M "The meaning of life is" 6
python3 models/serve.py SmolLM-135M 8000
GPT-2 and the Llama family run. That includes Llama 3.1, Mistral, Qwen2 and Qwen3, MoE models (Mixtral, Qwen2-MoE, Qwen3-MoE, gpt-oss), and Qwen3.5 and 3.6. Every model is checked against the same model in numpy. Weights can be bf16, bfp8 or bfp4.
models/serve.py is an OpenAI server for them. tinygrad also runs on baretile as a device so PyTorch works too through tinygrad's frontend.
For how any of it works, read NOTES.md. It covers where each fact about the chip comes from, how to bring up a card and what is still unknown.