bitlinear
This project aims to provide a production-ready implementation of 1.58-bit layers for quantization-aware training and time-, memory-, and energy-efficient inference. It builds on the ideas from The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits.
installation
Installation from PyPI:
pip install bitlinear
Installation from source:
git clone https://github.com/schneiderkamplab/bitlinear
cd bitlinear
pip install .
usage
The usage is best explained by a short example:
from bitlinear import replace_modules
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("HuggingFaceM4/tiny-random-LlamaForCausalLM")
replace_modules(model)
More elaborate examples are available under examples/classifier, including training and evaluating a binary classifer:
pip install -r examples/classifier/requirements.txt
python examples/classifier/train.py
python examples/classifier/eval.py
There is also an MNIST classifier:
pip install -r examples/classifier/requirements.txt
python examples/mnist/train.py
comparison to other work
There are other implementations of bit-linear layers, most of which get at least some of the details wrong at the time of this writing (April 2024).
The focus of this implementation is to develop:
- a flexible production-ready drop-in replacemenbt for torch.nn.LinearLayer,
- efficient fused kernels for training, and
- efficient fused kernels for inference with 2-bit weights and 8-bit activations.
Furthermore, this implementation is meant to serve as a testbed for research on low-bit quantization aware training and inference.
future work
- further examples (vision, llm)
- efficient fused kernels for GPU/AVX/CPU training
- efficient fused kernels for GPU/AVX/CPU inferenc
Metadata
Release files for bitlinear 2.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bitlinear-2.4.6.tar.gz | 10.8 kB | Without provenance | Details for bitlinear-2.4.6.tar.gz |
Release files / bitlinear-2.4.6.tar.gz
| Download URL | bitlinear-2.4.6.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18ddff7b31df619edabefd172197bcc6467741bdd2d81362d1996bb05b5ca0aa
|
|
BLAKE2b-256 checksum How to use checksums |
9dee4a068f7302f9a14994bcfcd2d569ed9b19eabba0f8a867316d415aebfcbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for bitlinear 2.4.6
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.