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

FEAT: Add possibility of skipping modules when quantizing #248

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

younesbelkada
Copy link
Collaborator

What does this PR do?

For some models (e.g., Whisper, Mixtral or Llava) it is important to skip some modules during quantization. This PR adds the experimental support for skipping modules during quantization with the following API.

from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer, AwqConfig

model_path = "facebook/opt-125m"
quant_path = "test-quant/opt-125m-awq-no-kproj"
modules_to_not_convert = ["k_proj"]

quant_config = {"zero_point": True, "q_group_size": 128, "w_bit": 4, "version":"GEMM", "modules_to_not_convert": modules_to_not_convert}

# Load model
model = AutoAWQForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)

# Quantize
model.quantize(tokenizer, quant_config=quant_config, modules_to_not_convert=modules_to_not_convert)

An example model has been pushed here: https://huggingface.co/ybelkada/opt-125m-awq-no-k-proj and works fine with a PR of transformers that I will open soon.

cc @casper-hansen @TheBloke

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