From bd5c00b2888e372da94516eb94ce5d056c9ec8d3 Mon Sep 17 00:00:00 2001 From: IlyasMoutawwakil Date: Fri, 8 Mar 2024 18:36:53 +0100 Subject: [PATCH 1/4] fix gptq exllamav2 check --- optimum_benchmark/backends/pytorch/backend.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/optimum_benchmark/backends/pytorch/backend.py b/optimum_benchmark/backends/pytorch/backend.py index 87d53290..981e8baa 100644 --- a/optimum_benchmark/backends/pytorch/backend.py +++ b/optimum_benchmark/backends/pytorch/backend.py @@ -278,15 +278,13 @@ def is_awq_quantized(self) -> bool: def is_exllamav2(self) -> bool: return (self.is_gptq_quantized or self.is_awq_quantized) and ( ( - hasattr(self.pretrained_config, "quantization_config") - and hasattr(self.pretrained_config.quantization_config, "exllama_config") - and "exllama_version" in self.pretrained_config.quantization_config.exllama_config - and self.pretrained_config.quantization_config.exllama_config["exllama_version"] == 2 + getattr(self.pretrained_config, "quantization_config", None) is not None + and getattr(self.pretrained_config.quantization_config, "exllama_config", None) is not None + and self.pretrained_config.quantization_config.exllama_config.get("exllama_version", None) == 2 ) or ( - hasattr(self.quantization_config, "exllama_config") - and "exllama_version" in self.quantization_config.exllama_config - and self.quantization_config.exllama_config["exllama_version"] == 2 + self.config.quantization_config.get("exllama_config", None) is not None + and self.config.quantization_config.exllama_config.get("exllama_version", None) == 2 ) ) From dcd8b8a92ae3ae3b9e196b381f3ea18b01c5d5af Mon Sep 17 00:00:00 2001 From: IlyasMoutawwakil Date: Fri, 8 Mar 2024 18:36:53 +0100 Subject: [PATCH 2/4] fix gptq exllamav2 check --- optimum_benchmark/backends/pytorch/backend.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/optimum_benchmark/backends/pytorch/backend.py b/optimum_benchmark/backends/pytorch/backend.py index 87d53290..981e8baa 100644 --- a/optimum_benchmark/backends/pytorch/backend.py +++ b/optimum_benchmark/backends/pytorch/backend.py @@ -278,15 +278,13 @@ def is_awq_quantized(self) -> bool: def is_exllamav2(self) -> bool: return (self.is_gptq_quantized or self.is_awq_quantized) and ( ( - hasattr(self.pretrained_config, "quantization_config") - and hasattr(self.pretrained_config.quantization_config, "exllama_config") - and "exllama_version" in self.pretrained_config.quantization_config.exllama_config - and self.pretrained_config.quantization_config.exllama_config["exllama_version"] == 2 + getattr(self.pretrained_config, "quantization_config", None) is not None + and getattr(self.pretrained_config.quantization_config, "exllama_config", None) is not None + and self.pretrained_config.quantization_config.exllama_config.get("exllama_version", None) == 2 ) or ( - hasattr(self.quantization_config, "exllama_config") - and "exllama_version" in self.quantization_config.exllama_config - and self.quantization_config.exllama_config["exllama_version"] == 2 + self.config.quantization_config.get("exllama_config", None) is not None + and self.config.quantization_config.exllama_config.get("exllama_version", None) == 2 ) ) From 80c01f124c71cb60a18a58b47efe1f0f74e44441 Mon Sep 17 00:00:00 2001 From: IlyasMoutawwakil Date: Fri, 8 Mar 2024 18:36:53 +0100 Subject: [PATCH 3/4] fix gptq exllamav2 check --- optimum_benchmark/backends/pytorch/backend.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/optimum_benchmark/backends/pytorch/backend.py b/optimum_benchmark/backends/pytorch/backend.py index 87d53290..981e8baa 100644 --- a/optimum_benchmark/backends/pytorch/backend.py +++ b/optimum_benchmark/backends/pytorch/backend.py @@ -278,15 +278,13 @@ def is_awq_quantized(self) -> bool: def is_exllamav2(self) -> bool: return (self.is_gptq_quantized or self.is_awq_quantized) and ( ( - hasattr(self.pretrained_config, "quantization_config") - and hasattr(self.pretrained_config.quantization_config, "exllama_config") - and "exllama_version" in self.pretrained_config.quantization_config.exllama_config - and self.pretrained_config.quantization_config.exllama_config["exllama_version"] == 2 + getattr(self.pretrained_config, "quantization_config", None) is not None + and getattr(self.pretrained_config.quantization_config, "exllama_config", None) is not None + and self.pretrained_config.quantization_config.exllama_config.get("exllama_version", None) == 2 ) or ( - hasattr(self.quantization_config, "exllama_config") - and "exllama_version" in self.quantization_config.exllama_config - and self.quantization_config.exllama_config["exllama_version"] == 2 + self.config.quantization_config.get("exllama_config", None) is not None + and self.config.quantization_config.exllama_config.get("exllama_version", None) == 2 ) ) From 4eb8731c7c354966c95723ebd6b13dfdc7733a2f Mon Sep 17 00:00:00 2001 From: IlyasMoutawwakil Date: Wed, 13 Mar 2024 10:25:26 +0100 Subject: [PATCH 4/4] style --- optimum_benchmark/trackers/energy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/optimum_benchmark/trackers/energy.py b/optimum_benchmark/trackers/energy.py index 3161946a..750aa188 100644 --- a/optimum_benchmark/trackers/energy.py +++ b/optimum_benchmark/trackers/energy.py @@ -56,13 +56,13 @@ def __sub__(self, other: "Energy") -> "Energy": """Enables subtraction of two Energy instances using the '-' operator.""" if self.unit != other.unit: raise ValueError("Energy units must match to perform subtraction") - + return Energy( cpu=self.cpu - other.cpu, gpu=self.gpu - other.gpu, ram=self.ram - other.ram, total=self.total - other.total, - unit=self.unit + unit=self.unit, )