`TestKLDeviceXPU::test_compile_kl_multivariate_normal_xpu` fails on XPU
- Dominant language
- Python
- Stars
- 113
- Forks
- 128
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 112
Description
### 🐛 Describe the bug
The PR https://github.com/pytorch/pytorch/pull/195730 enables `distributions/test_distributions.py` tests on XPU. One of the tests (previously only executed on CPU), i.e., `TestKLDeviceXPU::test_compile_kl_multivariate_normal_xpu` fails with the following error (two sub-test cases):
Case 1:
```
___ TestKLDeviceXPU.test_compile_kl_multivariate_normal_xpu (dynamic=False) ___
Traceback (most recent call last):
File "/usr/lib/python3.12/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib/python3.12/unittest/case.py", line 539, in subTest
yield
File "/home/gta/pytorch/test/distributions/test_distributions.py", line 5973, in test_compile_kl_multivariate_normal
actual = torch.compile(
^^^^^^^^^^^^^^
File "/home/gta/pytorch/torch/_dynamo/eval_frame.py", line 1272, in compile_wrapper
raise e.with_traceback(
torch._dynamo.exc.Unsupported: Attempted to call function marked as skipped
Explanation: Dynamo developers have intentionally marked that the function `is_dependent` in file `/home/gta/pytorch/torch/distributions/constraints.py` should not be traced.
Hint: Avoid calling the function `is_dependent`.
Hint: Apply `@torch._dynamo.dont_skip_tracing` to the function `is_dependent` to force tracing into the function. More graph breaks may occur as a result of attempting to trace into the function.
Hint: Please file an issue to PyTorch.
Developer debug context: module: torch.distributions.constraints, qualname: is_dependent, skip reason: file matches MOD_SKIPLIST (/home/gta/pytorch/torch/distributions)
For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0007.html
from user code:
File "/home/gta/pytorch/test/distributions/test_distributions.py", line 5960, in fn
p = MultivariateNormal(p_mu, p_var)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gta/pytorch/torch/_dynamo/polyfills/__init__.py", line 423, in instantiate_user_defined_class_object
obj.__init__(*args, **kwargs)
File "/home/gta/pytorch/torch/distributions/multivariate_normal.py", line 189, in __init__
super().__init__(batch_shape, event_shape, validate_args=validate_args)
File "/home/gta/pytorch/torch/distributions/distribution.py", line 68, in __init__
if constraints.is_dependent(constraint):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
```
Case 2:
```
___ TestKLXPU.test_compile_kl_multivariate_normal_xpu (dynamic=True) ___
Traceback (most recent call last):
File "/usr/lib/python3.12/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib/python3.12/unittest/case.py", line 539, in subTest
yield
File "/home/gta/pytorch/test/distributions/test_distributions.py", line 5973, in test_compile_kl_multivariate_normal
actual = torch.compile(
^^^^^^^^^^^^^^
File "/home/gta/pytorch/torch/_dynamo/eval_frame.py", line 1272, in compile_wrapper
raise e.with_traceback(
torch._dynamo.exc.Unsupported: Attempted to call function marked as skipped
Explanation: Dynamo developers have intentionally marked that the function `is_dependent` in file `/home/gta/pytorch/torch/distributions/constraints.py` should not be traced.
Hint: Avoid calling the function `is_dependent`.
Hint: Apply `@torch._dynamo.dont_skip_tracing` to the function `is_dependent` to force tracing into the function. More graph breaks may occur as a result of attempting to trace into the function.
Hint: Please file an issue to PyTorch.
Developer debug context: module: torch.distributions.constraints, qualname: is_dependent, skip reason: file matches MOD_SKIPLIST (/home/gta/pytorch/torch/distributions)
For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0007.html
from user code:
File "/home/gta/pytorch/test/distributions/test_distributions.py", line 5960, in fn
p = MultivariateNormal(p_mu, p_var)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gta/pytorch/torch/_dynamo/polyfills/__init__.py", line 423, in instantiate_user_defined_class_object
obj.__init__(*args, **kwargs)
File "/home/gta/pytorch/torch/distributions/multivariate_normal.py", line 189, in __init__
super().__init__(batch_shape, event_shape, validate_args=validate_args)
File "/home/gta/pytorch/torch/distributions/distribution.py", line 68, in __init__
if constraints.is_dependent(constraint):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
```
### Versions
Pytorch: changes from https://github.com/pytorch/pytorch/pull/195730
torch-xpu-ops: main
Contributor guide
Research direction
Start with test/distributions/test_distributions.py at test_compile_kl_multivariate_normal and reproduce both dynamic=False and dynamic=True cases. Trace the failure through torch/distributions/distribution.py, torch/distributions/constraints.py, and torch/distributions/multivariate_normal.py, focusing on the skipped is_dependent call during torch.compile. Done means both XPU sub-tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100