Skip to content

LittleBit binary low-rank factorization

At a glance

LittleBit binary low-rank factorization of linear maps (see LittleBitConfig).

Registered name Family Saves Lossless Trainable Configuration
littlebit weight-compression weight memory no no LittleBitConfig

Backends (default configuration): transformers: real · gguf: no · mlx: no · onnx: no · sglang: no · trtllm: no · vllm: no

LittleBit (Lee et al., 2025) compresses weights below one bit per weight by combining a low-rank factorization with binarization. Every selected linear map of the decoder layers becomes sum_p diag(h_p) sign(U_p) diag(l_p) sign(V_p) diag(g_p): two binary factors per path, stored as packed sign bits, with three 16-bit scale vectors. With residual compensation (residual=True, the paper's default) a second path approximates the error of the first. The rank follows from the target bpw, signs and scales included, rounded down to rank_multiple. The embeddings, the norms and the LM head keep their dtype.

Two methods choose the factors. dual_svid is the paper's Dual-SVID initialization from the truncated SVD of each weight and reads no data. blockwise starts from it and then trains each decoder layer's latent factors and scales against the original layer's outputs on calibration data, with the SmoothSign surrogate gradient. The paper trains the whole model end to end, so blockwise is its short-budget, layer-local form. The result is lossy. The packed factors are the stored weights on transformers, and the forward runs a Triton binary GEMM on CUDA GPUs and an unpack-and-matmul reference elsewhere. The other backends have no binary low-rank kernel, and writing the product of the factors as a dense weight would discard the saving, so their exports refuse the technique. The technique rewrites the base model in place, so it cannot be detached.

Setup

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

import economize

device = "cuda" if torch.cuda.is_available() else "cpu"
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B", dtype=torch.bfloat16, device_map=device)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
ids = tokenizer("Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. "
                "How many clips did Natalia sell altogether?", return_tensors="pt").input_ids.to(device)

Training data is a flat file of uint32 token ids, the format of nanoGPT-style pretraining shards, and calibration data is a [N, S] tensor of token ids. Both are made here from GSM8K:

import numpy as np
from datasets import load_dataset

texts = [f"{row['question']}\n{row['answer']}" for row in load_dataset("openai/gsm8k", "main", split="train")]
tokens = np.concatenate([tokenizer(t + tokenizer.eos_token).input_ids for t in texts]).astype(np.uint32)
tokens[: len(tokens) * 9 // 10].tofile("train.bin")
tokens[len(tokens) * 9 // 10 :].tofile("val.bin")

calibration = torch.from_numpy(tokens[: 128 * 2048].astype(np.int64)).view(128, 2048)

LittleBit changes the base model, so measure the full-precision perplexity first:

from economize.train import fixed_windows

windows = fixed_windows("val.bin", 64, 1024).cuda()


@torch.no_grad()
def perplexity(model, windows):
    return torch.stack([model(w[None], labels=w[None]).loss for w in windows]).float().mean().exp().item()


dense_ppl = perplexity(base, windows)

Quick start

The data-free Dual-SVID initialization at 0.55 bits per weight:

from economize.techniques.littlebit import LittleBitConfig

model = economize.apply(base, LittleBitConfig(method="dual_svid", bpw=0.55))

summary = model.techniques["littlebit"].summary
print(summary["modules"], summary["bpw"])     # compressed maps, stored bits per weight
print(dense_ppl, perplexity(model, windows))

summary["bpw"] is the measured storage of all compressed maps, signs and scales included, and summary["ranks"] gives the rank of every map ("<layer>.<name>", 1-indexed layers). Without training, the quality at this budget is far from the dense model's.

Calibration and training

blockwise trains the factors of each layer in turn, for epochs passes over the calibration batches, with Adam at learning rate lr. sequential=True feeds every layer the outputs of the already compressed layers instead of the original model's:

base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B", dtype=torch.bfloat16, device_map="cuda")
model = economize.apply(base, LittleBitConfig(method="blockwise", bpw=0.55, epochs=2, lr=1e-4),
                        calibration=calibration)
print(perplexity(model, windows))

The trainable parameters exist only during this calibration. Afterwards the factors are packed, and nothing is left for economize.train.fit.

Saving and loading

model.save_pretrained stores the configuration, and economize.load runs the method again, which for blockwise means training again. save_factors writes the packed factors themselves, and LittleBitConfig(factors=...) loads them without calibration or training:

from economize.techniques.littlebit import save_factors

save_factors(model.adapter, "qwen-littlebit.safetensors")

base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B", dtype=torch.bfloat16, device_map="cuda")
model = economize.apply(base, LittleBitConfig(factors="qwen-littlebit.safetensors"))
print(perplexity(model, windows))

Combining with other techniques

LittleBit runs after pruning and low rank and before quantization, which then sees only the maps LittleBit did not replace. targets and exclude choose which maps are binarized. Here the MLP is binarized and the attention projections are quantized to int4:

from economize.techniques.quant import QuantConfig

print(economize.compatible("littlebit", "quant"))
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B", dtype=torch.bfloat16, device_map="cuda")
model = economize.apply(base, LittleBitConfig(bpw=1.0, targets=("mlp.*",)),
                        QuantConfig(format="int4", targets=("self_attn.*",)))
print(perplexity(model, windows))

A Hadamard rotation (rotate) is refused after LittleBit, because it would turn the binary factors back into dense maps.

Configuration

LittleBitConfig dataclass

LittleBitConfig(method: str = 'dual_svid', bpw: float = 1.0, residual: bool = True, targets: tuple[str, ...] = ('*',), exclude: tuple[str, ...] = (), layers: tuple[int, ...] = (), rank_multiple: int = 32, backend: str = 'triton', factors: str = '', epochs: int = 2, lr: float = 0.0001, accumulate: int = 1, smooth_k: float = 100.0, sequential: bool = False, offload: bool = False)

Replace linear maps of the decoder layers by LittleBit binary factorizations (Lee et al., NeurIPS 2025).

Every selected map becomes sum_p diag(h_p) sign(U_p) diag(l_p) sign(V_p) diag(g_p) stored with bit-packed signs and 16-bit scales (:class:~economize.techniques.littlebit.LittleBitLinear); the embedding and the LM head stay in their dtype, as in the paper.

Parameters:

Name Type Description Default
method str

Registered method: "dual_svid" (the paper's data-free initialization, the PTQ row) or "blockwise" (Dual-SVID, then quantization-aware training of each decoder layer's factors against the original layer's outputs on calibration data).

'dual_svid'
bpw float

Target bits per weight of every map, signs and scales included (the paper's 1.0, 0.55, 0.3, 0.1).

1.0
residual bool

Two paths with residual compensation (the paper's default) instead of one.

True
targets tuple[str, ...]

Globs over linear-module names inside a layer.

('*',)
exclude tuple[str, ...]

Globs removed from targets.

()
layers tuple[int, ...]

1-indexed layers to compress; empty means all.

()
rank_multiple int

Round every rank down to a multiple of this (32 fills whole sign words).

32
backend str

Registered :data:~economize.techniques.littlebit.LITTLEBIT_BACKENDS entry for the forward.

'triton'
factors str

Path of a file written by :func:~economize.techniques.littlebit.save_factors. When set, the stored factors are loaded instead of running method (no calibration needed).

''
epochs int

blockwise: passes over the calibration batches per layer.

2
lr float

blockwise: Adam learning rate of the latent factors and scales.

0.0001
accumulate int

blockwise: calibration batches per optimizer step.

1
smooth_k float

blockwise: slope of the SmoothSign surrogate gradient (the paper's 100).

100.0
sequential bool

blockwise: train each layer on the inputs that the already compressed layers produce (the targets stay the original layer's outputs on those inputs) instead of the original model's.

False
offload bool

Keep calibration activations on the CPU between layers.

False

paths property

paths: int

Number of binary paths (2 with residual compensation).

References

  • Lee, B., Kim, D., You, Y., & Kim, Y. (2025). LittleBit: Ultra low-bit quantization via latent factorization. In Advances in Neural Information Processing Systems. https://doi.org/10.48550/arXiv.2506.13771