SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.09615 · ICML · 2025

SLIM: One-shot Quantization and Sparsity with Low-rank Approximation for LLM Weight Compression

Amir Yazdanbakhsh, Mohammad Mozaffari, Maryam Dehnavi, Mo- Hammad Mozaffari

arXiv · PDF · Open in the Atlas

Code that ran

8 of 16 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, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 8 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.09615.json · badge: /api/ran/2410.09615.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
mohammad-mozaffari/slim canonical (classifier label)
classifier basis: census
8 ran · 8 no recorded run
FunctionStatusWhere it lives
check_sparsity Ran
ran, honoured the contract we drafted
mohammad-mozaffari/slim/slim/utils.py
code served (permissive licence) · get_code("42183294cfd88747")
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 float, 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)

class MockConfig:
    def __init__(self):
        self.use_cache = False

class MockDecoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.ModuleList([
            nn.Sequential(
                nn.Linear(4, 3),
                nn.ReLU(),
                nn.Linear(3, 5)
            ),
            nn.Sequential(
                nn.Linear(4, 3),
                nn.ReLU(),
                nn.Linear(3, 5)
            )
        ])

class MockTransformer(nn.Module):
    def __init__(self):
        super().__init__()
        self.decoder = MockDecoder()

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MockConfig()
        self.transformer = MockTransformer()

model = MockModel()

# Sparsify some weights to create actual zero values
with torch.no_grad():
    for layer in model.transformer.decoder.layers:
        for module in layer.modules():
            if isinstance(module, nn.Linear):
                module.weight.data[0, 0] = 0.0
                module.weight.data[1, 1] = 0.0

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 float, 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
clip_matrix Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mohammad-mozaffari/slim/slim/jsq_utils.py
code served (permissive licence) · get_code("4571405e8c540b28")
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 3, dtype family float, shape (2, 4, 3) 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 a small test matrix
# The function uses matrix[0] when channel=True, and matrix.numel(), .flatten(), etc. when channel=False
# For channel=True case, matrix should be 3D (batch, height, width) or similar
# For channel=False case, matrix can be any shape
matrix = torch.randn(2, 4, 3)

ARGS = {
    "matrix": matrix,
    "abs": True,
    "clip_l": 0.1,
    "clip_h": 0.1,
    "channel": False
}
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 3, dtype family float, shape (2, 4, 3) — shape (2, 4, 3) 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
compute_average_error Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mohammad-mozaffari/slim/slim/quantization/quantization.py
code served (permissive licence) · get_code("84eb8004af9c2890")
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

torch.manual_seed(0)

# Construct tensors for the function
# pdf: probability density function, should be a 1D tensor of probabilities
# val: values corresponding to the pdf, should be a 1D tensor
# index: an integer index into these tensors
# q: quantization bits

pdf = torch.tensor([0.1, 0.2, 0.3, 0.25, 0.15], dtype=torch.float32)
val = torch.tensor([0.0, 1.0, 2.0, 3.0, 4.0], dtype=torch.float32)
index = 2
q = 3

ARGS = {
    "pdf": pdf,
    "val": val,
    "index": index,
    "q": q
}
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
compute_error Ran
ran; our contract draft was wrong, not the code
mohammad-mozaffari/slim/slim/quantization/quantization.py
code served (permissive licence) · get_code("52c8d10182e8a260")
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 float, 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 a small tensor for the matrix parameter
# Shape: 2x4 (batch size 2, dimension 4)
mat = torch.randn(2, 4)

# Alpha is a scaling factor (scalar)
alpha = 1.5

# Number of bits for quantization
num_bits = 8

ARGS = {
    "mat": mat,
    "alpha": alpha,
    "num_bits": num_bits,
}
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 float, 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_optimal_quantiztion_cap Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mohammad-mozaffari/slim/slim/quantization/quantization.py
code served (permissive licence) · get_code("020fcf9a9520fb1e")
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. 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, 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 a small tensor with some values to quantize
mat = torch.randn(2, 4) * 10  # Small tensor with range suitable for quantization

# Define ARGS dict with all parameters for find_optimal_quantiztion_cap
ARGS = {
    "mat": mat,
    "num_bits": 8,
    "num_bins": 64,  # Reduced for speed
    "integrate": 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 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
get_layers_list Ran
ran; our contract draft was wrong, not the code
mohammad-mozaffari/slim/slim/utils.py
code served (permissive licence) · get_code("85fa2999ab638291")
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 ModuleList. 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 SimpleDecoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.ModuleList([
            nn.Linear(4, 4),
            nn.Linear(4, 4)
        ])

class SimpleTransformer(nn.Module):
    def __init__(self):
        super().__init__()
        self.h = nn.ModuleList([
            nn.Linear(4, 4),
            nn.Linear(4, 4)
        ])

class SimpleLanguageModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.decoder = SimpleDecoder()

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.transformer = SimpleTransformer()

# Test with a model that has 'layers' attribute
model = SimpleModel()

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 ModuleList — a ModuleList output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ModuleList output the recorded ndim 1 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
quantize Ran
ran; our contract draft was wrong, not the code
mohammad-mozaffari/slim/slim/sparsegpt.py
code served (permissive licence) · get_code("50ceff9d34d96d60")
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)

# x: tensor to quantize
x = torch.randn(2, 4)

# scale: scaling factor (tensor or float)
scale = torch.tensor(0.1)

# zero: zero point offset
zero = torch.tensor(0, dtype=torch.long)

# maxq: maximum quantization level
maxq = 255

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
shift_zeros Ran
ran; our contract draft was wrong, not the code
mohammad-mozaffari/slim/slim/utils.py
code served (permissive licence) · get_code("7e09ff6cd96dfeb0")
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 a small tensor with some zeros and positive values
x = torch.tensor([
    [0.0, 1.5, 0.0, 2.3],
    [0.5, 0.0, 1.2, 0.0]
], dtype=torch.float32)

ARGS = {
    "x": x
}
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
generate_ss Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/jsq_utils.py
code served (permissive licence) · get_code("063194fe32e79956")
How it ran

no invocation recorded.

get_c4 Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/data.py
code served (permissive licence) · get_code("ddc3bcb5e5b4ab8d")
How it ran

no invocation recorded.

get_openwebtext Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/data.py
code served (permissive licence) · get_code("8bd4db5249a2e99e")
How it ran

no invocation recorded.

get_wikitext2 Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/data.py
code served (permissive licence) · get_code("83ea71aadeabb49a")
How it ran

no invocation recorded.

prepare_calibration_input Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/prune.py
code served (permissive licence) · get_code("11faa3c36aa963d7")
How it ran

no invocation recorded.

prune_and_optimize_lora Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/lora.py
code served (permissive licence) · get_code("e9ba4d8812c998e4")
How it ran

no invocation recorded.

prune_sparsegpt Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/prune.py
code served (permissive licence) · get_code("dd83c9200ae23e37")
How it ran

no invocation recorded.

sparse_quantized_linear Not yet run
unverified (harvested, no recorded run)
mohammad-mozaffari/slim/slim/fine_tune.py
code served (permissive licence) · get_code("99c9352eb054f54a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 15 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
quantize 6 other papers
4 dated earlier, 1 later, 1 same year, order not determinable
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
2310.00034 (2023-10)
PB-LLM: Partially Binarized Large Language Models
2024.findings-naacl.145 (2024 (year only))
Role Prompting Guided Domain Adaptation with General Capability Preserve for Large Language Models
and 3 more not named here

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

LLMs address high memory consumption and slow inference challenges but typically require computationally expensive retraining to preserve accuracy. In contrast, one-shot compression methods eliminate retraining costs, but struggle to achieve accuracy comparable to dense models. This paper presents SLIM, a new one-shot compression framework that holistically integrates hardware-friendly quantization, sparsity, and lowrank approximation into a unified process. First, we formulate the quantization process using a probabilistic approach (SLIM-Quant) that enables us to apply uniform quantization. Then, we use an existing one-shot pruning method to apply semi-structured sparsity on top of the quantized weights. Finally, to compensate for the introduced aggregated quantization and sparsity error, we use a novel saliency function with unique invertible and additive features that enables us to mathematically compute the value of low-rank adapters. SLIM improves model accuracy by up to 5.66% (LLaMA-2-7B) for 2:4 sparsity with 4-bit weight quantization, outperforming prior methods. Models compressed with SLIM achieve up to 4.3× and 3.8× layer-wise speedup on Nvidia RTX3060 and A100 GPUs, respectively. Additionally, they achieve up to 0.23× end-to-end memory reduction in comparison to their dense counterparts. We also propose an optional PEFT recipe that further improves accuracy by up to 1.66% (LLaMA-2-13B) compared to SLIM without fine-tuning. 1

For agents

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

get_harvested_code_for_paper("2410.09615")
get_code_for_paper("2410.09615")
have("2410.09615")

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

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

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

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

Connect an agent — have() is free.