Wow Qwen......
Browse files- generate_imatrix.py +15 -3
generate_imatrix.py
CHANGED
|
@@ -811,10 +811,22 @@ class TransformerRunner:
|
|
| 811 |
qkv_for_ssm = normed @ qkv_w.T
|
| 812 |
self._record(f'{pfx}.ssm_conv1d.weight', qkv_for_ssm)
|
| 813 |
if ssm_out_w is not None:
|
| 814 |
-
# SSM output projection — use
|
| 815 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 816 |
self._record(f'{pfx}.ssm_out.weight', ssm_proxy)
|
| 817 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 818 |
|
| 819 |
# Combine attention + SSM
|
| 820 |
hidden = hidden + attn_out_vec + ssm_out_vec
|
|
|
|
| 811 |
qkv_for_ssm = normed @ qkv_w.T
|
| 812 |
self._record(f'{pfx}.ssm_conv1d.weight', qkv_for_ssm)
|
| 813 |
if ssm_out_w is not None:
|
| 814 |
+
# SSM output projection — use qkv output as proxy for recurrent output
|
| 815 |
+
# (qkv is 10240, ssm_out expects 6144)
|
| 816 |
+
if 'qkv' in locals() and qkv.shape[-1] >= ssm_out_w.shape[1]:
|
| 817 |
+
ssm_proxy = qkv[:, :ssm_out_w.shape[1]]
|
| 818 |
+
else:
|
| 819 |
+
# Fallback zero pad
|
| 820 |
+
ssm_proxy = np.zeros((seq_len, ssm_out_w.shape[1]), dtype=np.float32)
|
| 821 |
+
|
| 822 |
self._record(f'{pfx}.ssm_out.weight', ssm_proxy)
|
| 823 |
+
|
| 824 |
+
# Note: We do NOT need to actually add the SSM output vector to hidden
|
| 825 |
+
# for importance matrix calculation. We just need to record the inputs
|
| 826 |
+
# to all quantized layers. The actual output isn't critical since we
|
| 827 |
+
# aren't doing loss backprop. But if we do, it must match hidden's dimension.
|
| 828 |
+
if ssm_out_w.shape[0] == hidden.shape[-1]:
|
| 829 |
+
ssm_out_vec = ssm_proxy @ ssm_out_w.T
|
| 830 |
|
| 831 |
# Combine attention + SSM
|
| 832 |
hidden = hidden + attn_out_vec + ssm_out_vec
|