apoapps commited on
Commit
3135154
·
verified ·
1 Parent(s): 614146b

Upload export_apochat_litert.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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
- base = name
225
- is_quantized = base in quantized
 
226
 
227
  if is_quantized:
228
- scales = weights[f"{base}.scales"]
229
- biases = weights[f"{base}.biases"]
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: