qwen3-4b-instruct-2507-phi-lattice-v2-cashback
Two-stream phi-lattice v2 + cashback on EVERY weight of Qwen/Qwen3-4B-Instruct-2507.
Each of the 252 linear layers is the published
v2-gecko
4-bit stream (stream 1, byte-identical) plus a second 4-bit stream holding
the exact residual R = W_bf16 − unpack(stream1); the token embedding is a
two-stream cashback pair (742 → 394 MiB). The unpacked sum reconstructs BF16 at
a whole-model 38.91 dB SQNR (body
38.87 dB, embedding 39.38 dB).
RMSNorms stay BF16; lm_head remains tied to the embedding.
qwen3_4b_phi_v2_cashback_all_packed_4bit.pt is 4076.44 MiB (sha256 fb7a69c2ceb17698…) — 53.1% of the
7671.6 MiB BF16 model, vs 2583.2 MiB for gecko (which kept the
embedding in BF16 and approximated the body to ~99%).
The same construction was first validated end-to-end on gemma-3-270m-it (card): broken single-stream v2 → 100.3% of quantization damage repaired, all five metrics back to BF16 level.
All four benchmarks complete — every score below measured on this exact archive.
1. Why cashback: the embedding A/B (L4, 2026-11-20)
The naive single 4-bit snap of the embedding breaks PPL; adding the exact residual as a second 4-bit stream ("cashback") fully repairs it (raw JSON):
| Embedding variant | Bytes | SQNR vs BF16 | 6-text PPL |
|---|---|---|---|
| BF16 (gecko as published) | 741.9 MiB | — | 7.395 |
| plain 4-bit, one stream | 197.1 MiB | 19.68 dB | 7.712 (broken) |
| cashback, two streams | 394.1 MiB | 39.38 dB | 7.370 |
2. Downstream benchmarks (lm-eval, BF16, one engine for every column)
GGUF columns are llama.cpp standard tiers: Q4_K_M 2381.6 MiB (~4.5 bpw),
Q6_K 3153.1 MiB (~6.6 bpw), Q8_0 4082 MiB (~8.5 bpw); this repo is the ~8.7 bpw
tier — a size/quality point ABOVE 4-bit, at HALF of BF16.
| Task | Metric | BF16 Base | v2 (plain) | v2-gecko | Q4_K_M | Q6_K | Q8_0 | v2-cashback all weights (this repo) |
|---|---|---|---|---|---|---|---|---|
| MMLU (14,042) | acc | 70.63% | 68.06% | 69.02% | 69.40% | 70.53% | 70.50% | 70.55% |
| GSM8K (1,319) | strict-match | 85.90% | 83.93% | 85.06% | 84.84% | —* | 86.05% | 84.91% |
| HellaSwag (10,042) | acc | 52.56% | 50.64% | 51.04% | 52.23% | 52.49% | 52.57% | 52.42% |
| HellaSwag (10,042) | acc_norm | 69.05% | 67.19% | 67.36% | 68.39% | 68.97% | 69.10% | 69.08% |
| IFEval (541) | prompt_strict | 46.58%† | 45.47% | 46.95% | —* | —* | 46.40% | 47.32% |
| IFEval (541) | inst_strict | 60.31%† | 60.07% | 61.03% | —* | —* | 60.67% | 61.03% |
| IFEval (541) | prompt_loose | 54.53%† | 51.39% | 55.64% | —* | —* | 55.27% | 56.01% |
| IFEval (541) | inst_loose | 66.67%† | 64.87% | 67.87% | —* | —* | 67.63% | 67.99% |
*Generation tasks were not run on the Q4_K_M and Q6_K paths; Q4_K_M, Q6_K (fast tasks
only, evals/lm_eval_qwen_q6/) and size-matched Q8_0 numbers (evals/lm_eval_qwen_q8/) are from
q4km-bench on the same lm-eval engine.
†Generation tasks and stop tokens (corrected 2026-11-30). lm-eval calls model.generate() without an explicit
generation_config, so each column ran with its own stop-token list: the hub BF16 checkpoint stops at <|im_end|>
and <|endoftext|>, the rebuilt models (all built from config.json) at <|im_end|> only. In raw-completion mode
26% of IFEval generations and 83% of GSM8K generations end in <|endoftext|>; with the shorter list the generation
runs on past the answer — IFEval's strict checks see trailing text, GSM8K flexible-extract (last number) picks up
the wrong number. Same BF16 weights, only the stop list changed: GSM8K flexible-extract 85.33 → 16.00 on 150
problems, IFEval prompt_strict 58.33 → 45.83 on 48 prompts
(A/B JSON). The †BF16 IFEval cells are the like-for-like re-measurement
of the hub weights with the rebuilt models' stop list (all 541 prompts,
JSON); with the hub's own list the same weights
score 57.86 / 69.18 / 64.14 / 74.10. GSM8K is reported as strict-match only: it does not depend on the stop list
(BF16 86.67 with either list on 150 problems). flexible-extract does (BF16 83.85% with the hub list) and is left
out. MMLU and HellaSwag are loglikelihood tasks and are not affected.
Perplexity (WikiText-2, 16,383 tokens scored, ctx 2048 / stride 1024, bf16 weights, fp32-logits cross-entropy, identical token ids for every column; author's measurement, 2026-11-30): BF16 7.923, Q6_K 7.938, the 4+3 tier of this family 7.983 (Q6_K JSON, 4+3 JSON). The Q6_K GGUF was dequantized into the official HF architecture for scoring — the same engine as every column above; perplexity favors the lower-bit GGUF tier here, while the downstream benchmarks below are what the cashback construction targets.
BF16 / plain / gecko columns: provenance in the
gecko repo (evals/lm_eval_qwen_gecko/)
and q4km-bench. Raw JSONs for this
archive: evals/lm_eval_qwen_cashback_all/ in this repo.
3. Usage (phi_loader.py)
import importlib.util
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
repo_id = "ununununununununununununununununununun/qwen3-4b-instruct-2507-phi-lattice-v2-cashback"
loader_path = hf_hub_download(repo_id=repo_id, filename="phi_loader.py")
spec = importlib.util.spec_from_file_location("phi_loader", loader_path)
loader = importlib.util.module_from_spec(spec)
spec.loader.exec_module(loader)
# mode="low_vram_4bit": nibbles stay packed in RAM (~3.5 GiB, cashback included)
# mode="unrolled_bf16": unpacks all 398/398 tensors (incl. every cashback sum)
model = loader.load_qwen3_from_packed_4bit(
repo_id=repo_id,
mode="low_vram_4bit",
device="cuda" if torch.cuda.is_available() else "cpu",
dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(repo_id)
4. Second tariff: stream2 @ 3 bits (one container, two files)
Same stream1 (published gecko 4-bit, byte-identical), every cashback stream
re-snapped at 3 bits with an 8-level phi codebook. Whole-model SQNR 33.01 dB
(gate 32.0). qwen3_4b_phi_v2_cashback_all_s2_3bit.pt = 3596.9 MiB, 11.9%
smaller than Q8_0, quality unchanged (all five benchmarks, same lm-eval engine):
| Task | Metric | BF16 Base | Q8_0 (4082 MiB) | Q4_K_M (2382 MiB) | stream2@3bit (3597 MiB) |
|---|---|---|---|---|---|
| MMLU (14,042) | acc | 70.63% | 70.50% | 69.40% | 70.67% |
| GSM8K (1,319) | strict-match | 85.90% | 86.05% | 84.84% | 85.52% |
| HellaSwag (10,042) | acc / acc_norm | 52.56 / 69.05 | 52.57 / 69.10 | 52.23 / 68.39 | 52.30 / 69.01 |
| IFEval (541) | prompt_strict | 46.58%† | 46.40% | —* | 45.84% |
| IFEval (541) | prompt_loose | 54.53%† | 55.27% | —* | 54.34% |
*IFEval not run on the Q4_K_M path. †All five cells re-measured on 2026-11-29/30 with the audited loader: the first eval pass had an embed-decode bug in the loader (archive always valid; re-measured scores moved within ±1 stderr in both directions), caught by external audit, all runs replaced. Load with the same phi_loader.py
(provenance_s2_3bit.json, layout phi_lattice_v2_cashback_all_s2_3bit;
2/3-bit stream unpacking is bits-field driven, legacy 4-bit archives unaffected).
Residual bit-width, corrected 2026-11-30: 3 bits was picked on a small-model testbed whose 6-sentence PPL
protocol proved too small to rank variants. The 2-bit residual tier was then built and measured on this model:
qwen3_4b_phi_v2_cashback_all_s2_2bit.pt, 3117.5 MiB (23.6% smaller than Q8_0), whole-model SQNR 27.06 dB —
MMLU 70.10% (BF16-level) but HellaSwag 51.78 / 68.08%, about 1 point of acc_norm below BF16 (2 stderr):
the first tier with a visible loss. GSM8K and IFEval were not run on it (provenance_s2_2bit.json,
evals/lm_eval_qwen_cashback_s2_2bit/). †BF16 IFEval: see the stop-token note in section 2.
Raw JSONs: evals/lm_eval_qwen_cashback_s2_3bit/.