ml-explore / mlx-examples

Examples in the MLX framework
MIT License
5.8k stars 824 forks source link

Lora example's `convert.py` throws `TypeError` because of `tuple[mx.array, mx.array]` #348

Open adhulipa opened 7 months ago

adhulipa commented 7 months ago

Description

I ran the following and observed an error

  1. Created a new condo env
    conda create -q -n mlx-examples python=3.8
    conda activate mlx-examples
  2. Ran pip install from lora dir pip install -r requirements.txt (from ..../mlx-examples/lora)
  3. Ran convert.py as convert.py --hf-path mistralai/Mistral-7B-v0.1 -q
  4. Observed the error
↪ python convert.py --hf-path mistralai/Mistral-7B-v0.1 -q                                                                                                                                           (mlx-examples)

Traceback (most recent call last):
  File "convert.py", line 8, in <module>
    import utils
  File "/Users/aditya_d/projects/mlx-examples/lora/utils.py", line 13, in <module>
    import models.phi2 as phi2
  File "/Users/aditya_d/projects/mlx-examples/lora/models/phi2.py", line 120, in <module>
    class Model(nn.Module):
  File "/Users/aditya_d/projects/mlx-examples/lora/models/phi2.py", line 131, in Model
    ) -> tuple[mx.array, mx.array]:
TypeError: 'type' object is not subscriptable
adhulipa commented 7 months ago

Seems like I need to use python 3.9 or newer? https://stackoverflow.com/questions/41535881/how-do-i-upgrade-to-python-3-6-with-conda

I upgraded my python env and that got sufficed for me.

I'll leave this issue open for mlx owners to decide best path forward. It seems like mlx may consider prescribing a python version for the lora example, or edit the convert.py script to be robust to slight version differences.

Hope this helps; else please pardon opening a nit/minor issue :)