ml-explore / ml-explore/mlx-swift-examples

Help with using LoRA adapter weights on a converted Qwen2.5 model in MLX

Open
#262 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
2.7k
Forks
426
PR merge metrics
No merged PRs in 30d

Description

Hi team,
I’m currently using a Qwen2.5 model that was originally written in Python, which I’ve converted to run with MLX and integrated into a Swift app.
I’d like to use LoRA with it. When I try to load adapter_model.safetensors using LoRATrain.loadLoRAWeights, I get the following error:

unhandledKeys(base: "Qwen2Model", keys: ["base_model"])

Do I need to convert the adapter_model.safetensors file into an MLX-compatible format in order to use LoRA?
If so, could you advise on how to properly convert it?
For reference, the model appears to have been converted, but running LoRATrain.convert(...) didn’t seem to work as expected.

Thanks a lot in advance!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the unhandledKeys error at LoRATrain.loadLoRAWeights with the referenced adapter_model.safetensors file, then inspect how LoRATrain.convert handles the converted Qwen2.5 model and its Qwen2Model keys. Done means establishing whether the adapter requires conversion and documenting or correcting the loading path.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.