You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support quantization for non-multiples of 32. #328
Yes that's a known limitation of our quantization at the moment. Will mark this as an ehnancment.
In the meantime one thing you could do as a workaround so you aren't blocked by this is to concatenate the K and V projections and do them as a single matmul (112 * 2 / 32 = 7).
Yes that's a known limitation of our quantization at the moment. Will mark this as an ehnancment.
In the meantime one thing you could do as a workaround so you aren't blocked by this is to concatenate the K and V projections and do them as a single matmul (112 * 2 / 32 = 7).
Hi Awni, thanks for the reply. Would you be able to give a bit more detail about the workaround? By the way, happy new year! :)
I think (at least for the non-group axis) fixing this is mostly a matter of bounds checking in the matmul.. but @angeloskath can say more about if / when we could support more flexible quantization.
Reacted by Anchen, Sukkrit Sharma and Haitam el Attar
Activity
awni commentedon Dec 31, 2023
Yes that's a known limitation of our quantization at the moment. Will mark this as an ehnancment.
In the meantime one thing you could do as a workaround so you aren't blocked by this is to concatenate the K and V projections and do them as a single matmul (112 * 2 / 32 = 7).
mzbac commentedon Dec 31, 2023
Hi Awni, thanks for the reply. Would you be able to give a bit more detail about the workaround? By the way, happy new year! :)
awni commentedon Dec 31, 2023
Yes so there are two projections, one for the keys and one for the values.
Instead you could do something like:
Now you can pre compute the concatenated matrix and quantize it since its dimensions should be divisible by 32.
mzbac commentedon Jan 1, 2024
Thanks @awni , this workaround works. I have added it to the yayi2 example. :)
[-]Quantization failed for the yayi2 30b model [/-][+]Support quantization for non-multiples of 32.[/+]awni commentedon Jan 1, 2024
Nice.
I think (at least for the non-group axis) fixing this is mostly a matter of bounds checking in the matmul.. but @angeloskath can say more about if / when we could support more flexible quantization.
awni commentedon Jan 10, 2024
Aslo ml-explore/mlx-examples#279
awni commentedon Jan 19, 2024
@mzbac not sure you saw, in 0.0.10 this should be fixed. We can add yayi2 to mlx-lm now 😃
mzbac commentedon Jan 19, 2024
Nice, I will take a look. Hopefully, it just needs to be mapped to the llama arch and it will work.
awni commentedon Jan 19, 2024
Oh that would be amazing.
mzbac commentedon Jan 26, 2024
Please close this now as MLX supports non-32 dims quantization and I have tested it on the yayi2 model, and it works as expected.
DOC: tweak for correctness