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

Add QK=128 q4_1 for GPTQ #937

Closed
wants to merge 11 commits into from
Closed

Add QK=128 q4_1 for GPTQ #937

wants to merge 11 commits into from

Conversation

qwopqwop200
Copy link

@qwopqwop200 qwopqwop200 commented Apr 13, 2023

Currently, GPTQ is converted to q4_1(QK=32) format. However, this is very inefficient considering that GPTQ generally recommends a QK value of 128.
And to solve this, I created a new q4_1 (qk=128) called q4_2.
Applying this gives an approximate 20% speed improvement and a 17% reduction in memory usage on GPTQ.
I'm sure this implementation will make llama run faster and more robustly.

Currently, I don't have an ARM cpu, so ARM may not work because I haven't tested the operation.

@qwopqwop200
Copy link
Author

qwopqwop200 commented Apr 13, 2023

make gptq model (not support act-order)
https://github.com/qwopqwop200/GPTQ-for-LLaMa
python llama.py ./llama-hf/llama-7b c4 --wbits 4 --true-sequential --groupsize 128 --save llama7b-4bit-128g.pt

use python 3.10

cd llama.cpp
make

# obtain the original LLaMA model weights and place them in ./models
ls ./models
tokenizer_checklist.chk tokenizer.model  llama7b-4bit-128g.pt

# install Python dependencies
python3 -m pip install -r requirements.txt

# convert the 7B model to ggml int4 format
python3 ./convert.py ./models/llama7b-4bit-128g.pt --outtype q4_2 --outfile ./models/llama7b-4bit-128g-ggjt.bin

# run the inference
./main -m ./models/llama7b-4bit-128g-ggjt.bin -n 128

do not force the prompt file to end with a new line (#908)
@ggerganov
Copy link
Member

Can you provide perplexity comparison between original Q4_1 quantization and the proposed one?

@qwopqwop200
Copy link
Author

Currently, some parts of my experiment seem to be wrong (set ctx=1024). In particular, the result of the current experiment is that the result is worse than that of Q4_1. Because of this, I will close the current issue.

Deadsg pushed a commit to Deadsg/llama.cpp that referenced this pull request Dec 19, 2023
jeroen-mostert pushed a commit to jeroen-mostert/llama.cpp that referenced this pull request Aug 30, 2024
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

Successfully merging this pull request may close these issues.

2 participants