Qwen......
Browse files- generate_imatrix.py +9 -9
generate_imatrix.py
CHANGED
|
@@ -141,16 +141,16 @@ class GGUFModel:
|
|
| 141 |
n_head = self.kv.get(f'{arch}.attention.head_count', 0)
|
| 142 |
n_head_kv = self.kv.get(f'{arch}.attention.head_count_kv', 0)
|
| 143 |
|
| 144 |
-
# Auto-detect head_dim: prefer
|
| 145 |
-
# (Qwen 3.6 has
|
| 146 |
-
#
|
| 147 |
head_dim = 0
|
| 148 |
-
|
| 149 |
-
if
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
if
|
| 153 |
-
head_dim =
|
| 154 |
if head_dim == 0 and n_head > 0:
|
| 155 |
head_dim = n_embd // n_head
|
| 156 |
|
|
|
|
| 141 |
n_head = self.kv.get(f'{arch}.attention.head_count', 0)
|
| 142 |
n_head_kv = self.kv.get(f'{arch}.attention.head_count_kv', 0)
|
| 143 |
|
| 144 |
+
# Auto-detect head_dim: prefer derived from attn_gate over n_embd/n_head
|
| 145 |
+
# (Qwen 3.6 has hybrid 10240 QKV output but attn_gate requires 6144.
|
| 146 |
+
# 6144 / 24 heads = 256 real head_dim).
|
| 147 |
head_dim = 0
|
| 148 |
+
gate_name = 'blk.0.attn_gate.weight'
|
| 149 |
+
if gate_name in self.tensor_infos:
|
| 150 |
+
# attn_gate is [n_embd, n_head * head_dim]
|
| 151 |
+
gate_cols = self.tensor_infos[gate_name]['dims'][1] # input dim
|
| 152 |
+
if n_head > 0:
|
| 153 |
+
head_dim = gate_cols // n_head
|
| 154 |
if head_dim == 0 and n_head > 0:
|
| 155 |
head_dim = n_embd // n_head
|
| 156 |
|