[skip-added] test_effn_attn_uniform_zero_bias on XPU: SDPA never selects the efficient-attention backend
- Dominant language
- Python
- Stars
- 113
- Forks
- 128
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 112
Description
Auto-added by `fix-implement` (allow_skip=true), from the batch fan-out on intel/torch-xpu-ops#5272.
**Test:** `test/inductor/test_cuda_repro.py::CudaReproTests::test_effn_attn_uniform_zero_bias`
(upstream DISABLED test: pytorch/pytorch#196552)
**Original failure:** `AssertionError: 0 != 1` at `test_cuda_repro.py:298` (`self.assertEqual(len(biases), 1)`),
reached from `test_cuda_repro.py:328` -- the phase that traces
`F.scaled_dot_product_attention(..., attn_mask=padding_mask)` under
`sdpa_kernel(SDPBackend.EFFICIENT_ATTENTION)` and expects exactly one
`aten._scaled_dot_product_efficient_attention` node in the joint graph.
**Root cause:** `select_sdp_backend_xpu` returns the *math* backend from its
`efficient_attention` case (`aten/src/ATen/native/mkldnn/xpu/Attention.cpp:224-231`):
```cpp
case sdp::SDPBackend::efficient_attention:
if (ctx.userEnabledMemEfficientSDP() &&
can_use_mem_efficient_attention(kernel_params, print_debug)) {
TORCH_WARN_ONCE(
"SDPA Memory Efficient Attention backend is not supported on XPU, falling back to math backend.");
return sdp::SDPBackend::math;
}
```
So on XPU, `F.scaled_dot_product_attention` under
`sdpa_kernel(SDPBackend.EFFICIENT_ATTENTION)` traces to the math decomposition and
never emits an `_scaled_dot_product_efficient_attention` call for the test's
`joint_custom_post_pass` to capture. The earlier phases of the same test pass
because they invoke `aten._scaled_dot_product_efficient_attention.default`
directly, bypassing backend selection.
**Reason for skip:** making the XPU SDPA dispatcher actually select
`efficient_attention` is a capability change, not a test fix: `_fused_sdp_choice_xpu`
would have to stop routing to math, and XPU's
`_scaled_dot_product_efficient_attention_backward` currently re-runs the whole math
forward under autograd, so flipping the selection would be a behavioral and
performance change well beyond this failure. That decision belongs to the XPU SDPA
owners.
**Base analyzed:** pytorch@31527a43
Follow-up: either implement/enable efficient-attention backend selection on XPU and
remove the `@skipIfXpu`, or confirm the math fallback is intentional and upstream a
permanent test-side exclusion.
Contributor guide
Research direction
Start with test/inductor/test_cuda_repro.py::CudaReproTests::test_effn_attn_uniform_zero_bias and inspect aten/src/ATen/native/mkldnn/xpu/Attention.cpp:224-231, along with _fused_sdp_choice_xpu and the referenced backward path. Run the named test on XPU; completion requires an owner-approved decision, either enabling the efficient-attention selection and removing the skip or documenting a permanent test-side exclusion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python, pytorch
- Domain
- backend, performance, testing-qa
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100