intel / intel/torch-xpu-ops

`TestPartitioningDeviceXPU.test_compiled_{forward,backward}_rng_codegen_xpu` fail on XPU

Open
#5,255 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
113
Forks
128
Avg merge
5d 13h
Merged PRs (30d)
107

Description

### 🐛 Describe the bug

The PR https://github.com/pytorch/pytorch/pull/196232 enables `functorch/test_aotdispatch.py` tests on XPU. Two of the tests (previously only executed on CUDA), i.e., `TestPartitioningDeviceXPU.test_compiled_{forward,backward}_rng_codegen_xpu` fail with the following errors:

Test case 1:
```
____ TestPartitioningDeviceXPU.test_compiled_backward_rng_codegen_xpu ____
Traceback (most recent call last):
(...)
File "/home/gta/pytorch/test/functorch/test_aotdispatch.py", line 10366, in test_compiled_backward_rng_codegen
self.assertIn("_rng_add_(_ctx_", source)
(...)
AssertionError: '_rng_add_(_ctx_' not found in "def _compiled_backward(_flat_args_, _ctx_, _prologue_, _rng_add_, _impl_, _epilogue_, _double_bw_):\n if len(_flat_args_) != 1 or not isinstance(_flat_args_[0], list):\n raise AssertionError('Compiled backward expects grads as a single mutable list ' f'argument, but got {len(_flat_args_)} args. ' 'Grads must be passed as [grad0, grad1, ...] to allow ' 'freeing individual grads mid-backward.')\n grad_args = _flat_args_[0]\n del _flat_args_\n _saved = _ctx_.saved_tensors\n all_args = _prologue_(_saved, _ctx_.symints, _ctx_.opaque_objects, grad_args)\n del _saved\n def impl_fn(double_ctx=None):\n out = _impl_(_ctx_, all_args)\n return _epilogue_(out)\n if (torch._C._is_key_in_tls('context') and (_cc := torch._C._get_obj_in_tls('context')) is not None):\n impl_fn = functools.partial(_cc.copy().run, impl_fn)\n if torch.is_grad_enabled():\n return _double_bw_(_ctx_, impl_fn, all_args)\n return impl_fn()"

To execute this test, run the following from the base repo dir:
PYTORCH_TEST_WITH_SLOW=1 python test/functorch/test_aotdispatch.py TestPartitioningDeviceXPU.test_compiled_backward_rng_codegen_xpu

```

Test case 2:
```
____ TestPartitioningDeviceXPU.test_compiled_forward_rng_codegen_xpu ____
Traceback (most recent call last):
(...)
File "/home/gta/pytorch/test/functorch/test_aotdispatch.py", line 10340, in test_compiled_forward_rng_codegen
self.assertIn("_rng_add_(ctx, args)", source)
(...)
AssertionError: '_rng_add_(ctx, args)' not found in 'def _compiled_forward(ctx, args, _rng_add_, _save_, _finalize_, _compiled_fw_):\n fw_outs = _compiled_fw_(list(args))\n if isinstance(fw_outs, tuple):\n fw_outs = list(fw_outs)\n elif not isinstance(fw_outs, list):\n fw_outs = [fw_outs]\n _save_(ctx, fw_outs)\n return _finalize_(ctx, fw_outs)'

To execute this test, run the following from the base repo dir:
PYTORCH_TEST_WITH_SLOW=1 python test/functorch/test_aotdispatch.py TestPartitioningDeviceXPU.test_compiled_forward_rng_codegen_xpu
```

### Versions

Pytorch: changes from https://github.com/pytorch/pytorch/pull/196232
torch-xpu-ops: main

Contributor guide

Open the contributing guide

Research direction

Start in test/functorch/test_aotdispatch.py at TestPartitioningDeviceXPU.test_compiled_forward_rng_codegen_xpu and test_compiled_backward_rng_codegen_xpu. Run each test with PYTORCH_TEST_WITH_SLOW=1 and inspect the generated source shown in the assertions. Done means both XPU tests pass with the expected RNG codegen assertions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.