SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper · CVPR · 2023

PD-Quant: Post-Training Quantization Based on Prediction Difference Metric

Wenyu Liu, Xinggang Wang, Dawei Yang, Zhihang Yuan, Jiawei Liu, Lin Niu

Open in the Atlas

Code that ran

8 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 2 violated it and 1 has no contract verdict; 4 failures of our instrument; 3 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-24; 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/Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper.json · badge: /api/ran/Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper.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
hustvl/PD-Quant canonical (classifier label)
classifier basis: census
8 ran · 3 no recorded run
FunctionStatusWhere it lives
round_ste Ran
ran; our contract draft was wrong, not the code
hustvl/PD-Quant/quant/quant_layer.py
code served (permissive licence) · get_code("675da8641c602b03")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-05T00:12:31Z). 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)

# The function takes a single parameter: x, which is a torch.Tensor
# It performs rounding with straight-through estimator
# We need a tensor with some values that will be rounded

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hustvl/PD-Quant/main_imagenet.py
code served (permissive licence) · get_code("b0f936d4d6ae3b8c")
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 list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 output tensor: batch_size=2, num_classes=4
# This represents logits from a model
output = torch.randn(2, 4)

# Create target tensor: batch_size=2
# These are class indices (0-3 for 4 classes)
target = torch.tensor([1, 3])

# topk parameter: tuple of k values to compute accuracy for
topk = (1, 2)

ARGS = {
    "output": output,
    "target": target,
    "topk": topk,
}
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 list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
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
get_train_samples Ran
ran on a synthesized input
hustvl/PD-Quant/main_imagenet.py
code served (permissive licence) · get_code("e2ac4ea89ec368a9")
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 tuple. 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

torch.manual_seed(0)

# Create a simple data loader: list of (data, target) tuples
# Each batch contains tensors of shape (batch_size, feature_dim)
batch_size = 2
feature_dim = 4
num_batches = 3

train_loader = [
    (torch.randn(batch_size, feature_dim), torch.randint(0, 2, (batch_size,)))
    for _ in range(num_batches)
]

num_samples = 3

ARGS = {
    "train_loader": train_loader,
    "num_samples": num_samples,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
is_absorbing Ran
ran, violated the contract we drafted
hustvl/PD-Quant/quant/fold_bn.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from yfguo91/ternary-spike, is pointer only (licence: NONE) · get_code("bc1bf5bb29e60206")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from yfguo91/ternary-spike, and GitHub detected no licence in that repository 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. A run is recorded.

is_bn Ran
ran, violated the contract we drafted
hustvl/PD-Quant/quant/fold_bn.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from yfguo91/ternary-spike, is pointer only (licence: NONE) · get_code("06ddc213753098ff")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from yfguo91/ternary-spike, and GitHub detected no licence in that repository 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. A run is recorded.

lp_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hustvl/PD-Quant/quant/quant_layer.py
code served (permissive licence) · get_code("08c6ea7576220a13")
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 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
import torch.nn as nn

torch.manual_seed(0)

# Create small tensors for pred and tgt
# pred: predictions, shape (batch_size, features)
# tgt: targets, shape (batch_size, features)
batch_size = 2
feature_dim = 4

pred = torch.randn(batch_size, feature_dim)
tgt = torch.randn(batch_size, feature_dim)

# Parameters for the loss function
p = 2.0
reduction = 'none'

ARGS = {
    'pred': pred,
    'tgt': tgt,
    'p': p,
    'reduction': reduction
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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
search_fold_and_remove_bn Ran
ran; our contract draft was wrong, not the code
hustvl/PD-Quant/quant/fold_bn.py
code served (permissive licence) · get_code("ef0fe1948e3ae202")
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 Conv2d. 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)

# Create a model that contains Conv2d followed by BatchNorm2d
# This matches the structure the function expects to process
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Conv2d: (in_channels=3, out_channels=4, kernel_size=3)
        self.conv1 = nn.Conv2d(3, 4, kernel_size=3, padding=1)
        # BatchNorm2d: (num_features=4)
        self.bn1 = nn.BatchNorm2d(4)
        # Another Conv2d to test the prev tracking
        self.conv2 = nn.Conv2d(4, 5, kernel_size=3, padding=1)
        # Another BatchNorm2d
        self.bn2 = nn.BatchNorm2d(5)
    
    def forward(self, x):
        x = self.conv1(x)
        x = self.bn1(x)
        x = self.conv2(x)
        x = self.bn2(x)
        return x

# Instantiate the model
model = SimpleModel()

# Initialize batch norm statistics by running in eval mode
# and ensure they have proper running_mean and running_var
model.eval()

# Optionally do a forward pass to populate running statistics
dummy_input = torch.randn(2, 3, 8, 8)
with torch.no_grad():
    model(dummy_input)

ARGS = {
    "model": model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
validate_model Ran
ran, honoured the contract we drafted
hustvl/PD-Quant/main_imagenet.py
code served (permissive licence) · get_code("605b5163dc46fdad")
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 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
import torch.nn as nn
import time

torch.manual_seed(0)

# Create a minimal model that takes images and outputs logits for 5 classes
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(4, 5)
    
    def forward(self, x):
        # Flatten input and pass through linear layer
        return self.fc(x.view(x.size(0), -1))

# Create a minimal data loader as a list of (images, targets) tuples
val_loader = [
    (torch.randn(2, 4), torch.randint(0, 5, (2,))),
    (torch.randn(2, 4), torch.randint(0, 5, (2,))),
    (torch.randn(2, 4), torch.randint(0, 5, (2,))),
]

# Instantiate the model
model = MinimalModel()

# Create arguments dict
ARGS = {
    'val_loader': val_loader,
    'model': model,
    'device': None,
    'print_freq': 100
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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
find_unquantized_module Not yet run
unverified (harvested, no recorded run)
hustvl/PD-Quant/quant/layer_recon.py
code served (permissive licence) · get_code("994105469fdfaa8d")
How it ran

no invocation recorded.

get_dc_fp_init Not yet run
unverified (harvested, no recorded run)
hustvl/PD-Quant/quant/set_weight_quantize_params.py
code served (permissive licence) · get_code("92cd96c6fcafe9dd")
How it ran

no invocation recorded.

get_init Not yet run
unverified (harvested, no recorded run)
hustvl/PD-Quant/quant/set_weight_quantize_params.py
code served (permissive licence) · get_code("072a043f9a70b03e")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 7 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 3 later) and 4 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
accuracy 116 other papers
66 dated earlier, 24 later, 26 same year, order not determinable · 8 only as an assembly brick
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1610.05820 (2016-10)
Membership Inference Attacks Against Machine Learning Models
1905.03696 (2019-05)
HAWQ: Hessian AWare Quantization of Neural Networks with Mixed-Precision
and 113 more not named here
round_ste 27 other papers
2 dated earlier, 17 later, 8 same year, order not determinable · 13 only as an assembly brick
2203.05740 (2022-03)
QDrop: Randomly Dropping Quantization for Extremely Low-bit Post-Training Quantization
2204.12322 (2022-04)
RAPQ: Rescuing Accuracy for Power-of-Two Low-bit Post-training Quantization
2302.04304 (2023-02)
Q-Diffusion: Quantizing Diffusion Models
and 24 more not named here
lp_loss 18 other papers
10 later, 8 same year, order not determinable · 7 only as an assembly brick
Li_RepQ-ViT_Scale_Reparameterization_for_Post-Training_Quantization_of_Vision_Transformers_ICCV_2023_paper (2023 (year only))
RepQ-ViT: Scale Reparameterization for Post-Training Quantization of Vision Transformers
2302.04304 (2023-02)
Q-Diffusion: Quantizing Diffusion Models
2305.10657 (2023-05)
PTQD: Accurate Post-Training Quantization for Diffusion Models
and 15 more not named here
is_absorbing 4 other papers
1 dated earlier, 3 same year, order not determinable
2106.06984 (2021-06)
A Free Lunch From ANN: Towards Efficient, Accurate Spiking Neural Networks Calibration
2303.11906 (2023-03)
Solving Oscillation Problem in Post-Training Quantization Through a Theoretical Perspective
2308.07650 (2023-08)
EQ-Net: Elastic Quantization Neural Networks
and 1 more not named here
is_bn 4 other papers
1 dated earlier, 3 same year, order not determinable
2106.06984 (2021-06)
A Free Lunch From ANN: Towards Efficient, Accurate Spiking Neural Networks Calibration
2303.11906 (2023-03)
Solving Oscillation Problem in Post-Training Quantization Through a Theoretical Perspective
2308.07650 (2023-08)
EQ-Net: Elastic Quantization Neural Networks
and 1 more not named here
search_fold_and_remove_bn 3 other papers
3 same year, order not determinable
2303.11906 (2023-03)
Solving Oscillation Problem in Post-Training Quantization Through a Theoretical Perspective
2307.10554 (2023-07)
EMQ: Evolving Training-free Proxies for Automated Mixed Precision Quantization
2312.06372 (2023-12)
Ternary Spike: Learning Ternary Spikes for Spiking Neural Networks
validate_model 1 other paper
1 dated earlier
2102.05426 (2021-02)
BRECQ: Pushing the Limit of Post-Training Quantization by Block Reconstruction

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-24.

Repositories linked to this paper

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

Abstract

Post-training quantization (PTQ) is a neural network compression technique that converts a full-precision model into a quantized model using lower-precision data types. Although it can help reduce the size and computational cost of deep neural networks, it can also introduce quantization noise and reduce prediction accuracy, especially in extremely low-bit settings. How to determine the appropriate quantization parameters (e.g., scaling factors and rounding of weights) is the main problem facing now. Existing methods attempt to determine these parameters by minimize the distance between features before and after quantization, but such an approach only considers local information and may not result in the most optimal quantization parameters. We analyze this issue and propose PD-Quant, a method that addresses this limitation by considering global information. It determines the quantization parameters by using the information of differences between network prediction before and after quantization. In addition, PD-Quant can alleviate the overfitting problem in PTQ caused by the small number of calibration sets by adjusting the distribution of activations. Experiments show that PD-Quant leads to better quantization parameters and improves the prediction accuracy of quantized models, especially in low-bit settings. For example, PD-Quant pushes the accuracy of ResNet-18 up to 53.14% and RegNetX-600MF up to 40.67% in weight 2-bit activation 2-bit. The code is released at https://github.com/hustvl/PD-Quant.

For agents

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

get_harvested_code_for_paper("Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper")
get_code_for_paper("Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper")
have("Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper")

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

curl https://syntology.ai/api/ran/Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper.json

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

[![Syntology run record](https://syntology.ai/api/ran/Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper.svg)](https://syntology.ai/paper/Liu_PD-Quant_Post-Training_Quantization_Based_on_Prediction_Difference_Metric_CVPR_2023_paper)

Connect an agent — have() is free.