SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.09426 · ICML · 2025

FLATQUANT: Flatness Matters for LLM Quantization

Wulong Liu, Lu Hou, Xin Jiang, Yuxuan Sun, Chun Yuan, Jun Yao, Han Bao, Ruikang Liu, Haoli Bai, Kang Zhao, Yuening Li, Jiaxin Hu, and 1 more

arXiv · PDF · Open in the Atlas

Code that ran

16 of 22 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; 5 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 9 failures of our instrument; 6 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/2410.09426.json · badge: /api/ran/2410.09426.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
ruikangliu/FlatQuant canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
ruikangliu/flatquant community
Papers with Code archive
9 ran · 2 no recorded run
FunctionStatusWhere it lives
ActivationQuantizer Ran
ran on a synthesized input · constructed an object; no result was computed
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("fb8c9a5bb6eddb3a")
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, ActivationQuantizer: the run constructed the object and did not call it, so no result was computed. 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)

ARGS = {
    "bits": 8,
    "sym": False,
    "lac": False,
    "groupsize": -1,
    "clip_ratio": None,
}
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 ActivationQuantizer — 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 ActivationQuantizer 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
WeightQuantizer Ran
ran on a synthesized input · constructed an object; no result was computed
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("c640fa304e83971e")
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, WeightQuantizer: the run constructed the object and did not call it, so no result was computed. 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 small WeightQuantizer instance
quantizer = nn.Module()

# Build arguments for WeightQuantizer.__init__
ARGS = {
    'shape': 1
}
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 WeightQuantizer — 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 WeightQuantizer 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
asym_dequant Ran
ran, honoured the contract we drafted
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("0225f1f47f1347ae")
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 2, dtype family float, shape (2, 4) 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 numpy as np

torch.manual_seed(0)

# Construct arguments for asym_dequant(q, scale, zero)
# The function performs: scale * (q - zero)
# All parameters should be tensors that support subtraction and multiplication

q = torch.tensor([[1.0, 2.0, 3.0, 4.0],
                   [5.0, 6.0, 7.0, 8.0]])

scale = torch.tensor([[2.0, 2.0, 2.0, 2.0],
                      [2.0, 2.0, 2.0, 2.0]])

zero = torch.tensor([[0.5, 0.5, 0.5, 0.5],
                     [0.5, 0.5, 0.5, 0.5]])

ARGS = {
    "q": q,
    "scale": scale,
    "zero": zero
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
asym_quant Ran
ran; our contract draft was wrong, not the code
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("5daeed014eb71da9")
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 small test tensors
x = torch.randn(2, 4)  # Input tensor to quantize
scale = torch.tensor([0.1])  # Scale factor for quantization
zero = torch.tensor([0], dtype=torch.long)  # Zero point
maxq = 255  # Maximum quantization value (typical for int8)

ARGS = {
    "x": x,
    "scale": scale,
    "zero": zero,
    "maxq": maxq,
}
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
asym_quant_dequant Ran
ran; our contract draft was wrong, not the code
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("1cff15f38a45ffdf")
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 2, dtype family float, shape (2, 4) 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 test tensors
x = torch.randn(2, 4)  # Input tensor to quantize/dequantize
scale = torch.tensor([0.1])  # Scale factor for quantization
zero = torch.tensor([0])  # Zero point for asymmetric quantization
maxq = 255  # Maximum quantization level (8-bit)

ARGS = {
    "x": x,
    "scale": scale,
    "zero": zero,
    "maxq": maxq,
}
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 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
create_logger Ran
ran; our contract draft was wrong, not the code
ruikangliu/FlatQuant/flatquant/args_utils.py
code served (permissive licence) · get_code("07d377e783931956")
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 Logger. 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 os
import tempfile
from datetime import datetime

# Create a temporary directory for logging
exp_dir = tempfile.mkdtemp()

ARGS = {
    'exp_dir': exp_dir,
    'dist_rank': 0,
    'name': 'test_logger'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
termcolor — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Logger — a Logger output has no array shape of its own; 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: none by the harness; any seed is in the setup block
get_act_stats Ran
ran; our contract draft was wrong, not the code
ruikangliu/FlatQuant/flatquant/flatness.py
code served (permissive licence) · get_code("ed340a7ba66258d0")
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, ndim 1, 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
import torch.nn as nn
import functools

torch.manual_seed(0)

# Build a minimal model with Linear layers
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        self.lm_head = nn.Linear(2, 2)  # This should be skipped
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        x = self.lm_head(x)
        return x

# Create model on CPU
model = SimpleModel()
model.eval()

# Build a minimal dataset - list of (input, target) tuples
# Input shape: (batch_size, input_dim) = (2, 4)
dataset = [
    (torch.randn(2, 4), torch.randn(2, 2)),
    (torch.randn(2, 4), torch.randn(2, 2)),
]

ARGS = {
    "model": model,
    "dataset": dataset,
}
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, ndim 1, dtype family float — a tuple 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_decompose_dim Ran
ran, honoured the contract we drafted
ruikangliu/FlatQuant/flatquant/function_utils.py
code served (permissive licence) · get_code("793e9add661c055d")
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, ndim 1, dtype family int; 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 math

def get_decompose_dim(n):
    a = int(math.sqrt(n))
    if a * a < n:
        a += 1
    while True:
        tmp = a * a - n
        b = int(math.sqrt(tmp))
        if b * b == tmp:
            break
        a += 1
    return (a - b, a + b)

# The function takes a single parameter n which should be an integer
# It decomposes n into a difference of two squares: n = (a-b)(a+b)
# Let's use a simple positive integer as input

ARGS = {
    "n": 15
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 tuple, ndim 1, dtype family int — a tuple 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_init_scale Ran
ran; our contract draft was wrong, not the code
ruikangliu/FlatQuant/flatquant/function_utils.py
code served (permissive licence) · get_code("8c5939efc897859f")
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 1, dtype family float, shape (4,) 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)

# The function uses .pow() and .clamp() methods on the arguments,
# so they need to be torch tensors that support these operations.
# w_smax and x_smax are used in mathematical operations and should be tensors.

w_smax = torch.tensor([2.0, 3.0, 1.5, 2.5])
x_smax = torch.tensor([1.0, 2.0, 0.5, 1.5])
alpha = 0.5

ARGS = {
    "w_smax": w_smax,
    "x_smax": x_smax,
    "alpha": alpha,
}
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 1, dtype family float, shape (4,) — shape (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
get_qmin_qmax Ran
ran, honoured the contract we drafted
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("5e9e63617f0d5c45")
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, ndim 1, dtype family int; 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)

ARGS = {
    "bits": 8,
    "sym": True
}
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, ndim 1, dtype family int — a tuple 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_random_orthg Ran
ran, honoured the contract we drafted
ruikangliu/FlatQuant/flatquant/function_utils.py
code served (permissive licence) · get_code("344ae3d0d1bfe716")
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 2, dtype family float, shape (5, 5) 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 numpy as np
from scipy.linalg import qr

torch.manual_seed(0)
np.random.seed(0)

ARGS = {
    "size": 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, 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 (5, 5) — shape (5, 5) 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
load_flat_parameters Ran
ran; our contract draft was wrong, not the code
ruikangliu/FlatQuant/flatquant/flat_utils.py
code served (permissive licence) · get_code("fd3ef59f69a8d1f9")
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 WrapperModel. 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
import os
import tempfile

torch.manual_seed(0)

# Create a temporary directory for the experiment
temp_dir = tempfile.mkdtemp()

# Create a simple layer module
class SimpleLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.weight = nn.Parameter(torch.randn(4, 3))
        self.bias = nn.Parameter(torch.randn(4))
    
    def forward(self, x):
        return x @ self.weight.t() + self.bias

# Create a simple model with layers attribute
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.ModuleList([
            SimpleLayer(),
            SimpleLayer(),
            SimpleLayer()
        ])
    
    def forward(self, x):
        for layer in self.layers:
            x = layer(x)
        return x

# Create a wrapper model that has a .model attribute
class WrapperModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = SimpleModel()
    
    def forward(self, x):
        return self.model(x)

# Create flat_parameters.pth file
flat_parameters = {
    0: SimpleLayer().state_dict(),
    1: SimpleLayer().state_dict(),
    2: SimpleLayer().state_dict()
}
torch.save(flat_parameters, os.path.join(temp_dir, 'flat_parameters.pth'))

# Create args object with exp_dir attribute
class Args:
    def __init__(self, exp_dir):
        self.exp_dir = exp_dir

args = Args(temp_dir)
model = WrapperModel()
path = None

ARGS = {
    'args': args,
    'model': model,
    'path': path
}
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 WrapperModel — a WrapperModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a WrapperModel 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
reparameterize_model Ran
ran; our contract draft was wrong, not the code
ruikangliu/FlatQuant/flatquant/flat_utils.py
code served (permissive licence) · get_code("44adddac22fc4be4")
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 MockModel. 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)

class MockTransform:
    def __init__(self, add_diag=True):
        self.diag_scale = torch.ones(4, dtype=torch.float64)
        self.add_diag = add_diag
        self.use_diag = True

class MockAttention(nn.Module):
    def __init__(self, has_ln_trans=True):
        super().__init__()
        self.ln_trans = MockTransform(add_diag=True) if has_ln_trans else None
    
    def reparameterize(self):
        pass

class MockMLP(nn.Module):
    def __init__(self, has_up_gate_trans=True):
        super().__init__()
        self.up_gate_trans = MockTransform(add_diag=True) if has_up_gate_trans else None
    
    def reparameterize(self):
        pass

class MockLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.self_attn = MockAttention(has_ln_trans=True)
        self.mlp = MockMLP(has_up_gate_trans=True)
        self.input_layernorm = nn.LayerNorm(4)
        self.post_attention_layernorm = nn.LayerNorm(4)

class MockModel(nn.Module):
    def __init__(self, num_hidden_layers=2):
        super().__init__()
        self.config = type('Config', (), {'num_hidden_layers': num_hidden_layers})()
        self.model = type('ModelContainer', (), {})()
        self.model.layers = nn.ModuleList([MockLayer() for _ in range(num_hidden_layers)])

model = MockModel(num_hidden_layers=2)

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 MockModel — a MockModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockModel 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
sym_dequant Ran
ran, honoured the contract we drafted
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("7240250f5015a29b")
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 2, dtype family float, shape (2, 4) 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 q and scale
q = torch.randn(2, 4)
scale = torch.randn(2, 4)

ARGS = {
    'q': q,
    'scale': scale
}
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 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
sym_quant Ran
ran; our contract draft was wrong, not the code
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("d0ba87ceb3a23391")
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
import torch.nn as nn

torch.manual_seed(0)

# Create small tensor inputs
x = torch.randn(2, 4)
scale = torch.tensor([0.5])
maxq = 127

ARGS = {
    "x": x,
    "scale": scale,
    "maxq": maxq,
}
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
sym_quant_dequant Ran
ran; our contract draft was wrong, not the code
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("c4b090924d22c621")
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 2, dtype family float, shape (2, 4) 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 test tensors
x = torch.randn(2, 4)  # Input tensor to quantize/dequantize
scale = torch.tensor([0.1])  # Scale factor for quantization
maxq = torch.tensor(127)  # Maximum quantization value

ARGS = {
    "x": x,
    "scale": scale,
    "maxq": maxq
}
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 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
FlatQuantizedLinear Not yet run
unverified (harvested, no recorded run)
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("6f9dc3b96143740a")
How it ran

no invocation recorded.

get_c4_new Not yet run
unverified (harvested, no recorded run)
ruikangliu/FlatQuant/flatquant/data_utils.py
code served (permissive licence) · get_code("5ce9fedf84036bba")
How it ran

no invocation recorded.

get_ptb_new Not yet run
unverified (harvested, no recorded run)
ruikangliu/FlatQuant/flatquant/data_utils.py
code served (permissive licence) · get_code("88930c61cc7cd4ec")
How it ran

no invocation recorded.

get_wikitext2 Not yet run
unverified (harvested, no recorded run)
ruikangliu/FlatQuant/flatquant/data_utils.py
code served (permissive licence) · get_code("4dd3c92f12273ec9")
How it ran

no invocation recorded.

kronecker_matmul Not yet run
unverified (harvested, no recorded run)
ruikangliu/flatquant/flatquant/flat_linear.py
code served (permissive licence) · get_code("0030c02f2d89d72e")
How it ran

no invocation recorded.

ppl_eval Not yet run
unverified (harvested, no recorded run)
ruikangliu/FlatQuant/flatquant/eval_utils.py
code served (permissive licence) · get_code("395f9a60e4270266")
How it ran

no invocation recorded.

Also present in other papers' code

Of 22 samples lifted from this paper's linked repositories, 22 carry a function identity and 0 do not. Of the 22 distinct functions with an identity, 5 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 5 later) and 17 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
asym_dequant
brick of this paper's assembly: helper
2 other papers
2 later
2511.04063 (2025-11)
DartQuant: Efficient Rotational Distribution Calibration for LLM Quantization
2605.19660 (2026-05)
OScaR: The Occam's Razor for Extreme KV Cache Quantization in LLMs and Beyond
asym_quant
brick of this paper's assembly: helper
1 other paper
1 later
2602.02546 (2026-02)
D 2 Quant: Accurate Low-bit Post-Training Weight Quantization for LLMs
asym_quant_dequant
brick of this paper's assembly: helper
1 other paper
1 later
2605.19660 (2026-05)
OScaR: The Occam's Razor for Extreme KV Cache Quantization in LLMs and Beyond
sym_dequant
brick of this paper's assembly: helper
1 other paper
1 later
2605.19660 (2026-05)
OScaR: The Occam's Razor for Extreme KV Cache Quantization in LLMs and Beyond
sym_quant_dequant
brick of this paper's assembly: helper
1 other paper
1 later
2605.19660 (2026-05)
OScaR: The Occam's Razor for Extreme KV Cache Quantization in LLMs and Beyond

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

Recently, quantization has been widely used for the compression and acceleration of large language models (LLMs). Due to the outliers in LLMs, it is crucial to flatten weights and activations to minimize quantization error with equally spaced quantization points. Prior research explores various pre-quantization transformations to suppress outliers, such as per-channel scaling and Hadamard transformation. However, we observe that these transformed weights and activations can still exhibit steep and dispersed distributions. In this paper, we propose FLATQUANT (Fast and Learnable Affine Transformation), a new posttraining quantization approach that enhances the flatness of weights and activations. Our approach identifies optimal affine transformations for each linear layer, calibrated in hours via a lightweight objective. To reduce runtime overhead of affine transformation, we apply Kronecker product with two lightweight matrices, and fuse all operations in FLATQUANT into a single kernel. Extensive experiments demonstrate that FLATQUANT establishes a new state-of-the-art benchmark for quantization. For example, it achieves less than 1% accuracy drop for W4A4 quantization on the LLaMA-3-70B model, surpassing SpinQuant by 7.5%. Additionally, it provides up to 2.3x prefill speedup and 1.7x decoding speedup compared to the FP16 model. Code is available at: https:// github.com/ruikangliu/FlatQuant.

For agents

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

get_harvested_code_for_paper("2410.09426")
get_code_for_paper("2410.09426")
have("2410.09426")

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

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

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

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

Connect an agent — have() is free.