SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2510.10467 · ICLR · 2025

AnyBCQ: Hardware Efficient Flexible Binary-Coded Quantization for Multi-Precision LLMs

Dongsoo Lee, Jung Kwon, Byeongwook Kim, Gunho Park, Beomseok Kwon, Jeongin Bae

arXiv · PDF · Open in the Atlas

Code that ran

12 of 27 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; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 8 failures of our instrument; 15 no recorded run), measured 2026-11-23; 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/2510.10467.json · badge: /api/ran/2510.10467.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
naver-aics/anybcq community
Papers with Code archive
12 ran · 15 no recorded run
FunctionStatusWhere it lives
GetLayerInpOut_fp Ran
ran on a synthesized input
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("4c7e38d4c326ec3e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

class StopForwardException(Exception):
    """
    Used to throw and catch an exception to stop traversing the graph
    """
    pass

class GetLayerInpOut_fp:

    def __init__(self, fp_block, device, input_prob: float=0.0, block_list_class=torch.nn.ModuleList):
        self.fp_block = fp_block
        self.device = device
        self.input_prob = input_prob
        self.block_list_class = block_list_class

    @torch.inference_mode()
    def __call__(self, model_input, is_first_block=False, others=None):
        try:
            if list == type(model_input):
                model_input[0] = model_input[0].to(self.device)
                _ = self.fp_block(model_input[0])
            elif is_first_block:
                model_input = {k: v.to(device=self.device, non_blocking=True) if hasattr(v, 'to') else v for k, v in model_input.items()}
                _ = self.fp_block(**model_input)
            else:
                _ = self.fp_block(model_input, **others)
        except StopForwardException:
            pass
        if is_first_block:
            for name, module in self.fp_block.named_modules():
                if isinstance(module, self.block_list_class):
                    out_data = module[0].out_data
                    inp_data = module[0].inp_data
                    other_data = module[0].other_data
                    break
        else:
            out_data = self.fp_block.out_data
            inp_data = self.fp_block.inp_data
            other_data = self.fp_block.other_data
        if 'tuple' in str(type(out_data)):
            out_data = out_data[0]
        torch.cuda.empty_cache()
        return (out_data.detach(), inp_data.detach(), other_data)


class SimpleBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.out_data = None
        self.inp_data = None
        self.other_data = None
    
    def forward(self, x):
        self.inp_data = x
        out = self.linear(x)
        self.out_data = out
        self.other_data = {}
        return out


class FirstBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.ModuleList([SimpleBlock()])
    
    def forward(self, x):
        return self.layers[0](x)


device = 'cpu'
fp_block = FirstBlock()

INIT_ARGS = {
    'fp_block': fp_block,
    'device': device,
    'input_prob': 0.0,
    'block_list_class': torch.nn.ModuleList
}

ARGS = {
    'model_input': {'x': torch.randn(2, 4)},
    'is_first_block': True,
    'others': None
}

METHOD = '__call__'

if __name__ == '__main__':
    getter = GetLayerInpOut_fp(**INIT_ARGS)
    result = getter(**ARGS)
    print("Result:", result)
    print("Output shape:", result[0].shape)
    print("Input shape:", result[1].shape)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
LossFunction Ran
ran on a synthesized input
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("f2815670c1e3ec0e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 0, 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
from tqdm import tqdm

class LinearTempDecay:

    def __init__(self, t_max: int, rel_start_decay: float=0.2, start_b: int=10, end_b: int=2):
        self.t_max = t_max
        self.start_decay = rel_start_decay * t_max
        self.start_b = start_b
        self.end_b = end_b

    def __call__(self, t):
        """
        Cosine annealing scheduler for temperature b.
        :param t: the current time step
        :return: scheduled temperature
        """
        if t < self.start_decay:
            return self.start_b
        else:
            rel_t = (t - self.start_decay) / (self.t_max - self.start_decay)
            return self.end_b + (self.start_b - self.end_b) * max(0.0, 1 - rel_t)

def lp_loss(pred, tgt, p=2.0, reduction='none'):
    """
    loss function measured in L_p Norm
    """
    if 'tuple' in str(type(pred)):
        pred = pred[0]
    if 'tuple' in str(type(tgt)):
        tgt = tgt[0]
    if reduction == 'none':
        return (pred - tgt).abs().pow(p).sum(1).mean()
    else:
        return (pred - tgt).abs().pow(p).mean()

class LossFunction:

    def __init__(self, block: torch.nn.Module, round_loss: str='relaxation', weight: float=1.0, rec_loss: str='mse', max_count: int=2000, b_range: tuple=(10, 2), decay_start: float=0.0, warmup: float=0.0, p: float=2.0):
        self.block = block
        self.round_loss = round_loss
        self.weight = weight
        self.rec_loss = rec_loss
        self.loss_start = max_count * warmup
        self.p = p
        self.temp_decay = LinearTempDecay(max_count, rel_start_decay=warmup + (1 - warmup) * decay_start, start_b=b_range[0], end_b=b_range[1])
        self.count = 0

    def __call__(self, pred, tgt, grad=None):
        """
        Compute the total loss for adaptive rounding:
        rec_loss is the quadratic output reconstruction loss, round_loss is
        a regularization term to optimize the rounding policy

        :param pred: output from quantized model
        :param tgt: output from FP model
        :param grad: gradients to compute fisher information
        :return: total loss function
        """
        self.count += 1
        if self.rec_loss == 'mse':
            rec_loss = lp_loss(pred, tgt, reduction='all')
        elif self.rec_loss == 'fisher_diag':
            rec_loss = ((pred - tgt).pow(2) * grad.pow(2)).sum(1).mean()
        elif self.rec_loss == 'fisher_full':
            a = (pred - tgt).abs()
            grad = grad.abs()
            batch_dotprod = torch.sum(a * grad, (1, 2, 3)).view(-1, 1, 1, 1)
            rec_loss = (batch_dotprod * a * grad).mean() / 100
        else:
            raise ValueError('Not supported reconstruction loss function: {}'.format(self.rec_loss))
        b = self.temp_decay(self.count)
        if self.count < self.loss_start or self.round_loss == 'none':
            b = round_loss = 0
        elif self.round_loss == 'relaxation':
            round_loss = 0
        else:
            raise NotImplementedError
        total_loss = rec_loss + round_loss
        if self.count % 500 == 0 or self.count == 1:
            tqdm.write(f'Total loss:{total_loss:10.10f} \tcount={self.count}')
        return total_loss


# Create a simple block module
block = nn.Sequential(
    nn.Linear(4, 8),
    nn.ReLU(),
    nn.Linear(8, 3)
)

INIT_ARGS = {
    'block': block,
    'round_loss': 'relaxation',
    'weight': 1.0,
    'rec_loss': 'mse',
    'max_count': 2000,
    'b_range': (10, 2),
    'decay_start': 0.0,
    'warmup': 0.0,
    'p': 2.0
}

ARGS = {
    'pred': torch.randn(2, 3),
    'tgt': torch.randn(2, 3),
    'grad': None
}

METHOD = '__call__'

if __name__ == '__main__':
    loss_fn = LossFunction(**INIT_ARGS)
    result = loss_fn(**ARGS)
    print(f"Loss result: {result}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, tqdm — 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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Packer Ran
ran on a synthesized input
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("129c89ce16e482bc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (8, 4) 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
import numpy as np

class Packer:

    def __init__(self):
        self.s = torch.from_numpy(np.array([1, 2, 4, 8, 16, 32, 64, 128])).view([-1, 1])
        if torch.cuda.is_available():
            self.s = self.s.cuda()
        self.w_pool = {}

    def __get_weight(self, shape, dtype):
        key = np.prod(shape)
        if key not in self.w_pool.keys():
            self.w_pool[key] = torch.zeros(shape, dtype=dtype)
            if torch.cuda.is_available():
                self.w_pool[key] = self.w_pool[key].cuda()
        return self.w_pool[key].reshape(shape)

    def pack(self, b):
        shape = b.shape
        p_b = b
        if torch.cuda.is_available():
            p_b = p_b.cuda()
        p_b = (p_b + 1) / 2
        p_b = torch.reshape(p_b, [8, -1]).type(torch.uint8)
        p_b = p_b * self.s
        p_b = p_b.sum(0)
        p_b = p_b.type(torch.uint8)
        return (p_b, shape)

    def unpack(self, pb, shape, dtype=torch.float16):
        b = self.__get_weight(shape, dtype).view([8, -1])
        for i in range(8):
            b[i] = pb & 1
            pb = pb >> 1
        b = b * 2 - 1
        b = b.reshape(shape)
        return b


INIT_ARGS = {}

b = torch.randn(8, 4, dtype=torch.float16)
packed_result = Packer().pack(b)
pb, shape = packed_result

ARGS = {
    'pb': pb,
    'shape': shape,
    'dtype': torch.float16
}

METHOD = 'unpack'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (8, 4) — shape (8, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Packer32 Ran
ran on a synthesized input
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("def899bb58fc029e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family int; no output shape is stated. 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 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 numpy as np

# INIT_ARGS for Packer32.__init__()
INIT_ARGS = {}

# Create a test tensor for pack method
# Shape: [OC, IC/group, group, num_bit]
# Let's use OC=3, IC/group=2, group=16, num_bit=4
# This gives IC = 2*16 = 32, which is divisible by 32
OC = 3
ICg = 2
G = 16
num_bit = 4
IC = ICg * G  # = 32

# Create a tensor with values in {-1, +1}
b_input = torch.randint(0, 2, (OC, ICg, G, num_bit), dtype=torch.float32) * 2 - 1

# ARGS for the pack method
ARGS = {
    'b': b_input
}

# Define which method to call
METHOD = 'pack'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 3, dtype family int — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
batch_cg_torch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("acb9fdb9c2e1fa94")
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)

# batch_cg_torch solves A @ x = b using conjugate gradient method
# A: shape (d1, k, k) - batch of square matrices
# b: shape (d1, k) - batch of right-hand sides
# x: shape (d1, k) - initial guess (optional)

d1 = 2  # batch size
k = 4   # dimension of square matrices

# Create a batch of symmetric positive definite matrices for valid CG convergence
A = torch.randn(d1, k, k)
A = A @ A.transpose(1, 2)  # Make symmetric positive definite
A = A + torch.eye(k) * 0.5  # Ensure positive definiteness

# Create a batch of right-hand sides
b = torch.randn(d1, k)

# Create initial guess
x = torch.zeros(d1, k)

ARGS = {
    "A": A,
    "b": b,
    "x": x,
}
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
find_B_torch Ran
ran; our contract draft was wrong, not the code
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("21d15db8dac451ac")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 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)

# w: shape (d1, d2) - a weight matrix
# Alpha: shape (d1, n_bits) - a matrix used to compute v via matrix multiplication
# The function uses w.shape, w.device, w.view()
# The function uses Alpha.shape[-1] to get n_bits, Alpha.mm(bin_mat.t())

d1 = 2
d2 = 3
n_bits = 4

# Create w as a small weight matrix
w = torch.randn(d1, d2, dtype=torch.float32)

# Create Alpha as a matrix with shape (d1, n_bits)
# It will be multiplied with bin_mat.t() which has shape (2^n_bits, n_bits)
# So Alpha.mm(bin_mat.t()) will have shape (d1, 2^n_bits)
Alpha = torch.randn(d1, n_bits, dtype=torch.float32)

ARGS = {
    "w": w,
    "Alpha": Alpha,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 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
greedy_mean_torch Ran
ran; our contract draft was wrong, not the code
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("4b56b022f857caf8")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct a small weight tensor
# Shape: (batch_size=2, feature_dim=4)
w = torch.randn(2, 4)

# Optional weight factors tensor for weighted mean computation
# Shape: (batch_size=2, feature_dim=4) - same shape as w for element-wise multiplication
wf = torch.randn(2, 4).abs()  # Use abs to ensure positive weights

# Number of bits for quantization
n_bits = 2

ARGS = {
    "w": w,
    "n_bits": n_bits,
    "wf": wf,
}
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
greedy_mean_torch_asym Ran
ran; our contract draft was wrong, not the code
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("c187d2fb3f613894")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small weight matrix (d1=2, d2=4)
w = torch.randn(2, 4, dtype=torch.float32)

# Optional: create a weight factor tensor (same shape as w)
wf = torch.abs(torch.randn(2, 4, dtype=torch.float32)) + 0.1

# Number of bits for quantization
n_bits = 2

ARGS = {
    "w": w,
    "n_bits": n_bits,
    "wf": wf,
}
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
list_binary_vecs Ran
ran; our contract draft was wrong, not the code
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("52bd9d12c195e4e2")
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 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 numpy as np

torch.manual_seed(0)

def list_binary_vecs(n):
    ListBinaryVecs = {0: [[]]}
    for m in range(1, n + 1):
        ListBinaryVecs[m] = [[1.0] + l for l in ListBinaryVecs[m - 1]] + [[-1.0] + l for l in ListBinaryVecs[m - 1]]
    return ListBinaryVecs

ARGS = {
    "n": 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — 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
lp_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("ea5af2ff88120865")
How it ran

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

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create small tensors for pred and tgt
# Shape: (batch_size=2, features=4)
pred = torch.randn(2, 4)
tgt = torch.randn(2, 4)

# Define ARGS dict with all parameters
ARGS = {
    'pred': pred,
    'tgt': tgt,
    'p': 2.0,
    'reduction': 'none'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
refine_mean_torch Ran
ran; our contract draft was wrong, not the code
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("fbec1b688a62c155")
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 numpy as np

torch.manual_seed(0)

# Helper function from the code
def list_binary_vecs(n):
    ListBinaryVecs = {0: [[]]}
    for m in range(1, n + 1):
        ListBinaryVecs[m] = [[1.0] + l for l in ListBinaryVecs[m - 1]] + [[-1.0] + l for l in ListBinaryVecs[m - 1]]
    return ListBinaryVecs

# Small tensor dimensions: batch=2, d1=2, d2=4, n_bits=2
batch_size = 2
d1 = 2
d2 = 4
n_bits = 2

# w: shape (d1, d2) - weight matrix
w = torch.randn(d1, d2)

# w_hat: shape (d1, d2) - estimated weight matrix
w_hat = torch.randn(d1, d2)

# B: shape (d1, d2, n_bits) - binary basis vectors
B = torch.randint(0, 2, (d1, d2, n_bits)).float() * 2 - 1  # values in {-1, 1}

# Alpha: shape (d1, n_bits) - coefficients
Alpha = torch.randn(d1, n_bits)

# wf: shape (d1, d2) - weights/mask (optional, but we'll provide it)
wf = torch.ones(d1, d2)

# use_bst: boolean flag
use_bst = True

ARGS = {
    "w": w,
    "w_hat": w_hat,
    "B": B,
    "Alpha": Alpha,
    "wf": wf,
    "use_bst": use_bst,
}
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 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
refine_mean_torch_asym Ran
ran; our contract draft was wrong, not the code
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("cf4cd62ace9548d0")
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 numpy as np

torch.manual_seed(0)

# Small dimensions for testing
d1, d2, n_bits = 2, 4, 2

# Create w: shape (d1, d2)
w = torch.randn(d1, d2, dtype=torch.float32)

# Create w_hat_no_bias: shape (d1, d2)
w_hat_no_bias = torch.randn(d1, d2, dtype=torch.float32)

# Create B: shape (d1, d2, n_bits)
B = torch.randn(d1, d2, n_bits, dtype=torch.float32)

# Create Alpha: shape (d1, n_bits)
Alpha = torch.randn(d1, n_bits, dtype=torch.float32)

# Create beta: shape (d1,)
beta = torch.randn(d1, dtype=torch.float32)

# Create wf (optional, can be None or a tensor of shape (d1, d2))
wf = torch.randn(d1, d2, dtype=torch.float32)

# use_bst is a boolean
use_bst = True

ARGS = {
    'w': w,
    'w_hat_no_bias': w_hat_no_bias,
    'B': B,
    'Alpha': Alpha,
    'beta': beta,
    'wf': wf,
    'use_bst': use_bst
}
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 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
AnyBCQ Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("e0191fe4148769d4")
How it ran

no invocation recorded.

AnyBCQLinear Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("80d71ac7f84b5979")
How it ran

no invocation recorded.

BCQLinear Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("523211640563f229")
How it ran

no invocation recorded.

BCQLinearFunction Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("ff02617f4660c1c6")
How it ran

no invocation recorded.

CachedDataset Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("8eb99e60a176d56f")
How it ran

no invocation recorded.

DataCacheWrapper Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("854a59d470d67896")
How it ran

no invocation recorded.

GetLayerInpOut_q Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("628b9d1ac1377fd3")
How it ran

no invocation recorded.

GradientScale Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("f1d59376e6dff570")
How it ran

no invocation recorded.

add_onebit_linear_v2 Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("e33891668a082a3e")
How it ran

no invocation recorded.

add_onebit_model Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("eb0dda0ce920bfde")
How it ran

no invocation recorded.

quantize Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("121de7b5e46dc9b5")
How it ran

no invocation recorded.

replace_bcq_with_lutgemm Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("6f5c30c3f0c1890d")
How it ran

no invocation recorded.

save_alpha_and_beta_in_bcqlinear Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("1642689e1e80931a")
How it ran

no invocation recorded.

swap_quant_linear Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("58488365cdb5c810")
How it ran

no invocation recorded.

swap_quant_model Not yet run
unverified (harvested, no recorded run)
naver-aics/anybcq/anybcq/quantization/anybcq.py
code served (permissive licence) · get_code("e90f86e2354b96dd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 27 samples lifted from this paper's linked repositories, 27 carry a function identity and 0 do not. Of the 27 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 27 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.

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

Repositories linked to this paper

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

Abstract

The deployment of large language models (LLMs) is increasingly constrained by memory and latency bottlenecks, motivating the need for quantization techniques that flexibly balance accuracy and efficiency. Recent work has introduced multiprecision models, which enable inference at multiple precisions within a single model depending on runtime constraints. To support such flexibility, quantized weights are often stored as bit-planes, where hardware efficiency improves when the compute operates directly at the bit-plane level and activates only the precision required by each request. In this work, we present AnyBCQ, a hardware-friendly multi-precision extension of Binary-Coded Quantization (BCQ) that supports direct bit-plane operations. By representing weights as binary bit-planes with corresponding scale factors, AnyBCQ enables bit-plane-level computation and maps naturally to accelerator-friendly, bit-parallel arithmetic. Our progressive precision expansion mechanism incrementally refines scaling factors while reusing previously assigned binary codes, yielding monotonic improvements in accuracy as additional bits are enabled. We further co-design a specialized kernel that exploits the BCQ structure to support dynamic per-request precision selection with negligible overhead. Experiments on recent LLMs demonstrate that AnyBCQ significantly narrows the accuracy drop in the low-bit regime (e.g. 2-bit), remains competitive at higher precision, and achieves throughput gains of up to 3.0× over half precision and 1.2× over state-of-the-art multi-precision methods. By aligning algorithmic flexibility with hardware efficiency, AnyBCQ provides a practical foundation for multi-precision LLM deployment across diverse service-level objectives. The code is available at github.com/naver-aics/anybcq

For agents

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

get_harvested_code_for_paper("2510.10467")
get_code_for_paper("2510.10467")
have("2510.10467")

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

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

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

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

Connect an agent — have() is free.