make test_snowman_image_captioning pass on XPU, by sharing same atol w/ ROCM (#37480)

Signed-off-by: YAO Matrix <matrix.yao@intel.com>
Co-authored-by: Yih-Dar <2521628+ydshieh@users.noreply.github.com>
This commit is contained in:
Yao Matrix
2025-04-14 17:39:45 +08:00
committed by GitHub
parent 78cea3e22c
commit 47b9f06aa2

View File

@@ -28,6 +28,7 @@ from transformers import AutoModelForImageTextToText, AutoProcessor, Kosmos2Conf
from transformers.models.kosmos2.configuration_kosmos2 import Kosmos2TextConfig, Kosmos2VisionConfig from transformers.models.kosmos2.configuration_kosmos2 import Kosmos2TextConfig, Kosmos2VisionConfig
from transformers.testing_utils import ( from transformers.testing_utils import (
IS_ROCM_SYSTEM, IS_ROCM_SYSTEM,
IS_XPU_SYSTEM,
require_torch, require_torch,
require_vision, require_vision,
slow, slow,
@@ -655,7 +656,7 @@ class Kosmos2ModelIntegrationTest(unittest.TestCase):
processed_text = processed_text[0] processed_text = processed_text[0]
final_text, entities = final_text_with_entities[0] final_text, entities = final_text_with_entities[0]
atol = 1e-4 if IS_ROCM_SYSTEM else 1e-5 atol = 1e-4 if (IS_ROCM_SYSTEM or IS_XPU_SYSTEM) else 1e-5
np.testing.assert_allclose( np.testing.assert_allclose(
torch.concat(scores[1:4])[:3, :3].to("cpu").numpy(), torch.concat(scores[1:4])[:3, :3].to("cpu").numpy(),