Skip to content

Commit e017e82

Browse files
fix rocm expectations for intervl
1 parent 5d2bdde commit e017e82

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

tests/models/internvl/test_modeling_internvl.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,14 @@ def test_qwen2_small_model_integration_batched_generate_multi_image(self):
430430
# Check first output
431431
decoded_output = processor.decode(output[0], skip_special_tokens=True)
432432
# Batching seems to alter the output slightly, but it is also the case in the original implementation. This seems to be expected: https://github.com/huggingface/transformers/issues/23017#issuecomment-1649630232
433-
expected_output = "user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature's peace." # fmt: skip
433+
expected_outputs = Expectations(
434+
{
435+
("xpu", 3): 'user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature\'s peace.',
436+
("cuda", 7): 'user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature\'s peace.',
437+
("rocm", (9, 4)): 'user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature\'s embrace.',
438+
}
439+
) # fmt: skip
440+
expected_output = expected_outputs.get_expectation()
434441
self.assertEqual(
435442
decoded_output,
436443
expected_output,
@@ -443,6 +450,7 @@ def test_qwen2_small_model_integration_batched_generate_multi_image(self):
443450
{
444451
("xpu", 3): "user\n\nWhat are the differences between these two images?\nassistant\nThe images show the Statue of Liberty and the Golden Gate Bridge from different angles. Here are the differences:\n\n1. **Foreground",
445452
("cuda", 7): "user\n\nWhat are the differences between these two images?\nassistant\nThe images show the Statue of Liberty and the Golden Gate Bridge from different angles. Here are the differences:\n\n1. **Foreground",
453+
("rocm", (9, 4)): "user\n\nWhat are the differences between these two images?\nassistant\nThe images show the Statue of Liberty and the Golden Gate Bridge from different angles. Here are the main differences:\n\n1. **",
446454
}
447455
) # fmt: skip
448456
expected_output = expected_outputs.get_expectation()
@@ -562,11 +570,13 @@ def test_qwen2_small_model_integration_interleaved_images_videos(self):
562570
output = model.generate(**inputs, do_sample=False, max_new_tokens=25)
563571

564572
decoded_output = processor.decode(output[0], skip_special_tokens=True)
573+
print("heeeere :", decoded_output)
565574
# Batching seems to alter the output slightly, but it is also the case in the original implementation. This seems to be expected: https://github.com/huggingface/transformers/issues/23017#issuecomment-1649630232
566575
expected_outputs = Expectations(
567576
{
568577
("xpu", 3): "user\n\n\nWhat are the differences between these two images?\nassistant\nThe images depict two distinct scenes:\n\n1. **Left Image:**\n - The Statue of Liberty is prominently featured on an",
569578
("cuda", 7): 'user\n\n\nWhat are the differences between these two images?\nassistant\nThe images depict two distinct scenes:\n\n1. **Left Image:**\n - The Statue of Liberty is prominently featured on an',
579+
("rocm", (9, 4)): 'user\n\n\nWhat are the differences between these two images?\nassistant\nThe images depict two distinct scenes:\n\n1. **Left Image:**\n - This image features the Statue of Liberty on Liberty',
570580
}
571581
) # fmt: skip
572582
expected_output = expected_outputs.get_expectation()
@@ -582,6 +592,7 @@ def test_qwen2_small_model_integration_interleaved_images_videos(self):
582592
{
583593
("xpu", 3): "user\nFrame1: \nFrame2: \nFrame3: \nFrame4: \nFrame5: \nFrame6: \nFrame7: \nFrame8: \nWhat type of shot is the man performing?\nassistant\nA forehand shot",
584594
("cuda", 7): 'user\nFrame1: \nFrame2: \nFrame3: \nFrame4: \nFrame5: \nFrame6: \nFrame7: \nFrame8: \nWhat type of shot is the man performing?\nassistant\nA forehand shot',
595+
("rocm", (9, 4)): 'user\nFrame1: \nFrame2: \nFrame3: \nFrame4: \nFrame5: \nFrame6: \nFrame7: \nFrame8: \nWhat type of shot is the man performing?\nassistant\nA forehand shot',
585596
}
586597
) # fmt: skip
587598
expected_output = expected_outputs.get_expectation()
@@ -593,9 +604,14 @@ def test_qwen2_small_model_integration_interleaved_images_videos(self):
593604

594605
# Check third output
595606
decoded_output = processor.decode(output[2], skip_special_tokens=True)
596-
expected_output = (
597-
"user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature's peace."
598-
)
607+
expected_outputs = Expectations(
608+
{
609+
("xpu", 3): 'user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature\'s peace.',
610+
("cuda", 7): 'user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature\'s peace.',
611+
("rocm", (9, 4)): 'user\n\nWrite a haiku for this image\nassistant\nSilky lake, \nWooden pier, \nNature\'s embrace.',
612+
}
613+
) # fmt: skip
614+
expected_output = expected_outputs.get_expectation()
599615
self.assertEqual(
600616
decoded_output,
601617
expected_output,
@@ -658,7 +674,7 @@ def test_llama_small_model_integration_forward(self):
658674
("xpu", 3): [-9.8828, -0.4954, 1.4561, -10.3438, -10.3438],
659675
("cuda", 7): [-9.8750, -0.4861, 1.4648, -10.3359, -10.3359],
660676
("cuda", 8): [-9.8906, -0.4995, 1.4473, -10.3359, -10.3438],
661-
("rocm", (9, 4)): [ -9.8828, -0.5005, 1.4697, -10.3438, -10.3438],
677+
("rocm", (9, 4)): [ -9.8672, -0.4888, 1.4648, -10.3281, -10.3281],
662678
("rocm", (9, 5)): [ -9.8906, -0.4976, 1.4502, -10.3359, -10.3438],
663679
}
664680
) # fmt: skip
@@ -934,7 +950,7 @@ def test_llama_small_model_integration_interleaved_images_videos(self):
934950
("xpu", 3): "user\n\n\nWhat are the difference between these two images?\nassistant\nI apologize for the confusion in my previous response. Upon closer inspection, the differences between the two images are:\n\n1. **",
935951
("cuda", 7): 'user\n\n\nWhat are the difference between these two images?\nassistant\nI apologize for the confusion in my previous response. Upon closer inspection, the differences between the two images are:\n\n1. **',
936952
("cuda", 8): 'user\n\n\nWhat are the difference between these two images?\nassistant\nI apologize for the confusion in my previous response. After re-examining the images, I can see that there are no',
937-
("rocm", (9, 4)): 'user\n\n\nWhat are the difference between these two images?\nassistant\nI apologize for the confusion in my previous response. Upon closer inspection, the differences between the two images are:\n\n1. **',
953+
("rocm", (9, 4)): 'user\n\n\nWhat are the difference between these two images?\nassistant\nI apologize for the confusion in my previous response. After re-examining the images, I can see that there are no',
938954
("rocm", (9, 5)): 'user\n\n\nWhat are the difference between these two images?\nassistant\nI apologize for the confusion in my previous response. After re-examining the images, I can see that there are no',
939955
}
940956
) # fmt: skip

0 commit comments

Comments
 (0)