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

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
  • Setup Github Actions workflow
  • 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.1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

bitlinear_pytorch-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bitlinear-pytorch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c84528e55dbfc1d58e3d04cea605c18f0d94570fb8fc1f9ca0fbccb97eaf5cb7
MD5 424cf317aa861389e542a3ed313ff31c
BLAKE2b-256 ca64ae28c47a0fc75a2a669fe5ef88503e1c71f3f4efbccadb7db759e15caa26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitlinear_pytorch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f943bb68bd968f2b785530f5982b1f144cc1e66184c26be2233b7bb4b1b3db2
MD5 b3a41afe82f83efe81a432abbd448c0f
BLAKE2b-256 0e846853bd7b76d3e3fd63639bcdc9d7b6c2cf5335903ee605bba9ead81b55fc

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