QUF: Quantized Unified Format
QUF is a single-file container (.quf) for a 4-bit quantized decoder-only LLM. One file holds the model config, tokenizer files, quantization scheme and all tensors. This package provides a reference writer and reader, a native GPTQ converter, a runtime with CPU and CUDA backends, and a benchmark suite.
QUF runs natively on Windows (and any platform with PyTorch). No WSL or Linux environment is needed.
Supported architectures: Qwen2ForCausalLM (first), with Qwen3ForCausalLM addable through the architecture allow-list. Weights are 4-bit, group size 128, packed 8 per int32, with fp16 scales. Embeddings and lm_head stay fp16.
Quickstart
pip install quf
quf convert Qwen/Qwen2.5-0.5B out.quf
quf run out.quf --prompt "The capital of France is" --max-new-tokens 32 --temperature 0
quf bench out.quf --out results.json
quf convert needs the convert extra: pip install "quf[convert]".
Status: what is and is not verified
| Component | Status |
|---|---|
| Format writer/reader, quantizer, packer, CPU backend | Implemented. Covered by the CPU test suite. |
Native GPTQ converter (quf convert) |
Verified on native Windows with Qwen/Qwen2.5-0.5B (docs/RESULTS.md). |
torch_gpu backend on RTX 5080 Laptop (compute capability 12.0) |
Verified: quf run and quf bench work on CUDA with a real converted Qwen2.5-0.5B. |
torch_fused backend |
Verified, but slower than torch_gpu on this GPU (uses less memory). |
| gigatoken on Windows | Verified: gigatoken 0.11.0 installs and runs, 36.8x faster than HF tokenizers on WikiText-2 with identical ids. |
| Perplexity target (3 percent) | Measured and missed on Qwen2.5-0.5B: +8.47% and +7.41% over fp16. |
| Marlin backend | Optional, never selected automatically, not verified on this hardware. |
Details are in docs/ENV.md and docs/RESULTS.md.
Installation
Requires Python 3.10 or newer.
pip install quf # core: format, quantizer, runtime (torch is a base dependency)
pip install "quf[cuda]" # same as core; kept so the extra name resolves
pip install "quf[convert]" # adds transformers, datasets, accelerate, gigatoken, tokenizers,
# safetensors, huggingface_hub for `quf convert`
pip install "quf[test]" # pytest and hypothesis
From a source checkout, use pip install . and the same extras.
The quf console script is installed with the package. Run quf --help to list subcommands: info, convert, run, bench.
For a CUDA build of PyTorch on an RTX 50-series GPU, install a CUDA 12.8 wheel (the version recorded in ENV.md is 2.11.0+cu128). With no GPU, everything works on CPU.
Convert
quf convert loads a Hugging Face Qwen checkpoint with transformers and quantizes it with QUF's own GPTQ implementation (4 bit, group size 128). It runs on native Windows, Linux and macOS.
quf convert Qwen/Qwen2.5-0.5B out.quf
quf convert ./local-model out.quf --dataset calib.txt --samples 128 --seq-len 512 --seed 0
Options: --dataset (text file, wikitext config or HF dataset id; default wikitext-2-raw-v1), --samples (128), --seq-len (512), --seed (0), --overwrite. The command prints the output size and compression ratio. It refuses to replace an existing output unless --overwrite is given, rejects unsupported architectures before heavy work, and deletes a partial file if conversion fails.
Inspect the result:
quf info out.quf
This prints the model config, quantization scheme, tensor count and file size. A corrupt file exits with status 1 and an error message.
Run
quf run out.quf --prompt "Hello" --max-new-tokens 64 --temperature 0
Options: --max-new-tokens (64), --temperature (0 means greedy), --top-k, --top-p, --seed (0), --no-stream, --device {auto,cpu,cuda} (auto), --backend {auto,cached,fused,marlin} (auto), --prefer-fused.
Backends:
cpu: used when no NVIDIA GPU is present.torch_gpu(--backend cached): dequantizes weights to fp16 at load. Default on GPU when the weights fit in free GPU memory.torch_fused(--backend fused): keeps packed int4 on the GPU. Chosen automatically when the cached weights do not fit, or with--prefer-fused.marlin: optional, only with--backend marlin, never automatic. Unverified on this hardware.
The choice and its reason are logged to stderr. --device cuda without an NVIDIA GPU exits with status 1. A prompt that exceeds the context length and GPU out-of-memory also exit with status 1.
Benchmark
quf bench out.quf --out results.json
quf bench out.quf --out results.json --fp16-ref Qwen/Qwen2.5-0.5B --gguf model-q4.gguf --device auto
The results JSON records WikiText perplexity, file size, tokens per second, backend, device name and software versions. With --fp16-ref, the relative perplexity increase over fp16 is printed next to the documented target of at most 3 percent. The target is reported, not enforced, and was missed on Qwen2.5-0.5B (see below). --gguf adds a GGUF Q4 comparison. An lm-evaluation-harness adapter is in quf/bench/lm_eval_adapter.py.
Measured results
Qwen/Qwen2.5-0.5B, converted natively on Windows (4 bit, group size 128), RTX 5080 Laptop GPU, PyTorch 2.11.0+cu128, WikiText-2 raw. Full details and raw JSON: docs/RESULTS.md.
| Metric | Value |
|---|---|
| fp16 perplexity | 13.07 |
| QUF perplexity (32 x 512 calibration) | 14.18 (+8.47%) |
| QUF perplexity (128 x 1024 calibration) | 14.04 (+7.41%) |
| 3% target | Missed (+7 to +8%) |
| File size | 469,483,072 bytes, about 2.1x smaller than fp16 weights (about 988 MB). Embeddings and lm_head stay fp16, which limits the ratio on a small model. |
| Decode, CPU | 9.6 tokens/s |
Decode, RTX 5080 torch_gpu (default) |
20.7 tokens/s |
Decode, RTX 5080 torch_fused |
9.1 tokens/s (slower, less memory) |
| gigatoken vs HF tokenizers | 0.23 s vs 8.44 s (36.8x, identical ids) |
The cause of the perplexity gap was not investigated. Qwen2.5-1.5B was not run. Speeds are single measurements and the decode loop is not optimized.
Documentation
- docs/FORMAT.md: byte layout, header fields, tensor naming, dtypes and the canonical Packed_Int4 order.
- docs/ENV.md: environment results for native Windows and the backend selection rules.
- docs/RESULTS.md: measured accuracy, size and speed.
README.md, docs/ENV.md and docs/FORMAT.md ship with the package: they are in the source distribution and are installed to share/doc/quf by the wheel.
Tests
pytest -m "not gpu and not convert" # CPU suite, no NVIDIA GPU needed
pytest -m gpu # needs an NVIDIA GPU
pytest -m convert # needs the convert extra and downloads a model
Tests marked gpu are skipped automatically when no NVIDIA GPU is available.
Links and license
Source and issues: https://github.com/vtrsharvin-sj/Quantized-Model-Format
Released under the MIT license. See LICENSE.
Metadata
Release files for quf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quf-0.1.0.tar.gz | 79.2 kB | Without provenance | Details for quf-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for quf-0.1.0-py3-none-any.whl |
Total release size: 142.0 kB
Release files / quf-0.1.0.tar.gz
| Download URL | quf-0.1.0.tar.gz |
|---|---|
| Size | 79.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c27fe20a440cadb1baf80fd3ab7ef78b1dbd1081eda32f05d15b1f5fdf0c6fde
|
|
BLAKE2b-256 checksum How to use checksums |
9bb6964e56413f406d04d07a75f6941c3ac8ce2e3a7b2b5eb9ef3edbd1899dee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0rc2
|
Release files / quf-0.1.0-py3-none-any.whl
| Download URL | quf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 62.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7daa1003d741a2e8fbe37a8bc228ae7a0a4d7c754d17850edcb10cc1049296c
|
|
BLAKE2b-256 checksum How to use checksums |
a0b76e12f7efc9cc93c8e2b4cc74b7071642311340f87a02e0414659fd90e2a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0rc2
|
Security for quf 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.