From 54d57227036fb151e721c35726f8cc7f9c6cbf3a Mon Sep 17 00:00:00 2001 From: ydshieh Date: Sun, 31 Aug 2025 13:06:27 +0200 Subject: [PATCH 1/2] fix --- tests/test_modeling_common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_modeling_common.py b/tests/test_modeling_common.py index 21cb0fcf178e..b7812dc9d0f7 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -991,6 +991,10 @@ def test_determinism(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() def check_determinism(first, second): + # Simply don't compare if both tensors only contain `nan` elements + if torch.all(torch.isnan(first)) and torch.all(torch.isnan(second)): + return + out_1 = first.cpu().numpy() out_2 = second.cpu().numpy() out_1 = out_1[~np.isnan(out_1)] From af9bf5d3334338ae990cf218031a24126080467c Mon Sep 17 00:00:00 2001 From: ydshieh Date: Wed, 3 Sep 2025 17:16:45 +0200 Subject: [PATCH 2/2] fix --- tests/test_modeling_common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_modeling_common.py b/tests/test_modeling_common.py index 5f89eadcfd6b..98c095f96804 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -1002,6 +1002,7 @@ def test_determinism(self): def check_determinism(first, second): # Simply don't compare if both tensors only contain `nan` elements + # See: https://github.com/huggingface/transformers/pull/40661 if torch.all(torch.isnan(first)) and torch.all(torch.isnan(second)): return