From 81a2cfbda9bc04d26cdaef3a7bc27abd9b940279 Mon Sep 17 00:00:00 2001 From: Younes Belkada <49240599+younesbelkada@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:31:39 +0100 Subject: [PATCH] [`Awq`] Add peft support for AWQ (#28987) * add peft support for AWQ * Update src/transformers/quantizers/quantizer_awq.py Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> * fix --------- Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> --- src/transformers/quantizers/quantizer_awq.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/transformers/quantizers/quantizer_awq.py b/src/transformers/quantizers/quantizer_awq.py index 3e10730994968e..08342df175f7ca 100644 --- a/src/transformers/quantizers/quantizer_awq.py +++ b/src/transformers/quantizers/quantizer_awq.py @@ -11,8 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import importlib.metadata from typing import TYPE_CHECKING +from packaging import version + from .base import HfQuantizer @@ -105,6 +108,6 @@ def is_serializable(self): @property def is_trainable(self): - # AWQ does not support neither QAT (Quantization Aware Training or PEFT yet.) - # TODO: if this is supported in the future, do a version check here. - return False + # AWQ supports PEFT fine-tuning from version 0.2.0 + MIN_AWQ_VERSION_FOR_PEFT = "0.2.0" + return version.parse(importlib.metadata.version("autoawq")) >= version.parse(MIN_AWQ_VERSION_FOR_PEFT)