Skip to content

Commit 05da31c

Browse files
authored
Merge branch 'main' into penghuic/pytest_by_script
2 parents ebc83be + 9ed0a1a commit 05da31c

22 files changed

+1426
-74
lines changed

.github/actions/inductor-xpu-e2e-test/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ runs:
5151
shell: bash
5252
run: |
5353
source activate e2e_ci
54-
source .github/scripts/env.sh
54+
source .github/scripts/env.sh ${{ inputs.pytorch }}
5555
if [[ ${{ inputs.suite }} == *"torchbench"* ]]; then
5656
if [ "${{ inputs.pytorch }}" != "nightly_wheel" ]; then
5757
cd ../ && rm -rf audio && git clone --single-branch -b main https://github.com/pytorch/audio.git
@@ -94,7 +94,7 @@ runs:
9494
shell: bash
9595
run: |
9696
source activate e2e_ci
97-
source .github/scripts/env.sh
97+
source .github/scripts/env.sh ${{ inputs.pytorch }}
9898
cp .github/scripts/inductor_xpu_test.sh ../pytorch
9999
cd ../pytorch
100100

.github/scripts/apply_torch_pr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def appyly_pr(pr_info, re_apply_msg):
5858
pr_file = pr_info["diff_url"].split("/")[-1]
5959
urllib.request.urlretrieve(pr_info["diff_url"], pr_file)
6060
# apply diff
61-
apply_cmd = "git apply --3way " + pr_file + " && rm -f " + pr_file
61+
apply_cmd = "git apply --3way " + pr_file
6262
apply_info = subprocess.Popen(apply_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
6363
apply_message = apply_info.communicate()[0].decode("utf-8")
6464
apply_status = apply_info.returncode

.github/scripts/env.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/bash
2-
source /opt/intel/oneapi/compiler/latest/env/vars.sh
3-
source /opt/intel/oneapi/umf/latest/env/vars.sh
4-
source /opt/intel/oneapi/pti/latest/env/vars.sh
2+
3+
if [ "$1" != "nightly_wheel" ];then
4+
source /opt/intel/oneapi/compiler/latest/env/vars.sh
5+
source /opt/intel/oneapi/umf/latest/env/vars.sh
6+
source /opt/intel/oneapi/pti/latest/env/vars.sh
7+
else
8+
echo "Don't need to source DL-Essential for nightly wheel"
9+
fi

.github/scripts/inductor_summary.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import pandas as pd
44
from scipy.stats import gmean
55
from styleframe import StyleFrame, Styler, utils
6+
import numpy as np
7+
from openpyxl import Workbook
68

79
parser = argparse.ArgumentParser(description="Generate report")
810
parser.add_argument('-s', '--suite', default=["huggingface"], nargs='*', type=str, help='model suite name')
@@ -665,6 +667,73 @@ def update_summary(excel, scenario, suite):
665667
sf.set_row_height(j, 30)
666668
sf.to_excel(sheet_name=suite + '_' + scenario + '_Summary', excel_writer=excel)
667669

670+
def summary_conclusion(scenario, excel):
671+
excel.book.save(excel)
672+
df = pd.read_excel(excel, sheet_name = None, header = None)
673+
#df = pd.DataFrame(excel)
674+
if scenario == 'performance':
675+
sheet_names = list(df.keys())
676+
sheet_names = [s for s in sheet_names if 'Summary' in s and 'performance' in s]
677+
sheet_names.sort()
678+
print(f"Merge excel as below:\n{sheet_names}")
679+
print("\n")
680+
features = [[]] * 21
681+
for sheet_name in sheet_names:
682+
df_sheet = df[sheet_name]
683+
df_sheet = df_sheet.values
684+
features = np.hstack((features, df_sheet))
685+
686+
if len(sheet_names) == 1:
687+
print("sheet not merge")
688+
elif len(sheet_names) == 2:
689+
print("2 sheets merge")
690+
if 'huggingface' in sheet_names[0]:
691+
features[:, 4:5] = features[:, 14:15]
692+
features[:, 6:7] = features[:, 16:17]
693+
else:
694+
features[:, 4:5] = features[:, 14:15]
695+
else:
696+
print("3 sheets merge")
697+
features[:, 4:5] = features[:, 24:25]
698+
features[:, 6:7] = features[:, 16:17]
699+
700+
df_concat = StyleFrame(pd.DataFrame(features).iloc[:,:10])
701+
for i in range(10):
702+
df_concat.set_column_width(i, 22)
703+
for j in range(1, 23):
704+
df_concat.set_row_height(j, 30)
705+
df_concat.to_excel(sheet_name='Perf_Summary', excel_writer=excel, index=False)
706+
else:
707+
sheet_names = list(df.keys())
708+
sheet_names = [s for s in sheet_names if 'Summary' in s and 'accuracy' in s]
709+
sheet_names.sort()
710+
print(f"Merge excel as below:\n{sheet_names}")
711+
print("\n")
712+
features = [[]] * 11
713+
for sheet_name in sheet_names:
714+
df_sheet = df[sheet_name]
715+
df_sheet = df_sheet.values
716+
features = np.hstack((features, df_sheet))
717+
if len(sheet_names) == 1:
718+
print("sheet not merge")
719+
elif len(sheet_names) == 2:
720+
print("2 sheets merge")
721+
if 'huggingface' in sheet_names[0]:
722+
features[:, 3:4] = features[:, 12:13]
723+
features[:, 5:6] = features[:, 14:15]
724+
else:
725+
features[:, 3:4] = features[:, 12:13]
726+
else:
727+
print("3 sheets merge")
728+
features[:, 3:4] = features[:, 21:22]
729+
features[:, 5:6] = features[:, 14:15]
730+
731+
df_concat = StyleFrame(pd.DataFrame(features).iloc[:,:9])
732+
for i in range(10):
733+
df_concat.set_column_width(i, 22)
734+
for j in range(1, 13):
735+
df_concat.set_row_height(j, 30)
736+
df_concat.to_excel(sheet_name='Acc_Summary', excel_writer=excel, index=False)
668737

669738
def generate_report(excel, scenario_list, precision_list, mode_list, suite_list):
670739
for sc in scenario_list:
@@ -693,8 +762,19 @@ def excel_postprocess(file, scenario, precison, mode, suite):
693762
wdt.merge_cells(start_row=1, end_row=1, start_column=13, end_column=16)
694763
wb.save(file)
695764

765+
if len(scenario) == 2:
766+
wb.move_sheet("Perf_Summary", -(len(wb.worksheets)-1))
767+
wb.move_sheet("Acc_Summary", -(len(wb.worksheets)-1))
768+
elif len(scenario) == 1 and sc == 'accuracy':
769+
wb.move_sheet("Acc_Summary", -(len(wb.worksheets)-1))
770+
else:
771+
wb.move_sheet("Perf_Summary", -(len(wb.worksheets)-1))
772+
696773

697774
if __name__ == '__main__':
698775
excel = StyleFrame.ExcelWriter('inductor_log/Inductor_E2E_Test_Report.xlsx')
699776
generate_report(excel, args.scenario, args.precision, args.mode, args.suite)
777+
for sc in args.scenario:
778+
summary_conclusion(sc, excel)
700779
excel_postprocess(excel, args.scenario, args.precision, args.mode, args.suite)
780+
excel.close()

.github/scripts/spec.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import torch
2+
3+
DEVICE_NAME = 'xpu'
4+
5+
MANUAL_SEED_FN = torch.xpu.manual_seed
6+
EMPTY_CACHE_FN = torch.xpu.empty_cache
7+
DEVICE_COUNT_FN = torch.xpu.device_count
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Linux Transformers Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '.github/scripts/spec.py'
9+
- '.github/workflows/_linux_transformers.yml'
10+
workflow_dispatch:
11+
inputs:
12+
pytorch:
13+
required: false
14+
type: string
15+
default: 'nightly'
16+
description: Pytorch branch/commit
17+
python:
18+
required: false
19+
type: string
20+
default: '3.10'
21+
description: Python version
22+
runner:
23+
required: true
24+
type: string
25+
default: 'linux.idc.xpu'
26+
description: Runner label
27+
driver:
28+
required: false
29+
type: string
30+
default: 'lts'
31+
description: Driver lts/rolling
32+
nightly_whl:
33+
required: false
34+
type: string
35+
default: ''
36+
description: Pytorch nightly wheel version
37+
transformers:
38+
required: false
39+
type: string
40+
default: 'v4.47.0'
41+
description: Transformers version
42+
43+
permissions: read-all
44+
45+
jobs:
46+
Torch-XPU-Transformers-Tests:
47+
runs-on: ${{ inputs.runner != '' && inputs.runner || 'linux.idc.xpu' }}
48+
env:
49+
NEOReadDebugKeys: ${{ inputs.driver == 'rolling' && '1' || '0' }}
50+
DisableScratchPages: ${{ inputs.driver == 'rolling' && '1' || '0' }}
51+
python: ${{ inputs.python != '' && inputs.python || '3.10' }}
52+
pytorch: ${{ inputs.pytorch != '' && inputs.pytorch || 'nightly' }}
53+
TRANSFORMERS_TEST_DEVICE_SPEC: 'spec.py'
54+
steps:
55+
- name: Checkout torch-xpu-ops
56+
uses: actions/checkout@v4
57+
with:
58+
path: torch-xpu-ops
59+
- name: Checkout Transformers
60+
uses: actions/checkout@v4
61+
with:
62+
repository: huggingface/transformers
63+
ref: ${{ inputs.transformers != '' && inputs.transformers || 'v4.47.0' }}
64+
path: transformers
65+
- name: Prepare OS environment
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y \
69+
espeak-ng \
70+
git-lfs \
71+
pkg-config \
72+
libavcodec-dev \
73+
libavdevice-dev \
74+
libavfilter-dev \
75+
libavformat-dev \
76+
libavutil-dev \
77+
libswresample-dev \
78+
libswscale-dev
79+
git lfs install
80+
- name: Prepare Conda ENV
81+
run: |
82+
which conda && conda clean -ay
83+
conda remove --all -y -n huggingface_transformers_test || rm -rf $(dirname ${CONDA_EXE})/../envs/huggingface_transformers_test
84+
conda create -y -n huggingface_transformers_test python=${{ env.python }}
85+
source activate huggingface_transformers_test
86+
- name: Prepare Stock XPU Pytorch
87+
run: |
88+
pwd
89+
source activate huggingface_transformers_test
90+
if [ -z "${{ inputs.nightly_whl }}" ]; then
91+
pip install torch torchvision torchaudio --pre --index-url https://download.pytorch.org/whl/nightly/xpu
92+
else
93+
pip install torch==$(echo ${{ inputs.nightly_whl }}) torchvision torchaudio --pre --index-url https://download.pytorch.org/whl/nightly/xpu
94+
fi
95+
- name: Prepare Transformers
96+
run: |
97+
pwd
98+
source activate huggingface_transformers_test
99+
cd transformers
100+
pip install -e .
101+
pip install -e ".[dev-torch,testing,video]"
102+
rm -rf tests_log && mkdir -p tests_log
103+
rm -rf reports
104+
cp ${{ github.workspace }}/torch-xpu-ops/.github/scripts/spec.py ./
105+
- name: Report installed versions
106+
id: installed
107+
run: |
108+
source activate huggingface_transformers_test
109+
echo "TORCH_BRANCH_ID=$(python -c 'import torch; print(torch.__version__)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}"
110+
echo "TORCH_COMMIT_ID=$(python -c 'import torch; print(torch.version.git_version)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}"
111+
echo "pip installed packages:"
112+
pip list | tee ${{ github.workspace }}/transformers/tests_log/pip_list.txt
113+
echo "GPU render nodes:"
114+
cat /sys/class/drm/render*/device/device | tee ${{ github.workspace }}/transformers/tests_log/device_IDs.txt
115+
- name: Sanitry check installed packages
116+
run: |
117+
source activate huggingface_transformers_test
118+
# These checks are to exit earlier if for any reason Transformers
119+
# reinstalled torch packages back to CUDA versions (not expected).
120+
pip show torch | grep Version | grep xpu
121+
pip show torchaudio | grep Version | grep xpu
122+
pip show torchvision | grep Version | grep xpu
123+
- name: Run XPU backbone
124+
run: |
125+
source activate huggingface_transformers_test
126+
cd transformers
127+
python3 -m pytest -rsf --make-reports=tests_benchmark -k backbone tests
128+
- name: Upload Test log
129+
if: ${{ ! cancelled() }}
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: Torch-XPU-Transformers-Log-${{ github.event.pull_request.number || github.sha }}
133+
path: |
134+
${{ github.workspace }}/transformers/reports
135+
${{ github.workspace }}/transformers/tests_log

0 commit comments

Comments
 (0)