Skip to content

Commit f9150bd

Browse files
faaanyByronHsuhebiao064
authored
add GitHub CI for Intel GPU (#536)
## Summary This PR adds the dependencies for using liger-kernel on XPU and adds the workflow.yml. ## Testing Done Test done on local XPU machine. To make all tests pass, we need to first merge PR #535 first. - Hardware Type: Intel(R) Data Center GPU Max 1550 - [x] run `make test` to ensure correctness - [x] run `make checkstyle` to ensure code style - [x] run `make test-convergence` to ensure convergence --------- Co-authored-by: Byron Hsu <[email protected]> Co-authored-by: Stefan He <[email protected]>
1 parent 80b409a commit f9150bd

File tree

2 files changed

+84
-4
lines changed

2 files changed

+84
-4
lines changed

.github/workflows/intel-ci.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Intel GPU
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "src/**"
9+
- "test/**"
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- "src/**"
15+
- "test/**"
16+
schedule:
17+
# Runs at 00:00 UTC daily
18+
- cron: '0 0 * * *'
19+
workflow_dispatch: # Enables manual trigger
20+
21+
concurrency:
22+
# This causes it to cancel previous in-progress actions on the same PR / branch,
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
checkstyle:
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v3
36+
with:
37+
python-version: '3.10'
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install -r dev/fmt-requirements.txt
43+
44+
- name: Run checkstyle
45+
run: make checkstyle
46+
47+
tests:
48+
runs-on: linux-max1550-gpu-8
49+
needs: [checkstyle]
50+
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v3
54+
55+
- name: Set up Python
56+
uses: actions/setup-python@v3
57+
with:
58+
python-version: '3.10'
59+
60+
- name: Setup Dependencies
61+
run: |
62+
python -m pip install --upgrade pip
63+
pip install -e .[dev] --extra-index-url https://download.pytorch.org/whl/test/xpu
64+
65+
- name: List Python Environments
66+
run: python -m pip list
67+
68+
- name: Run Unit Tests
69+
run: |
70+
make test
71+
make test-convergence

setup.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def get_default_dependencies():
2121
"torch>=2.6.0.dev",
2222
"triton>=3.0.0",
2323
]
24+
elif platform == "xpu":
25+
return [
26+
"torch>=2.6.0",
27+
"pytorch-triton-xpu>=3.2.0",
28+
]
2429

2530

2631
def get_optional_dependencies():
@@ -43,8 +48,7 @@ def get_optional_dependencies():
4348
}
4449

4550

46-
# TODO: add intel XPU
47-
def get_platform() -> Literal["cuda", "rocm", "cpu"]:
51+
def get_platform() -> Literal["cuda", "rocm", "cpu", "xpu"]:
4852
"""
4953
Detect whether the system has NVIDIA or AMD GPU without torch dependency.
5054
"""
@@ -60,8 +64,13 @@ def get_platform() -> Literal["cuda", "rocm", "cpu"]:
6064
print("ROCm GPU detected")
6165
return "rocm"
6266
except (subprocess.SubprocessError, FileNotFoundError):
63-
print("No GPU detected")
64-
return "cpu"
67+
try:
68+
subprocess.run(["xpu-smi"], check=True)
69+
print("Intel GPU detected")
70+
return "xpu"
71+
except (subprocess.SubprocessError, FileNotFoundError):
72+
print("No GPU detected")
73+
return "cpu"
6574

6675

6776
setup(

0 commit comments

Comments
 (0)