Why convert at all
Most LLMs on Hugging Face are stored in PyTorch's safetensors format with PyTorch-shaped weight names. MLX wants the same weights but with MLX-shaped names and (often) quantization applied. mlx_lm.convert is the tool that reads a Hugging Face model and writes out a directory ready for mlx_lm.load.
The mlx-community Hugging Face org is full of pre-converted models — for popular base models you usually don't need to convert anything yourself. You convert when (1) the model you want isn't in mlx-community, (2) you want a specific quantization that nobody uploaded yet, or (3) you've fine-tuned a model and want to ship the result.
The single command
The CLI is a one-liner. Pull a Hugging Face model, convert it (optionally quantizing on the way), write to disk:
The flags worth knowing
--hf-path(alias--model) — the Hugging Face repo id (e.g.meta-llama/Llama-3.2-1B-Instruct) or a local directory.--mlx-path— where to write the MLX-format output. Defaults to a sensible path under the current directory.-q / --quantize— quantize the weights during conversion. Without this flag, you get the original precision (typically bf16/fp16).--q-bits— bits per weight (typically 4 or 8). Default is 4 when-qis set.--q-group-size— granularity of quantization. Smaller group size means better quality but larger file. Common values are 32, 64, 128.--q-mode— affine (the classic), or one of the newer MX formats (mxfp4,nvfp4,mxfp8) for hardware-accelerated inference on the right chips.--quant-predicate— mixed-precision recipe (e.g.mixed_3_4= some layers at 3-bit, others at 4-bit). Lesson 4 covers this.--dtype— for non-quantized weights, the dtype to save (float16,bfloat16,float32).--upload-repo— if set, pushes the converted model to a Hugging Face repo. Requireshuggingface-cli login.-d / --dequantize— go the other way; turn a quantized MLX model back into full-precision weights.--trust-remote-code— required for some models with custom modeling code (use carefully).
The silent-fail trap to know about
If the source model's config.json is missing a field mlx-lm needs (e.g. an unusual rope-scaling config, or a non-standard model_type value), conversion may complete, but loading fails later with a confusing key error. The defense is to test-load the converted model before trusting it: python -c "from mlx_lm import load, generate; m, t = load('./my-converted'); print(generate(m, t, prompt='hi', max_tokens=5))". Five seconds; saves an hour.