ADAPTIVE PRECISION STORAGE

ElasticBit

Experimental

Store only the precision a matrix actually needs.

Conventional quantization usually starts by choosing a target width — 8-bit, 4-bit, 3-bit — and then forcing weights into that budget. ElasticBit reverses the decision. It measures the output error of a matrix on representative inputs, finds thesmallest storage widththat satisfies the requested error threshold, packs the weights at that width, and uses the next supported compute precision when the matrix is executed.

4–32-bitError-boundedCompact storageCUDA runtime
StatusExperimental
Storage range4 → 32 bits
Selection ruleSmallest width within error target
RuntimeCompact / Fast CUDA

[ THE STORAGE PROBLEM ]

Compute keeps growing.
Model storage still has to fit somewhere.

Large models are expensive not only because they perform many operations, but because their weights must be downloaded, stored, moved into memory and repeatedly read. Quantization helps — but a single fixed bit-width gives every matrix the same precision budget even when their sensitivity is different.

FIXED-WIDTH QUANTIZATION

Choose the bit-width first.

444444

A predetermined 4-bit or 8-bit target is applied broadly. Modern methods can preserve quality remarkably well, but lower precision is still a lossy transformation and sensitivity is not uniform across a model.

ONE BUDGET → MANY MATRICES
IMPORTANT DISTINCTIONElasticBit does not prune parameters or shrink the architecture.

It changes how weights are represented. The current implementation chooses precision per matrix, not a different width for every individual scalar parameter. Quality preservation is threshold-controlled and must still be validated on the target model and dataset.

[ HOW IT WORKS ]

Analyze → choose → pack → promote → execute.

The core idea is to separate the precision needed forstoragefrom the precision that the runtime uses forarithmetic.

01Calibrate

Run representative input vectors through the original matrix so the analyzer has a functional reference.

02Sweep 4–32 bits

Measure candidate widths against the requested error threshold instead of assuming 4, 8 or 16 bits in advance.

03Select minimum

Keep the smallest width whose measured calibration error satisfies the target.

04Pack compactly

Intermediate widths use exact bit-packed integer payloads with row-wise symmetric scales.

05Promote to compute

At execution, storage is widened into the next supported compute bucket rather than forcing hardware to calculate at an awkward width.

[ STORAGE ≠ COMPUTE ]

A 9-bit model does not need
a mythical 9-bit ALU.

ElasticBit can store a matrix at an intermediate width while executing it through a precision class the hardware already understands. That decoupling is the practical bridge between compact representation and available compute.

STORAGE4-bitINT4 compute

Use the native 4-bit compute bucket.

STORAGE5–8-bitINT8 compute

Keep the packed width, widen for INT8 execution.

STORAGE9–16-bitFP16 compute

For example, 9-bit storage can execute through FP16.

STORAGE17–32-bitFP32 compute

Higher-precision fallback when the error target requires it.

FP32 SOURCEanalyze9-BIT STORAGEpromoteFP16 COMPUTEexecuteOUTPUT

[ VALIDATED RUNTIME SNAPSHOT / TESLA T4 ]

In the merge-gate matrix test,
the analyzer chose 9 bits.

This is a runtime validation snapshot, not a universal model-compression claim. The test used a 1024×512 matrix, a 0.01 calibration threshold and 100 benchmark iterations on swapped Tesla T4 GPUs.

SELECTED STORAGE9-bit

smallest width selected bybitsAnaliser

measured selected error: 0.003737
COMPACT WEIGHTS593,920 B

GPU/file weight payload

vs 1,048,576 B native FP16
STORAGE REDUCTION43.36%

less than the FP16 weight baseline

for this matrix and selected width
FAST MODE≈ FP16

runtime speed in this validation

fast layout widened to the FP16 compute bucket
COMPACT MODE

Keep the packed form resident.

RuntimeMatrix(..., "compact")retains the exact packed representation on GPU, maximizing memory reduction while the runtime handles conversion for execution.

FAST MODE

Trade memory for ready-to-run layout.

RuntimeMatrix(..., "fast")widens to the selected compute bucket ahead of execution. In the T4 snapshot it was roughly 25–27% faster than compact and essentially matched the FP16 baseline speed.

Evidence scope: synthetic runtime matrix validation from the final MLBricks dual-T4 merge gate. Storage savings, selected width and latency vary by matrix distribution, calibration inputs, threshold, GPU and model. Full-model quality must be measured after export.

[ QUANTIZATION RESEARCH CONTEXT ]

The field already knows
that not all weights are equally sensitive.

ElasticBit sits in a broader research direction where quantization decisions are informed by sensitivity or hardware constraints rather than blindly applying one precision everywhere. Its implementation makes a different engineering choice: search every integer storage width from 4 through 32, then decouple packed storage from the runtime compute bucket.

GPTQ · ICLR 2023

Second-order post-training quantization

GPTQ showed that large language models can be compressed to low fixed widths such as 3–4 bits with very small accuracy loss using approximate second-order information.

Read GPTQ ↗
AWQ · MLSYS 2024

Activation-aware protection

AWQ observes that weights are not equally important and uses activation statistics to protect salient channels while keeping a hardware-friendly low-bit weight format.

Read AWQ ↗
HAWQ-V3 · ICML 2021

Hardware-aware mixed precision

HAWQ-V3 treats bit precision as an optimization variable, balancing model perturbation with constraints such as memory footprint and latency.

Read HAWQ-V3 ↗

These projects are related by the general goal of preserving useful model behavior while reducing numerical cost. ElasticBit should not be described as the first adaptive or mixed-precision quantizer; its differentiator is the specific 4–32-bit storage-selection and storage/compute-decoupling runtime implemented by MLBricks.

[ CAPABILITIES ]

01

Threshold-driven bit analysis

bitsAnaliserevaluates candidate widths and returns the selected width, selected error, compute type and a report for every tested precision.

MEASURE BEFORE COMPRESSING
02

Per-matrix precision

The real-model exporter captures representative inputs for everynn.Linearmatrix and analyzes them independently instead of requiring one model-wide bit-width.

LOCAL SENSITIVITY
03

Compact & fast runtime modes

Keep packed weights for memory efficiency or widen them to the selected compute bucket when latency is the stronger requirement.

MEMORY ↔ SPEED
04

Save, load & reconstruct

Runtime matrices can be saved to the ElasticBit matrix format, loaded in compact or fast mode, dequantized for inspection, and benchmarked against native FP16.

DEPLOYMENT WORKFLOW

[ WHY IT MATTERS ]

Preserve precision where it earns its storage.

The objective is not “make everything 4-bit.” It is to stop paying 16 or 32 bits everywhere when a specific matrix can meet the desired error envelope with less.

Model distribution

Smaller weight files can reduce artifact size, download cost and local disk pressure for models that ship to many devices.

GPU memory headroom

Compact mode can keep packed representations resident, leaving more device memory for larger models, context, batches or other runtime state.

Quality-sensitive compression

A matrix can retain more than 4 or 8 bits when calibration shows that aggressive quantization would exceed the allowed error target.

Hardware-aware execution

Intermediate storage widths do not require matching arithmetic units: values are promoted into the next supported compute precision at runtime.

[ OPTIONAL NATIVE CUDA API ]

Analyze adaptive storage
when the native runtime is available.

The optional CUDA runtime exposes 4–32-bit analysis plus compact and fast runtime matrices. Use the portable API above when the native extension is not installed.

PYTHON
from mlbricks import ElasticBit

analysis = ElasticBit.bitsAnaliser(
    weights,
    calibration,
    threshold=0.01,
    min_bits=4,
    max_bits=32,
)

bits = analysis["selected_bits"]
matrix = ElasticBit.RuntimeMatrix(
    weights,
    bits,
    "compact",
)

y = matrix.forward(x)

[ RESEARCH STATUS ]

Compression is useful only
when the model still behaves correctly.

ElasticBit is experimental because bit selection is only one part of the deployment problem. Calibration coverage, end-to-end quality, kernel cost, hardware support and model-specific sensitivity all matter.

IMPLEMENTED

4–32-bit storage analysis

The analyzer sweeps candidate widths and reports measured calibration error, payload size and compute type.

IMPLEMENTED

CUDA RuntimeMatrix

Compact and fast runtime modes, save/load, dequantization, reference execution and native FP16 comparison are available.

IMPLEMENTED

Real-model linear export

Each PyTorch linear matrix can be calibrated independently and reconstructed for loss/perplexity evaluation.

VALIDATION REQUIRED

Model-level quality

An error threshold is not an unconditional quality guarantee. The exported model should be evaluated on the actual validation tasks that matter.

PLATFORM SCOPE

Linux + NVIDIA CUDA

The native 4–32-bit runtime currently targets CUDA builds withnvcc. MLBricks retains PyTorch-compatible ElasticLinear fallbacks separately.

RESEARCH DIRECTION

Storage-first deployment

Future work can explore broader model classes, calibration strategies, device architectures and end-to-end bandwidth/energy effects.

[ INSTALLATION · MLBRICKS KIT 1.0.0B1 ]

Install once.
Import frommlbricks.

This component ships inside the unifiedmlbricks-kitdistribution. Python imports continue to use themlbricksnamespace.

TERMINAL
pip install mlbricks-kit==1.0.0b1

[ API · MLBRICKS KIT 1.0.0B1 ]

Portable quantization first.
Native runtime when available.

The public package surface supports PyTorch-compatible tensor and module quantization in every install. The 4–32-bit CUDA runtime remains an optional native capability.

PORTABLE API
from mlbricks import ElasticBit

elastic = ElasticBit(
    bits=4,
    group_size=128,
    backend="auto",
)

packed = elastic.quantize(weights)
restored = elastic.dequantize(packed)
qlinear = elastic.linear(torch_linear)
quantize(tensor) / dequantize(...)

Pack a tensor and reconstruct it for inspection or fallback execution.

linear(layer) / embedding(layer)

Wrap PyTorch Linear or Embedding modules with packed ElasticBit storage.

quantize_module(...)

Convert supported modules across a larger PyTorch model.

set_backend(...) / resolved_backend()

Use the standard MLBricks backend surface.

ElasticBit.bitsAnaliser(...)

Optional native CUDA 4–32-bit analysis API when the native runtime is packaged.

ElasticBit.RuntimeMatrix(...)

Optional native compact/fast runtime matrix.

Portable vs native:the PyTorch-compatible ElasticBit surface does not require the optional native runtime.bitsAnaliserandRuntimeMatrixdo.

[ ELASTICBIT ]

Do not choose the bits.
Measure the need.

ElasticBit turns precision into a storage decision informed by observed model behavior — compact when it can be, higher precision when it needs to be, and mapped onto real compute formats when execution begins.