From HuggingFace to TPU binary, via MLIR
TPU-MLIR lowers pre-trained networks from mainstream frameworks into `bmodel` files that execute on Sophgo TPUs.

What it does
TPU-MLIR is an open-source machine-learning compiler built on MLIR that ingests models from PyTorch, ONNX, TensorFlow Lite, Caffe, and HuggingFace. It passes them through a unified intermediate representation—split into Top and Tpu dialects—before emitting bmodel binaries tuned for Sophgo’s BM1684X, BM1688, and CV186AH chips. The toolchain includes quantization, calibration, accuracy validation, and layer-group memory planning.
The interesting bit
TPU-MLIR exposes its lowering pipeline through clean MLIR dialects—Top and Tpu—with pattern rewrites and layer-group memory planning. It also treats LLMs as first-class citizens, offering llm_convert.py to ingest pre-quantized HuggingFace models in one shot.
Key highlights
- Multi-framework front ends: PyTorch, ONNX, TFLite, Caffe, and HuggingFace (other frameworks via ONNX).
- Full quantization toolchain supporting F32, BF16, F16, and INT8, plus passthrough for AWQ, GPTQ, and AutoRound weights.
- Distinct
TopandTpuMLIR dialects with pattern rewrites and layer-group memory planning. - Production tooling including a simulator, visualizer,
model_runner, andmodel_tool. - Bilingual documentation and community resources in English and Chinese.
Caveats
- Output is strictly locked to Sophgo chips (BM1684X, BM1688, CV186AH); it will not target GPUs or other TPUs.
- The development workflow is tightly coupled to a prebuilt Docker image, and the documentation steers you heavily toward using it.
- LLM conversion can hit version mismatches with
transformersortorch, requiring manual dependency upgrades.
Verdict Worth a look if you are deploying vision or language models on Sophgo hardware and want an inspectable compiler stack. Everyone else—especially those on generic GPUs or Google TPUs—can safely skip it.
Frequently asked
- What is sophgo/tpu-mlir?
- TPU-MLIR lowers pre-trained networks from mainstream frameworks into `bmodel` files that execute on Sophgo TPUs.
- Is tpu-mlir open source?
- Yes — sophgo/tpu-mlir is an open-source project tracked on heatdrop.
- What language is tpu-mlir written in?
- sophgo/tpu-mlir is primarily written in C++.
- How popular is tpu-mlir?
- sophgo/tpu-mlir has 950 stars on GitHub.
- Where can I find tpu-mlir?
- sophgo/tpu-mlir is on GitHub at https://github.com/sophgo/tpu-mlir.