{"id":34042855,"url":"https://github.com/aovoc/nnieqat-pytorch","last_synced_at":"2026-04-07T11:31:56.170Z","repository":{"id":56472962,"uuid":"287927898","full_name":"aovoc/nnieqat-pytorch","owner":"aovoc","description":"A nnie quantization aware training tool on pytorch.","archived":false,"fork":false,"pushed_at":"2020-12-10T16:16:19.000Z","size":425,"stargazers_count":238,"open_issues_count":7,"forks_count":38,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-03T08:07:24.639Z","etag":null,"topics":["nnie","nnieqat-pytorch","pytorch","quantized-training"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aovoc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-16T11:11:33.000Z","updated_at":"2025-09-10T21:11:40.000Z","dependencies_parsed_at":"2022-08-15T19:20:54.291Z","dependency_job_id":null,"html_url":"https://github.com/aovoc/nnieqat-pytorch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/aovoc/nnieqat-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aovoc%2Fnnieqat-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aovoc%2Fnnieqat-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aovoc%2Fnnieqat-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aovoc%2Fnnieqat-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aovoc","download_url":"https://codeload.github.com/aovoc/nnieqat-pytorch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aovoc%2Fnnieqat-pytorch/sbom","scorecard":{"id":201178,"data":{"date":"2025-08-11","repo":{"name":"github.com/aovoc/nnieqat-pytorch","commit":"91410cf331a120d9a1df1b435a14d30f10743541"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":4,"reason":"binaries present in source code","details":["Warn: binary detected: nnieqat/cuda10/lib/gfpq.dll:1","Warn: binary detected: nnieqat/cuda10/lib/gfpq.lib:1","Warn: binary detected: nnieqat/cuda10/lib/libgfpq.a:1","Warn: binary detected: nnieqat/cuda10/lib/libgfpq.so.1.1.5:1","Warn: binary detected: nnieqat/cuda10/lib/libgfpq_gpu.a:1","Warn: binary detected: nnieqat/cuda10/lib/libgfpq_gpu.so.1.1.5:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: docker/Dockerfile:5","Warn: pipCommand not pinned by hash: docker/Dockerfile:16","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T22:52:39.283Z","repository_id":56472962,"created_at":"2025-08-16T22:52:39.283Z","updated_at":"2025-08-16T22:52:39.283Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31511585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nnie","nnieqat-pytorch","pytorch","quantized-training"],"created_at":"2025-12-13T22:47:25.041Z","updated_at":"2026-04-07T11:31:56.144Z","avatar_url":"https://github.com/aovoc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nnieqat-pytorch\n\nNnieqat is a quantize aware training package for  Neural Network Inference Engine(NNIE) on pytorch, it uses hisilicon quantization library to quantize module's weight and activation as fake fp32 format.\n\n\n## Table of Contents\n\n- [nnieqat-pytorch](#nnieqat-pytorch)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [Code Examples](#code-examples)\n  - [Results](#results)\n  - [Todo](#todo)\n  - [Reference](#reference)\n\n\n\u003cdiv id=\"installation\"\u003e\u003c/div\u003e  \n\n## Installation\n\n* Supported Platforms: Linux\n* Accelerators and GPUs: NVIDIA GPUs via CUDA driver ***10.1*** or ***10.2***.\n* Dependencies:\n  * python \u003e= 3.5, \u003c 4\n  * llvmlite \u003e= 0.31.0\n  * pytorch \u003e= 1.5\n  * numba \u003e= 0.42.0\n  * numpy \u003e= 1.18.1\n* Install nnieqat via pypi:  \n  ```shell\n  $ pip install nnieqat\n  ```\n\n* Install nnieqat in docker(easy way to solve environment problems)：\n  ```shell\n  $ cd docker\n  $ docker build -t nnieqat-image .\n\n  ```\n* Install nnieqat via repo：\n  ```shell\n  $ git clone https://github.com/aovoc/nnieqat-pytorch\n  $ cd nnieqat-pytorch\n  $ make install\n  ```\n\n\u003cdiv id=\"usage\"\u003e\u003c/div\u003e\n\n## Usage\n\n* add quantization hook.\n\n  quantize and dequantize weight and data with HiSVP GFPQ library in forward() process.\n\n  ```python\n\n  from nnieqat import quant_dequant_weight, unquant_weight, merge_freeze_bn, register_quantization_hook\n  ...\n  ...\n    register_quantization_hook(model)\n  ...\n  ```\n\n* merge bn weight into conv and freeze bn\n\n  suggest finetuning from a well-trained model, merge_freeze_bn at beginning. do it after a few epochs of training otherwise.\n\n  ```python\n  from nnieqat import quant_dequant_weight, unquant_weight, merge_freeze_bn, register_quantization_hook\n  ...\n  ...\n      model.train()\n      model = merge_freeze_bn(model)  #it will change bn to eval() mode during training\n  ...\n  ```\n\n* Unquantize weight before update it\n\n  ```python\n  from nnieqat import quant_dequant_weight, unquant_weight, merge_freeze_bn, register_quantization_hook\n  ...\n  ...\n      model.apply(unquant_weight)  # using original weight while updating\n      optimizer.step()\n  ...\n  ```\n\n* Dump weight optimized model\n\n  ```python\n  from nnieqat import quant_dequant_weight, unquant_weight, merge_freeze_bn, register_quantization_hook\n  ...\n  ...\n      model.apply(quant_dequant_weight)\n      save_checkpoint(...)\n      model.apply(unquant_weight)\n  ...\n  ```\n\n* Using EMA with caution(Not recommended).\n\n\u003cdiv id=\"examples\"\u003e\u003c/div\u003e\n\n## Code Examples\n\n* [Cifar10 quantization aware training example][cifar10_qat]  (add nnieqat into [pytorch_cifar10_tutorial][cifar10_example])\n\n  ```python test/test_cifar10.py```\n\n* [ImageNet quantization finetuning example][imagenet_qat]  (add nnieqat into [pytorh_imagenet_main.py][imagenet_example])\n\n  ```python test/test_imagenet.py  --pretrained  path_to_imagenet_dataset```\n\n\u003cdiv id=\"results\"\u003e\u003c/div\u003e\n\n## Results  \n\n* ImageNet\n\n  ```\n  python test/test_imagenet.py /data/imgnet/ --arch squeezenet1_1  --lr 0.001 --pretrained --epoch 10   # nnie_lr_e-3_ft\n  python pytorh_imagenet_main.py /data/imgnet/ --arch squeezenet1_1  --lr 0.0001 --pretrained --epoch 10  # lr_e-4_ft\n  python test/test_imagenet.py /data/imgnet/ --arch squeezenet1_1  --lr 0.0001 --pretrained --epoch 10  # nnie_lr_e-4_ft\n  ```\n\n  finetune result：\n\n    |     | trt_fp32 | trt_int8     | nnie     |\n    | -------- |  -------- | -------- | -------- |\n    | torchvision     | 0.56992  | 0.56424  | 0.56026 |\n    | nnie_lr_e-3_ft | 0.56600   | 0.56328   | 0.56612 |\n    | lr_e-4_ft  | 0.57884   | 0.57502   | 0.57542 |\n    | nnie_lr_e-4_ft | 0.57834   | 0.57524   | 0.57730 |  \n\n\n* coco\n\nnet: simplified  yolov5s\n\ntrain 300 epoches, hi3559 test result:   \n\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.338   \n Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.540   \n Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.357   \n Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.187   \n Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.377   \n Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.445   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.284   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.484   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.542   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.357   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.595   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.679   \n\n\nfinetune 20 epoches, hi3559 test result:   \n\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.339   \n Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.539   \n Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.360   \n Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.191   \n Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.378   \n Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.446   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.285   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.485   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.544   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.361   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.596   \n Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.683   \n\n\n\n\u003cdiv id=\"Todo\"\u003e\u003c/div\u003e\n\n## Todo\n\n* Generate quantized model directly.\n\n\u003cdiv id=\"reference\"\u003e\u003c/div\u003e  \n\n## Reference\n\nHiSVP 量化库使用指南\n\n[Quantizing deep convolutional networks for efficient inference: A whitepaper][quant_whitepaper]\n\n[8-bit Inference with TensorRT][trt_quant]\n\n[Distilling the Knowledge in a Neural Network][distillingNN]\n\n[cifar10_qat]: https://github.com/aovoc/nnieqat-pytorch/blob/master/test/test_cifar10.py\n\n[imagenet_qat]: https://github.com/aovoc/nnieqat-pytorch/blob/master/test/test_imagenet.py\n\n[imagenet_example]: https://github.com/pytorch/examples/blob/master/imagenet/main.py\n\n[cifar10_example]: https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html\n\n[quant_whitepaper]: https://arxiv.org/abs/1806.08342\n\n[trt_quant]: https://on-demand.gputechconf.com/gtc/2017/presentation/s7310-8-bit-inference-with-tensorrt.pdf\n\n[distillingNN]: https://arxiv.org/abs/1503.02531\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faovoc%2Fnnieqat-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faovoc%2Fnnieqat-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faovoc%2Fnnieqat-pytorch/lists"}