Skip to content

Commit

Permalink
[tests] enable autoawq tests on XPU (#36327)
Browse files Browse the repository at this point in the history
add autoawq

Co-authored-by: Yih-Dar <[email protected]>
  • Loading branch information
faaany and ydshieh authored Feb 25, 2025
1 parent b4b9da6 commit c3700b0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/quantization/autoawq/test_awq.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, AwqConfig, OPTForCausalLM
from transformers.testing_utils import (
backend_empty_cache,
require_accelerate,
require_auto_awq,
require_intel_extension_for_pytorch,
require_torch_accelerator,
require_torch_gpu,
require_torch_multi_gpu,
slow,
Expand All @@ -37,8 +39,9 @@
from accelerate import init_empty_weights


@require_torch_gpu
@require_torch_accelerator
class AwqConfigTest(unittest.TestCase):
@require_torch_gpu
def test_wrong_backend(self):
"""
Simple test that checks if a user passes a wrong backend an error is raised
Expand Down Expand Up @@ -90,7 +93,7 @@ def test_from_dict(self):


@slow
@require_torch_gpu
@require_torch_accelerator
@require_auto_awq
@require_accelerate
class AwqTest(unittest.TestCase):
Expand All @@ -107,7 +110,7 @@ class AwqTest(unittest.TestCase):
"Hello my name is Katie and I am a 20 year old student from the UK. I am currently studying for a degree in English Literature and History at the University of York. I am a very out",
"Hello my name is Katie and I am a 20 year old student from the UK. I am currently studying for a degree in English Literature and History at the University of York. I am a very creative",
]
device_map = "cuda"
device_map = torch_device

# called only once for all test in this class
@classmethod
Expand All @@ -120,7 +123,7 @@ def setUpClass(cls):

def tearDown(self):
gc.collect()
torch.cuda.empty_cache()
backend_empty_cache(torch_device)
gc.collect()

def test_quantized_model_conversion(self):
Expand Down Expand Up @@ -475,7 +478,7 @@ def test_generation_mixtral_fused(self):


@slow
@require_torch_gpu
@require_torch_accelerator
@require_auto_awq
@require_accelerate
class AwqScaleTest(unittest.TestCase):
Expand All @@ -488,7 +491,7 @@ def test_load_quantized_model(self):
Simple test that checks if the scales have been replaced in the quantized model
"""
quantized_model = AutoModelForCausalLM.from_pretrained(
"TechxGenus/starcoder2-3b-AWQ", torch_dtype=torch.float16, device_map="cuda"
"TechxGenus/starcoder2-3b-AWQ", torch_dtype=torch.float16, device_map=torch_device
)
self.assertTrue(isinstance(quantized_model.model.layers[0].mlp.act, ScaledActivation))

Expand Down

0 comments on commit c3700b0

Please sign in to comment.