Upload 3 files
Browse files- pipeline.py +6 -4
- q3_k.py +5 -3
pipeline.py
CHANGED
|
@@ -931,8 +931,9 @@ class Q2KQuantizer:
|
|
| 931 |
if seg_perm is not None:
|
| 932 |
from .segmentation import band_labels
|
| 933 |
|
| 934 |
-
|
| 935 |
-
|
|
|
|
| 936 |
labels_rec = band_labels(Xh, max(2, int(cfg.segment_k)))
|
| 937 |
res.stats.segment_rounds = seg_rounds
|
| 938 |
res.stats.segment_flips = int(np.count_nonzero(labels_rec != labels_slot))
|
|
@@ -1262,8 +1263,9 @@ class Q2KQuantizer:
|
|
| 1262 |
# mis-derive from the stored slot values
|
| 1263 |
from .segmentation import band_labels
|
| 1264 |
|
| 1265 |
-
|
| 1266 |
-
|
|
|
|
| 1267 |
labels_rec = band_labels(Xh, max(2, int(cfg.segment_k)))
|
| 1268 |
seg_flips = int(np.count_nonzero(labels_rec != labels_slot))
|
| 1269 |
|
|
|
|
| 931 |
if seg_perm is not None:
|
| 932 |
from .segmentation import band_labels
|
| 933 |
|
| 934 |
+
n_chk = min(n_blocks, 256)
|
| 935 |
+
Xh = np.stack([b.dequantize() for b in res.blocks[:n_chk]]).astype(np.float64)
|
| 936 |
+
labels_slot = np.take_along_axis(seg_labels[:n_chk], seg_perm[:n_chk], axis=1)
|
| 937 |
labels_rec = band_labels(Xh, max(2, int(cfg.segment_k)))
|
| 938 |
res.stats.segment_rounds = seg_rounds
|
| 939 |
res.stats.segment_flips = int(np.count_nonzero(labels_rec != labels_slot))
|
|
|
|
| 1263 |
# mis-derive from the stored slot values
|
| 1264 |
from .segmentation import band_labels
|
| 1265 |
|
| 1266 |
+
n_chk = min(n_blocks, 256)
|
| 1267 |
+
Xh = np.stack([b.dequantize() for b in blocks[:n_chk]]).astype(np.float64)
|
| 1268 |
+
labels_slot = np.take_along_axis(seg_labels[:n_chk], seg_perm[:n_chk], axis=1)
|
| 1269 |
labels_rec = band_labels(Xh, max(2, int(cfg.segment_k)))
|
| 1270 |
seg_flips = int(np.count_nonzero(labels_rec != labels_slot))
|
| 1271 |
|
q3_k.py
CHANGED
|
@@ -1064,10 +1064,12 @@ def quantize_tensor_q3_k(
|
|
| 1064 |
rmse = float(np.sqrt(total_sse / x.size))
|
| 1065 |
|
| 1066 |
if cfg.segment:
|
| 1067 |
-
|
| 1068 |
-
|
|
|
|
|
|
|
| 1069 |
)
|
| 1070 |
-
labels_slot = np.take_along_axis(seg_labels, seg_order, axis=1)
|
| 1071 |
labels_rec = band_labels(xh, max(2, int(cfg.segment_k)))
|
| 1072 |
seg_flips = int(np.count_nonzero(labels_rec != labels_slot))
|
| 1073 |
_log.info(
|
|
|
|
| 1064 |
rmse = float(np.sqrt(total_sse / x.size))
|
| 1065 |
|
| 1066 |
if cfg.segment:
|
| 1067 |
+
n_chk = min(n_blocks, 256)
|
| 1068 |
+
raw_chk = b"".join(chunks)[: n_chk * Q3_K_BLOCK_BYTES]
|
| 1069 |
+
xh = np.asarray(dequantize_q3_k_bytes(raw_chk, n_chk), dtype=np.float64).reshape(
|
| 1070 |
+
n_chk, QK3_K
|
| 1071 |
)
|
| 1072 |
+
labels_slot = np.take_along_axis(seg_labels[:n_chk], seg_order[:n_chk], axis=1)
|
| 1073 |
labels_rec = band_labels(xh, max(2, int(cfg.segment_k)))
|
| 1074 |
seg_flips = int(np.count_nonzero(labels_rec != labels_slot))
|
| 1075 |
_log.info(
|