Support torch validation and add to spmd tests#3003
Support torch validation and add to spmd tests#3003ethanglaser wants to merge 4 commits intouxlfoundation:mainfrom
Conversation
|
/intelci: run |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| xp = array_api_modules[target_df] | ||
| return xp.asarray(obj) | ||
| elif target_df == "torch": | ||
| if hasattr(torch, "xpu") and torch.xpu.is_available(): |
There was a problem hiding this comment.
should probably be documented to prevent confusion
|
I assume the dpc runtime mismatch issue between torch and dpnp is solved? otherwise this may make things difficult. good addition |
|
/intelci: run |
|
The CI error: |
If installing both torch and dpnp without oneapi deps, there are no issues |
| return xp.asarray(obj) | ||
| elif target_df == "torch": | ||
| if hasattr(torch, "xpu") and torch.xpu.is_available(): | ||
| return torch.as_tensor(obj, device="xpu", *args, **kwargs) |
There was a problem hiding this comment.
It seems we are testing np.float32/np.float64 dtypes in convert_to_dataframe and torch does not take this, maybe we need to conver to torch dtype before passing to as_tensor
the release schedules are not matching which caused previous issues in one of the oneAPI minor releases. may break things for a bit at 2026.0 release w. r. t. torch |
CI Failure Triage ReportRun: 22786779906 | Date: 2026-03-06 Failed Jobs: WindowsNightly/venv Python3.10_Sklearn1.0, LinuxNightly [pytorch,numpy]-cpu test Python3.13_Sklearn1.6
AnalysisCI Failure Analysis1. Failure Classification: PR-specific2. Root Cause:The PR introduces PyTorch tensor support but has dtype conversion incompatibilities between numpy/Python types and PyTorch's expected 3. Evidence:Linux failure pattern: Windows failure pattern: The Linux error shows PyTorch rejecting Python/numpy 4. Relevant Code Changes:Primary issue in def _convert_to_dataframe(obj, sycl_queue=None, target_df=None, *args, **kwargs):
# ...
elif target_df == "torch":
if hasattr(torch, "xpu") and torch.xpu.is_available():
return torch.as_tensor(obj, device="xpu", *args, **kwargs) # ← dtype issue here
else:
return torch.as_tensor(obj, device="cpu", *args, **kwargs) # ← dtype issue hereThe Secondary issue: get_dataframes_and_queues(dataframe_filter_="dpnp,dpctl,torch", device_filter_="gpu")5. Recommendation:Fix the dtype conversion in elif target_df == "torch":
# Convert numpy dtypes to torch dtypes if present
if 'dtype' in kwargs:
import numpy as np
dtype_map = {
np.float32: torch.float32,
np.float64: torch.float64,
np.int32: torch.int32,
np.int64: torch.int64,
# Add other needed mappings
}
if kwargs['dtype'] in dtype_map:
kwargs['dtype'] = dtype_map[kwargs['dtype']]
if hasattr(torch, "xpu") and torch.xpu.is_available():
return torch.as_tensor(obj, device="xpu", **kwargs)
else:
return torch.as_tensor(obj, device="cpu", **kwargs)Additionally:
The failures are directly caused by this PR's PyTorch integration and require dtype handling fixes before merging. Similar failures in recent runs
Generated by CI Triage Bot |
Description
Checklist:
Completeness and readability
Testing
Performance