Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

FEAT: Add possibility of skipping modules when quantizing#248

Merged
casper-hansen merged 1 commit into
mainfrom
fix-release
Dec 11, 2023
Merged

FEAT: Add possibility of skipping modules when quantizing#248
casper-hansen merged 1 commit into
mainfrom
fix-release

Conversation

@younesbelkada

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants