Skip to content

Commit d551ab1

Browse files
authored
SDXL E2E Pipeline CI (#885)
1 parent 541572a commit d551ab1

File tree

2 files changed

+132
-22
lines changed

2 files changed

+132
-22
lines changed

.github/workflows/test_sdxl.yml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,78 @@
1-
name: SDXL Models Nightly
1+
name: SDXL E2E Pipeline CI
22

33
on:
4+
workflow_dispatch:
5+
pull_request:
46
schedule:
5-
- cron: '30 6 * * *'
7+
- cron: "*/50 * * * *"
8+
9+
concurrency:
10+
# A PR number if a pull request and otherwise the commit hash. This cancels
11+
# queued and in-progress runs for the same PR (presubmit) or commit
12+
# (postsubmit). The workflow name is prepended to avoid conflicts between
13+
# different workflows.
14+
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
15+
cancel-in-progress: true
616

717
jobs:
818
test-sdxl-models:
919
strategy:
1020
matrix:
1121
version: [3.11]
12-
os: [nodai-amdgpu-w7900-x86-64]
22+
os: [nodai-amdgpu-mi300-x86-64]
1323

1424
runs-on: ${{matrix.os}}
25+
env:
26+
IREE_TOKEN: ${{ secrets.IREE_TOKEN }}
1527
steps:
1628
- name: "Setting up Python"
1729
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
1830
with:
1931
python-version: ${{matrix.version}}
2032

21-
- name: "Checkout Code"
33+
- name: "Checkout SHARK-ModelDev"
2234
uses: actions/checkout@v4
2335
with:
24-
ref: ean-sd-fp16
36+
ref: bump-punet-tom
2537

2638
- name: "Checkout iree-turbine"
2739
uses: actions/checkout@v4
2840
with:
2941
repository: iree-org/iree-turbine
30-
# TODO: Let the ref be passed as a parameter to run integration tests.
3142
path: iree-turbine
43+
44+
- name: "Checkout iree"
45+
uses: actions/checkout@v4
46+
with:
47+
repository: iree-org/iree
48+
path: iree
3249

33-
- name: Sync source deps
34-
# build IREE from source with -DIREE_BUILD_TRACY=ON if getting tracy profile
50+
- name: Python deps
3551
run: |
52+
python3.11 -m venv sdxl_venv
53+
source sdxl_venv/bin/activate
3654
python -m pip install --upgrade pip
37-
# Note: We install in three steps in order to satisfy requirements
38-
# from non default locations first. Installing the PyTorch CPU
39-
# wheels saves multiple minutes and a lot of bandwidth on runner setup.
40-
pip install --no-compile --index-url https://download.pytorch.org/whl/cpu \
41-
-r ${{ github.workspace }}/iree-turbine//pytorch-cpu-requirements.txt
42-
pip install --no-compile --upgrade -r ${{ github.workspace }}/iree-turbine/requirements.txt
43-
pip install --no-compile -e ${{ github.workspace }}/iree-turbine/[testing,torch-cpu-nightly]
44-
pip install --no-compile --upgrade -r models/requirements.txt
45-
pip install --no-compile -e models
46-
55+
pip install --no-compile -r ${{ github.workspace }}/iree-turbine/pytorch-cpu-requirements.txt
56+
pip install --pre --upgrade -r ${{ github.workspace }}/iree-turbine/requirements.txt
57+
pip install --no-compile --pre --upgrade -e models -r models/requirements.txt
58+
pip uninstall torch torchvision torchaudio -y
59+
pip install https://download.pytorch.org/whl/nightly/pytorch_triton_rocm-3.0.0%2B21eae954ef-cp311-cp311-linux_x86_64.whl
60+
pip install https://download.pytorch.org/whl/nightly/rocm6.1/torch-2.5.0.dev20240710%2Brocm6.1-cp311-cp311-linux_x86_64.whl
61+
pip install https://download.pytorch.org/whl/nightly/rocm6.1/torchvision-0.20.0.dev20240711%2Brocm6.1-cp311-cp311-linux_x86_64.whl
62+
pip install https://download.pytorch.org/whl/nightly/rocm6.1/torchaudio-2.4.0.dev20240711%2Brocm6.1-cp311-cp311-linux_x86_64.whl
63+
pip uninstall iree-compiler iree-runtime iree-base-compiler iree-base-runtime -y
64+
python ci-tools/latest-pkgci.py
65+
cd wheels
66+
unzip *.zip
67+
pip install *.whl
68+
cd ..
69+
rm -rf wheels
70+
4771
- name: Show current free memory
4872
run: |
4973
free -mh
5074
5175
- name: Run sdxl tests
5276
run: |
53-
pip install --upgrade --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
54-
pytest models/turbine_models/tests/sdxl_test.py --device cpu --rt_device local-task --iree_target_triple x86_64-linux-gnu
55-
pytest models/turbine_models/tests/sdxl_test.py --device vulkan --rt_device vulkan --iree_target_triple rdna3-unknown-linux
56-
pytest models/turbine_models/tests/sdxl_test.py --device rocm --rt_device rocm --iree_target_triple gfx90a
77+
source sdxl_venv/bin/activate
78+
python3 models/turbine_models/custom_models/sd_inference/sd_pipeline.py --device=hip --precision=fp16 --iree_target_triple=gfx942 --external_weights=safetensors --hf_model_name=stabilityai/stable-diffusion-xl-base-1.0 --width=1024 --height=1024 --batch_size=1 --use_i8_punet --attn_spec=punet --vae_decomp_attn --external_weights=safetensors --num_inference_steps=20 --benchmark=all --verbose

ci-tools/latest-pkgci.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import requests
2+
import json
3+
import os
4+
5+
GITHUB_TOKEN = os.getenv("IREE_TOKEN")
6+
7+
OWNER = "iree-org"
8+
REPO = "iree"
9+
10+
API_URL = (
11+
f"https://api.github.com/repos/{OWNER}/{REPO}/actions/workflows/pkgci.yml/runs"
12+
)
13+
14+
15+
# Get the latest workflow run ID for pkgci.yml
16+
def get_latest_pkgci_workflow_run():
17+
headers = {
18+
"Accept": "application/vnd.github+json",
19+
"Authorization": f"Bearer {GITHUB_TOKEN}",
20+
"X-GitHub-Api-Version": "2022-11-28",
21+
}
22+
params = {
23+
"per_page": 1,
24+
"event": "push",
25+
"branch": "main",
26+
}
27+
response = requests.get(API_URL, headers=headers, params=params)
28+
29+
if response.status_code == 200:
30+
data = response.json()
31+
if data["total_count"] > 0:
32+
latest_run = data["workflow_runs"][0]
33+
return latest_run["id"], latest_run["artifacts_url"]
34+
else:
35+
print("No workflow runs found for pkgci.yml.")
36+
return None
37+
else:
38+
print(f"Error fetching workflow runs: {response.status_code}")
39+
return None
40+
41+
42+
# Get the artifacts of a specific workflow run
43+
def get_artifacts(workflow_run_id, artifacts_url):
44+
headers = {
45+
"Accept": "application/vnd.github+json",
46+
"Authorization": f"Bearer {GITHUB_TOKEN}",
47+
"X-GitHub-Api-Version": "2022-11-28",
48+
}
49+
response = requests.get(artifacts_url, headers=headers)
50+
51+
if response.status_code == 200:
52+
artifacts = response.json()["artifacts"]
53+
if artifacts:
54+
print(f"Artifacts for pkgci.yml workflow run {workflow_run_id}:")
55+
for artifact in artifacts:
56+
print(f"- {artifact['name']} (Size: {artifact['size_in_bytes']} bytes)")
57+
download_artifact(artifact["archive_download_url"], artifact["name"])
58+
else:
59+
print("No artifacts found for the pkgci.yml workflow run.")
60+
else:
61+
print(f"Error fetching artifacts: {response.status_code}")
62+
63+
64+
# Download an artifact
65+
def download_artifact(download_url, artifact_name):
66+
headers = {
67+
"Accept": "application/vnd.github+json",
68+
"Authorization": f"Bearer {GITHUB_TOKEN}",
69+
"X-GitHub-Api-Version": "2022-11-28",
70+
}
71+
response = requests.get(download_url, headers=headers, stream=True)
72+
73+
if response.status_code == 200:
74+
file_name = f"wheels/{artifact_name}.zip"
75+
os.mkdir("wheels")
76+
with open(file_name, "wb") as f:
77+
for chunk in response.iter_content(chunk_size=8192):
78+
if chunk:
79+
f.write(chunk)
80+
print(f"Artifact '{artifact_name}' downloaded successfully as '{file_name}'.")
81+
else:
82+
print(f"Error downloading artifact '{artifact_name}': {response.status_code}")
83+
84+
85+
if __name__ == "__main__":
86+
workflow_run_id, artifact_url = get_latest_pkgci_workflow_run()
87+
if workflow_run_id:
88+
get_artifacts(workflow_run_id, artifact_url)

0 commit comments

Comments
 (0)