Skip to content

feat: add Intel GPU (XPU) support via auto-round-lib dispatch#375

Open
luoyu-intel wants to merge 3 commits into
thu-ml:mainfrom
luoyu-intel:xpu
Open

feat: add Intel GPU (XPU) support via auto-round-lib dispatch#375
luoyu-intel wants to merge 3 commits into
thu-ml:mainfrom
luoyu-intel:xpu

Conversation

@luoyu-intel

@luoyu-intel luoyu-intel commented Jul 6, 2026

Copy link
Copy Markdown

Summary

Adds XPU support to SageAttention by detecting Intel GPUs and dispatching sageattn() and sageattn_varlen() to the ARK kernel backend (auto-round-lib). No CUDA compilation is required on XPU systems. The dispatch is transparent — users call sageattn() as usual and it automatically routes to the correct backend.

Changes

3 files, 85 insertions, 10 deletions

File Change
setup.py Auto-detect XPU → skip CUDA compilation, print install hint for auto-round-lib
sageattention/core.py sageattn(): XPU dispatch with head_dim auto-padding (<64→64, 64-128→128), bool mask → FP32 conversion. sageattn_varlen(): XPU dispatch with head_dim auto-padding. CUDA quant imports guarded with try/except for XPU-only environments.
README.md Add Intel GPU (XPU) installation section and API documentation.

Design Decisions

  1. No CUDA kernel porting — XPU uses auto-round-lib (ARK) as an external dependency, installed via pip install auto-round-lib. No SYCL code is added to this repository.
  2. Zero API breakagesageattn(q, k, v, ...) works identically on CUDA and XPU. The same parameters are accepted.
  3. head_dim auto-padding — Models using head_dim=96 (e.g., some diffusion models) are automatically padded to 128 before dispatching to ARK, matching upstream behavior.
  4. bool mask supporttorch.bool attention masks are auto-converted to FP32 additive masks for ARK compatibility.

Test Results

Same as ARK PR above (the fork routes to ARK, so performance is identical). Verified on Intel Arc Pro B60:

sageattn:            [1, 16, 4096, 128]
sageattn (hd=96):    [1, 16, 4096, 96]       # auto-padding
sageattn return_lse: O=[1, 16, 4096, 128], LSE=[1, 16, 4096]
sageattn_varlen:     [4096, 16, 128]

Installation (XPU)

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu
pip install auto-round-lib
git clone https://github.com/luoyu-intel/SageAttention.git # for this PR
git clone https://github.com/thu-ml/SageAttention.git # after merge
cd SageAttention
python setup.py install   # CUDA compilation skipped automatically

Performance (TOPS)

FLOPs = 4 × B × Hq × Sq × Sk × D (non-causal attention) · GPU: Intel Arc Pro B60 (BMG-G21) · FP16, non-causal
BMG theoretical peak: ~197 TOPS (INT8) / ~98 TFLOPS (FP16).

Config torch.sdpa ARK sdpa ARK sagev1 sagev1/ARK sagev1/torch
Sq=4096 Sk=4096 H=16 56.2 TOPS 71.0 TOPS 74.6 TOPS 1.05× 1.33×
Sq=8192 Sk=8192 H=16 57.5 TOPS 81.1 TOPS 91.0 TOPS 1.12× 1.58×
Sq=16384 Sk=16384 H=16 58.4 TOPS 82.0 TOPS 96.0 TOPS 1.17× 1.64×
Sq=4096 Sk=4096 H=96(8) GQA 57.3 TOPS 81.3 TOPS 92.3 TOPS 1.13× 1.61×
Sq=4096 Sk=8192 H=96(8) GQA 57.9 TOPS 82.1 TOPS 96.1 TOPS 1.17× 1.66×
Sq=4096 Sk=16384 H=96(8) GQA 58.0 TOPS 82.0 TOPS 98.1 TOPS 1.20× 1.69×
Sq=4096 Sk=32768 H=96(8) GQA 56.5 TOPS 81.9 TOPS 98.9 TOPS 1.21× 1.75×

- Updated README with installation instructions for Intel GPU (XPU).
- Enhanced core.py to include XPU dispatch via auto-round-lib.
- Modified setup.py to skip CUDA compilation on XPU.
- Introduced bench_xpu.py for benchmarking SageAttention on XPU.
@luoyu-intel
luoyu-intel marked this pull request as ready for review July 7, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant