Skip to main content

Implementation of the BitLinear layer from: The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits

Reason this release was yanked:

test

Project description

bitlinear-pytorch

Implementation of the BitLinear layer from: The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits

Install

pip install bitlinear_pytorch

Usage

import torch
from bitlinear_pytorch import BitLinear, replace_linear_with_bitlinear

class TinyMLP(nn.Module):
    def __init__(self):
        super(TinyMLP, self).__init__()

        self.layers = nn.Sequential(
            nn.Linear(784, 256),
            nn.ReLU(),
            nn.Linear(256, 128),
            nn.ReLU(),
            nn.Linear(128, 10),
        )

    def forward(self, x):
        return self.layers(x)

model = TinyMLP()
replace_linear_with_bitlinear(model)

# or use BitLinear directly
bitlinear = BitLinear(784, 256)

License

MIT

Citation

@misc{ma2024era,
      title={The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits}, 
      author={Shuming Ma and Hongyu Wang and Lingxiao Ma and Lei Wang and Wenhui Wang and Shaohan Huang and Li Dong and Ruiping Wang and Jilong Xue and Furu Wei},
      year={2024},
      eprint={2402.17764},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

TODO

  • Implement base BitLinear layer
  • Add example usage
  • Implement memory efficient weight encoding/decoding
  • Implement Fast Inference (CUDA/CPU/VHDL)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitlinear-pytorch-0.0.3.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

bitlinear_pytorch-0.0.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file bitlinear-pytorch-0.0.3.tar.gz.

File metadata

  • Download URL: bitlinear-pytorch-0.0.3.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for bitlinear-pytorch-0.0.3.tar.gz
Algorithm Hash digest
SHA256 508e08c383c9c7996598517b1e35ee61b58213e2111aa7a6d3f3072cc4d340c4
MD5 ed6056225fb50bfd4448e69f0a92bbab
BLAKE2b-256 5c92d796482f1ee809591f9b2e85316783c3381dde7fc1119c45556f6c569ee5

See more details on using hashes here.

File details

Details for the file bitlinear_pytorch-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bitlinear_pytorch-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3066dfc5b247fd7a97a001937bba92e99fe205ab1728b0e405524a935d195550
MD5 91805ecb85d3a8d3e95cde3d342523fe
BLAKE2b-256 ec6617986dbce16319ed725212ce8d8d2a7cc97dca6d11700514eaee487268cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page