Hy4-flash GGUF

GGUF quants of tencent/Hy4-flash (220B total, 12B active), text and vision, for llama.cpp master.

It fits on a single 96 GB GPU. The files look too big for one card, but a large part of each one is the Engram table: a per-token lookup table that is only read, never multiplied, so it stays in system RAM at no speed cost. Without it the Q2 quants need about 60 GB of GPU memory, the IQ3_XXS quants 65 and 72 GB, the Q3 quants about 77 GB and the IQ4_XS_XL 87 GB, and both the Q3_K_XL and the IQ4_XS_XL run on one RTX PRO 6000 with 256k context (q8_0 KV cache, 4 parallel slots) and the Engram table in RAM.

llama.cpp support

The hy_v4_flash architecture is supported on llama.cpp master since #32960, vision included. No fork, patch or extra branch is needed.

The GGUF files published before that merge, AngelSlim/Hy4-flash-GGUF and Xylolabs/Hy4-flash-GGUF, were produced for another pull request, #32517, which was closed without being merged. They do not follow the format of llama.cpp master: their text models carry no rope.dimension_sections, so master refuses to start vision with them, and AngelSlim's IQ2_AH does not load at all on master because its FP8 Engram table has no weight scale tensor.

Files

File Size Weights (VRAM/RAM) Engram (RAM/SSD)
Q8_0/ (2 parts) 232.8 GB 165.5 GB 67.3 GB
Q6_K_XL/ (2 parts) 209.2 GB 141.9 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q5_K_XL.gguf 184.1 GB 116.7 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q5_K_L.gguf 160.3 GB 116.7 GB 43.6 GB
Hy4-flash-220B-A12B-v1.0-Q4_K_XL.gguf 165.1 GB 97.8 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q4_K_L.gguf 141.3 GB 97.8 GB 43.6 GB
Hy4-flash-220B-A12B-v1.0-IQ4_XS_XL.gguf 154.3 GB 86.9 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q3_K_XL.gguf 143.8 GB 76.5 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q3_K_L.gguf 120.0 GB 76.5 GB 43.6 GB
Hy4-flash-220B-A12B-v1.0-IQ3_XXS_XXL.gguf 139.6 GB 72.2 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-IQ3_XXS_XL.gguf 132.2 GB 64.9 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q2_K_XL.gguf 127.2 GB 59.9 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q2_K_L.gguf 95.5 GB 59.9 GB 35.6 GB
mmproj-Hy4-flash-220B-A12B-v1.0-BF16.gguf 1.0 GB
kld_data/ 0.3 MB
BF16/ (4 parts) 438.8 GB
Hy4-flash-220B-A12B-v1.0-imatrix.gguf 810 MB

All quants except Q8_0 use the importance matrix of Xylolabs, the author of the first Hy4-flash GGUF quants, computed on 125 chunks of 512 tokens of calibration_datav3.txt, the calibration text bartowski publishes (by Dampf, built on Kalomaze's), as its imatrix.datasets metadata records. It is republished here unchanged as Hy4-flash-220B-A12B-v1.0-imatrix.gguf, with credit to Xylolabs. The per-tensor recipe of each quant is in layouts/ and can be passed to llama-quantize --tensor-type-file.

The Q4_K quants need 97.8 GB on the GPU and the Q5 quants 116.7 GB: they do not fit on a 96 GB card with any useful context and are for larger unified memory machines or several GPUs. The IQ4_XS_XL, with 86.9 GB on the GPU, is the best quant that fits a 96 GB card.

Usage

hf download Serveurperso/Hy4-flash-GGUF Hy4-flash-220B-A12B-v1.0-Q2_K_XL.gguf mmproj-Hy4-flash-220B-A12B-v1.0-BF16.gguf --local-dir Hy4-flash-GGUF

llama-server -m Hy4-flash-GGUF/Hy4-flash-220B-A12B-v1.0-Q2_K_XL.gguf --mmproj Hy4-flash-GGUF/mmproj-Hy4-flash-220B-A12B-v1.0-BF16.gguf -ot per_layer_token_embd=CPU --lazy-mode off -ngl 999 --jinja

-ot per_layer_token_embd=CPU keeps the Engram table in system RAM. It is read with get_rows, a few rows per token, so it costs no speed there.

Naming

File names follow the GGUF naming convention: <BaseName>-<SizeLabel>-<Version>-<Encoding>.gguf, here Hy4-flash, 220B-A12B, v1.0 and the quant recipe.

The recipe names follow bartowski's meaning of the _L and _XL suffixes, where the large embedding tables are kept at Q8_0. The Engram table is a per-layer token embedding table, so:

  • _XL (Q2 to Q6): Engram table in Q8_0.
  • Q2_K_L: Engram table in IQ4_NL, half the system RAM, everything else identical.
  • Q3_K_L to Q5_K_L: Engram table in Q5_0, everything else identical. From Q3 the experts are clean enough for the Engram error to show, and Q5_0 recovers about half of it for 8 GB more than IQ4_NL (see the Engram study below).

The Q2 to Q6 prefix gives the level of the routed experts, which hold most of the weights. In IQ4_XS_XL and IQ3_XXS_XL the prefix is the llama.cpp IQ type, used for all the routed experts (gate, up and down), and _XL keeps its usual meaning. IQ3_XXS_XXL is the larger IQ3_XXS: gate and up in IQ3_XXS, down one level up in IQ4_XS, for 7.3 GB more on the GPU. Above Q5 there is no _L: once the experts are precise, the Engram table becomes the main source of error, so it stays in Q8_0. Q8_0 is the plain llama.cpp Q8_0 of the whole model, made without imatrix because Q8_0 quantization does not use one.

The recipes (Aes Sedai / ddh0 style)

The routed experts are quantized at the named level, while everything that runs for every token keeps a high precision. This approach comes from the quants of Aes Sedai and ddh0, and was later used in Unsloth's dynamic quants. The high precision part follows Aes Sedai's rule: Q6_K for the low bit recipes, where the routed experts dominate the error, and Q8_0 with a BF16 output once the experts are precise enough for the rest of the model to show:

Tensors Q2_K, Q3_K IQ3_XXS, IQ4_XS, Q4_K to Q6_K stock Q2_K
attention, shared expert, routed FFN, indexer Q6_K Q8_0 Q2_K / Q3_K
attn_k_b, engram_kv Q8_0 Q8_0 Q4_0 / Q2_K
indexer compressor gate/value BF16 BF16 Q2_K
router, hyper-connections, indexer.proj, norms F32 F32 F32
token_embd Q6_K Q8_0 Q2_K
output Q6_K BF16 Q6_K

and differs only in the routed experts and the Engram table:

Recipe Experts gate/up Experts down Engram table Size Weights (VRAM/RAM) Engram (RAM/SSD)
Q8_0 Q8_0 Q8_0 Q8_0 232.8 GB 165.5 GB 67.3 GB
Q6_K_XL Q6_K Q8_0 Q8_0 209.2 GB 141.9 GB 67.3 GB
Q5_K_XL Q5_K Q6_K Q8_0 184.1 GB 116.7 GB 67.3 GB
Q5_K_L Q5_K Q6_K Q5_0 160.3 GB 116.7 GB 43.6 GB
Q4_K_XL Q4_K Q5_K Q8_0 165.1 GB 97.8 GB 67.3 GB
Q4_K_L Q4_K Q5_K Q5_0 141.3 GB 97.8 GB 43.6 GB
IQ4_XS_XL IQ4_XS IQ4_XS Q8_0 154.3 GB 86.9 GB 67.3 GB
Q3_K_XL Q3_K Q4_K Q8_0 143.8 GB 76.5 GB 67.3 GB
Q3_K_L Q3_K Q4_K Q5_0 120.0 GB 76.5 GB 43.6 GB
IQ3_XXS_XXL IQ3_XXS IQ4_XS Q8_0 139.6 GB 72.2 GB 67.3 GB
IQ3_XXS_XL IQ3_XXS IQ3_XXS Q8_0 132.2 GB 64.9 GB 67.3 GB
Q2_K_XL Q2_K Q3_K Q8_0 127.2 GB 59.9 GB 67.3 GB
Q2_K_L Q2_K Q3_K IQ4_NL 95.5 GB 59.9 GB 35.6 GB
stock Q2_K Q2_K Q3_K Q4_0 92.4 GB 56.8 GB 35.6 GB

Outside of the Engram table, the Q2_K_XL costs about 3 GB more than a stock Q2_K, spent on the tensors that every token goes through. From IQ3_XXS up, moving that part from Q6_K to Q8_0 with a BF16 output costs about 1.9 GB and lowers the mean KLD by 8% on the IQ4_XS_XL and by 12 to 25% on the Q4_K to Q6_K quants; on a Q3_K_XL test it changed the median by 9% and the mean not at all, so the Q2 and Q3 recipes keep Q6_K. The IQ4_XS_XL keeps its down experts in IQ4_XS instead of one level up, which keeps it under 96 GB of GPU memory.

Measurements by GPU weight size

Hy4-flash GGUF mean KL divergence and top token agreement against BF16, by weight size without the Engram table

This is the size that matters: the Engram table can stay in system RAM or on SSD without slowing the model down, so only the rest of the weights needs fast GPU or unified memory. On this axis an _L and its _XL sit at the same place, and the difference between them is quality bought with RAM only. The dashed line is a 96 GB GPU before the KV cache and the compute buffer, which is why the Q4_K quants at 97.8 GB do not fit with a useful context while the IQ4_XS_XL at 86.9 GB does. At the same GPU size, the IQ4_XS_XL is ahead of nace-ai's IQ4_XS-4.48bpw on every statistic. The nace-ai quants are measured with the same protocol, from the files as published. Both charts of this card are drawn by assets/make_charts.py from the logs in kld_data/.

Measurements

Hy4-flash GGUF mean KL divergence and top token agreement against BF16, by file size

KL divergence against the BF16 model on the llama.cpp documentation (230 KB, -c 4096, 12 chunks). The corpus is the 56 docs/*.md files of llama.cpp master: prose, shell commands and C++ and Python code, the kind of text this model is used for here, working on llama.cpp itself. The corpus, the exact commands and every raw log are in kld_data/.

Quant Engram Size Mean KLD Median KLD 90% KLD 99% KLD Same top token
Q8_0 Q8_0 232.8 GB 0.195 0.0045 0.18 4.82 90.7%
Q6_K_XL Q8_0 209.2 GB 0.203 0.0048 0.19 5.15 90.6%
Q5_K_XL Q8_0 184.1 GB 0.217 0.0060 0.23 5.52 89.7%
Q5_K_L Q5_0 160.3 GB 0.245 0.0061 0.25 6.28 89.5%
Q4_K_XL Q8_0 165.1 GB 0.272 0.0094 0.34 6.67 88.2%
Q4_K_L Q5_0 141.3 GB 0.293 0.0096 0.35 6.99 88.1%
IQ4_XS_XL Q8_0 154.3 GB 0.308 0.0115 0.40 7.00 87.3%
Q3_K_XL Q8_0 143.8 GB 0.439 0.0222 0.76 9.15 84.1%
Q3_K_L Q5_0 120.0 GB 0.453 0.0225 0.79 9.55 83.9%
IQ3_XXS_XXL Q8_0 139.6 GB 0.493 0.0283 0.91 9.61 82.8%
IQ3_XXS_XL Q8_0 132.2 GB 0.562 0.0358 1.14 10.27 81.4%
Q2_K_XL Q8_0 127.2 GB 0.745 0.0533 1.66 12.50 78.6%
Q2_K_L IQ4_NL 95.5 GB 0.756 0.0532 1.69 12.69 78.5%
Xylolabs IQ2_M-E4, as published IQ4_NL 91.9 GB 0.739 0.0573 1.69 11.91 78.3%
nace-ai IQ4_XS-4.48bpw, as published IQ4_NL 122.6 GB 0.346 0.0121 0.44 8.32 86.7%
nace-ai Q4_K_M, as published IQ4_NL 127.2 GB 0.383 0.0145 0.55 8.67 85.9%
nace-ai Q3_K_M-norm096, as published IQ4_NL 107.5 GB 0.540 0.0310 1.00 10.46 82.3%
nace-ai Q3_K_M, as published IQ4_NL 107.5 GB 0.577 0.0325 1.05 11.17 81.7%

Moving the routed experts from Q2 to Q3 cuts the median KLD by more than half and the mean by 40%, and Q4 halves the median again. The two IQ3_XXS quants fill the gap between Q2 and Q3 and are both above the line between them; at the same GPU size the IQ3_XXS_XXL is ahead of nace-ai's Q3_K_M-norm096 on every statistic. With the experts in IQ4_XS and the rest of the model in Q8_0, the IQ4_XS_XL is the best quant that fits a 96 GB GPU: against the Q3_K_XL it lowers the mean KLD by 30% and the median by 48% for 10.4 GB more on the GPU. At Q4 and Q5 the Engram table in Q5_0 instead of Q8_0 keeps the same median KLD and raises the mean by 8% and 13%, for 24 GB less RAM. The Q6_K_XL is within the error bars of the full Q8_0 (mean KLD 0.203 against 0.195, same top token 90.6% against 90.7%) for 23.6 GB less. The floor of the model is close: the Engram table alone in Q8_0, on an otherwise BF16 model, already gives 0.167 (see the Engram study below). At Q2 the Engram table in IQ4_NL costs nothing measurable, the experts dominate the error. At Q3 the Engram error starts to show, which is why the _L quants from Q3 use Q5_0 (see the Engram study below). Against the same Q2_K_XL recipe without imatrix (mean 0.796, median 0.0648, same top token 77.7%), the imatrix lowers the mean KLD by 6% and the median by 18%. The Q2_K_L and Xylolabs' IQ2_M-E4 are on par. AngelSlim's IQ2_AH could not be measured: it does not load on llama.cpp master.

The mean is dominated by a heavy tail that even Q8_0 shows: the sparse attention picks its blocks with a discrete top-k, so a small rounding difference can switch the selection. For the same reason perplexity is not a reliable quality measure on this model, and KLD against BF16 is the one to look at.

Engram table quant study

To measure the Engram table alone, the whole model is kept in BF16 and only per_layer_token_embd is quantized, in each of the types its 96 columns allow (Q8_0, Q5_0, IQ4_NL, Q4_0). The KLD against BF16 is then the error of the Engram table and nothing else.

Engram table Size Mean KLD Median KLD 90% KLD 99% KLD Same top token
Q8_0 67.3 GB 0.167 0.0035 0.15 4.02 91.7%
Q5_0 43.6 GB 0.212 0.0046 0.19 5.48 90.7%
IQ4_NL 35.6 GB 0.248 0.0051 0.22 6.69 89.9%
Q4_0 35.6 GB 0.262 0.0060 0.25 6.94 89.8%

Quantizing the Engram table alone to Q8_0 already gives most of the error of a full Q8_0 model (mean KLD 0.167 against 0.195): any small change to it switches some of the discrete top-k selections downstream. At the same size, IQ4_NL is better than Q4_0 (median KLD 15% lower), which is why the Q2_K_L uses it. Next to the routed experts at Q2 this error disappears, at Q3 it starts to show.

Performance work in progress

On Hy4-flash, decoding at long context is limited by millions of softmax and row sums over rows of 4 to 8 values in the sparse attention pooling, which the generic kernels run with one warp per row. Three pull requests run these short rows with one thread per row. Decoding speed with the Q2_K_XL, pull request against master:

  • CUDA #33187: on an RTX PRO 6000, 87.2 / 73.4 / 47.5 t/s at 8k / 32k / 107k context, against 66.2 / 38.8 / 17.0 on master.
  • Metal #33189: 31.7 / 25.0 t/s at 4k / 16k on an M5 Max, against 25.4 / 20.5.
  • Vulkan #33197: 59.5 / 54.8 t/s at 4k / 16k on an RTX PRO 6000, against 53.0 / 9.6.
Downloads last month
5,530
GGUF
Model size
219B params
Architecture
hy_v4_flash
Hardware compatibility
Log In to add your hardware

2-bit

3-bit

4-bit

5-bit

6-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Serveurperso/Hy4-flash-GGUF

Quantized
(82)
this model