Downloads · 30 days
66
39% of all-time downloads
apocryphx/gemma-4-31b-it-qat-q4-apml
gemma-4-31b-it-qat-q4-apml is a machine learning model from apocryphx. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for mlx. The card lists the license as gemma.
Replaced 2026-10-09. Revisions before this date held an MLX-affine group-64 quantization of the QAT weights (28% bit-exact, 95% top-1 vs bf16). This revision is the lattice-exact recipe below; the bundle layout and na…
Downloads · 30 days
66
39% of all-time downloads
All-time downloads
170
Public
Repo size
37.2 GB
Likes
0
Public
Click a slice to open those files.
.safetensors19.2 GB · 100%
From the Hugging Face model README
Replaced 2026-10-09. Revisions before this date held an MLX-affine group-64 quantization of the QAT weights (28% bit-exact, 95% top-1 vs bf16). This revision is the lattice-exact recipe below; the bundle layout and name are unchanged.
Gemma 4 31B instruction-tuned, Google's QAT-Q4 weights converted to the
Apertura .apml bundle format with the lattice-exact recipe: MLX-affine
4-bit, group size 32, where each block's scale is the QAT-learned step itself
(scale = d, bias = -8·d), so the 4-bit weights the kernel sees are the trained
lattice points — not a second, misaligned quantization of them. The tied
embedding / LM head sits on the same lattice and is stored exact at 4 bits.
tokenizer.json + chat_template.jinja included, runtime mlx, architecture gemma4.
Consumed by Apertura — an Objective-C++ transformer engine + macOS chat app on MLX.
google/gemma-4-31B-it-qat-q4_0-unquantized is bf16 weights that already sit on an
int4 lattice: per 32-element block, w = bf16(k·d) with codes k ∈ [-8, 7] and a
learned per-block step d. Running a min/max affine quantizer over that (as the
earlier revisions of this repo, group 64, did) picks a different
scale and zero point and lands most weights off their trained values — the same
failure Unsloth documented for naive Q4_0 GGUFs of these checkpoints. Here d is
recovered from the lattice structure per block and written as the affine scale.
Measured against the bf16 QAT checkpoint, over all 30.7 B quantized weights:
| recipe | bit-exact | within 1 bf16 ulp | top-1 vs bf16, 3 probes | top-1, 2176-tok prompt ×256 |
|---|---|---|---|---|
| affine g64 + Q8 head (previous bundle) | 28.3% | 33.4% | 57/60 | 243/256 |
| lattice g32 + exact Q4 head (this bundle) | 90.7% | 100.0000% | 60/60 | 255/256 |
The 9.3% that are not bit-identical differ by one bf16 rounding step: the checkpoint
stores bf16 roundings of k·d, so no single bf16 step reproduces every element. The
bundle and the checkpoint are two equally faithful bf16 renderings of the trained
lattice. Group 32 costs ~23% decode throughput vs group 64 on this model (Apertura
roadmap §3); fidelity was the aim.
weights/mlx-q4/quantization.json records lattice: qat-int4-g32 and the fit
statistics. Do not pass --quant-embed when loading: it would re-quantize the
exact 4-bit head.
hf download apocryphx/gemma-4-31b-it-qat-q4-apml --local-dir gemma-4-31b-it-qat-q4.apml
Gemma is provided under and subject to the
Gemma Terms of Use. By downloading this
model you agree to those terms, including the
Gemma Prohibited Use Policy.
This repository redistributes a quantized Model Derivative of
google/gemma-4-31B-it-qat-q4_0-unquantized; the same terms and use
restrictions apply to it and to any further derivatives.