Mindket

bitnet.cpp

Newversion 2 · updated
Star41.5k

Overview

Microsoft’s official inference framework for 1-bit LLMs, built on llama.cpp. It runs ternary models such as BitNet b1.58 on x86 and ARM CPUs, and has a GPU kernel too. The setup notes cover Windows, Linux, the GPU kernel and the embedding models.

bitnet.cpp is an open-source project on GitHub in the Developer category, listed by Mindket. It is free. This is version 2, last updated on . Install it from GitHub as its README says. Get Mindket’s setup notes on your Mindket account, as a zip.

At a glance

Runs in
  • Windows: Visual Studio 2022 with the clang tools, and a Developer Command Prompt or PowerShell for every command
  • Debian and Ubuntu: clang 18 or newer from the automatic installation script at apt.llvm.org
  • x86 CPUs with AVX2, and ARM CPUs with NEON or the DOTPROD extension
  • NVIDIA GPUs: a separate W2A8 CUDA kernel in the gpu folder, built by a bash script into libbitnet.so, with speeds measured on an A100 40GB
Start with
git clone --recursive https://github.com/microsoft/BitNet.git
cd BitNet
conda create -n bitnet-cpp python=3.10

Platform

WindowsOperating system
LinuxOperating system
macOSOperating system

About

What it is

bitnet.cpp is Microsoft’s official inference framework for 1-bit LLMs such as BitNet b1.58. The README says it offers optimized kernels for fast and lossless inference of 1.58-bit models on CPU and GPU, with NPU support coming next. It is based on llama.cpp, and its kernels build on the lookup table methods of T-MAC. You build it from source, download a model from Hugging Face and run it with Python scripts. The README reports speedups of 1.37x to 5.07x on ARM CPUs and 2.37x to 6.17x on x86 CPUs, against full-precision models.

  1. Clone the repo with its llama.cpp code
  2. Install the Python packages in a conda environment
  3. Download a 1-bit model from Hugging Face
  4. setup_env.py builds the project, with i2_s or tl1
  5. run_inference.py starts a chat or one prompt

Who it suits

Developers and researchers who want to run a small 1-bit model on a laptop or server CPU with no GPU. People who study low-bit inference also get the kernels and a benchmark script. It is a C++ project with Python scripts, so expect a compiler and a build step. Skip it if you want a finished chat app. The README says it uses existing 1-bit models to demonstrate the framework, and the largest model in its table is 10B.

Who uses it, and how
IndustryWho uses itHow they use itExample
Local AIPeople with a laptop and no GPURun the 2B chat model on the CPU with run_inference.pyA reader with an ARM laptop builds the project and chats with BitNet-b1.58-2B-4T in the terminal.
Search and RAGEngineers who embed textRun the 0.6B or 270M embedding model on an x86 CPUA team asks llama-embedding for a 1024-dimensional vector for each search query.
Performance engineeringEngineers who tune kernelsChange the tiling in gemm-config.h and compare runs with e2e_benchmark.pyAn engineer sets the row and column block sizes to fit a CPU’s cache, then reruns the benchmark.
Model researchPeople who work with low-bit modelsConvert a safetensors checkpoint to GGUF and test it on a CPUA researcher downloads the BF16 checkpoint of BitNet-b1.58-2B-4T and converts it with convert-helper-bitnet.py.

Where to use it

bitnet.cpp is a framework you build and run yourself, so this is about systems rather than coding agents. The README documents no coding-agent integration.

  • Windows: Visual Studio 2022 with the clang tools, and a Developer Command Prompt or PowerShell for every command
  • Debian and Ubuntu: clang 18 or newer from the automatic installation script at apt.llvm.org
  • x86 CPUs with AVX2, and ARM CPUs with NEON or the DOTPROD extension
  • NVIDIA GPUs: a separate W2A8 CUDA kernel in the gpu folder, built by a bash script into libbitnet.so, with speeds measured on an A100 40GB
  • Other Linux systems and macOS: the README’s build steps carry no OS label, but its clang install line is for Debian and Ubuntu only. For macOS it shows only a demo of a BitNet b1.58 3B model on an Apple M2

How to set it up

Get it saves a zip of Minda’s setup notes in your downloads folder, with steps for Windows, Linux, the GPU kernel, the embedding models and tuning. They are taken from Microsoft’s README and docs, with Minda’s own notes marked as Minda’s. The main route is a clone, a conda environment, a model download and one build script.

What you need first
NeedDetail
Python3.10 or newer. The README highly recommends a conda environment
CMake3.22 or newer
clang18 or newer. On Windows it comes from Visual Studio 2022 with five options turned on. On Debian or Ubuntu the README gives an installation script
A modelDownloaded from Hugging Face. The README’s first example uses BitNet-b1.58-2B-4T-gguf
For the GPU kernelAn NVIDIA GPU and the CUDA compiler, since the compile script calls nvcc. Neither page lists them
  1. Open a shell that can build. On Windows, a Developer Command Prompt or PowerShell for VS2022. On Linux, a shell where clang 18 or newer works.
  2. Clone the repo with --recursive. Then go into its folder.
  3. Make a Python 3.10 conda environment. Then install requirements.txt.
  4. Download the model with huggingface-cli. Then run setup_env.py to build the project.
  5. Run run_inference.py with the model file.
git clone --recursive https://github.com/microsoft/BitNet.git
cd BitNet
conda create -n bitnet-cpp python=3.10
conda activate bitnet-cpp
pip install -r requirements.txt
huggingface-cli download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir models/BitNet-b1.58-2B-4T
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s

The README does not list huggingface-cli as a requirement or say how to install it.

How to use it

Run the model with run_inference.py. With -cnv it starts a chat, and the text after -p becomes the system prompt.

python run_inference.py -m models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf -p "You are a helpful assistant" -cnv

The other flags the README lists are -n for the number of tokens to predict, -t for threads, -c for the prompt context size and -temp for the temperature. To measure speed, the README ships a benchmark script.

python utils/e2e_benchmark.py -m /path/to/model -n 200 -p 256 -t 4

Example

You want a vector for a search query. The embedding guide has you check out a llama.cpp branch, run setup_env.py with the 0.6B model, and then call llama-embedding:

cd 3rdparty/llama.cpp && git checkout release-bitnet-embedding-0.6b-270m && cd ../..
python setup_env.py -hr microsoft/bitnet-embedding-0.6b -md /path/to/save/model
./build/bin/llama-embedding \
  -m /path/to/save/model/bitnet-embedding-0.6b/ggml-model-i2_s.gguf \
  -p "query: What is BitNet?" \
  --embd-normalize 2 \
  --embd-output-format array

The guide says the result is a 1024-dimensional, L2-normalized embedding, printed as an array that starts [[0.0239517, 0.6826404. The guide’s FAQ says to add an instruction to the query, a one-sentence instruction that describes the task, because that is how the model is trained. Without it you will see a performance degradation. The document side needs no instruction. The guide’s own example passes “query: What is BitNet?”.

For newcomers and experts

If you are new. A language model keeps what it learned in numbers called weights. A 1-bit model such as BitNet b1.58 limits each weight to -1, 0 or +1, a ternary value, which is where the 1.58 bits come from. Small weights make the model smaller and the arithmetic cheaper, so a CPU can run it. bitnet.cpp is the program that runs such models. The embedding guide says its I2_S conversion needs natively trained BitNet models with ternary weights. Its F16 conversion does not. Start with BitNet-b1.58-2B-4T, the model the README builds first.

For experts. The README’s table marks which of three kernels, I2_S, TL1 and TL2, work for each model on x86 and on ARM. I2_S stores ternary weights in 2 bits. The embedding guide packs every 128 values into 32 bytes, four values to a byte, and appends a float32 scale to the buffer. The README’s 15 January 2026 CPU update adds weight-parallel and activation-parallel kernels, native I2_S GEMM and GEMV in ggml, tiling set in include/gemm-config.h, and Q6_K embedding quantization. The CPU page recommends activation parallel for I2_S, and the current kernel defaults to it.

The usage text offers only i2_s and tl1 as --quant-type values, so the README does not say how to choose TL2. It also says bitnet.cpp can run a 100B BitNet b1.58 model on one CPU at 5 to 7 tokens per second, yet no model that size is in its table. Check what that claim rests on before you plan around it.

Good to know

Most of it runs on your machine, and a few paths reach out.

  • What it fetches: git clone --recursive pulls llama.cpp code from a fork that .gitmodules names, pip installs packages, and the model comes from Hugging Face. On Debian or Ubuntu the clang line downloads a script from apt.llvm.org and runs it at once
  • Models: the framework is separate from its models, and each model has its own Hugging Face page. The embedding guide gives MIT for its models, so check the page of any other model you download
  • The maker’s own caution: under Use in High-Risk Applications, the embedding guide says its models are not recommended for commercial or real-world applications without further testing and development
  • Usage data: the README and the docs say nothing about telemetry
  • Windows traps: every command needs the Developer shell, and the README prints the two PowerShell commands of its clang fix on one line. Minda’s Windows notes split them onto two lines
  • The GPU kernel: its page is tailored to BitNet-b1.58-2B-4T, and its compile script builds for compute_80
  • A mismatch in the docs: the README’s usage text calls --quant-embd a conversion to f16, and the CPU page says it converts embeddings to Q6_K
  • Removal: the README gives no uninstall steps. Minda’s notes say to delete the clone and its model folder and to remove the conda environment
  • License: MIT. The LICENSE file reads “Copyright (c) Microsoft Corporation.”

README and files

README

bitnet.cpp: setup notes

This kit holds setup notes only. Mindket wrote them. bitnet.cpp is built and run from Microsoft's repository: https://github.com/microsoft/BitNet

These notes are not made or endorsed by Microsoft. The README calls bitnet.cpp "the official inference framework for 1-bit LLMs (e.g., BitNet b1.58)". It "offers a suite of optimized kernels that support fast and lossless inference of 1.58-bit models on CPU and GPU (NPU support coming next)."

License: MIT. The LICENSE file (https://github.com/microsoft/BitNet/blob/main/LICENSE) is the MIT License and reads "Copyright (c) Microsoft Corporation." The README says the project is based on the llama.cpp framework, and that its kernels build on the Lookup Table methods of T-MAC (https://github.com/microsoft/T-MAC/).

What you get

  • A clone of the repository. The README clones with --recursive, which also fetches the llama.cpp code under 3rdparty/llama.cpp. The repository's .gitmodules file names a llama.cpp fork on GitHub as the source (https://github.com/isHuangXin/llama.cpp.git). Sources: https://github.com/microsoft/BitNet/blob/main/README.md and https://github.com/microsoft/BitNet/blob/main/.gitmodules
  • The Python packages in requirements.txt, which pulls in llama.cpp's own requirement files for its conversion scripts.
  • A build of the project, made by setup_env.py, and a model you download separately. The README's examples put the model in models/, inside the clone. The CPU optimization page and the embedding guide run the built tools from build/bin/.
  • Scripts to run the model, run_inference.py, and to measure speed, utils/e2e_benchmark.py.

bitnet.cpp is the framework. The models are separate downloads from Hugging Face. The README says it uses existing 1-bit models to show what bitnet.cpp can do, and hopes the release will inspire 1-bit LLMs at larger scale in model size and training tokens.

What you need first

  • Python 3.10 or newer, CMake 3.22 or newer and clang 18 or newer. The README highly recommends conda. Source: https://github.com/microsoft/BitNet/blob/main/README.md
  • On Windows, Visual Studio 2022 with five options turned on, and a Developer Command Prompt or PowerShell for VS2022 for every command. See setup/windows.md.
  • On Debian or Ubuntu, the README gives an automatic installation script for clang. See setup/linux.md.
  • For the GPU kernel, a CUDA setup: its compile script calls nvcc. See setup/gpu.md.
  • A model from Hugging Face. The README does not state a disk or memory need.

Main commands

Run them in a shell where clang works. Every command is copied from the README, Installation, Build from source and Usage: https://github.com/microsoft/BitNet/blob/main/README.md

git clone --recursive https://github.com/microsoft/BitNet.git
cd BitNet
conda create -n bitnet-cpp python=3.10
conda activate bitnet-cpp

pip install -r requirements.txt
huggingface-cli download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir models/BitNet-b1.58-2B-4T
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s
python run_inference.py -m models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf -p "You are a helpful assistant" -cnv

The README does not list huggingface-cli as a requirement or say how to install it.

Per-platform notes

  • setup/windows.md: Visual Studio 2022, the Developer shell, and the two FAQ fixes
  • setup/linux.md: Debian and Ubuntu clang, and what the README says about other systems
  • setup/gpu.md: the W2A8 GPU kernel and its end-to-end run
  • setup/models-and-kernels.md: which models run on x86 and on ARM, and the options of setup_env.py and run_inference.py
  • setup/embeddings.md: the 0.6B and 270M embedding models, their I2_S conversion and a first embedding
  • setup/tune-and-benchmark.md: the CPU tuning file, embedding quantization and the benchmark script

Update or remove

The README and the docs give no update or uninstall steps. To take it out (Mindket's note, not Microsoft's), delete the clone and its model folder, and remove the conda environment with conda's own remove command.

Usage data and outbound connections

The README and the docs say nothing about telemetry or usage data. Nothing in them says the program connects to a server while it runs a model. These steps do reach out: git clone --recursive, the Hugging Face download, the pip installs, and on Debian or Ubuntu the clang script from apt.llvm.org. The online demo linked from the README is a separate hosted page and is not part of the install.

Sources

Files
README.md  5 KB
setup/embeddings.md  4 KB
setup/gpu.md  3 KB
setup/linux.md  2 KB
setup/models-and-kernels.md  5 KB
setup/tune-and-benchmark.md  4 KB
setup/windows.md  3 KB

7 files, 28 KB, downloaded as a zip.

What’s new

  • Version 2 · 2026-11-09

    Updated by Mindket to the current version of this kit.

  • Version 1 · 2026-11-03

Reviews

No ratings yet

Write a review

No reviews yet.

What people say

Posts and comments that name this project on Hacker News, Bluesky, X, Reddit, Facebook and YouTube, found by a weekly search and on Trendshift. Mindket doesn’t write or check them. Open one to read it where it was posted.

galeosMicrosoft BitNet: inference framework for 1-bit LLMs173 points · 33 repliesHackobar5. Coding Agents Increase Code Volume but Not Software Output LINK 6. Microsoft releases BitNet inference framework for 1-bit LLMs LINK1 reply@AndyBuildsAIBig AI on cheap hardware, free? BitNet shrinks weights to -1/0/+1 to run fast on a CPU. AirLLM fits a 70B model in ~4GB GPU, but it's slow. Which would you try? #AI https://t.co/ywZCzq58rxr/BestGitHubReposBitNet: Official inference framework for 1-bit LLMs (40.7k stars)dhilipsivaShow HN: A Zero-Copy 1.58-bit LLM Engine hitting 117 Tokens/s on single CPU coreThe Project: I am building R3-Engine, a from-scratch, local AI inference engine for Microsoft's bitnet-b1.58-2B-4T. It is written in 100% Safe Rust, natively cross-compiles to Wasm SIMD128, and uses Zero heap allocations in the execution loop. The Physics: By mapping a 64-byte aligned .r3 file…4 points@sm14yu.bsky.socialMicrosoft released BitNet embedding models using 1.58-bit ternary weights. The 600M version reaches 67.60 benchmark score vs 67.95 for its FP16 teacher, with up to 2.28× CPU throughput.@laogeai想本地跑大模型,一看显存就劝退?不一定得买显卡 💪 Petals 多机拼集群、微软 BitNet 1 比特量化 CPU 能推、Dolly 拿来学流程正好。 https://t.co/QwWYJ6xeTcFlere-ImsahoMicrosoft BitNet – inference with 1.58 bits2 points · 1 replyMarc ON4AAX #HAMR #DX #ax25 #MultiLingual #TheOutpost #TSF 📻🎙️📡github.com/microsoft/Bi...@Samir_Magdiii3 GitHub repos trending hard right now: 1-bit LLM inference, live satellite intel in your browser, and free web eyes for your AI agent. Swipe 👇 Links in reply. #AI #GitHub https://t.co/fTHFAL176jufos1111Running Microsoft's BitNet via Electron, React and Astro1 point · 1 reply@sm14yu.bsky.socialMicrosoft open-sourced BitNet, a C++ inference framework for 1-bit LLMs. It runs up to 100B-parameter models on consumer CPUs with reported 6x speedups and 82% lower energy use, supporting local offline chat and RAG without GPUs.

Searched

More from Mindket

See all from Mindket

Bonsai-27B-GGUF

lmstudio-community · Kit

A GGUF conversion of the 27B Bonsai model for LM Studio, with a 3.80 GB Q1_0 language file and a 0.93 GB BF16 vision projector. Tested for text, vision and par…

New

Runs DeepSeek-V4.1-Flash-1017 as a 2.9 bits-per-weight EXL3 quantization, a 196 GiB copy for people serving large models on their own hardware. Perplexity stay…

New

MusicGen Small

facebook · Kit

Generates short music clips from a text description or an audio prompt, in the small checkpoint of facebook's MusicGen. It suits developers and music hobbyists…

New

Similar in Developer

See all in Developer

Lexnet

alpindale · Kit

Tags every character of C source code for syntax highlighting with a tiny neural network of about 984 weights, run through a small C program. For developers an…

New

FLUX.2 Klein LoRA Studio

prithivMLmods · Kit

Try a set of LoRAs for the FLUX.2 Klein image model in a Gradio app that runs in your browser or on your own computer. Made for people who make or test AI imag…

New

anaksor-ocr

Sokheng · Kit

Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…

New