ml-explore / ml-explore/mlx-swift-examples
Help with using LoRA adapter weights on a converted Qwen2.5 model in MLX
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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