bitlinear-pytorch


Namebitlinear-pytorch JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryImplementation of the BitLinear layer from: The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits
upload_time2024-03-19 00:07:54
maintainer
docs_urlNone
author
requires_python
licenseMIT License Copyright (c) 2024 Ingur Veken Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pytorch quantization bitlinear linear layer ternary binary quantized quantized weights
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bitlinear-pytorch

Implementation of the BitLinear layer from: [The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits](https://arxiv.org/abs/2402.17764)

## Install
```bash
pip install bitlinear-pytorch
```

## Usage
```python
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
```bibtex
@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
- [x] Implement base BitLinear layer
- [x] Add example usage
- [x] Setup Github Actions workflow
- [ ] Implement memory efficient weight encoding/decoding
- [ ] Implement Fast Inference (CUDA/CPU/VHDL)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bitlinear-pytorch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pytorch,quantization,bitlinear,linear,layer,ternary,binary,quantized,quantized weights",
    "author": "",
    "author_email": "Ingur Veken <ingurv99@gmail.com>, Niels Rouws <nrouws@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c3/18/8b64cdf794e051b269dc56cee4b0337795dc50882b79d1b804f228ad7538/bitlinear-pytorch-0.4.0.tar.gz",
    "platform": null,
    "description": "# bitlinear-pytorch\n\nImplementation of the BitLinear layer from: [The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits](https://arxiv.org/abs/2402.17764)\n\n## Install\n```bash\npip install bitlinear-pytorch\n```\n\n## Usage\n```python\nimport torch\nfrom bitlinear_pytorch import BitLinear, replace_linear_with_bitlinear\n\nclass TinyMLP(nn.Module):\n    def __init__(self):\n        super(TinyMLP, self).__init__()\n\n        self.layers = nn.Sequential(\n            nn.Linear(784, 256),\n            nn.ReLU(),\n            nn.Linear(256, 128),\n            nn.ReLU(),\n            nn.Linear(128, 10),\n        )\n\n    def forward(self, x):\n        return self.layers(x)\n\nmodel = TinyMLP()\nreplace_linear_with_bitlinear(model)\n\n# or use BitLinear directly\nbitlinear = BitLinear(784, 256)\n```\n\n## License\nMIT\n\n## Citation\n```bibtex\n@misc{ma2024era,\n      title={The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits}, \n      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},\n      year={2024},\n      eprint={2402.17764},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n\n```\n## TODO\n- [x] Implement base BitLinear layer\n- [x] Add example usage\n- [x] Setup Github Actions workflow\n- [ ] Implement memory efficient weight encoding/decoding\n- [ ] Implement Fast Inference (CUDA/CPU/VHDL)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Ingur Veken  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Implementation of the BitLinear layer from: The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits",
    "version": "0.4.0",
    "project_urls": {
        "Homepage": "https://github.com/ingur/bitlinear-pytorch",
        "Issues": "https://github.com/ingur/bitlinear-pytorch/issues"
    },
    "split_keywords": [
        "pytorch",
        "quantization",
        "bitlinear",
        "linear",
        "layer",
        "ternary",
        "binary",
        "quantized",
        "quantized weights"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59896ec86fce92e7cd7066de7baec1623a9ad0ad9c37df0e126c2bb18fb8be87",
                "md5": "77381f0b9ac0e6cc90acc71ec7be2bda",
                "sha256": "fad40ed588eff6c325689fa77f53046e065e53652638ae3fd5a623ff3d215199"
            },
            "downloads": -1,
            "filename": "bitlinear_pytorch-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "77381f0b9ac0e6cc90acc71ec7be2bda",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4957,
            "upload_time": "2024-03-19T00:07:52",
            "upload_time_iso_8601": "2024-03-19T00:07:52.565317Z",
            "url": "https://files.pythonhosted.org/packages/59/89/6ec86fce92e7cd7066de7baec1623a9ad0ad9c37df0e126c2bb18fb8be87/bitlinear_pytorch-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3188b64cdf794e051b269dc56cee4b0337795dc50882b79d1b804f228ad7538",
                "md5": "3b74fc1bc604d85739c5ca73398880a7",
                "sha256": "47c56b4e1d3b832e35689bcc180248f565656ade1e641a1dad6fd598e63df676"
            },
            "downloads": -1,
            "filename": "bitlinear-pytorch-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3b74fc1bc604d85739c5ca73398880a7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4121,
            "upload_time": "2024-03-19T00:07:54",
            "upload_time_iso_8601": "2024-03-19T00:07:54.646996Z",
            "url": "https://files.pythonhosted.org/packages/c3/18/8b64cdf794e051b269dc56cee4b0337795dc50882b79d1b804f228ad7538/bitlinear-pytorch-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-19 00:07:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ingur",
    "github_project": "bitlinear-pytorch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bitlinear-pytorch"
}
        
Elapsed time: 0.21368s