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

mlx 0.13 very slow with q8 and fp16 #776

Open
ivanfioravanti opened this issue May 11, 2024 · 5 comments
Open

mlx 0.13 very slow with q8 and fp16 #776

ivanfioravanti opened this issue May 11, 2024 · 5 comments

Comments

@ivanfioravanti
Copy link
Contributor

ivanfioravanti commented May 11, 2024

I was testing the new quantize by @angeloskath with some Italian prompts that were failing with previous version and now are PERFECT! But while doing this I have seen extreme slowness with q8 and fp16 version.

I'm using meta-llama/Meta-Llama-3-70B-Instruct for test on M2 Ultra 192GB.

I created 3 conversions of it with:

mlx_lm.convert --hf-path meta-llama/Meta-Llama-3-70B-Instruct -q --q-bits 4 --mlx-path mlx_model_q4
mlx_lm.convert --hf-path meta-llama/Meta-Llama-3-70B-Instruct -q --q-bits 8 --mlx-path mlx_model_q8
mlx_lm.convert --hf-path meta-llama/Meta-Llama-3-70B-Instruct --mlx-path mlx_model_fp16

Then I tested generation with:

mlx_lm.generate --prompt "Write the story of Albert Einstein" --model mlx_model_q4
mlx_lm.generate --prompt "Write the story of Albert Einstein" --model mlx_model_q8
mlx_lm.generate --prompt "Write the story of Albert Einstein" --model mlx_model_fp16

q4 14.9 t/s (GPU >1300Mhz 115W)
q8 & fp16 0.4 t/s (GPU <1100Mhz peak 2W)

@ivanfioravanti
Copy link
Contributor Author

I tested on M3 Max and got same result. with even lower power consumption and GPU frequency. Really strange.

@awni
Copy link
Member

awni commented May 13, 2024

It's pretty slow for me also in 8-bit (and presumably 16 as well, but didn't test). Not sure why yet.

@awni
Copy link
Member

awni commented May 13, 2024

@ivanfioravanti just curious you phrased this issue as if it used to be faster in previous MLX versions. Is that the case?

@ivanfioravanti
Copy link
Contributor Author

Sorry for the delay I was out the whole week and happy to be back playing with MLX 🛝
I thought the issue was impacting all models using q8 but this is not the case. It seems issue is present with Llama 70B only.

  • Mistral-7B-Instruct-v0.2 works like a charm
  • mlx-community/dolphin-2.9.1-yi-1.5-34b-8bit works like a charm

Can this be related to model size? 70B? I will try comparing another large model.

@awni
Copy link
Member

awni commented May 20, 2024

Can this be related to model size? 70B?

Oh yes, it's almost certainly related to the size / amount of RAM required. There seems to be a performance cliff for very large models. It shouldn't be swapping because its still not using all the RAM on the machine but it does seem related to memory page demand. Still debugging.. this one might take a little while to iron out.

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