Repository navigation
Description
TL; DR
Following PyTorch PR #195146, migrate torch-xpu-ops to the APIs in ATen/xpu/XPUContext.h and remove src/comm/DeviceProperties.h.
PR Stage 1: Use upstream XPU device-property APIs
This is the direct 1-to-1 mapping, just API change, no calculation or anything to change. Possibly just one PR is enough.
PR Stage 2: Remove DeviceProperties.h while preserving launch calculations
This PR would be a code logic change because there are no 1-to-1 mapping. See the following for details. Possibly 3 PRs.
API migration and affected files
All replacement APIs below belong to at::xpu. Preserve the caller's device argument.
PR Stage 1: Equivalent API replacements
| Existing API or expression | Change | Consumer files |
|---|---|---|
syclMaxWorkGroupSize (3 overloads) |
Use getKernelMaxWorkGroupSize |
46 |
syclDeviceMaxWorkGroupSize |
Use getDeviceMaxWorkGroupSize |
9 |
syclMaxSubGroupSize |
Use getDeviceMaxSubGroupSize |
14 |
syclMinSubGroupSize |
Use getDeviceMinSubGroupSize |
3 |
syclMaxWorkItemsPerTile |
Use getDeviceMaxWorkItems |
20 |
syclLocalMemSize |
Use getDeviceLocalMemSize |
6 |
syclGpuEUCountPerSubslice |
Use getDeviceEUCountPerXeCore, except when folded into the quotient below |
3 |
syclGpuEuCount() * syclGpuHWThreadsPerEU() |
Use getDeviceHWThreads() |
6 |
syclGpuEuCount() / syclGpuEUCountPerSubslice() |
Use getDeviceXeCoreCount() |
1 |
PR Stage 2: Proposed Changes
In the expressions below, props means at::xpu::getDeviceProperties(device). All upstream comparisons refer to the surveyed XPUContext.h.
A. Upstream APIs exist, but their calculations differ.
A rename would change launch sizes or scheduling. PR 2 preserves the old values explicitly.
| Old helper | Difference in upstream API | Change in PR 2 | Files |
|---|---|---|---|
syclMaxWorkItemsPerSubSlice |
Old: maximum subgroup size times EUs per Xe Core. getDeviceMaxWorkItemsPerXeCore additionally multiplies by hardware threads per EU, so it represents resident capacity. getDeviceMaxWorkGroupSize is a separate launch limit and also need not equal the old value. |
Replace calls with getDeviceMaxSubGroupSize(device) * getDeviceEUCountPerXeCore(device). Preserve existing multipliers, including BatchNorm's * 2 launch bound and Loops' * 4 latency threshold. |
18 |
syclMaxDSSNum |
Old numerator: max_compute_units. getDeviceXeCoreCount uses gpu_eu_count. These are separately queried properties; equality is not guaranteed by the implementation. |
Replace calls with props->max_compute_units / getDeviceEUCountPerXeCore(device). |
2 |
B. No dedicated upstream equivalent exists.
The needed fields or component APIs already exist, so PR 2 does not add getters to PyTorch.
| Old helper | What is missing | Change in PR 2 | Files |
|---|---|---|---|
Remaining syclGpuHWThreadsPerEU uses |
A per-EU thread getter; getDeviceHWThreads returns the total for the device. |
Read props->gpu_hw_threads_per_eu in GroupNorm, Transpose, and Distance; retain surrounding calculations. |
3 |
syclMaxWorkItemsPerEU |
A per-EU work-item capacity getter. | Use getDeviceMaxSubGroupSize(device) * props->gpu_hw_threads_per_eu in BatchNorm. |
1 |
syclHasFloat64 |
A dedicated FP64 getter in XPUContext.h; the property already exists. |
Read props->has_fp64 in UnaryGamma. |
1 |
syclPrefVectorWidth |
An upstream equivalent for the old fixed 16-byte vector-width policy. This helper does not query device properties. | Fold the calculation into preferred_vector_width in MemoryAccess.h: return 16, 8, 4, or 2 for element sizes 1, 2, 4, or 8; retain fallback 1. |
1 |
C. Remove definitions and header dependencies once consumers are migrated.
| Item | Change in PR 2 | Files |
|---|---|---|
syclMaxComputeUnitSize |
Remove definition and update the one remaining comment reference; its max_compute_units field remains in the preserved DSS calculation. |
1 comment consumer |
syclGpuEuCount and helpers migrated in PR 1 |
Remove definitions with the header; their consumer migrations are already complete. | 0 remaining consumers |
syclGpuEuSimdWidth, syclMaxNumSubGroups, syclGlobalMemSize, syclNativeVectorWidth |
Remove unused definitions; no replacement is needed. | 0 consumers |
Direct DeviceProperties.h includes |
Remove or replace with explicit dependencies, including in SYCLContext.h. Preserve required syclext/syclexp aliases and resolve dependencies on using namespace xpu::sycl. |
15 include sites |
src/comm/DeviceProperties.h |
Delete the file. | 1 deletion |
Activity
[1/2] Migrating DeviceProperties.h to ATen/xpu/XPUContext.h for 1:1 A…
Stonepia commentedon Sep 16, 2026
Move to PT2.16
[1/2] Migrating DeviceProperties.h to ATen/xpu/XPUContext.h for 1:1 A…
[2/2][3/3] Remove DeviceProperties.h
[1/3] Migrate leftover DeviceProperties.h calls and helpers without u…
[2/3] Inline syclMaxWorkItemsPerSubSlice and syclMaxDSSNum with XPUCo…
[3/3] Remove DeviceProperties.h
[2/3] Inline syclMaxWorkItemsPerSubSlice and syclMaxDSSNum with XPUCo…
[2/3] Port DeviceProperties.h's old API (syclMaxWorkItemsPerSubSlice,…
daisyden commentedon Nov 10, 2026
label-issue: #5245
Root cause: Not a defect; refactor RFC to replace
src/comm/DeviceProperties.hhelpers (11 including files in src/) withat::xpuAPIs from XPUContext.h per pytorch/pytorch#195146.typeTaskTask(human-set, preserved).testtest: utmodulemodule: rfc[RFC]; staged design proposal for API migration of src/comm/DeviceProperties.h.priorityMediumMedium(human-set, preserved).Applied to this issue. Generated by a local
label-issuerun.