HGQ2: High Granularity Quantization 2
=============================================
[](https://www.gnu.org/licenses/lgpl-3.0.en.html)
[](https://calad0i.github.io/HGQ2/)
This is a refactored version of the [HGQ](https://github.com/calad0i/HGQ) library: a quantization-aware training framework targeting realtime deep learning applications. Besides all the features provided by the original HGQ library, this version includes the following improvements:
- **Scalability**: HGQ2 is built on Keras v3 with all layers with proper supports for all backends: TensorFlow, JAX, and PyTorch. As XLA compilation is also supported, which can significantly speed up the training process. Besides GPU acceleration, HGQ2 also supports TPU acceleration for TensorFlow and JAX backends. Training speed on HGQ2 can be 1.2-5 times faster than the original HGQ library, depending on the model and the backend.
- **Flexibility**: Effective Bit-Operations (EBOP) based resource estimation can now be turned off, and cross layer talking is fully eliminated by moving the datalane quantizer location. This allows the user to mix HGQ2 layers with vanilla Keras layers without any restrictions. (Use with caution though, if you want to put the final model on hardware!)
- **Quantizers**:
- _Fixed-point_: While the original HGQ library only optimizes the number of floating bits with one way of parameterizing the fixed-point numbers, HGQ2 supports multiple ways of parametrizing them, and allows of optimizing any part of them via gradients.
- _Minifloat_: Training with minifloat quantization is supported, also with surrogate gradients support (alpha quality).
- **More Layers**: HGQ2 supports more layers than the original HGQ library, including the powerful `EinsumDense(BatchNorm)` layer and the `MultiHeadAttention` layer with bit-accurate softmax and scaled dot-product attention (alpha quality).
## Installation
```bash
pip install HGQ2
```
If you are using `hls4ml`, please make sure it is at least version 1.2:
```bash
pip install hls4ml>=1.2.0
```
If you are using `da4ml`, please make sure it is at least version 0.3:
```bash
pip install da4ml>=0.3
```
## Usage
Please refer to the [documentation](https://calad0i.github.io/HGQ2/) for more details on how to use the library.
Raw data
{
"_id": null,
"home_page": null,
"name": "hgq2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "hls4ml, keras, qkeras, quantization",
"author": null,
"author_email": "Chang Sun <chsun@cern.ch>",
"download_url": "https://files.pythonhosted.org/packages/cb/9b/0aaae2b039156affd663a7829ae53e4520af27bc18ca3827cd3a4be64c8d/hgq2-0.1.1.tar.gz",
"platform": null,
"description": "HGQ2: High Granularity Quantization 2\n=============================================\n\n[](https://www.gnu.org/licenses/lgpl-3.0.en.html)\n[](https://calad0i.github.io/HGQ2/)\n\nThis is a refactored version of the [HGQ](https://github.com/calad0i/HGQ) library: a quantization-aware training framework targeting realtime deep learning applications. Besides all the features provided by the original HGQ library, this version includes the following improvements:\n\n- **Scalability**: HGQ2 is built on Keras v3 with all layers with proper supports for all backends: TensorFlow, JAX, and PyTorch. As XLA compilation is also supported, which can significantly speed up the training process. Besides GPU acceleration, HGQ2 also supports TPU acceleration for TensorFlow and JAX backends. Training speed on HGQ2 can be 1.2-5 times faster than the original HGQ library, depending on the model and the backend.\n- **Flexibility**: Effective Bit-Operations (EBOP) based resource estimation can now be turned off, and cross layer talking is fully eliminated by moving the datalane quantizer location. This allows the user to mix HGQ2 layers with vanilla Keras layers without any restrictions. (Use with caution though, if you want to put the final model on hardware!)\n- **Quantizers**:\n - _Fixed-point_: While the original HGQ library only optimizes the number of floating bits with one way of parameterizing the fixed-point numbers, HGQ2 supports multiple ways of parametrizing them, and allows of optimizing any part of them via gradients.\n - _Minifloat_: Training with minifloat quantization is supported, also with surrogate gradients support (alpha quality).\n\n- **More Layers**: HGQ2 supports more layers than the original HGQ library, including the powerful `EinsumDense(BatchNorm)` layer and the `MultiHeadAttention` layer with bit-accurate softmax and scaled dot-product attention (alpha quality).\n\n\n## Installation\n\n```bash\npip install HGQ2\n```\n\nIf you are using `hls4ml`, please make sure it is at least version 1.2:\n\n```bash\npip install hls4ml>=1.2.0\n```\n\nIf you are using `da4ml`, please make sure it is at least version 0.3:\n\n```bash\npip install da4ml>=0.3\n```\n\n## Usage\n\nPlease refer to the [documentation](https://calad0i.github.io/HGQ2/) for more details on how to use the library.\n",
"bugtrack_url": null,
"license": "GNU Lesser General Public License v3 (LGPLv3)",
"summary": "High Granularity Quantization 2",
"version": "0.1.1",
"project_urls": {
"repository": "https://github.com/calad0i/HGQ2"
},
"split_keywords": [
"hls4ml",
" keras",
" qkeras",
" quantization"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c90f583fc9420d4af2c143ab9109face5c886ede598348f0a766bd14bb985238",
"md5": "8781c21121d3fb4561ade503aa8626c6",
"sha256": "94c4c44fa315fd32fade104fb971866ba8f7c33655632b3bd9b2cc40f51db59f"
},
"downloads": -1,
"filename": "hgq2-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8781c21121d3fb4561ade503aa8626c6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 68441,
"upload_time": "2025-09-01T00:37:20",
"upload_time_iso_8601": "2025-09-01T00:37:20.224126Z",
"url": "https://files.pythonhosted.org/packages/c9/0f/583fc9420d4af2c143ab9109face5c886ede598348f0a766bd14bb985238/hgq2-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cb9b0aaae2b039156affd663a7829ae53e4520af27bc18ca3827cd3a4be64c8d",
"md5": "8107a79167e38ff72e281d20710758e4",
"sha256": "a248fc77e137e8012965f9514e8d82a25f9e3500c364db897ccb6ace0d58cc54"
},
"downloads": -1,
"filename": "hgq2-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "8107a79167e38ff72e281d20710758e4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 163948,
"upload_time": "2025-09-01T00:37:21",
"upload_time_iso_8601": "2025-09-01T00:37:21.665246Z",
"url": "https://files.pythonhosted.org/packages/cb/9b/0aaae2b039156affd663a7829ae53e4520af27bc18ca3827cd3a4be64c8d/hgq2-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-01 00:37:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "calad0i",
"github_project": "HGQ2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hgq2"
}