intel / intel/torch-xpu-ops

`ImportError` when trying to import torch when built with `BUILD_SEPARATE_OPS=1`

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

Description

### 🐛 Describe the bug

## The Problem

Importing `torch` when it is built with `BUILD_SEPARATE_OPS=1` raises `ImportError`.

There is a problem with PyTorch when it is built with `BUILD_SEPARATE_OPS` flag set. The problem is related to recently introduced `at::xpu::sleep`. When the same code is built without the `BUILD_SEPARATE_OPS` flag, then it works correctly.

## Error message:
```text
ImportError: /home/bbela/pytorch/.venv/lib/python3.12/site-packages/torch/lib/libtorch_python.so: undefined symbol: _ZN2at3xpu5sleepEm
```

## Reproducer

To reproduce, simply build torch with:
```bash
export BUILD_SEPARATE_OPS=1
```
then simply try to import torch:
```python
import torch
```
it should fail at this stage already.

### Versions

PyTorch SHA: `9985428cfce1b55d1df7e0f85363ce17a39b0644`
torch-xpu-ops SHA: `f225bffa58791851584207ca764f92b85f395403`

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure by building with BUILD_SEPARATE_OPS=1 and running `import torch` at the recorded PyTorch and torch-xpu-ops SHAs. Trace the missing `at::xpu::sleep` symbol through the separate-ops build and linking configuration; done means the build imports torch successfully without the undefined-symbol error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.