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

[quantize] All dimensions should be divisible by 32 for now #279

Closed
LMSPaul opened this issue Jan 10, 2024 · 1 comment
Closed

[quantize] All dimensions should be divisible by 32 for now #279

LMSPaul opened this issue Jan 10, 2024 · 1 comment

Comments

@LMSPaul
Copy link

LMSPaul commented Jan 10, 2024

Mlx doesn't seem to be working with quantizing with any model. I ran this command python convert.py --hf-path openchat/openchat-3.5-0106 -q

And I got this error Traceback (most recent call last): File "/Users/personal/Downloads/mlx-examples-main/lora/convert.py", line 89, in <module> weights, config = quantize(weights, config, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/personal/Downloads/mlx-examples-main/lora/convert.py", line 21, in quantize nn.QuantizedLinear.quantize_module(model, args.q_group_size, args.q_bits) File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/nn/layers/quantized.py", line 124, in quantize_module leaves = tree_map(_quantize_if_linear, leaves, is_leaf=Module.is_module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/utils.py", line 49, in tree_map return { ^ File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/utils.py", line 50, in <dictcomp> k: tree_map(fn, child, *(r[k] for r in rest), is_leaf=is_leaf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/utils.py", line 41, in tree_map return fn(tree, *rest) ^^^^^^^^^^^^^^^ File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/nn/layers/quantized.py", line 119, in _quantize_if_linear return cls.from_linear(m, group_size, bits) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/nn/layers/quantized.py", line 100, in from_linear ql = cls(input_dims, output_dims, False, group_size, bits) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/personal/Downloads/mlx-examples-main/lora/myenv/lib/python3.11/site-packages/mlx/nn/layers/quantized.py", line 58, in __init__ self.weight, self.scales, self.biases = mx.quantize(weight, group_size, bits) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: [quantize] All dimensions should be divisible by 32 for now

@awni
Copy link
Member

awni commented Jan 10, 2024

Quantization works with with many models but not all. Specifically if a model weight matrix dimension is not divisible by 32 then it will fail. This is on our roaadmap. I am closing as a dup of ml-explore/mlx#328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants