You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] MLX export/runtime pass transformers-5 rope_parameters to mlx-lm, which ignores it: exported Llama/Qwen2/Gemma run with rope_theta=10000 and no rope scaling #4607
Found on main @ 4b65923, CPU only (Linux, mlx-cpu 0.32.4, mlx-lm 0.32.2, transformers 5.22.1).
What is wrong
Any checkpoint that GPT-QModel saves under transformers 5 has its RoPE settings in the transformers-5 layout: config.json holds "rope_parameters": {"rope_theta": ..., "rope_type": "llama3", ...}, with no top-level rope_theta/rope_scaling. The MLX paths pass that config.json to mlx-lm unchanged:
GPTQModel.export(..., "mlx"): convert_gptq_to_mlx_weights -> _packed_mlx_weights builds mlx_config = deepcopy(load_config(model_path)) (gptqmodel/utils/mlx.py:340), and auto.py:1255save_config(mlx_config, ...) writes it out as is;
the Apple-Silicon runtime (GPTQModel.load(backend=MLX)) builds the MLX model from the same dict (utils/mlx.py:351, model_args_class.from_dict(mlx_config); the requant path is the same at :623-624).
Most mlx-lm architectures do not read rope_parameters: llama, qwen2, qwen3_moe, gemma2, gemma3_text, phi3, olmo2 and granite only know rope_theta (default 10000) and rope_scaling. Only a few, such as qwen3, understand the nested form. For those models, the exported or loaded MLX model silently runs with rope_theta=10000 and without the Llama-3 / YaRN scaling. That is a different positional encoding from the one the checkpoint was trained with. The packed weights themselves transfer exactly (per-layer dequantized max |dW| = 0), so the error comes entirely from the config.
Repro
Llama-3.2-1B-Instruct-AWQ-bit4-g128-symFasle-descFalse, a GPT-QModel AWQ checkpoint saved with transformers 5.5.3, whose config.json has rope_parameters:
The error grows with position, because RoPE frequency is the thing that is wrong.
Suggested fix
Before building the MLX model or writing the MLX config.json, normalize the RoPE fields to the layout mlx-lm reads: copy rope_parameters["rope_theta"] to top-level rope_theta, and the remaining non-default rope_parameters to rope_scaling (including per-layer-type dicts such as Gemma's {"full_attention": ..., "sliding_attention": ...}, which need model-specific mapping or a refusal). Keep rope_parameters for the models that read it. Add a test that exports a transformers-5-saved Llama and checks load(out)[0].args.rope_theta.
Severity: high for MLX users. Every Llama/Qwen2/Gemma checkpoint quantized by current GPT-QModel and then exported to MLX, or served by the MLX backend, gets the wrong positional encoding without any error.
Activity
Qubitium commentedon Nov 17, 2026
Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.
fix(mlx): translate transformers-5 rope_parameters into the keys mlx-…