ankahi / ankahi_bundle /mac_optimized /convert_to_mlx.py
bhriguverma's picture
Add files using upload-large-folder tool
b81150d verified
Raw
History Blame Contribute Delete
594 Bytes
import mlx_lm
import os
# This script converts the heavy 15GB 8-bit model to a
# 4-bit MLX model optimized for Apple Silicon (M1/M2/M3).
# Size will drop to ~8GB.
model_path = "../model"
output_path = "ankahi_mlx_4bit"
if not os.path.exists(output_path):
print(f"Converting {model_path} to 4-bit MLX...")
mlx_lm.convert(
hf_path=model_path,
mlx_path=output_path,
quantize=True,
q_group_size=64,
q_bits=4
)
print(f"Success! Optimized model saved to: {output_path}")
else:
print(f"Optimized model already exists at {output_path}")