Repository: huggingface/transformers
Pull request: AutoAWQ tests 

# What does this PR do?

Fixes AutoAwq tests 

Changed files:
filename: conftest.py
patch: @@ -89,7 +89,7 @@ def pytest_configure(config):
     config.addinivalue_line("markers", "torch_compile_test: mark test which tests torch compile functionality")
     config.addinivalue_line("markers", "torch_export_test: mark test which tests torch export functionality")
 
-    os.environ['DISABLE_SAFETENSORS_CONVERSION'] = 'true'
+    os.environ["DISABLE_SAFETENSORS_CONVERSION"] = "true"
 
 
 def pytest_collection_modifyitems(items):

filename: src/transformers/activations.py
patch: @@ -51,6 +51,10 @@ def forward(self, input: Tensor) -> Tensor:
         return self.act(input)
 
 
+# Added for compatibility with autoawq which is archived now and imports PytorchGELUTanh from activations.py
+PytorchGELUTanh = GELUTanh
+
+
 @use_kernel_forward_from_hub("NewGELU")
 class NewGELUActivation(nn.Module):
     """

filename: tests/quantization/autoawq/test_awq.py
patch: @@ -109,8 +109,20 @@ class AwqTest(unittest.TestCase):
 
     input_text = "Hello my name is"
 
-    EXPECTED_OUTPUT = "Hello my name is Katie and I am a 20 year old student at the University of North Carolina at Chapel Hill. I am a junior and I am majoring in Journalism and minoring in Spanish"
-    EXPECTED_OUTPUT_BF16 = "Hello my name is Katie and I am a 20 year old student at the University of North Carolina at Chapel Hill. I am a junior and I am majoring in Journalism and minoring in Spanish"
+    EXPECTED_OUTPUT = set()
+    EXPECTED_OUTPUT.add(
+        "Hello my name is Katie and I am a 20 year old student at the University of North Carolina at Chapel Hill. I am a junior and I am majoring in Journalism and minoring in Spanish"
+    )
+    EXPECTED_OUTPUT.add(
+        "Hello my name is Katie and I am a 20 year old student at the University of North Carolina at Chapel Hill. I am a junior and I am majoring in Journalism and minoring in Spanish. I am"
+    )
+    EXPECTED_OUTPUT.add(
+        "Hello my name is Katie and I am a 20 year old student at the University of North Carolina at Chapel Hill. I am a junior and I am majoring in Exercise and Sport Science with a"
+    )
+
+    EXPECTED_OUTPUT_BF16 = [
+        "Hello my name is Katie and I am a 20 year old student at the University of North Carolina at Chapel Hill. I am a junior and I am majoring in Journalism and minoring in Spanish"
+    ]
 
     EXPECTED_OUTPUT_EXLLAMA = [
         "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",
@@ -181,7 +193,7 @@ def test_quantized_model(self):
         input_ids = self.tokenizer(self.input_text, return_tensors="pt").to(torch_device)
 
         output = self.quantized_model.generate(**input_ids, max_new_tokens=40)
-        self.assertEqual(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
+        self.assertIn(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
 
     def test_raise_if_non_quantized(self):
         model_id = "facebook/opt-125m"
@@ -199,7 +211,7 @@ def test_quantized_model_bf16(self):
         quantized_model = AutoModelForCausalLM.from_pretrained(self.model_name, dtype=torch.bfloat16).to(torch_device)
 
         output = quantized_model.generate(**input_ids, max_new_tokens=40)
-        self.assertEqual(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT_BF16)
+        self.assertIn(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT_BF16)
 
     @require_torch_gpu
     def test_quantized_model_exllama(self):
@@ -225,7 +237,7 @@ def test_quantized_model_no_device_map(self):
         quantized_model = AutoModelForCausalLM.from_pretrained(self.model_name).to(torch_device)
         output = quantized_model.generate(**input_ids, max_new_tokens=40)
 
-        self.assertEqual(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
+        self.assertIn(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
 
     def test_save_pretrained(self):
         """
@@ -238,7 +250,7 @@ def test_save_pretrained(self):
             input_ids = self.tokenizer(self.input_text, return_tensors="pt").to(torch_device)
 
             output = model.generate(**input_ids, max_new_tokens=40)
-            self.assertEqual(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
+            self.assertIn(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
 
     @require_torch_multi_accelerator
     def test_quantized_model_multi_accelerator(self):
@@ -249,11 +261,11 @@ def test_quantized_model_multi_accelerator(self):
 
         quantized_model = AutoModelForCausalLM.from_pretrained(self.model_name, device_map="auto")
 
-        self.assertTrue(set(quantized_model.hf_device_map.values()) == {0, 1})
+        self.assertTrue(len(set(quantized_model.hf_device_map.values())) >= 2)
 
         output = quantized_model.generate(**input_ids, max_new_tokens=40)
 
-        self.assertEqual(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
+        self.assertIn(self.tokenizer.decode(output[0], skip_special_tokens=True), self.EXPECTED_OUTPUT)
 
     def test_quantized_model_no_k_proj_quantized(self):
         """