BitNet is a high-performance inference framework for 1-bit large language models, specifically the BitNet b1.58 ternary architecture. It provides CPU (x86 with AVX2, ARM with NEON) and GPU (NVIDIA CUDA) backends with custom quantization formats (I2_S, TL1, TL2) that pack ternary weights and use efficient look-up tables and integer matrix multiplication (int8Γint2) to achieve significant speedups over full-precision models (1.37β6.17Γ on CPU). The system is built on a fork of llama.cpp, adding custom GEMM kernels and a Python utility suite for model conversion, embedding quantization, benchmark, and deployment. It includes a CLI interactive mode and an HTTP server for production serving. The repository contains extensive performance benchmarks and configuration tools, making it a production-ready solution for deploying 1-bit LLMs on commodity hardware.
BitNet is a PyTorch library implementing the BitNet architecture for 1-bit transformers, as described in the paper "BitNet: Scaling 1-bit Transformers for Large Language Models". The library provides drop-in replacements for standard linear layers with BitLinear layers that use quantized weights and activations to enable efficient computation. It includes components such as BitMGQA (Multi-Grouped Query Attention), BitFeedForward, and full transformer models (BitNetTransformer), as well as adapters for other architectures like Mamba and Mixture of Experts. The library also offers utilities to convert existing Hugging Face or PyTorch models to use BitLinear layers and includes an optimized CUDA kernel for low-precision GEMM operations to accelerate inference. The architecture is modular, with the core BitLinear layer encapsulated in `bitnet/bitlinear.py`, which can be used independently. Higher-level components like attention and feed-forward networks are built using BitLinear and are designed to be reusable in other projects. The library supports training and inference workflows, as demonstrated by the provided example scripts and training routine for the enwik8 dataset. With active maintenance and a focus on performance through CUDA optimization, BitNet serves as a specialized tool for researchers and practitioners interested in extremely low-precision deep learning models.