Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

This is the CPU fork — bitsandbytes-cpu-fork, not upstream bitsandbytes. It replaces the CUDA kernels with a pure-CPU backend (AVX2 on x86-64, NEON on ARM64): 8-bit optimizers, fused Gated DeltaNet, gemm_8bit, block-wise 4/8-bit quantisation. No GPU, no CUDA toolkit, no NVIDIA driver. Full guide: docs_cpu/QUICKSTART.md (中文) · docs_cpu/QUICKSTART_EN.md.

Install

torch is deliberately not a dependency. On PyPI the name torch resolves to the CUDA build, so declaring it made this CPU-only library download roughly 2.5 GB of nvidia-* wheels — cublas, cudnn, nccl, nvshmem and thirteen more — onto machines with no NVIDIA device at all. Measured on a clean Ubuntu install. install_requires cannot express "the CPU build", because that lives on a different index, so install it first:

pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install bitsandbytes-cpu-fork

Windows

A wheel is published with the CPU library already built in, so no compiler and no Visual C++ Redistributable are needed:

pip install bitsandbytes-cpu-fork

Linux

Only the source distribution is published. pip builds it, and setup.py runs build_linux.sh for you, so the library is compiled against your own glibc rather than shipped prebuilt. That needs a C++ compiler with OpenMP:

sudo apt install g++ libomp-dev        # Debian / Ubuntu
sudo dnf install gcc-c++ libomp-devel  # Fedora / RHEL
sudo pacman -S gcc openmp              # Arch

If the toolchain is missing the build stops and names that command, rather than producing a wheel that installs cleanly and then fails at import bitsandbytes.

To build by hand instead, or to check the kernels without torch:

bash build_linux.sh --selftest

Verify the install

python -m bitsandbytes

Then ask it what it can do

pip installs a bitsandbytes-cpu command (also available as bnb-cpu). It is the reference for this fork: what the hardware is, whether the kernels load, and how to call every feature it adds — each entry carries the exact call, and every Python example in it is executed before release.

bitsandbytes-cpu detect          # CPU model, cores, SIMD, RAM, recommended thread count
bitsandbytes-cpu selftest        # runs a 4-bit layer, an 8-bit optimizer step, the GDN kernel
bitsandbytes-cpu help            # the whole reference
bitsandbytes-cpu help 8bitopt    # one section: the 8-bit optimizer
bitsandbytes-cpu help 4bit       # one section: 4-bit layers on a CPU
bitsandbytes-cpu help kernels    # one section: the fused kernels, called directly
bitsandbytes-cpu doctor          # which .dll/.so will load, and which symbols it has

Section keys: intro start 4bit qlora 8bitopt kernels toolkit threads memory gdn disks layers optim functional notes. The same tables are published as docs_cpu/API_REFERENCE.md (English).


bitsandbytes

License Downloads Nightly Unit Tests GitHub Release PyPI - Python Version

bitsandbytes enables accessible large language models via k-bit quantization for PyTorch. We provide three main features for dramatically reducing memory consumption for inference and training:

  • 8-bit optimizers uses block-wise quantization to maintain 32-bit performance at a small fraction of the memory cost.
  • LLM.int8() or 8-bit quantization enables large language model inference with only half the required memory and without any performance degradation. This method is based on vector-wise quantization to quantize most features to 8-bits and separately treating outliers with 16-bit matrix multiplication.
  • QLoRA or 4-bit quantization enables large language model training with several memory-saving techniques that don't compromise performance. This method quantizes a model to 4-bits and inserts a small set of trainable low-rank adaptation (LoRA) weights to allow training.

The library includes quantization primitives for 8-bit & 4-bit operations, through bitsandbytes.nn.Linear8bitLt and bitsandbytes.nn.Linear4bit and 8-bit optimizers through bitsandbytes.optim module.

System Requirements

bitsandbytes has the following minimum requirements for all platforms:

  • Python 3.10+
  • PyTorch 2.4+
    • Note: While we aim to provide wide backwards compatibility, we recommend using the latest version of PyTorch for the best experience.

Accelerator support:

Note: this table reflects the status of the current development branch. For the latest stable release, see the document in the 0.50.0 tag.

Legend:

🚧 = Planned | 〰️ = Partially Supported | ✅ = Supported | ❌ = Not Supported

Platform Accelerator Hardware Requirements LLM.int8() QLoRA 4-bit 8-bit Optimizers
🐧 Linux, glibc >= 2.24
x86-64 ◻️ CPU Minimum: AVX2
Optimized: AVX512F, AVX512BF16
✅ ✅ ✅
🟩 NVIDIA GPU
cuda
SM60+ minimum
SM75+ recommended
✅ ✅ ✅
🟥 AMD GPU
cuda
CDNA: gfx908, gfx90a, gfx942, gfx950, gfx1250
RDNA: gfx103X, gfx110X, gfx115X, gfx120X
✅ ✅ ✅
🟦 Intel GPU
xpu
Data Center GPU Max Series
Arc A-Series (Alchemist)
Arc B-Series (Battlemage)
✅ ✅ ✅
🟪 Intel Gaudi
hpu
Gaudi2, Gaudi3 ✅ 〰️ ❌
aarch64 ◻️ CPU ✅ * ✅ ✅
🟩 NVIDIA GPU
cuda
SM75+ ✅ ✅ ✅
🪟 Windows 11 / Windows Server 2022+
x86-64 ◻️ CPU AVX2 ✅ ✅ ✅
🟩 NVIDIA GPU
cuda
SM60+ minimum
SM75+ recommended
✅ ✅ ✅
🟥 AMD GPU
cuda
RDNA: gfx103X, gfx110X, gfx115X, gfx120X ✅ ✅ ✅
🟦 Intel GPU
xpu
Arc A-Series (Alchemist)
Arc B-Series (Battlemage)
✅ ✅ ✅
arm64 ◻️ CPU ✅ ✅ ✅
🟩 NVIDIA GPU
cuda
SM121 ✅ ✅ ✅
🍎 macOS 14+
arm64 ◻️ CPU Apple M1+ ✅ * ✅ ✅
⬜ Metal
mps
Apple M1+ ✅ * ✅ 🚧
* While supported, these marked features may lack in performance optimizations.

📖 Documentation

💻 CPU Backend Extensions (this fork)

This fork adds training-grade CPU kernels to the bitsandbytes CPU backend, for machines without NVIDIA GPUs (AVX2 only / ARM64 NEON, e.g. consumer laptops, Mini-PCs). The upstream CPU backend is inference-oriented; these extensions make pure-CPU LoRA / quantization / diffusion training practical.

Install (Windows, no compiler needed)

pip install bitsandbytes-cpu-fork

The wheel bundles the prebuilt CPU kernel and its OpenMP runtime, so nothing has to be built after installing; pip pulls torch and numpy itself. One wheel covers every Python 3 version on 64-bit Windows. The import name is unchanged, so existing code and the Transformers / PEFT / Diffusers integrations keep working as-is:

import bitsandbytes as bnb          # the fork, not upstream
print(bnb.__version__)              # 0.50.2.dev1

Building from source instead (any platform) is described in docs_cpu/QUICKSTART.md §2 and §2A.

📚 Docs (docs_cpu/):

  • TECHNICAL_GUIDE.md — 技术文档:改了什么、每个内核的架构与细节(面向技术人员)
  • QUICKSTART.md — 快速入门手册:命令、用途与参数(面向首次使用者)
  • TECH_REPORT.md — 技术报告:完整方法论、实验数据与结论(含负面结论)
  • 灾难恢复指南已并入 QUICKSTART.md §9。
  • 🌐 English: 英文为独立文件 —— QUICKSTART_EN.md、TECHNICAL_GUIDE_EN.md、 TECH_REPORT_EN.md(内容与中文版对应,以中文为准;灾难恢复同样在 QUICKSTART_EN.md §9)。

🌐 English README: see README_EN.md.

关于硬盘均衡负载:它能在内存紧张时帮助维持训练,但不能替代 Windows 虚拟内存。 训练期间仍建议保留至少 1GB 虚拟内存以应对突发内存峰值。

What's added

Kernel Entry point Purpose
Gated DeltaNet fwd/bwd gdn_fwd_cpu / gdn_bwd_cpu (csrc/cpu_gdn.cpp) Fused Gated DeltaNet (Qwen3-Next/3.5 linear attention) — ~35× vs per-step Python loop; chunk-checkpointed backward
Fused 8-bit blockwise dequant GEMM cgemm_8bit_inference_cpu_fp32 (bitsandbytes::gemm_8bit, bnb.functional.fused_dequant_linear_8bit) out = A @ dequant8(B) with weights kept uint8 (¼ DRAM traffic), no fp32 temporary
Fused 8-bit optimizer coptimizer_update_8bit_blockwise_cpu (bnb.optim.AdamW8bit etc.) Single-pass dequant→update→requant; optimizer state memory ≈ 1/3.8 of fp32
Blockwise 8/4-bit quant & dequant cquantize_blockwise_cpu_* / cdequantize_blockwise_cpu_* AVX2 LUT quantize + dequantize; NF4/FP4 kernels with NEON/AVX2 paths
4-bit inference GEMV cgemv_4bit_inference_cpu_* Fused 4-bit dequant GEMV/GEMM for AVX2 machines (symbol alias fixed)
GDN runtime patch bitsandbytes/gdn_cpu.py patch_transformers() / patch_fla() — route transformers GDN slow paths to the fused kernel
iGPU (DirectML) block-level executor gpu_scheduler.py (IgpuExecutor, train.py --igpu) Experimental: frozen weights resident on the DirectML iGPU, forward/backward on-device, one sync per step; off by default — measured +30~35% for GEMM-dense seq≤256 training, negative at long sequences (driver limits)

Build

# Linux (x86_64 AVX2 or aarch64 NEON, g++/clang + OpenMP)
# deps: sudo apt install g++ libomp-dev   (Debian/Ubuntu)
bash build_linux.sh            # -> bitsandbytes/libbitsandbytes_cpu.so
bash build_linux.sh --selftest # also build+run torch-free C self-test

# Windows (MSVC, manual cl build, no CMake)
build_manual\build_manual.bat amd   # (in VS x64 Native Tools prompt)

.gitattributes 强制 C/C++ 源码与构建脚本用 LF 换行,clone 到 Windows/Linux 均可 直接编译(CRLF 会让 MSVC 吞行、Linux g++ 报 bad interpreter)。 disk_balancer(--flash)跨平台:Windows 用 ctypes,Linux/WSL 用 psutil。

Prebuilt wheels (optional)

预编译的 wheel(pip install bitsandbytes-<ver>-py3-none-<platform>.whl)可从 Release 获取,无需自己编译(Windows win_amd64 / Linux linux_x86_64 / aarch64 linux_aarch64)。wheel 内含 bitsandbytes/ 包 + 编译好的 native 库 (.dll/.so),安装即用。

Self-test (no torch required)

# C-level kernel self-test: quantize roundtrip / gemm_8bit / 4bit GEMV / 8bit optimizer
bash build_linux.sh --selftest

Notes

  • This fork is based on bitsandbytes v0.45.1 (MIT, Facebook) and keeps the upstream MIT license. See NOTICE.md for contributions.
  • The CPU backend keeps the upstream NEON/AVX paths for plain quant/dequant; the fused training kernels (GDN, gemm_8bit, 8-bit optimizer) are the addition of this fork.
  • Not recommended for use without the compiled native library — build first (Windows: build_manual\build_manual.bat amd, Linux: build_linux.sh).

❤️ Sponsors

The continued maintenance and development of bitsandbytes is made possible thanks to the generous support of our sponsors. Their contributions help ensure that we can keep improving the project and delivering valuable updates to the community.

Hugging Face

License

bitsandbytes is MIT licensed.

How to cite us

If you found this library useful, please consider citing our work:

QLoRA

@article{dettmers2023qlora,
  title={Qlora: Efficient finetuning of quantized llms},
  author={Dettmers, Tim and Pagnoni, Artidoro and Holtzman, Ari and Zettlemoyer, Luke},
  journal={arXiv preprint arXiv:2305.14314},
  year={2023}
}

LLM.int8()

@article{dettmers2022llmint8,
  title={LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale},
  author={Dettmers, Tim and Lewis, Mike and Belkada, Younes and Zettlemoyer, Luke},
  journal={arXiv preprint arXiv:2208.07339},
  year={2022}
}

8-bit Optimizers

@article{dettmers2022optimizers,
  title={8-bit Optimizers via Block-wise Quantization},
  author={Dettmers, Tim and Lewis, Mike and Shleifer, Sam and Zettlemoyer, Luke},
  journal={9th International Conference on Learning Representations, ICLR},
  year={2022}
}

Metadata

Release files for bitsandbytes-cpu-fork 0.50.2.dev2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for bitsandbytes-cpu-fork 0.50.2.dev2
File Interpreter ABI Platform Actions
bitsandbytes_cpu_fork-0.50.2.dev2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for bitsandbytes_cpu_fork-0.50.2.dev2-py3-none-win_amd64.whl

Release files / bitsandbytes_cpu_fork-0.50.2.dev2-py3-none-win_amd64.whl

Download URL bitsandbytes_cpu_fork-0.50.2.dev2-py3-none-win_amd64.whl
Size 460.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
8e3368805beb2164858dcbc815de6f1472613a5ad68665906810405b610d918d
BLAKE2b-256 checksum
How to use checksums
4c19b338e9443ec2abe6f2352221e04d6f285ec7ccff8deff546a09d90f97902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.3

Security for bitsandbytes-cpu-fork 0.50.2.dev2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page