SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.17323 · ICLR · 2022

GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers

Elias Frantar, Dan Alistarh, Torsten Hoefler, Saleh Ashkboos

arXiv · PDF · Open in the Atlas

Code that ran

5 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 3 failures of our instrument; 10 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2210.17323.json · badge: /api/ran/2210.17323.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
IST-DASLab/gptq canonical (classifier label)
classifier basis: classifier_2025
1 ran · 2 no recorded run
cornell-zhang/llm-datatypes community
Papers with Code archive
1 ran · 2 no recorded run
huggingface/text-generation-inference community
Papers with Code archive
1 ran · 2 no recorded run
qwopqwop200/GPTQ-for-LLaMa application (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
PanQiWei/AutoGPTQ community
Papers with Code archive
1 ran · 0 no recorded run
ist-daslab/gptq community
Papers with Code archive
0 ran · 1 no recorded run
ecolab-postech/owq community
Papers with Code archive
0 ran · 1 no recorded run
vectorch-ai/scalellm community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
GPTQ Ran
ran on a synthesized input · constructed an object; no result was computed
PanQiWei/AutoGPTQ/auto_gptq/quantization/gptq.py
code served (permissive licence) · get_code("6729f9f2a233d315")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, GPTQ: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import transformers

torch.manual_seed(0)

# Create a minimal layer that GPTQ expects
# GPTQ accesses layer.weight.device and layer.weight.data
layer = nn.Linear(4, 3, bias=False)

# Move to CPU (default, but explicit)
layer = layer.cpu()

# Verify the layer has the required attributes
assert hasattr(layer, 'weight')
assert hasattr(layer.weight, 'device')
assert hasattr(layer.weight, 'data')

ARGS = {
    'layer': layer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type GPTQ — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GPTQ output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Logger Ran
ran on a synthesized input · constructed an object; no result was computed
cornell-zhang/llm-datatypes/neural_compressor/torch/algorithms/weight_only/gptq.py
code served (permissive licence) · get_code("c1a5aa86dbaf659b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Logger: the class was constructed and called, and the call returned an instance of its own class. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import logging
import os

class Logger(object):
    """Logger class."""
    __instance = None

    def __new__(cls):
        """Create a singleton Logger instance."""
        if Logger.__instance is None:
            Logger.__instance = object.__new__(cls)
            Logger.__instance._log()
        return Logger.__instance

    def _log(self):
        """Setup the logger format and handler."""
        LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
        self._logger = logging.getLogger('neural_compressor')
        self._logger.handlers.clear()
        self._logger.setLevel(LOGLEVEL)
        formatter = logging.Formatter('%(asctime)s [%(levelname)s][%(filename)s:%(lineno)d] %(message)s', '%Y-%m-%d %H:%M:%S')
        streamHandler = logging.StreamHandler()
        streamHandler.setFormatter(formatter)
        self._logger.addHandler(streamHandler)
        self._logger.propagate = False

    def get_logger(self):
        """Get the logger."""
        return self._logger


INIT_ARGS = {}

ARGS = {}

METHOD = 'get_logger'

logger_instance = Logger()
result = logger_instance.get_logger()
print(f"Logger retrieved: {result}")
print(f"Logger name: {result.name}")
print(f"Logger level: {result.level}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Logger — the call returned an instance of its own class, which has no array shape; none is stated — the instrument coerces any output to an array; for a Logger output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
get_opt Ran
ran; our contract draft was wrong, not the code
IST-DASLab/gptq/opt.py
code served (permissive licence) · get_code("887f43fe08a6472d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned MockOPTForCausalLM. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# The function expects a model parameter that is a string (model name/path)
# However, since we can't actually download from HuggingFace, we need to mock
# the from_pretrained call. We'll create a minimal mock setup.

class MockConfig:
    def __init__(self):
        self.max_position_embeddings = 2048

class MockOPTForCausalLM(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MockConfig()
        self.linear = nn.Linear(4, 4)
    
    @classmethod
    def from_pretrained(cls, model_name, torch_dtype='auto'):
        return cls()

# Monkey patch the transformers module before the function runs
import sys
from types import ModuleType

mock_transformers = ModuleType('transformers')
mock_transformers.OPTForCausalLM = MockOPTForCausalLM
sys.modules['transformers'] = mock_transformers

# The model parameter should be a string (model identifier)
model_name = "facebook/opt-125m"

ARGS = {
    "model": model_name
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockOPTForCausalLM — a MockOPTForCausalLM output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockOPTForCausalLM output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
torch_snr_error Ran
ran; our contract draft was wrong, not the code
qwopqwop200/GPTQ-for-LLaMa/gptq.py
code served (permissive licence) · get_code("a855208c73825af0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors for y_pred and y_real
# Using batch size 2, flattened dimension 4
y_pred = torch.randn(2, 4, dtype=torch.float32)
y_real = torch.randn(2, 4, dtype=torch.float32)

# Test with different reduction methods
reduction = 'mean'

ARGS = {
    'y_pred': y_pred,
    'y_real': y_real,
    'reduction': reduction
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
torch_snr_error Ran
ran; our contract draft was wrong, not the code
huggingface/text-generation-inference/server/text_generation_server/layers/gptq/quantize.py
code served (permissive licence) · get_code("671302aaa20f0ee9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors for y_pred and y_real
# Batch size 2, flattened dimension 4
y_pred = torch.randn(2, 4)
y_real = torch.randn(2, 4)

# Test with different reduction methods
reduction = 'mean'

ARGS = {
    'y_pred': y_pred,
    'y_real': y_real,
    'reduction': reduction
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
GPTQ Not yet run
unverified (harvested, no recorded run)
qwopqwop200/GPTQ-for-LLaMa/gptq.py
code served (permissive licence) · get_code("6164b2bb82400dba")
How it ran

no invocation recorded.

GPTQ Not yet run
unverified (harvested, no recorded run)
cornell-zhang/llm-datatypes/neural_compressor/torch/algorithms/weight_only/gptq.py
code served (permissive licence) · get_code("f4d20c4a7bccc9a2")
How it ran

no invocation recorded.

GPTQ Not yet run
unverified (harvested, no recorded run)
ist-daslab/gptq/gptq.py
code served (permissive licence) · get_code("cdbcb9ec70b30c58")
How it ran

no invocation recorded.

GPTQ Not yet run
unverified (harvested, no recorded run)
huggingface/text-generation-inference/server/text_generation_server/layers/gptq/quantize.py
code served (permissive licence) · get_code("0747a1d535734929")
How it ran

no invocation recorded.

GPTQ_OWQ Not yet run
unverified (harvested, no recorded run)
ecolab-postech/owq/owq/recon.py
pointer only (licence: NONE) · get_code("c30c4d1c0c0838ff")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ecolab-postech/owq when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Kernel Not yet run
unverified (harvested, no recorded run)
vectorch-ai/scalellm/src/kernels/quantization/marlin/generate_instantiations.py
code served (permissive licence) · get_code("2e160e59dad498ff")
How it ran

no invocation recorded.

Quantizer Not yet run
unverified (harvested, no recorded run)
cornell-zhang/llm-datatypes/neural_compressor/torch/algorithms/weight_only/gptq.py
code served (permissive licence) · get_code("dd6638bb4690fc4c")
How it ran

no invocation recorded.

Quantizer Not yet run
unverified (harvested, no recorded run)
huggingface/text-generation-inference/server/text_generation_server/layers/gptq/quantize.py
code served (permissive licence) · get_code("7452671bd2402cf2")
How it ran

no invocation recorded.

opt_pack3 Not yet run
unverified (harvested, no recorded run)
IST-DASLab/gptq/opt.py
code served (permissive licence) · get_code("5a1ab8a11275fe3d")
How it ran

no invocation recorded.

opt_sequential Not yet run
unverified (harvested, no recorded run)
IST-DASLab/gptq/opt.py
code served (permissive licence) · get_code("60602426146a6763")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 2 later) and 13 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_opt 5 other papers
5 later
2301.00774 (2023-01)
SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot
2307.13304 (2023-07)
QuIP: 2-Bit Quantization of Large Language Models With Guarantees
2406.05981 (2024-06)
ShiftAddLLM: Accelerating Pretrained LLMs via Post-Training Multiplication-Less Reparameterization
and 2 more not named here
opt_pack3 2 other papers
2 later
2406.05981 (2024-06)
ShiftAddLLM: Accelerating Pretrained LLMs via Post-Training Multiplication-Less Reparameterization
2411.05282 (2024-11)
MicroScopiQ: Accelerating Foundational Models through Outlier-Aware Microscaling Quantization

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Generative Pre-trained Transformer models, known as GPT or OPT, set themselves apart through breakthrough performance across complex language modelling tasks, but also by their extremely high computational and storage costs. Specifically, due to their massive size, even inference for large, highly-accurate GPT models may require multiple performant GPUs, which limits the usability of such models. While there is emerging work on relieving this pressure via model compression, the applicability and performance of existing compression techniques is limited by the scale and complexity of GPT models. In this paper, we address this challenge, and propose GPTQ, a new one-shot weight quantization method based on approximate second-order information, that is both highlyaccurate and highly-efficient. Specifically, GPTQ can quantize GPT models with 175 billion parameters in approximately four GPU hours, reducing the bitwidth down to 3 or 4 bits per weight, with negligible accuracy degradation relative to the uncompressed baseline. Our method more than doubles the compression gains relative to previously-proposed one-shot quantization methods, preserving accuracy, allowing us for the first time to execute an 175 billion-parameter model inside a single GPU for generative inference. Moreover, we also show that our method can still provide reasonable accuracy in the extreme quantization regime, in which weights are quantized to 2-bit or even ternary quantization levels. We show experimentally that these improvements can be leveraged for end-to-end inference speedups over FP16, of around 3.25x when using high-end GPUs (NVIDIA A100) and 4.5x when using more cost-effective ones (NVIDIA A6000). The implementation is available at https://github.com/IST-DASLab/gptq.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2210.17323")
get_code_for_paper("2210.17323")
have("2210.17323")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2210.17323.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2210.17323.svg)](https://syntology.ai/paper/2210.17323)

Connect an agent — have() is free.