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

from torch import nn
from bitlinear_pytorch import BitLinear

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

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

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

model = TinyMLP()

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.5.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

bitlinear_pytorch-0.5.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file bitlinear_pytorch-0.5.0.tar.gz.

File metadata

  • Download URL: bitlinear_pytorch-0.5.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for bitlinear_pytorch-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b1a851fd0e2d5fe81664522bbca28add20f9528cfb7ab46ac7528f5f63f5ac73
MD5 85f263d3a4b71a3862625957a8306f71
BLAKE2b-256 47e512fd3eb835590a012e24a63d3ba6a6631d5190ef7a48ca48367a33ebdccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitlinear_pytorch-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63c98d49e597ecf13ed5cdc7f764a0a7329bc0007fdf61bb9cac38c78a6103d8
MD5 71ecae14352c7cad6a75a979bbfff82f
BLAKE2b-256 aa642ac51ec07cca314ee5b648052e214dc5d4a37fcb3b5e82d2c1e41ca4b528

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