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

Linux wheels. This release ships two Linux x86_64 wheels: a native one (manylinux_2_39) with the OpenMP-parallel kernels, and a portable one (manylinux_2_17, single-threaded) for older distributions. pip picks the best one for the host automatically. If neither matches your glibc, install from the sdist (it compiles csrc with the local toolchain via build_linux.sh).

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: gfx101X, 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
CDNA: gfx908, gfx90a
RDNA: gfx101X, 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.dev4

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.dev4

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

Source distribution (sdist)

Source distribution for bitsandbytes-cpu-fork 0.50.2.dev4
File Size Uploaded Provenance Actions
bitsandbytes_cpu_fork-0.50.2.dev4.tar.gz 841.8 kB Without provenance Details for bitsandbytes_cpu_fork-0.50.2.dev4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for bitsandbytes-cpu-fork 0.50.2.dev4
File Interpreter ABI Platform Actions
bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-win_amd64.whl
bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux_2_39_x86_64.whl Python 3 none Linux glibc 2.39+ x86-64 Details for bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux_2_39_x86_64.whl
bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 6.4 MB

Release files / bitsandbytes_cpu_fork-0.50.2.dev4.tar.gz

Download URL bitsandbytes_cpu_fork-0.50.2.dev4.tar.gz
Size 841.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7a364da2ccd5ec81e5ee4d30520c4e2ea5d99a2f4fa902b58bdd3266bb60234f
BLAKE2b-256 checksum
How to use checksums
19465601900b3cbe977d5baf329bf071d63edbf5da35e00ac3bcbc829a087bf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.3

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

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

Release files / bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux_2_39_x86_64.whl

Download URL bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux_2_39_x86_64.whl
Size 2.3 MB
Tags Linux glibc 2.39+ x86-64 Python 3
SHA-256 checksum
How to use checksums
07d09ebd63bcf276246d7cda231f44fa6dad61155febe4979a6ae734db555e20
BLAKE2b-256 checksum
How to use checksums
6f10de82c855c70d6f6bf19eae5c5417b22e6245d9638bfaaf567cf8601b13b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.3

Release files / bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL bitsandbytes_cpu_fork-0.50.2.dev4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.9 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
70585c7a56e2bd453ff3084fce9ca3031e9c5db1a308db3e1b3f7edfd997609e
BLAKE2b-256 checksum
How to use checksums
984b1b35c095b875030c49d215a8b8b4c2fe21d2394a26a999b7abe6a6fb0315
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.dev4

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