test_nn.py cases fail under dynamo wrapper (PYTORCH_TEST_WITH_DYNAMO=1) on XPU
- Dominant language
- Python
- Stars
- 113
- Forks
- 129
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 112
Description
## Describe the bug
When running the following `test/test_nn.py` cases with the dynamo wrapper (`PYTORCH_TEST_WITH_DYNAMO=1`), they all fail. They pass in the normal (non-dynamo) test run.
Affected cases:
- `test_Hardshrink_no_batch_dim_xpu`
- `test_Softshrink_no_batch_dim_xpu`
- `test_Conv1d_zero_batch_xpu_fp32`
- `test_Conv2d_zero_batch_xpu_fp32`
- `test_Conv3d_zero_batch_xpu_fp32`
- `test_Conv1d_zero_batch_xpu_tf32`
- `test_Conv2d_zero_batch_xpu_tf32`
- `test_Conv3d_zero_batch_xpu_tf32`
- `test_Embedding_sparse_xpu`
- `test_EmbeddingBag_sparse_xpu`
## Repro
```
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_nn.py TestNN.test_Hardshrink_no_batch_dim_xpu
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_nn.py TestNN.test_EmbeddingBag_sparse_xpu
```
## Observed failures
There appear to be two distinct root causes, both in the dynamo / compiled-autograd path.
**1. Hardshrink / Softshrink** — compiled autograd fails running fake tensor meta for the backward op:
```
torch._dynamo.exc.TorchRuntimeError: RuntimeError when making fake tensor call
Explanation: Dynamo failed to run FX node with fake tensors:
call_function torch._dynamo.compiled_autograd.ops.HardshrinkBackward0(...)
got RuntimeError('TensorIterator does not support symbolic shapes; please
implement this operator in torch/_refs using the elementwise or reduction helpers ...')
E ... failed while attempting to run meta for aten.hardshrink_backward.default
E RuntimeError: TensorIterator does not support symbolic shapes; ...
```
**2. Embedding / EmbeddingBag / Conv zero-batch** — `IndexError` in dynamo PGO stride handling:
```
File ".../torch/_dynamo/pgo.py", line 340, in is_stride_dynamic
return self.stride[dim] is auto_dynamic
IndexError: tuple index out of range
from user code:
File ".6", line 5, in forward
getitem = inputs[0]
```
## Environment
- Python 3.10.20, pytest 7.3.2
- torch 2.15.0.dev20260907+xpu (git f2ac3133587499ab2dfe33d5f4009bf89accebb0)
- Device: XPU (`torch.xpu.is_available()` = True)
- Reproduce with https://github.com/pytorch/pytorch/pull/189653
## Notes
Both root causes look like they live in upstream PyTorch (compiled autograd / dynamo PGO / backward meta implementations) rather than in torch-xpu-ops kernels; the XPU dynamo test config surfaces them.
Contributor guide
Research direction
Start by running the listed test/test_nn.py cases with PYTORCH_TEST_WITH_DYNAMO=1 on XPU and compare them with the normal run. Trace the Hardshrink/Softshrink failures through compiled-autograd fake-tensor meta handling, and inspect torch/_dynamo/pgo.py around is_stride_dynamic for the stride errors. Done means all affected cases pass under the dynamo wrapper without regressing the normal tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100