CompressedGemma commited on
Commit
fca1031
·
verified ·
1 Parent(s): 8a88d87

Qwen......

Browse files
Files changed (1) hide show
  1. 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 fused QKV tensor dims over n_embd/n_head
145
- # (Qwen 3.6 has n_embd=5120, n_head=24 non-integer ratio;
146
- # real head_dim=320, computed from QKV: 10240 / (24+2*4) = 320)
147
  head_dim = 0
148
- qkv_name = 'blk.0.attn_qkv.weight'
149
- if qkv_name in self.tensor_infos:
150
- qkv_cols = self.tensor_infos[qkv_name]['dims'][1] # output dim
151
- n_head_total = n_head + 2 * n_head_kv
152
- if n_head_total > 0:
153
- head_dim = qkv_cols // n_head_total
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