Unexpected implicit dependency: removing local code triggers undeclared identifier in ATen XPU headers
- Dominant language
- Python
- Stars
- 113
- Forks
- 128
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 112
Description
### 🐛 Describe the bug
In our [PR](https://github.com/intel/torchlib-xpu/pull/74#discussion_r3753523587) for https://github.com/intel/torchlib-xpu, we borrowed parts of the comm/ code from torch-xpu-ops. When we remove a helper that appears locally unused (e.g. syclMaxWorkGroupSize), we start seeing an undeclared identifier error originating from PyTorch internal XPU headers (ATen/native/xpu/sycl/BatchKernel.h).
We’re trying to better understand an integration behavior we observed in our repo code and want to make sure we’re following the intended usage from torch-xpu-ops. From our side, this suggests there may be an implicit dependency through include order or symbol visibility, but we may be misunderstanding the expected contract.
Could you please help clarify:
- Is this behavior expected in the current stack, or does it indicate an unintended coupling?
- Should downstream/integration code ever be in a position to satisfy symbols used by upstream internal headers?
- What is the recommended way to avoid this class of dependency when reusing code patterns from torch-xpu-ops?
- Where is the intended public API surface for torch-xpu-ops (Python and/or C++) documented, and which directories (e.g., comm/) should be treated as internal-only implementation details?
- We’d appreciate any pointers so we can align with the intended architecture and avoid fragile integrations going forward.
### Minimal observed reproducible pattern
0. Install uv or other package manager if needed: https://docs.astral.sh/uv/getting-started/installation/
1. Clone repo and checkout the PR branch:
```bash
git clone https://github.com/aagalleg/torchlib-xpu.git
cd torchlib-xpu
git checkout 555e902
```
2. Create uv environment:
```bash
uv venv
source .venv/bin/activate
```
2. Remove the local helper declaration/definition of `syclMaxWorkGroupSize` from the borrowed `DeviceProperties.h` code.
```bash
sed -i '/^template $/,/^}$/d' packages/fbgemm-xpu/src/fbgemm_xpu/fbgemm_utils/comm/DeviceProperties.h
```
3. Build:
```bash
uv pip install -e packages/fbgemm-xpu \
--index https://download.pytorch.org/whl/xpu
```
4. Observe compile failure
```
/root/.cache/uv/builds-v0/.tmpzk5PAb/lib/python3.12/site-packages/torch/include/ATen/native/xpu/sycl/BatchKernel.h:213:17:
error: use of undeclared identifier 'syclMaxWorkGroupSize'
213 | wg_size = syclMaxWorkGroupSize();
```
cc: @dvrogozh, @flezaalv, @EikanWang, @guangyey
### Versions
Collecting environment information...
PyTorch version: 2.13.0+xpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.3 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.39
Python version: 3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-176-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: True
XPU used to build PyTorch: 20260000
Intel GPU driver version:
* intel-opencl-icd: 26.22.38646.6-1~24.04~ppa1
* libze1: 1.28.6-1~24.04~ppa1
Intel GPU models onboard:
N/A
Intel GPU models detected:
* [0] _XpuDeviceProperties(name='Intel(R) Data Center GPU Max 1100', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xBDA, uuid=8680da0b-2f00-0000-0300-000000000000, driver_version='1.15.38646+6', total_memory=49136MB, local_mem_size=128KB, last_level_cache_size=196608KB, max_compute_units=448, memory_clock_rate=3200MHz, memory_bus_width=64-bit, gpu_eu_count=448, gpu_subslice_count=56, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1, is_integrated_gpu=0)
* [1] _XpuDeviceProperties(name='Intel(R) Data Center GPU Max 1100', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xBDA, uuid=8680da0b-2f00-0000-0301-000000000000, driver_version='1.15.38646+6', total_memory=49136MB, local_mem_size=128KB, last_level_cache_size=196608KB, max_compute_units=448, memory_clock_rate=3200MHz, memory_bus_width=64-bit, gpu_eu_count=448, gpu_subslice_count=56, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1, is_integrated_gpu=0)
* [2] _XpuDeviceProperties(name='Intel(R) Data Center GPU Max 1100', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xBDA, uuid=8680da0b-2f00-0000-0302-000000000000, driver_version='1.15.38646+6', total_memory=49136MB, local_mem_size=128KB, last_level_cache_size=196608KB, max_compute_units=448, memory_clock_rate=3200MHz, memory_bus_width=64-bit, gpu_eu_count=448, gpu_subslice_count=56, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1, is_integrated_gpu=0)
* [3] _XpuDeviceProperties(name='Intel(R) Data Center GPU Max 1100', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', device_id=0xBDA, uuid=8680da0b-2f00-0000-0303-000000000000, driver_version='1.15.38646+6', total_memory=49136MB, local_mem_size=128KB, last_level_cache_size=196608KB, max_compute_units=448, memory_clock_rate=3200MHz, memory_bus_width=64-bit, gpu_eu_count=448, gpu_subslice_count=56, max_work_group_size=1024, max_num_sub_groups=64, sub_group_sizes=[16 32], has_fp16=1, has_fp64=1, has_atomic64=1, is_integrated_gpu=0)
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False
Caching allocator config: N/A
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 45 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 46
On-line CPU(s) list: 0-45
Vendor ID: GenuineIntel
BIOS Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8468V
BIOS Model name: Intel(R) Xeon(R) Platinum 8468V CPU @ 2.2GHz
BIOS CPU family: 2
CPU family: 6
Model: 143
Thread(s) per core: 1
Core(s) per socket: 46
Socket(s): 1
Stepping: 8
BogoMIPS: 4799.99
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 2.2 MiB (46 instances)
L1i cache: 1.4 MiB (46 instances)
L2 cache: 92 MiB (46 instances)
L3 cache: 97.5 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-45
Vulnerability Gather data sampling: Not affected
Vulnerability Indirect target selection: Mitigation; Aligned branch/return thunks
Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Unknown: No mitigations
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Not affected
Versions of relevant libraries:
[pip3] Could not collect
[conda] No relevant packages
Contributor guide
Assessment
This issue has not been assessed yet.