Various test fixes for AMD (#39978)

* Add amd expectation in internvl

* Add amd expectation to llama

* Added bnb decorator for a llava test that requires bnb

* Added amd expectation for mistral3

* Style
This commit is contained in:
Rémi Ouazan
2025-08-07 10:57:04 +02:00
committed by GitHub
parent 6121e9e46c
commit 597ed1a11d
4 changed files with 19 additions and 19 deletions

View File

@@ -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)

View File

@@ -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):

View File

@@ -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)

View File

@@ -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