Upload export_apochat_litert.py with huggingface_hub
Browse files- export_apochat_litert.py +5 -4
export_apochat_litert.py
CHANGED
|
@@ -221,12 +221,13 @@ def dequantize_mlx_to_pytorch(
|
|
| 221 |
if name.endswith(".scales") or name.endswith(".biases"):
|
| 222 |
continue
|
| 223 |
|
| 224 |
-
|
| 225 |
-
|
|
|
|
| 226 |
|
| 227 |
if is_quantized:
|
| 228 |
-
scales = weights[f"{
|
| 229 |
-
biases = weights[f"{
|
| 230 |
# Dequantize to bfloat16 on the MLX device.
|
| 231 |
arr = mx.dequantize(arr, scales, biases, group_size=64, bits=4).astype(mx.bfloat16)
|
| 232 |
elif arr.dtype != mx.bfloat16:
|
|
|
|
| 221 |
if name.endswith(".scales") or name.endswith(".biases"):
|
| 222 |
continue
|
| 223 |
|
| 224 |
+
# The quantized group is the key prefix without the final `.weight`.
|
| 225 |
+
group_base = name[: -len(".weight")] if name.endswith(".weight") else name
|
| 226 |
+
is_quantized = group_base in quantized
|
| 227 |
|
| 228 |
if is_quantized:
|
| 229 |
+
scales = weights[f"{group_base}.scales"]
|
| 230 |
+
biases = weights[f"{group_base}.biases"]
|
| 231 |
# Dequantize to bfloat16 on the MLX device.
|
| 232 |
arr = mx.dequantize(arr, scales, biases, group_size=64, bits=4).astype(mx.bfloat16)
|
| 233 |
elif arr.dtype != mx.bfloat16:
|