Papers › AffineQuant: Affine Transformation Quantization for Large Language Models

AffineQuant: Affine Transformation Quantization for Large Language Models

19 Mar 2024arXiv:2403.12544archive 2025-07-28

Yuexiao Ma, Huixia Li, Xiawu Zheng, Feng Ling, Xuefeng Xiao, Rui Wang, Shilei Wen, Fei Chao, Rongrong Ji

The significant resource requirements associated with Large-scale Language Models (LLMs) have generated considerable interest in the development of techniques aimed at compressing and accelerating neural networks. Among these techniques, Post-Training Quantization (PTQ) has emerged as a subject of considerable interest due to its noteworthy compression efficiency and cost-effectiveness in the context of training. Existing PTQ methods for LLMs limit the optimization scope to scaling transformations between pre- and post-quantization weights. In this paper, we advocate for the direct optimization using equivalent Affine transformations in PTQ (AffineQuant). This approach extends the optimization scope and thus significantly minimizing quantization errors. Additionally, by employing the corresponding inverse matrix, we can ensure equivalence between the pre- and post-quantization outputs of PTQ, thereby maintaining its efficiency and generalization capabilities. To ensure the invertibility of the transformation during optimization, we further introduce a gradual mask optimization method. This method initially focuses on optimizing the diagonal elements and gradually extends to the other elements. Such an approach aligns with the Levy-Desplanques theorem, theoretically ensuring invertibility of the transformation. As a result, significant performance improvements are evident across different LLMs on diverse datasets. To illustrate, we attain a C4 perplexity of 15.76 (2.26 lower vs 18.02 in OmniQuant) on the LLaMA2-7B model of W4A4 quantization without overhead. On zero-shot tasks, AffineQuant achieves an average of 58.61 accuracy (1.98 lower vs 56.63 in OmniQuant) when using 4/4-bit quantization for LLaMA-30B, which setting a new state-of-the-art benchmark for PTQ in LLMs.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 15 code samples harvested from 1 repository linked to this paper: 9 ran (of which 0 constructed an object rather than computing a result; 4 with no instrument failure: 1 honoured, 0 violated, 3 with no contract checked; 5 where Syntology's instrument failed) · 6 unverified. Where Syntology's instrument failed: 5 where our contract draft was wrong; failures of Syntology's instrument, not of the code.

By repository: official repository: 15 samples from 1 repository, 9 ran (4 with no instrument failure; 5 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written between 2026-09-22 and 2026-09-26 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed.

bytedance/affinequant officialmentioned in papermentioned on GitHubpytorchApache-2.0Syntology: 15 samples, 9 ran (5 instrument-failed) · 6 unverified report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

15 samples harvested: 9 ran (of which 0 constructed an object rather than computing a result; 4 with no instrument failure: 1 honoured, 0 violated, 3 with no contract checked; 5 where Syntology's instrument failed) · 6 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · honoured contract
5ran · our draft was wrong
3ran
6unverified

Licence: 7 of the 15 samples are pointer only, meaning Syntology does not serve that copy's text. For 7 of them, this paper's copy is under a permissive licence and cleared, but the stored copy of the same code that Syntology serves is not; the licence label's tooltip gives Syntology's recorded reason. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from bytedance/affinequant. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: 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. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity.

bytedance/affinequant official repository 15 samples, 9 ran (5 instrument-failed) · 6 unverified
ampscaler_get_grad_norm in 7 papers utils.py ran · honoured contract Apache-2.0 (permissive) · 4ac3f836e543e81c · report fixture: signature parameters:list/1/Tensor, norm_type:float/0/float · returned Tensor · level recorded 2026-09-24
create_logger in 172 papers utils.py ran · our draft was wrong Apache-2.0 (permissive) here; the stored copy is pointer only · 87877d0c60858bff · report fixture: signature output_dir:str/0/str, dist_rank:int/0/int, name:str/0/str · returned Logger · level recorded 2026-09-26
find_layers in 68 papers models/models_utils.py ran Apache-2.0 (permissive) here; the stored copy is pointer only · 904cd61df2fe8fb9 · report fixture: signature module:callable/0/?, layers:list/1/callable, name:str/0/str · returned dict · level recorded 2026-09-24
get_act_scales in 9 papers generate_act_scale_shift.py ran Apache-2.0 (permissive) · bd1c7aaaa05aeaf3 · report fixture: signature model:callable/0/?, dataloader:list/1/tuple, num_samples:int/0/int · returned dict · level recorded 2026-09-24
get_act_shifts generate_act_scale_shift.py ran Apache-2.0 (permissive) · 550d556e74fb20f7 · report fixture: signature model:callable/0/?, dataloader:list/1/tuple, num_samples:int/0/int · returned dict · level recorded 2026-09-24
make_disjoint_window in 11 papers models/models_utils.py ran · our draft was wrong Apache-2.0 (permissive) · 4df9168e0a0c38eb · report fixture: signature pair:tuple/1/list · returned tuple · level recorded 2026-09-22
sort_layers_by_params in 7 papers parallel_utils.py ran · our draft was wrong Apache-2.0 (permissive) here; the stored copy is pointer only · aaa7723c864e0a5e · report fixture: signature layers:list/1/callable · returned list · level recorded 2026-09-24
truncate_number in 11 papers models/transformation.py ran · our draft was wrong fingerprinted Apache-2.0 (permissive) here; the stored copy is pointer only · 94587954e392b665 · report fixture: signature number:Tensor/2/float, threshold:float/0/float · returned Tensor · level recorded 2026-09-22
truncate_number in 11 papers models/models_utils.py ran · our draft was wrong fingerprinted Apache-2.0 (permissive) here; the stored copy is pointer only · 4e53fbbdfa160f7d · report fixture: signature number:Tensor/2/float, threshold:float/0/float · returned Tensor · level recorded 2026-09-24
assign_layers_to_gpus in 7 papers parallel_utils.py unverified Apache-2.0 (permissive) here; the stored copy is pointer only · 7e3ef1ed347af0f3 · report
build_model_and_tokenizer in 5 papers generate_act_scale_shift.py unverified Apache-2.0 (permissive) · a041d7c9b413c995 · report
get_lowest_occupied_gpu in 7 papers parallel_utils.py unverified Apache-2.0 (permissive) here; the stored copy is pointer only · 3c6439a3c61dd2bb · report
get_pile in 9 papers datautils.py unverified Apache-2.0 (permissive) · fe6f95071099234c · report
get_ptb in 43 papers datautils.py unverified Apache-2.0 (permissive) · bd4f416e271c2fb5 · report
get_wikitext2 in 78 papers datautils.py unverified Apache-2.0 (permissive) · 406294899f965c2f · report

Tasks

Quantization

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections