{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/aphq-vit-post-training-quantization-with","title":"APHQ-ViT: Post-Training Quantization with Average Perturbation Hessian Based Reconstruction for Vision Transformers","arxiv_id":"2504.02508","date":"2025-04-03","proceeding":"CVPR 2025 1","authors":["Zhuguanyu Wu","Jiayi Zhang","Jiaxin Chen","Jinyang Guo","Di Huang","Yunhong Wang"],"abstract":"Vision Transformers (ViTs) have become one of the most commonly used backbones for vision tasks. Despite their remarkable performance, they often suffer significant accuracy drops when quantized for practical deployment, particularly by post-training quantization (PTQ) under ultra-low bits. Recently, reconstruction-based PTQ methods have shown promising performance in quantizing Convolutional Neural Networks (CNNs). However, they fail when applied to ViTs, primarily due to the inaccurate estimation of output importance and the substantial accuracy degradation in quantizing post-GELU activations. To address these issues, we propose \\textbf{APHQ-ViT}, a novel PTQ approach based on importance estimation with Average Perturbation Hessian (APH). Specifically, we first thoroughly analyze the current approximation approaches with Hessian loss, and propose an improved average perturbation Hessian loss. To deal with the quantization of the post-GELU activations, we design an MLP Reconstruction (MR) method by replacing the GELU function in MLP with ReLU and reconstructing it by the APH loss on a small unlabeled calibration set. Extensive experiments demonstrate that APHQ-ViT using linear quantizers outperforms existing PTQ methods by substantial margins in 3-bit and 4-bit across different vision tasks. The source code is available at https://github.com/GoatWu/APHQ-ViT.","url_abs":"https://arxiv.org/abs/2504.02508v1","url_pdf":"https://arxiv.org/pdf/2504.02508v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"aphq-vit-post-training-quantization-with","repo_url":"https://github.com/GoatWu/APHQ-ViT","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"quantization","task_name":"Quantization"}],"methods":[{"method_slug":"relu","method_name":"ReLU"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2504.02508","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2504.02508"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/GoatWu/APHQ-ViT","reach":null}],"summary":{"ran":1,"ran_fixture":2,"ran_draft_wrong":1,"unverified":5},"by_repo_kind":{"official":{"samples":9,"ran":4,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"fa84db46289995ad","entry":"LossFunction","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fa84db46289995ad"}},{"code_sha256_prefix":"4c0321fd4f221905","entry":"patch_embed_forward","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4c0321fd4f221905"}},{"code_sha256_prefix":"c3aa10aca8e3d4f2","entry":"swin_patchmerging_forward","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c3aa10aca8e3d4f2"}},{"code_sha256_prefix":"0afb8b4e757385ce","entry":"vit_block_forward","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0afb8b4e757385ce"}},{"code_sha256_prefix":"e57b20bac95de843","entry":"AdaRoundQuantizer","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e57b20bac95de843"}},{"code_sha256_prefix":"a69a114345a6be8b","entry":"BlockReconstructor","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a69a114345a6be8b"}},{"code_sha256_prefix":"14974a54218e1889","entry":"QuantCalibrator","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"14974a54218e1889"}},{"code_sha256_prefix":"40e2f2d6bcc163d9","entry":"UniformQuantizer","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"40e2f2d6bcc163d9"}},{"code_sha256_prefix":"44a6dd7e559c25bb","entry":"swin_block_forward","repo":"GoatWu/APHQ-ViT","repo_kind":"official","path":"utils/block_recon.py","file_url":"https://github.com/GoatWu/APHQ-ViT/blob/HEAD/utils/block_recon.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"44a6dd7e559c25bb"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}