[ut]Re-enable test_unused_cpu_input_cudagraphs on XPU once inductor cudagraph runtime supports XPU
- Dominant language
- Python
- Stars
- 113
- Forks
- 128
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 112
Description
## Context
`test/inductor/test_cuda_repro.py::CudaReproTests::test_unused_cpu_input_cudagraphs` is currently skipped on XPU via `@skipIfXpu(msg="cudagraph is not supported on xpu")`.
- Upstream disable issue: pytorch/pytorch#189815
- Skip restored by: pytorch/pytorch#189974
- Skip was originally removed by pytorch/pytorch#186915 on the premise that "cudagraphs now supported on XPU". That premise did not hold, so the skip was restored.
## Why it cannot pass on XPU today
Two independent reasons in inductor:
1. `torch/_inductor/cudagraph_utils.py::check_multiple_devices_or_any_cpu_nodes` explicitly whitelists only `"cuda"` for the single-remaining-device fast path:
```python
if (
len(device_node_mapping) == 1
and next(iter(device_node_mapping.keys())).type == "cuda"
):
return None
```
For XPU this falls through to the "multiple devices" branch and sets `disable_cudagraphs_reason`, which the test asserts is `None`.
2. `torch/_inductor/cudagraph_trees.py` (the inductor runtime that captures/replays cudagraphs) has zero XPU references. Even if the device whitelist above were extended, the runtime path (`compiled_fn(*inp)`) would still not work end-to-end on XPU.
The sibling test `test_cpu_index` in the same file carries the same skip for the same reason, and should be re-enabled together.
## Definition of done
Remove `@skipIfXpu` from `test_unused_cpu_input_cudagraphs` (and ideally `test_cpu_index`) in `test/inductor/test_cuda_repro.py` once **both** of the following hold:
- [ ] `torch/_inductor/cudagraph_utils.py::check_multiple_devices_or_any_cpu_nodes` accepts XPU as a single-device fast-path (e.g. `.type in ("cuda", "xpu")`, matching the established pattern in `torch/_inductor/graph.py:2837`).
- [ ] `torch/_inductor/cudagraph_trees.py` supports XPU end-to-end (capture, pool, replay, invalidation), backed by `torch.xpu.XPUGraph` which already exists in `torch/xpu/graphs.py`.
## Verification when re-enabling
```bash
source /opt/intel/oneapi/setvars.sh
python test/inductor/test_cuda_repro.py -k "test_unused_cpu_input_cudagraphs or test_cpu_index" -v
```
Both should PASS (not skip) on XPU. Cross-check that `graph.disable_cudagraphs_reason` is `None`, `graph.device_types == {"xpu"}`, and `compiled_fn(*inp)` matches eager output.
## References
- pytorch/pytorch#189815 — disable-test tracking issue
- pytorch/pytorch#189974 — restore skip PR
- pytorch/pytorch#186915 — premature unskip
- pytorch/pytorch#134749 — original test intent (allow cudagraphs with unused CPU inputs)
- `torch/xpu/graphs.py` — existing XPUGraph API to build the runtime on
Contributor guide
Assessment
This issue has not been assessed yet.