SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.12023 · 2023

LQ-LoRA: Low-rank Plus Quantized Matrix Decomposition for Efficient Language Model Finetuning

arXiv · PDF · Open in the Atlas

Code that ran

9 of 12 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; 8 failures of our instrument; 3 no recorded run), measured 2026-11-24; 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/2311.12023.json · badge: /api/ran/2311.12023.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
hanguo97/lq-lora canonical (classifier label)
classifier basis: census
9 ran · 3 no recorded run
FunctionStatusWhere it lives
compute_empirical_Fisher_RoBERTa Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hanguo97/lq-lora/models/allocation_utils_2.py
code served (permissive licence) · get_code("a3d0d1e07441f8ff")
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 dict. 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
from transformers import RobertaForMaskedLM
from transformers.models.roberta.configuration_roberta import RobertaConfig

torch.manual_seed(0)

# Create a minimal RobertaForMaskedLM model with tiny dimensions
config = RobertaConfig(
    vocab_size=100,
    hidden_size=4,
    num_hidden_layers=2,
    num_attention_heads=2,
    intermediate_size=8,
    max_position_embeddings=16,
    type_vocab_size=2,
)

model = RobertaForMaskedLM(config)
model.eval()

# Create minimal input batch with batch_size=1 and sequence_length=3
batch_size = 1
seq_length = 3

input_ids = torch.randint(0, 100, (batch_size, seq_length), dtype=torch.long)
attention_mask = torch.ones((batch_size, seq_length), dtype=torch.long)
labels = torch.randint(0, 100, (batch_size, seq_length), dtype=torch.long)

# Create list of input dicts - the function processes one at a time
inputs = [
    {
        'input_ids': input_ids,
        'attention_mask': attention_mask,
        'labels': labels,
    },
    {
        'input_ids': input_ids,
        'attention_mask': attention_mask,
        'labels': labels,
    }
]

dtype = torch.float32
device = None

ARGS = {
    'model': model,
    'inputs': inputs,
    'dtype': dtype,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
create_normal_float_scheme Ran
ran; our contract draft was wrong, not the code
hanguo97/lq-lora/models/quantization_utils.py
code served (permissive licence) · get_code("40ba32e8f13af3e2")
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 QuantScheme. 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 math
import scipy.special

torch.manual_seed(0)

ARGS = {
    "num_bits": 4,
    "device": torch.device("cpu"),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type QuantScheme — a QuantScheme 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
create_quantization_scheme Ran
ran; our contract draft was wrong, not the code
hanguo97/lq-lora/models/quantization_utils.py
code served (permissive licence) · get_code("3175476f3e4363e4")
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 QuantScheme. 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 values tensor
# The function expects values to be 1D, and will create boundaries between them
values = torch.tensor([1.0, 2.0, 3.0, 4.0])

# Device to use (CPU only)
device = torch.device('cpu')

ARGS = {
    'values': values,
    'device': device,
}
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 QuantScheme — a QuantScheme 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
from_binary Ran
ran, honoured the contract we drafted
hanguo97/lq-lora/models/packbits_utils.py
code served (permissive licence) · get_code("4e9c1bc486b3cb15")
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 int, shape (2,) 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 binary tensor with shape (2, 4) where last dimension is num_bits
# dtype must be torch.bool
tensor = torch.randint(0, 2, (2, 4)).to(dtype=torch.bool)

# num_bits must match the last dimension of tensor and be <= 8
num_bits = 4

# legacy parameter controls which mask calculation is used
legacy = True

ARGS = {
    "tensor": tensor,
    "num_bits": num_bits,
    "legacy": legacy,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, 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 int, shape (2,) — shape (2,) 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
pack_bools_into_integers Ran
ran; our contract draft was wrong, not the code
hanguo97/lq-lora/models/packbits_utils.py
code served (permissive licence) · get_code("def1ac254e2bf2ca")
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 jaxtyping
from typing import Tuple, Union, Optional, NamedTuple

torch.manual_seed(0)

# Create a 1D binary tensor
binary_tensor = torch.tensor([True, False, True, True, False, True, False, False, True, True], dtype=torch.bool)

# Create ARGS dict with all required parameters
ARGS = {
    "tensor": binary_tensor,
    "packed_dtype": torch.uint8
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, 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
quantize_with_scheme Ran
ran; our contract draft was wrong, not the code
hanguo97/lq-lora/models/quantization_utils.py
code served (permissive licence) · get_code("3a5ac3bc042f6593")
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 3, 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
from typing import Tuple, Optional, NamedTuple

torch.manual_seed(0)

class QuantScheme(NamedTuple):
    values: torch.Tensor
    boundaries: torch.Tensor

# Create a small QuantScheme with quantization values and boundaries
# boundaries define the bucketization thresholds
qscheme = QuantScheme(
    values=torch.tensor([-1.0, 0.0, 1.0, 2.0], dtype=torch.float32),
    boundaries=torch.tensor([-0.5, 0.5, 1.5], dtype=torch.float32)
)

# Create input tensor A with shape (2, 4)
A = torch.randn(2, 4, dtype=torch.float32)

# Create scales_q with same shape as A
scales_q = torch.ones(2, 4, dtype=torch.float32) * 0.5

# Create scales_dq with same shape as A
scales_dq = torch.ones(2, 4, dtype=torch.float32) * 2.0

ARGS = {
    "A": A,
    "qscheme": qscheme,
    "scales_q": scales_q,
    "scales_dq": scales_dq
}
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 3, 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
svd_decomposition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hanguo97/lq-lora/models/factorizations_utils.py
code served (permissive licence) · get_code("426e5a6d0c6824e8")
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 small 2D tensor for SVD decomposition
# Using distinct dimensions: 6 rows, 4 columns
A = torch.randn(6, 4, dtype=torch.float32)

ARGS = {
    'A': A,
    'randomized': False,
    'num_ranks': 2,
    'num_oversampling': 5
}
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
to_binary Ran
ran; our contract draft was wrong, not the code
hanguo97/lq-lora/models/packbits_utils.py
code served (permissive licence) · get_code("2327775e49455531")
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
import jaxtyping

torch.manual_seed(0)

# Create a small uint8 tensor with values that fit within num_bits range
# Shape: (2, 4) - batch of 2, dimension of 4
tensor = torch.tensor(
    [[1, 2, 3, 4],
     [5, 6, 7, 0]],
    dtype=torch.uint8
)

num_bits = 3
legacy = True

ARGS = {
    "tensor": tensor,
    "num_bits": num_bits,
    "legacy": legacy
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, 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
weighted_svd_decomposition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hanguo97/lq-lora/models/factorizations_utils.py
code served (permissive licence) · get_code("27c3361a9d756b76")
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
# A is a 2D matrix (4x3)
A = torch.randn(4, 3)

# W is a weight matrix with same shape as A
W = torch.rand(4, 3)

# Parameters for the function
ARGS = {
    "A": A,
    "W": W,
    "heuristic": "two-sided",
    "randomized": False,
    "num_ranks": 2,
    "num_oversampling": 5,
    "normalize": False,
    "reduce_before_sqrt": 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 — 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
apply_three_tensor_op Not yet run
unverified (harvested, no recorded run)
hanguo97/lq-lora/models/tensor_container_utils.py
code served (permissive licence) · get_code("e6327c65d67b9b9d")
How it ran

no invocation recorded.

compute_empirical_Fisher_LLaMA Not yet run
unverified (harvested, no recorded run)
hanguo97/lq-lora/models/allocation_utils.py
code served (permissive licence) · get_code("75320a91f402092b")
How it ran

no invocation recorded.

get_hf_quantization_config Not yet run
unverified (harvested, no recorded run)
hanguo97/lq-lora/models/lora_utils.py
code served (permissive licence) · get_code("adc7b34aa6bae5f9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 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 10 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
from_binary 1 other paper
1 later
2411.17525 (2024-11)
Pushing the Limits of Large Language Model Quantization via the Linearity Theorem
to_binary 1 other paper
1 later
2411.17525 (2024-11)
Pushing the Limits of Large Language Model Quantization via the Linearity Theorem

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

We propose a simple approach for memory-efficient adaptation of pretrained language models. Our approach uses an iterative algorithm to decompose each pretrained matrix into a high-precision low-rank component and a memory-efficient quantized component. During finetuning, the quantized component remains fixed and only the low-rank component is updated. We present an integer linear programming formulation of the quantization component which enables dynamic configuration of quantization parameters (e.g., bit-width, block size) for each matrix given an overall target memory budget. We further explore a data-aware version of the algorithm which uses an approximation of the Fisher information matrix to weight the reconstruction objective during matrix decomposition. Experiments on finetuning RoBERTa and LLaMA-2 (7B and 70B) demonstrate that our low-rank plus quantized matrix decomposition approach (LQ-LoRA) outperforms strong QLoRA and GPTQ-LoRA baselines and enables aggressive quantization to sub-3 bits with only minor performance degradations. When finetuned on a language modeling calibration dataset, LQ-LoRA can also be used for model compression; in this setting our 2.75-bit LLaMA-2-70B model (which has 2.85 bits on average when including the low-rank components and requires 27GB of GPU memory) performs respectably compared to the 16-bit baseline.

For agents

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

get_harvested_code_for_paper("2311.12023")
get_code_for_paper("2311.12023")
have("2311.12023")

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

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

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

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

Connect an agent — have() is free.