`TestRsampleDeviceXPU.test_beta_wrt_alpha_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., `TestRsampleDeviceXPU.test_beta_wrt_alpha_xpu` fails with the following error:
```
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 634, in run
self._callTestMethod(testMethod)
File "/usr/lib/python3.12/unittest/case.py", line 589, in _callTestMethod
if method() is not None:
^^^^^^^^
File "/home/gta/pytorch/torch/testing/_internal/common_utils.py", line 3886, in wrapper
method(*args, **kwargs)
File "/home/gta/pytorch/torch/testing/_internal/common_device_type.py", line 672, in instantiated_test
result = test(self, **param_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gta/pytorch/test/distributions/test_distributions.py", line 4854, in test_beta_wrt_alpha
self.assertLess(
File "/usr/lib/python3.12/unittest/case.py", line 1257, in assertLess
self.fail(self._formatMessage(msg, standardMsg))
File "/usr/lib/python3.12/unittest/case.py", line 715, in fail
raise self.failureException(msg)
AssertionError: np.float64(0.010159537761671986) not less than 0.005 : Bad gradient dx/dcon1 for x ~ Beta(10.0, 10.0)
x [0.279613 0.3439685 0.3463726 0.36038747 0.36593115 0.37700483
0.38709897 0.40213177 0.41760403 0.48446003 0.48644167 0.49669835
0.5203008 0.548802 0.5537562 0.55672115 0.55987024 0.6132305
0.69115895 0.70956725]
expected [0.02739259 0.02792154 0.02792312 0.02790858 0.02789188 0.02784052
0.02777335 0.0276386 0.02745813 0.02623088 0.02618417 0.02593347
0.02530125 0.02443952 0.0242792 0.02418179 0.02407715 0.02212545
0.0187168 0.0178229 ]
actual [0.02739702 0.02791995 0.02792138 0.02790578 0.02788873 0.02783668
0.02776894 0.0276336 0.02745236 0.0261227 0.02591815 0.02592491
0.02531159 0.02443273 0.02427133 0.02417436 0.02406992 0.02211922
0.01871399 0.01782108]
rel error [1.61724444e-04 5.70534599e-05 6.24135059e-05 1.00272820e-04
1.12852626e-04 1.37799397e-04 1.58952887e-04 1.80910806e-04
2.10240537e-04 4.12413729e-03 1.01595378e-02 3.30285316e-04
4.08569445e-04 2.77917521e-04 3.24201787e-04 3.07243625e-04
3.00398920e-04 2.81684860e-04 1.50362596e-04 1.01925679e-04]
max error 0.010159537761671986
at x = 0.4864416718482971
```
### 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 and the TestRsampleDeviceXPU.test_beta_wrt_alpha_xpu entry point, then run the failing test on XPU using the versions described in the issue. Compare the reported Beta gradient calculation with the CPU behavior and determine why the XPU result exceeds the tolerance. Done means the test passes on XPU with valid gradient accuracy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100