diff --git a/tests/models/internvl/test_modeling_internvl.py b/tests/models/internvl/test_modeling_internvl.py index 7b5d6a2905..4317cb3682 100644 --- a/tests/models/internvl/test_modeling_internvl.py +++ b/tests/models/internvl/test_modeling_internvl.py @@ -652,10 +652,11 @@ class InternVLLlamaIntegrationTest(unittest.TestCase): expected_logits_all = Expectations( { - ("xpu", 3): torch.tensor([-9.8750, -0.5703, 1.4297, -10.3125, -10.3125], dtype=torch.float16), - ("cuda", 7): torch.tensor([-9.8750, -0.4861, 1.4648, -10.3359, -10.3359], dtype=torch.float16), - ("cuda", 8): torch.tensor([-9.8906, -0.4995, 1.4473, -10.3359, -10.3438], dtype=torch.float16), - ("rocm", (9, 5)): torch.tensor([ -9.8906, -0.4976, 1.4502, -10.3359, -10.3438], dtype=torch.float16), + ("xpu", 3): [-9.8750, -0.5703, 1.4297, -10.3125, -10.3125], + ("cuda", 7): [-9.8750, -0.4861, 1.4648, -10.3359, -10.3359], + ("cuda", 8): [-9.8906, -0.4995, 1.4473, -10.3359, -10.3438], + ("rocm", (9, 4)): [ -9.8750, -0.4885, 1.4668, -10.3359, -10.3359], + ("rocm", (9, 5)): [ -9.8906, -0.4976, 1.4502, -10.3359, -10.3438], } ) # fmt: skip expected_logits = torch.tensor(expected_logits_all.get_expectation(), dtype=torch.float16) diff --git a/tests/models/llama/test_modeling_llama.py b/tests/models/llama/test_modeling_llama.py index a6c2c3eee2..0867a5a270 100644 --- a/tests/models/llama/test_modeling_llama.py +++ b/tests/models/llama/test_modeling_llama.py @@ -151,14 +151,16 @@ class LlamaIntegrationTest(unittest.TestCase): { ("xpu", 3): torch.tensor([[-6.5208, -4.1218, -4.9377, -3.2536, 0.8127, -2.9811, 1.2918, -3.3848]]), ("cuda", 7): torch.tensor([[-6.5061, -4.1147, -4.9669, -3.2038, 0.8069, -2.9694, 1.2864, -3.3786]]), - ("cuda", 8): torch.tensor([[-6.5208, -4.1218, -4.9377, -3.2536, 0.8127, -2.9811, 1.2918, -3.3848]]) - }) + ("cuda", 8): torch.tensor([[-6.5208, -4.1218, -4.9377, -3.2536, 0.8127, -2.9811, 1.2918, -3.3848]]), + ("rocm", (9, 4)): torch.tensor([[-6.5094, -4.1329, -4.9754, -3.5042, 0.8082, -2.9443, 1.2830, -3.3539]]), + }) - expected_mean = expected_means.get_expectation() + expected_mean = expected_means.get_expectation().to(torch_device) + actual_mean = out.logits.float().mean(-1) self.assertTrue( torch.allclose( - expected_mean.to(torch_device), - out.logits.float().mean(-1), + expected_mean, + actual_mean, atol=1e-2, rtol=1e-2 ) @@ -169,18 +171,13 @@ class LlamaIntegrationTest(unittest.TestCase): { ("xpu", 3): torch.tensor([[-12.5625, -7.1250, -0.6289, -7.8750, -6.9688, -7.8125, -6.5000, -7.4375, -7.6562, -6.9688, -6.0312, -7.0312, -1.8203, 1.8750, -8.5000]]), ("cuda", 7): torch.tensor([[-12.5000, -7.0625, -0.6289, -7.8750, -6.9688, -7.8125, -6.4688, -7.4375, -7.6875, -6.9375, -6.0312, -7.0000, -1.8594, 1.8438, -8.5000]]), - ("cuda", 8): torch.tensor([[-12.5625, -7.1250, -0.6289, -7.8750, -6.9688, -7.8125, -6.5000, -7.4375, -7.6562, -6.9688, -6.0312, -7.0312, -1.8203, 1.8750, -8.5000]]) + ("cuda", 8): torch.tensor([[-12.5625, -7.1250, -0.6289, -7.8750, -6.9688, -7.8125, -6.5000, -7.4375, -7.6562, -6.9688, -6.0312, -7.0312, -1.8203, 1.8750, -8.5000]]), + ("rocm", (9, 4)): torch.tensor([[-12.5000, -7.0625, -0.6289, -7.8750, -6.9688, -7.8125, -6.5000, -7.4375, -7.6562, -6.9375, -6.0312, -7.0312, -1.8594, 1.8438, -8.5000]]) }) # fmt: on - expected_slice = expected_slices.get_expectation() - self.assertTrue( - torch.allclose( - expected_slice.to(torch_device), - out.logits[0, 0, :15].float(), - atol=1e-2, - rtol=1e-2, - ) - ) + expected_slice = expected_slices.get_expectation().to(torch_device) + actual_slice = out.logits[0, 0, :15].float() + self.assertTrue(torch.allclose(expected_slice, actual_slice, atol=1e-2, rtol=1e-2)) @slow def test_model_7b_logits(self): diff --git a/tests/models/llava/test_modeling_llava.py b/tests/models/llava/test_modeling_llava.py index f8d61fb62b..095c8aecf1 100644 --- a/tests/models/llava/test_modeling_llava.py +++ b/tests/models/llava/test_modeling_llava.py @@ -476,6 +476,7 @@ class LlavaForConditionalGenerationIntegrationTest(unittest.TestCase): @slow @require_torch @require_vision + @require_bitsandbytes def test_batched_generation(self): model = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-7b-hf", load_in_4bit=True) diff --git a/tests/models/mistral3/test_modeling_mistral3.py b/tests/models/mistral3/test_modeling_mistral3.py index 4dfd539646..666997d4a5 100644 --- a/tests/models/mistral3/test_modeling_mistral3.py +++ b/tests/models/mistral3/test_modeling_mistral3.py @@ -317,6 +317,7 @@ class Mistral3IntegrationTest(unittest.TestCase): { ("xpu", 3): "The image features two cats resting on a pink blanket. The cat on the left is a kitten", ("cuda", 8): 'The image features two cats lying on a pink surface, which appears to be a couch or a bed', + ("rocm", (9, 4)): "The image features two cats lying on a pink surface, which appears to be a couch or a bed", ("rocm", (9, 5)): "The image features two tabby cats lying on a pink surface, which appears to be a cushion or" } ) # fmt: skip