From b298747f825a1482ed1a1ba9661810c589861d83 Mon Sep 17 00:00:00 2001 From: yucai-intel <108388355+yucai-intel@users.noreply.github.com> Date: Tue, 11 Nov 2025 16:52:00 +0800 Subject: [PATCH 1/5] Update test_nn_xpu.py --- test/xpu/test_nn_xpu.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/xpu/test_nn_xpu.py b/test/xpu/test_nn_xpu.py index 4ff4bcef21..c738df0077 100644 --- a/test/xpu/test_nn_xpu.py +++ b/test/xpu/test_nn_xpu.py @@ -30,6 +30,7 @@ subtest, TEST_WITH_CROSSREF, ) +TEST_WITH_CROSSREF = 1 try: from xpu_test_utils import XPUPatchForImport @@ -3132,8 +3133,17 @@ def perm_fn(x): # will result in nan. mask = torch.tensor([[1]], device=device) == 1 result = model(encoder_input, src_key_padding_mask=mask) + fast_path_device = result.is_xpu or result.is_cpu result = result.cpu().detach().numpy() - self.assertTrue(np.isnan(result).all()) + # Non Fast Paths + if training or not batch_first or TEST_WITH_CROSSREF or not fast_path_device: + # We changed the semenatic, on the non fast path so that fully masked out rows return + # 0 from attention thus NaNs should no longer be present and the output should be nonzero + # due to skip connections + self.assertTrue(not np.isnan(result).any()) + else: + # Fast Paths + self.assertTrue(np.isnan(result).all()) # deterministic input encoder_input = perm_fn( From 9abf073f03070597d51de59a46eb1d9932d73e7f Mon Sep 17 00:00:00 2001 From: yucai-intel <108388355+yucai-intel@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:10:03 +0800 Subject: [PATCH 2/5] format --- test/xpu/test_nn_xpu.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/xpu/test_nn_xpu.py b/test/xpu/test_nn_xpu.py index c738df0077..7a4984dbcd 100644 --- a/test/xpu/test_nn_xpu.py +++ b/test/xpu/test_nn_xpu.py @@ -30,6 +30,7 @@ subtest, TEST_WITH_CROSSREF, ) + TEST_WITH_CROSSREF = 1 try: From b6d13981d5722e933ea321a8d8bb54f0ec64b88b Mon Sep 17 00:00:00 2001 From: yucai-intel <108388355+yucai-intel@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:14:32 +0800 Subject: [PATCH 3/5] Update test_nn_xpu.py --- test/xpu/test_nn_xpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/xpu/test_nn_xpu.py b/test/xpu/test_nn_xpu.py index 7a4984dbcd..abb4f98583 100644 --- a/test/xpu/test_nn_xpu.py +++ b/test/xpu/test_nn_xpu.py @@ -31,7 +31,7 @@ TEST_WITH_CROSSREF, ) -TEST_WITH_CROSSREF = 1 +TEST_WITH_CROSSREF = 1 # noqa: F811 try: from xpu_test_utils import XPUPatchForImport From 3897e97b84d418cad2d67d88713e0df83b19dfa6 Mon Sep 17 00:00:00 2001 From: yucai-intel <108388355+yucai-intel@users.noreply.github.com> Date: Wed, 12 Nov 2025 09:20:15 +0800 Subject: [PATCH 4/5] format --- test/xpu/test_nn_xpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/xpu/test_nn_xpu.py b/test/xpu/test_nn_xpu.py index abb4f98583..4dfd2f49e0 100644 --- a/test/xpu/test_nn_xpu.py +++ b/test/xpu/test_nn_xpu.py @@ -31,7 +31,7 @@ TEST_WITH_CROSSREF, ) -TEST_WITH_CROSSREF = 1 # noqa: F811 +TEST_WITH_CROSSREF = 1 # noqa: F811 try: from xpu_test_utils import XPUPatchForImport From 54091fd0aed0d5e17a9a8e112fe5a86e7d8b56fb Mon Sep 17 00:00:00 2001 From: yucai-intel <108388355+yucai-intel@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:56:24 +0800 Subject: [PATCH 5/5] Update test_nn_xpu.py --- test/xpu/test_nn_xpu.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/xpu/test_nn_xpu.py b/test/xpu/test_nn_xpu.py index 4dfd2f49e0..3e20e7eabb 100644 --- a/test/xpu/test_nn_xpu.py +++ b/test/xpu/test_nn_xpu.py @@ -31,8 +31,6 @@ TEST_WITH_CROSSREF, ) -TEST_WITH_CROSSREF = 1 # noqa: F811 - try: from xpu_test_utils import XPUPatchForImport except Exception as e: