Skip to content

Conversation

@yucai-intel
Copy link
Contributor

@yucai-intel yucai-intel commented Nov 11, 2025

The Problem Solved
The nn.TransformerEncoderLayer unit test failed on XPU devices when checking the expected output for a fully masked input (Sequence Length=1, Mask=[[True]]). #2015
Root Cause:
Due to a missing device entry in the core PyTorch's Fast Path whitelist, XPU execution was incorrectly forced into the slow Python Fallback path, instead of the optimized C++ fused kernel. pytorch/pytorch#168234
Semantic Mismatch:
The XPU implementation executing the Fallback path produces a non-NaN finite value for fully masked inputs (reflecting the robust mathematical result of X+Attention(0)).
Assertion Error:
However, the unit test's internal logic erroneously categorized the XPU execution as belonging to a Fast Path, which expected a NaN result. The actual non-NaN finite result did not match the expected NaN assertion, causing the test failure.

Fix Implementation
By modifying the internal UT logic to explicitly track the device's correct execution semantics (Non-NaN for XPU), we switch the test's assertion from the incorrect self.assertTrue(np.isnan(result).all()) to the correct self.assertTrue(not np.isnan(result).any()).

@yucai-intel yucai-intel changed the title Update test_nn_xpu.py Fix transformerEncoderLayer Full Mask UT Failure on XPU Nov 11, 2025
@intel intel deleted a comment from github-actions bot Nov 12, 2025
@yucai-intel yucai-intel changed the title Fix transformerEncoderLayer Full Mask UT Failure on XPU Fix TransformerEncoderLayer Full Mask UT Failure on XPU Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants