{"id":17486231,"url":"https://github.com/phrb/haq-autotuning-experiments","last_synced_at":"2025-09-23T22:00:01.451Z","repository":{"id":72626058,"uuid":"265892842","full_name":"phrb/haq-autotuning-experiments","owner":"phrb","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-07T23:51:09.000Z","size":51059,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T14:43:31.966Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phrb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-21T16:05:19.000Z","updated_at":"2020-12-07T23:51:12.000Z","dependencies_parsed_at":"2023-03-01T16:15:39.492Z","dependency_job_id":null,"html_url":"https://github.com/phrb/haq-autotuning-experiments","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phrb/haq-autotuning-experiments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrb%2Fhaq-autotuning-experiments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrb%2Fhaq-autotuning-experiments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrb%2Fhaq-autotuning-experiments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrb%2Fhaq-autotuning-experiments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phrb","download_url":"https://codeload.github.com/phrb/haq-autotuning-experiments/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrb%2Fhaq-autotuning-experiments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276655558,"owners_count":25680942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-23T02:00:09.130Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-19T02:09:55.523Z","updated_at":"2025-09-23T22:00:01.442Z","avatar_url":"https://github.com/phrb.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# HAQ: Hardware-Aware Automated Quantization with Mixed Precision\n\n## Introduction\n\nThis repo contains PyTorch implementation for paper [HAQ: Hardware-Aware Automated Quantization with Mixed Precision](http://openaccess.thecvf.com/content_CVPR_2019/papers/Wang_HAQ_Hardware-Aware_Automated_Quantization_With_Mixed_Precision_CVPR_2019_paper.pdf) (CVPR2019, oral)\n\n![overview](https://hanlab.mit.edu/projects/haq/images/overview.png)\n\n```\n@inproceedings{haq,\nauthor = {Wang, Kuan and Liu, Zhijian and Lin, Yujun and Lin, Ji and Han, Song},\ntitle = {HAQ: Hardware-Aware Automated Quantization With Mixed Precision},\nbooktitle = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},\nyear = {2019}\n}\n```\n\nOther papers related to automated model design:\n- AMC: AutoML for Model Compression and Acceleration on Mobile Devices ([ECCV 2018](https://arxiv.org/abs/1802.03494))\n\n- ProxylessNAS: Direct Neural Architecture Search on Target Task and Hardware ([ICLR 2019](https://arxiv.org/abs/1812.00332))\n\n## Dependencies\nWe evaluate this code with Pytorch 1.1 (cuda10) and torchvision 0.3.0, you can install pytorch with conda:\n```\n# install pytorch\nconda install -y pytorch torchvision cudatoolkit=10.0 -c pytorch\n```\nAnd you can use the following command to set up the environment:\n```\n# install packages\nbash run/setup.sh\n```\nCurrent code base is tested under following environment:\n1. Python         3.7.3\n2. PyTorch        1.1\n3. torchvision    0.3.0\n4. numpy          1.14\n5. matplotlib     3.0.1\n6. scikit-learn   0.21.0\n7. easydict       1.8\n8. progress       1.4\n9. tensorboardX   1.7\n\n## Dataset\nIf you already have the ImageNet dataset for pytorch, you could create a link to data folder and use it:\n```\n# prepare dataset, change the path to your own\nln -s /path/to/imagenet/ data/\n```\nIf you do not have the ImageNet yet, you can download the ImageNet dataset and move validation images to labeled subfolders. To do this, you can use the following script: \n[https://raw.githubusercontent.com/soumith/imagenetloader.torch/master/valprep.sh](https://raw.githubusercontent.com/soumith/imagenetloader.torch/master/valprep.sh)\n\n\n## Reinforcement learning search\n- You can run the bash file as following to search the quantization strategy for specific model.\n```\nbash run/run_search.sh\n```\n- Usage details\n```\npython rl_quantize.py --help\n```\n\n## Finetune Policy\n- After searching, you can get the quantization strategy list, and you can replace the strategy list in **finetune.py** to finetune and evaluate the performance on ImageNet dataset.\n- We set the default quantization strategy searched under preserve ratio = 0.1 like:\n```\n# preserve ratio 10%\nstrategy = [6, 6, 5, 5, 5, 5, 4, 5, 5, 4, 5, 5, 5, 5, 5, 5, 3, 5, 4, 3, 5, 4, 3, 4, 4, 4, 2, 5, 4, 3, 3, 5, 3, 2, 5, 3, 2, 4, 3, 2, 5, 3, 2, 5, 3, 4, 2, 5, 2, 3, 4, 2, 3, 4]\n```\nYou can follow the following bash file to finetune the quantized model to get a better performance:\n```\nbash run/run_finetune.sh\n```\n- Usage details\n```\npython finetune.py --help\n```\n## Evaluate\nYou can download the pretrained quantized model and evaluate it.\n```\n# download checkpoint\nmkdir -p checkpoints/resnet50/\ncd checkpoints/resnet50/\nwget https://hanlab.mit.edu/files/haq/resnet50_0.1_75.48.pth.tar\ncd ../..\n# evaluate \nbash run/run_eval.sh\n```\n\n| Models                   | preserve ratio | Top1 Acc (%) | Top5 Acc (%) |\n| ------------------------ | -------------- | ------------ | ------------ |\n| resnet50 (original)    |       1.0      |     76.15    |    92.87     |\n| resnet50 (10x compress)|       0.1      |     75.48    |    92.42     |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphrb%2Fhaq-autotuning-experiments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphrb%2Fhaq-autotuning-experiments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphrb%2Fhaq-autotuning-experiments/lists"}