Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoRA Qwen2 Error: non-default argument 'hidden_size' follows default argument #438

Closed
madroidmaq opened this issue Feb 13, 2024 · 4 comments · Fixed by #441
Closed

LoRA Qwen2 Error: non-default argument 'hidden_size' follows default argument #438

madroidmaq opened this issue Feb 13, 2024 · 4 comments · Fixed by #441
Labels
bug Something isn't working

Comments

@madroidmaq
Copy link
Contributor

I have encountered the following error message when fine-tuning a Qwen1.5 model with the latest mlx_lm (version 0.0.10), which was fine-tuned on version 0.0.9. The error message is as follows:
 

python -m mlx_lm.lora --model mlx-community/Qwen1.5-1.8B-Chat-4bit \
               --data /Users/madroid/Desktop/mlx-examples/lora/data/chat-im \
               --adapter-file qwen_adapters.npz \
               --lora-layers 16 \
               --batch-size 32 \
               --train \
               --test \
               --prompt "hello" \
               --iters 800
Loading pretrained model
Fetching 8 files: 100%|████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 92948.57it/s]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/homebrew/lib/python3.11/site-packages/mlx_lm/lora.py", line 171, in <module>
    model, tokenizer = load(args.model)
                       ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/mlx_lm/utils.py", line 278, in load
    model = load_model(model_path)
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/mlx_lm/utils.py", line 221, in load_model
    model_class, model_args_class = _get_classes(config=config)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/mlx_lm/utils.py", line 46, in _get_classes
    arch = importlib.import_module(f"mlx_lm.models.{model_type}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/homebrew/lib/python3.11/site-packages/mlx_lm/models/qwen2.py", line 10, in <module>
    @dataclass
     ^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 1027, in _process_class
    _init_fn(all_init_fields,
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 545, in _init_fn
    raise TypeError(f'non-default argument {f.name!r} '
TypeError: non-default argument 'hidden_size' follows default argument
@awni
Copy link
Member

awni commented Feb 13, 2024

Oops, I probably broke that in #426. I will send a fix shortly.

@awni awni added the bug Something isn't working label Feb 13, 2024
@awni awni mentioned this issue Feb 14, 2024
@awni awni closed this as completed in #441 Feb 14, 2024
@katopz
Copy link
Contributor

katopz commented Feb 17, 2024

@awni Not sure this released? It has been fixed in 0.0.11 am I right?

pip install mlx-lm=="0.0.11"
ERROR: Could not find a version that satisfies the requirement mlx-lm==0.0.11 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9.dev0, 0.0.9, 0.0.10)
ERROR: No matching distribution found for mlx-lm==0.0.11

Thanks

@awni
Copy link
Member

awni commented Feb 17, 2024

Sorry I didn't push a release to pypi yet! I will do so within the next day or two!

@awni
Copy link
Member

awni commented Feb 19, 2024

Should be fixed in the latest mlx lm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants