qwen2.5-coder-7b-instruct-phi-lattice-v2
4-bit phi-lattice v2 build of Qwen/Qwen2.5-Coder-7B-Instruct (7.62B parameters, 28 transformer layers, 6,525,288,448 quantized linear weights across 196 linear layers, 255 / 255 stored tensors).
lm_head and embed_tokens stay BF16. They are the token tables (tie_word_embeddings is false, so both are stored). Norms stay BF16.
qwen25_coder_7b_phi_v2_packed_4bit.pt(5,385.8 MiB) plusphi_loader.pyandphi_lut_gemm.py. The archive is true 4-bituint8nibbles plus fp16 group scales (3,306.0 MiBfor the 196 linears,2,079.8 MiBfor the BF16 token tables and norms).mode="low_vram_4bit"andmode="triton_4bit"keep that archive resident. Upstream BF16 shards are14.18 GiB.- The codebook used to unpack the nibbles is stored inside the archive as
codebook.
Archive sha256: 0a7aec0875ad28826b1d585f54d2e984b737b88ec857911cc7ef7b5d83cd5819 (5,647,392,174 bytes). Every quantized layer has K % 64 == 0.
1. Repository layout and memory
qwen2.5-coder-7b-instruct-phi-lattice-v2/
├── qwen25_coder_7b_phi_v2_packed_4bit.pt # 5,385.8 MiB packed archive (255/255 tensors)
├── phi_loader.py # low_vram_4bit, triton_4bit, unrolled_bf16
├── phi_lut_gemm.py # fused Triton 4-bit LUT-GEMM
├── run_text_evals.py # MMLU, GSM8K, IFEval, HellaSwag, one task at a time
├── config.json and tokenizer files
└── README.md
| Checkpoint | Disk | Resident | Linear weights (6.53B) | Versus upstream BF16 |
|---|---|---|---|---|
| Upstream BF16 shards | 14.18 GiB | 14.18 GiB | 12,446.3 MiB | 1.00x |
Packed 4-bit (low_vram_4bit / triton_4bit) | 5,385.8 MiB | 5,385.8 MiB | 3,306.0 MiB (3.76x) | 2.70x |
Two quality numbers appear below. They are different measurements.
The packed file in this repo scores 19.28 dB SQNR against the upstream tensors. Exact zeros in its indices: 886,957,441 (13.59%).
2. Crystallizer comparison, not the bytes in the file
This second number, 18.64 dB, is not a second reading of the archive. It is a separate in-memory comparison of phi-lattice v1, phi-lattice v2, and a uniform 4-bit quantizer on the original BF16 weights. Perplexity below is a sanity check on four short texts, not a benchmark. The is_prime sample is greedy and capped at 64 new tokens. NVIDIA L4.
| Method | 4-bit SQNR | 4-bit exact sparsity | Perplexity (4 texts) |
|---|---|---|---|
| Baseline BF16 | Reference | 0.00% | 14.995 |
| Uniform | 18.93 dB | 0.00% | 16.978 |
| phi-lattice v1 | 18.63 dB | 8.54% (557,537,535) | 16.437 |
| phi-lattice v2 | 18.64 dB | 8.54% (557,403,128) | 16.317 |
Unrounded, v2 is 18.6386 dB and v1 is 18.6326 dB, a difference of +0.006 dB. The zero counts differ by 134,407 weights, 0.002% of the 6.53B linears. The table rounds both SQNR figures to the same hundredth and both sparsities to 8.54%.
On Gemma 3 270M the same comparison moved SQNR: v2 19.48 dB, v1 18.65 dB (+0.83 dB), Uniform 18.69 dB (+0.79 dB). The gain depends on the architecture. On this coder it does not show up in SQNR.
The four-text perplexity moves the other way from SQNR. Uniform has the best SQNR (18.93 dB) and the worst perplexity (16.978). v2 pays about 0.3 dB of SQNR against Uniform, keeps the 8.5% zeros, and scores 16.317. SQNR by itself does not predict that gap. Baseline and v2 both started a correct is_prime. The v2 sample was cut at the 64-token cap.
Text benchmarks for this archive:
python3 run_text_evals.py --target qwen25-coder-base --task mmlu
python3 run_text_evals.py --target qwen25-coder-v2 --task mmlu
qwen25-coder-v2 unrolls this repo. qwen25-coder-base is Qwen/Qwen2.5-Coder-7B-Instruct. Omit --task to run MMLU, GSM8K, IFEval, and HellaSwag one at a time.
HumanEval
humaneval_instruct, greedy, chat template on, 164 tasks, pass@1. The file is evals/humaneval_qwen25_coder.json.
| Model | Run | pass@1 | stderr | solved |
|---|---|---|---|---|
Base Qwen/Qwen2.5-Coder-7B-Instruct | NVIDIA L4, BF16 | 0.8415 | 0.0286 | 138 / 164 |
| phi-lattice v2 | NVIDIA A100, archive unpacked to BF16 | 0.8537 | 0.0277 | 140 / 164 |
v2 solved two more tasks. The difference is 0.012, smaller than either stderr, so the scores sit inside the same error bar.
v2 was scored from unrolled_bf16: the packed archive is unpacked once, then generation matches the base run. low_vram_4bit dequantizes on every token and was not used for this number.
3. Quick start
PyTorch or Triton
import importlib.util
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
repo_id = "ununununununununununununununununununun/qwen2.5-coder-7b-instruct-phi-lattice-v2"
loader_path = hf_hub_download(repo_id=repo_id, filename="phi_loader.py")
spec = importlib.util.spec_from_file_location("phi_loader", loader_path)
phi_loader = importlib.util.module_from_spec(spec)
spec.loader.exec_module(phi_loader)
# "triton_4bit" fused LUT-GEMM on CUDA
# "low_vram_4bit" PyTorch dequant inside each linear
# "unrolled_bf16" unpacks all 255 tensors into BF16 linears
model = phi_loader.load_qwen25_coder_from_packed_4bit(
repo_id=repo_id,
mode="low_vram_4bit",
device="cuda",
dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(repo_id)
mode="triton_4bit" reads phi_lut_gemm.py from the same repo. Every packed layer has K % 64 == 0.