-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
FIX GPTQModel Lora Wrapper #2404
base: main
Are you sure you want to change the base?
Changes from 12 commits
f5ce3fa
65f9583
7bc4817
e0b069d
c5b07bb
7421210
9b77802
fbf909f
9caf45f
5531ddd
aa9f98c
14b87b4
05ebad6
1bd6f2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
get_peft_model, | ||
prepare_model_for_kbit_training, | ||
) | ||
from peft.tuners.lora import GPTQLoraLinear | ||
from peft.utils import SAFETENSORS_WEIGHTS_NAME, infer_device | ||
|
||
from .testing_utils import ( | ||
|
@@ -347,3 +348,30 @@ def test_non_default_adapter_name(self): | |
# sanity check | ||
assert n_trainable_default == n_trainable_other | ||
assert n_total_default == n_total_other | ||
|
||
@staticmethod | ||
Qubitium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def test_load_lora(): | ||
model_id = "ModelCloud/Llama-3.2-1B-gptqmodel-ci-4bit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a smaller model that could be used here? That would reduce the risk of getting a network timeout or full disk error on CI. If not, we can try how this one works out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anything below 1B have massive quantization errors and would cause inference to be highly unstable which cause ci tests to be wildly unstable too. Let's stick with 1B unless we get errors. |
||
adapter_id = "ModelCloud/Llama-3.2-1B-gptqmodel-ci-4bit-lora" | ||
|
||
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto") | ||
model.load_adapter(adapter_id) | ||
|
||
print("peft model", model) | ||
Qubitium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# assert dynamic rank | ||
v_proj_module = model.model.layers[5].self_attn.v_proj | ||
assert isinstance(v_proj_module, GPTQLoraLinear) | ||
assert v_proj_module.lora_A["default"].weight.data.shape[0] == 128 | ||
assert v_proj_module.lora_B["default"].weight.data.shape[1] == 128 | ||
gate_proj_module = model.model.layers[5].mlp.gate_proj | ||
assert isinstance(gate_proj_module, GPTQLoraLinear) | ||
assert gate_proj_module.lora_A["default"].weight.data.shape[0] == 256 | ||
assert gate_proj_module.lora_B["default"].weight.data.shape[1] == 256 | ||
|
||
tokenizer = AutoTokenizer.from_pretrained(model_id) | ||
inp = tokenizer("Capital of France is", return_tensors="pt").to(model.device) | ||
tokens = model.generate(**inp)[0] | ||
result = tokenizer.decode(tokens) | ||
|
||
print("result: ", result) | ||
Qubitium marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently problematic, as there is no gptqmodel release that satisfies this version requirement. Therefore,
is_gptqmodel_available
will always raise an error. Sinceis_gptqmodel_available
is called byrequire_auto_gptq
, even this check will always fail, meaning that our GPU tests cannot run at all.I think
require_auto_gptq
should be adjusted to not fail if the installed gptqmodel version is too low.