Views
No views yet
q4_0 KV cache quantization, it allows pushing the context length up to 105k tokens.⚠️ Note: This model is designed exclusively for nVidia GPUs and is based on the advanced KS quants developed by ikawrakow from the ik_llama.cpp repository.
1# 1. Base Tensors & Embeddings
2^output\.weight$ -> iq5_k
3^output_norm\.weight$ -> f32
4^token_embd\.weight$ -> iq4_ks
5
6# 2. Exceptions (High precision for the first block's attention gate)
7^blk\.0\.attn_gate\.weight$ -> iq6_k
8
9# 3. Feed-Forward Networks (FFN)
10# Aggressive compression (iq4_kss) for middle blocks 5-51
11^blk\.([5-9]|[1-4][0-9]|50|51)\.ffn_(down|up)\.weight$ -> iq4_kss
12.*ffn_(down|up)\.weight$ -> iq4_ks
13.*ffn_gate\.weight$ -> iq4_ks
14
15# 4. Attention Layers
16.*attn_v\.weight$ -> iq5_ks
17.*attn_(qkv|q|k|output)\.weight$ -> iq4_kss
18.*attn_gate\.weight$ -> iq4_ks
19
20# 5. Mamba / SSM Layers
21.*ssm_out\.weight$ -> iq4_kss
22.*ssm_(alpha|beta)\.weight$ -> iq4_ks
23.*ssm_conv1d\.weight$ -> f32
24.*ssm_a$ -> f32
25.*ssm_dt\.bias$ -> f32
26
27# 6. All Normalization Layers (Kept in f32 for stability)
28.*norm\.weight$ -> f321# Hybrid Sandwich quantization — from quantize_hybrid_sandwich_logic_test29.sh
2# Pattern: alternating fused QKV (with SSM) / split QKV (no SSM) blocks
3# - Blocks n%4 == 0,1,2 (n<60): fused QKV + SSM
4# - Blocks n%4 == 3: split Q (iq4_kss) / K / V (iq5_ks) / output — no SSM
5# - Blocks 60-62: fused QKV + SSM (no iq4_kss FFN)
6# - Blocks 63: split QKV — no SSM
7
8# 1. Base Tensors & Embeddings
9^output\.weight$ -> iq5_k
10^output_norm\.weight$ -> f32
11^token_embd\.weight$ -> iq4_ks
12
13# 2. Exceptions — first blocks & tail blocks (higher precision gates)
14^blk\.0\.attn_gate\.weight$ -> q8_0
15^blk\.([1-2]|6[01])\.attn_gate\.weight$ -> iq6_k
16^blk\.62\.attn_gate\.weight$ -> q8_0
17
18# 3. Feed-Forward Networks (FFN)
19# Aggressive compression (iq4_kss) for middle blocks 4-59
20^blk\.([4-9]|[1-5][0-9])\.ffn_(down|up)\.weight$ -> iq4_kss
21.*ffn_(down|up)\.weight$ -> iq4_ks
22.*ffn_gate\.weight$ -> iq4_ks
23
24# 4. Attention Layers
25# 4a. Fused QKV blocks: 0-2, 4,8,12..56, 60-62
26^blk\.(([0-2])|([0-4][048])|(5[26])|(6[0-2]))\.attn_qkv\.weight$ -> iq4_ks
27
28# 4b. Split QKV blocks: 3,7,11,15..59,63
29^blk\.(([37])|([1-5][13579])|(63))\.attn_q\.weight$ -> iq4_kss
30^blk\.(([37])|([1-5][13579])|(63))\.attn_k\.weight$ -> iq4_ks
31^blk\.(([37])|([1-5][13579])|(63))\.attn_v\.weight$ -> iq5_ks
32^blk\.(([37])|([1-5][13579])|(63))\.attn_output\.weight$ -> iq4_ks
33
34# 4c. Default attention gate
35.*attn_gate\.weight$ -> iq4_ks
36
37# 5. Mamba / SSM Layers (only in fused QKV blocks)
38.*ssm_out\.weight$ -> iq4_ks
39.*ssm_(alpha|beta)\.weight$ -> iq4_ks
40.*ssm_conv1d\.weight$ -> f32
41.*ssm_a$ -> f32
42.*ssm_dt\.bias$ -> f32
43
44# 6. All Normalization Layers (Kept in f32 for stability)
45.*norm\.weight$ -> f32| Aspect | Original (test11) | New (test29) |
|---|---|---|
| Block 0 attn_gate | iq6_k | q8_0 |
| Blocks 1-2 attn_gate | iq6_k | iq6_k |
FFN iq4_kss range | blocks 5-51 | blocks 4-59 |
| Attention pattern | uniform iq4_kss for all qkv/q/k | alternating fused/split per block |
| Fused QKV blocks | — | iq4_ks (blocks 0-2, 4,8,12..56, 60-62) |
| Split Q blocks | iq4_kss (all) | iq4_kss (blocks 3,7,11..59,63 only) |
| Split V blocks | iq5_ks (all) | iq5_ks (blocks 3,7,11..59,63 only) |
SSM ssm_out | iq4_kss | iq4_ks |
| Blocks 60-62 | not specified | fused QKV + SSM, iq4_ks FFN |
| Block 62 attn_gate | — | q8_0 |
| Blocks 60-61 attn_gate | — | iq6_k |
q4_0), as this is the primary target use case:1wget [https://www.gutenberg.org/files/2600/2600-0.txt](https://www.gutenberg.org/files/2600/2600-0.txt) -O pg19.txt \
2
3./llama-perplexity -m Qwen3.6-27B.i1-IQ4_KS-attn_qkv-IQ4_KSS.gguf -f pg19.txt -c 65536 --chunks 32 -ngl 99 -khad -vhad -ctk q4_0 -ctv q4_0 -fa 1 -b 512 -ub 5121perplexity: calculating perplexity over 12 chunks, n_ctx=65536, batch_size=512, n_seq=1
2perplexity: 71.10 seconds per pass - ETA 14.22 minutes
3[1]6.6897,[2]7.0032,[3]7.1989,[4]7.3327,[5]7.4816,[6]7.3770,[7]7.4325,[8]7.4378,[9]7.4754,[10]7.5192,[11]7.5669,[12]7.4040,
4
5Final estimate: PPL over 12 chunks for n_ctx=65536 = 7.4040 +/- 0.02773./llama-perplexity -m Qwen3.6-27B.i1-IQ4_KS-attn_qkv-IQ4_KS.gguf -f /mnt/Samsung4TB/models/pg19.txt -c 65536 --chunks 32 -ngl 99 -khad -vhad -ctk q4_0 -ctv q4_0 -fa 1 -b 512 -ub 2561[1]6.6926,[2]7.0049,[3]7.2043,[4]7.3382,[5]7.4861,[6]7.3838,[7]7.4411,[8]7.4459,[9]7.4857,[10]7.5303,[11]7.5779,[12]7.4131,
2
3Final estimate: PPL over 12 chunks for n_ctx=65536 = 7.4131 +/- 0.02774| Test | Recipe | PPL (n_ctx=65536) | Margin of Error |
|---|---|---|---|
| test11 | Original v1 (attn_qkv-IQ4_KSS) | 7.4040 | +/- 0.02773 |
| test29 | Hybrid Sandwich v2 | 7.4131 | +/- 0.02774 |
llama-server. It utilizes the corrected chat template (chat.template) by ex-arman68, sourced from froggeric/Qwen-Fixed-Chat-Templates.1llama-server \
2 -m "$MODEL_PATH" \
3 -a Qwen3.6-27B \
4 --ctx-size 105000 \
5 --chat-template-file chat_template.jinja \
6 --n-gpu-layers 99 \
7 --cache-type-k q4_0 \
8 --cache-type-v q4_0 \
9 --batch-size 512 \
10 --ubatch-size 256 \
11 --flash-attn on \
12 --no-mmap \
13 --host 0.0.0.0 \
14 --port 8081 \
15 --reasoning on \
16 --reasoning-format deepseek \
17 -t 8 \
18 --parallel 1 \
19 -khad \
20 -vhad \
21 --chat-template-kwargs '{"preserve_thinking": true}' \
22 --defrag-thold 0.3 \
23 --jinja \
24 --cont-batching \
25 --temp 0.15 \
26 --top-k 1 \
27 --min-p 0.1 \
28 --keep -1 \
29 --repeat-last-n 512 \
30 --repeat-penalty 1.051llama-server \
2 -m "$MODEL_PATH" \
3 -a Qwen3.6-27B \
4 --ctx-size 50000 \
5 --chat-template-file chat_template.jinja \
6 --n-gpu-layers 99 \
7 -mtp \
8 --spec-type mtp \
9 --draft-n 3 \
10 --cache-type-k q4_0 \
11 --cache-type-v q4_0 \
12 --batch-size 512 \
13 --ubatch-size 256 \
14 --flash-attn on \
15 --no-mmap \
16 --host 0.0.0.0 \
17 --port 8081 \
18 --reasoning on \
19 --reasoning-format deepseek \
20 -t 8 \
21 --parallel 1 \
22 -khad \
23 -vhad \
24 --chat-template-kwargs '{"preserve_thinking": true}' \
25 --defrag-thold 0.3 \
26 --jinja \
27 --cont-batching \
28 --temp 0.15 \
29 --top-k 1 \
30 --min-p 0.1 \
31 --keep -1 \
32 --repeat-last-n 512 \
33 --repeat-penalty 1.05