bitlinear-pytorch


Namebitlinear-pytorch JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryImplementation of the BitLinear layer from: The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits
upload_time2024-09-11 15:26:31
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
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 bitlinear bitnet quantization 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
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
```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": null,
    "name": "bitlinear-pytorch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "pytorch, bitlinear, bitnet, quantization, linear, layer, ternary, binary, quantized, quantized weights",
    "author": null,
    "author_email": "Ingur Veken <ingurv99@gmail.com>, Niels Rouws <nrouws@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/47/e5/12fd3eb835590a012e24a63d3ba6a6631d5190ef7a48ca48367a33ebdccf/bitlinear_pytorch-0.5.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\nfrom torch import nn\nfrom bitlinear_pytorch import BitLinear\n\nclass TinyMLP(nn.Module):\n    def __init__(self):\n        super(TinyMLP, self).__init__()\n\n        self.layers = nn.Sequential(\n            nn.LayerNorm(784),\n            BitLinear(784, 256),\n            nn.ReLU(),\n            nn.LayerNorm(256),\n            BitLinear(256, 128),\n            nn.ReLU(),\n            nn.LayerNorm(128),\n            BitLinear(128, 10),\n        )\n\n    def forward(self, x):\n        return self.layers(x)\n\nmodel = TinyMLP()\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.5.0",
    "project_urls": {
        "Homepage": "https://github.com/ingur/bitlinear-pytorch",
        "Issues": "https://github.com/ingur/bitlinear-pytorch/issues"
    },
    "split_keywords": [
        "pytorch",
        " bitlinear",
        " bitnet",
        " quantization",
        " linear",
        " layer",
        " ternary",
        " binary",
        " quantized",
        " quantized weights"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa642ac51ec07cca314ee5b648052e214dc5d4a37fcb3b5e82d2c1e41ca4b528",
                "md5": "71ecae14352c7cad6a75a979bbfff82f",
                "sha256": "63c98d49e597ecf13ed5cdc7f764a0a7329bc0007fdf61bb9cac38c78a6103d8"
            },
            "downloads": -1,
            "filename": "bitlinear_pytorch-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71ecae14352c7cad6a75a979bbfff82f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4450,
            "upload_time": "2024-09-11T15:26:30",
            "upload_time_iso_8601": "2024-09-11T15:26:30.389492Z",
            "url": "https://files.pythonhosted.org/packages/aa/64/2ac51ec07cca314ee5b648052e214dc5d4a37fcb3b5e82d2c1e41ca4b528/bitlinear_pytorch-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47e512fd3eb835590a012e24a63d3ba6a6631d5190ef7a48ca48367a33ebdccf",
                "md5": "85f263d3a4b71a3862625957a8306f71",
                "sha256": "b1a851fd0e2d5fe81664522bbca28add20f9528cfb7ab46ac7528f5f63f5ac73"
            },
            "downloads": -1,
            "filename": "bitlinear_pytorch-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "85f263d3a4b71a3862625957a8306f71",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3664,
            "upload_time": "2024-09-11T15:26:31",
            "upload_time_iso_8601": "2024-09-11T15:26:31.225749Z",
            "url": "https://files.pythonhosted.org/packages/47/e5/12fd3eb835590a012e24a63d3ba6a6631d5190ef7a48ca48367a33ebdccf/bitlinear_pytorch-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-11 15:26:31",
    "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.32420s