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, and the Q2_K_XL runs 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) 207.3 GB 139.9 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q5_K_XL.gguf 182.1 GB 114.8 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q5_K_L.gguf 158.3 GB 114.8 GB 43.6 GB
Hy4-flash-220B-A12B-v1.0-Q4_K_XL.gguf 163.1 GB 95.8 GB 67.3 GB
Hy4-flash-220B-A12B-v1.0-Q4_K_L.gguf 139.4 GB 95.8 GB 43.6 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-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
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 (calibration_datav3.txt, 125 chunks of 512 tokens). 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 256k context setup above is verified with the Q2_K_XL. The Q3 quants put 16.6 GB more on the GPU, so the context that fits next to them on a 96 GB card has not been measured yet. The Q4 quants need 95.8 GB on the GPU and the Q5 quants 114.8 GB: they do not fit on a 96 GB card with any useful context and are for larger unified memory machines or several GPUs.

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. 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 (Unsloth style)

The routed experts are quantized at the named level, while everything that runs for every token keeps a high precision, as in Unsloth's dynamic quants. Every recipe except Q8_0 shares the same high precision part:

Tensors All recipes stock Q2_K
attention, shared expert, routed FFN, indexer Q6_K Q2_K / Q3_K
attn_k_b, engram_kv Q8_0 Q4_0 / Q2_K
indexer compressor gate/value BF16 Q2_K
router, hyper-connections, indexer.proj, norms F32 F32
token_embd, output Q6_K Q2_K / 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 207.3 GB 139.9 GB 67.3 GB
Q5_K_XL Q5_K Q6_K Q8_0 182.1 GB 114.8 GB 67.3 GB
Q5_K_L Q5_K Q6_K Q5_0 158.3 GB 114.8 GB 43.6 GB
Q4_K_XL Q4_K Q5_K Q8_0 163.1 GB 95.8 GB 67.3 GB
Q4_K_L Q4_K Q5_K Q5_0 139.4 GB 95.8 GB 43.6 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
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.

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).

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 207.3 GB 0.270 0.0080 0.30 6.74 88.5%
Q5_K_XL Q8_0 182.1 GB 0.287 0.0089 0.33 6.95 88.0%
Q5_K_L Q5_0 158.3 GB 0.282 0.0088 0.33 6.63 88.3%
Q4_K_XL Q8_0 163.1 GB 0.329 0.0114 0.43 7.70 87.1%
Q4_K_L Q5_0 139.4 GB 0.332 0.0112 0.44 7.62 86.9%
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%
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%

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. At Q4 and Q5 the Engram table in Q5_0 and in Q8_0 give the same result within the error bars, so the _L quants save 24 GB of RAM for nothing measurable. Q5 lowers the mean KLD by another 15% against Q4, closer to the floor of the model: 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
-
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
(72)
this model