Skip to content

Commit 76d48bd

Browse files
authored
Merge branch 'main' into chao/xccl
2 parents 1989262 + 354a514 commit 76d48bd

File tree

6 files changed

+226
-4
lines changed

6 files changed

+226
-4
lines changed

.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

.github/workflows/nightly_ondemand.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ permissions: read-all
6363

6464
concurrency:
6565
group: ${{ github.workflow }}-${{ github.sha }}-${{ github.event_name }}-${{ inputs.pytorch }}-${{ inputs.keep_torch_xpu_ops }}-${{ inputs.ut }}-${{ inputs.triton }}-${{ inputs.suite }}-${{ inputs.dt }}-${{ inputs.mode }}-${{ inputs.scenario }}-${{ inputs.model }}-${{ inputs.python }}
66-
cancel-in-progress: true
66+
cancel-in-progress: ${{ github.event_name != 'schedule' }}
6767

6868
jobs:
6969
Linux-Nightly-Ondemand-UT-Tests:

.github/workflows/nightly_ondemand_rolling.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ permissions: read-all
6363

6464
concurrency:
6565
group: ${{ github.workflow }}-${{ github.sha }}-${{ github.event_name }}-${{ inputs.pytorch }}-${{ inputs.keep_torch_xpu_ops }}-${{ inputs.ut }}-${{ inputs.triton }}-${{ inputs.suite }}-${{ inputs.dt }}-${{ inputs.mode }}-${{ inputs.scenario }}-${{ inputs.model }}-${{ inputs.python }}
66-
cancel-in-progress: true
66+
cancel-in-progress: ${{ github.event_name != 'schedule' }}
6767

6868
jobs:
6969
Linux-Nightly-Ondemand-UT-Tests-Rolling:

.github/workflows/nightly_ondemand_whl.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ permissions: read-all
5353

5454
concurrency:
5555
group: ${{ github.workflow }}-${{ github.sha }}-${{ github.event_name }}-${{ inputs.pytorch }}-${{ inputs.ut }}-${{ inputs.suite }}-${{ inputs.dt }}-${{ inputs.mode }}-${{ inputs.scenario }}-${{ inputs.model }}-${{ inputs.python }}
56-
cancel-in-progress: true
56+
cancel-in-progress: ${{ github.event_name != 'schedule' }}
5757

5858
jobs:
5959
Linux-Nightly-Ondemand-UT-WHL-Tests:
60-
if: github.event_name == 'schedule' || ${{ inputs.ut_suite }}
60+
if: github.event_name == 'schedule' || ${{ inputs.ut }}
6161
uses: ./.github/workflows/_linux_ut.yml
6262
with:
6363
ut: ${{ github.event_name == 'schedule' && 'op_regression,op_regression_dev1,op_extended,op_ut,torch_xpu' || inputs.ut }}

0 commit comments

Comments
 (0)