Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Onnxruntime parity checks to CI #1938

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXR
/bin/sh /onnxruntime/dockerfiles/scripts/install_common_deps.sh


ADD tools/build_and_test_onnxrt.sh /onnxruntime/build_and_test_onnxrt.sh
ADD tools/build_and_install_onnxrt.sh /onnxruntime/build_and_install_onnxrt.sh
ADD tools/test_onnxrt_unit_tests.sh /onnxruntime/test_onnxrt_unit_tests.sh
ADD tools/test_onnxrt_parity_tests.sh /onnxruntime/test_onnxrt_parity_tests.sh

RUN cget -p /usr/local install ROCmSoftwarePlatform/rocMLIR@8d25af3b3721c159bb41cc6388e9453b1018c126 -DBUILD_MIXR_TARGET=On -DLLVM_ENABLE_ZSTD=Off -DLLVM_ENABLE_THREADS=Off

Expand Down
33 changes: 30 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,41 @@ def onnxnode(name, body) {
}
}

rocmtest onnx: onnxnode('anygpu') { cmake_build ->
stage("Onnx runtime") {
rocmtest onnxbuild onnxnode('anygpu') { cmake_build ->
stage("Onnxruntime Build and Install") {
sh '''
apt install half
#ls -lR
md5sum ./build/*.deb
dpkg -i ./build/*.deb
cd /onnxruntime && ./build_and_test_onnxrt.sh
cd /onnxruntime && ./build_and_install_onnxrt.sh
'''
stash includes:'/onnxruntime/build/Linux/Release/dist/*.whl', name:'onnxruntime-wheel'
}
}

def onnxtestnode(name, body) {
return { label ->
rocmtestnode(variant: label, node: rocmnodename(name), docker_args: '-u root', body: body, pre: {
sh ''' apt install half
md5sum ./build/*.deb
dpkg -i ./build/*.deb
pip3 install /onnxruntime/build/Linux/Release/dist/*.whl '''
unstash 'migraphx-package'
unstash 'onnxruntime-wheel'
})
}
}

rocmtest onnxtests onnxtestnode('anygpu') {cmake_build ->
stage("Onnxruntime Unit tests") {
sh '''
cd /onnxruntime && ./test_onnxrt_unit_tests.sh
'''
}
stage("Onnxruntime Parity tests") {
sh '''
cd /onnxruntime && ./test_onnxrt_parity_tests.sh
'''
}
}
37 changes: 37 additions & 0 deletions tools/build_and_install_ort.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
set -e

ulimit -c unlimited

cd /onnxruntime
pip3 install -r requirements-dev.txt
# Add newer cmake to the path
export PATH="/opt/cmake/bin:$PATH"
export CXXFLAGS="-D__HIP_PLATFORM_AMD__=1 -w"
./build.sh --config Release --cmake_extra_defines CMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ --update --build --build_wheel --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --skip_tests --rocm_home /opt/rocm --use_migraphx --migraphx_home /opt/rocm --rocm_version=`cat /opt/rocm/.info/version-dev` --allow_running_as_root

#install onnxruntime wheel for parity tests
cd build/Linux/Release
pip3 install dist/*.whl
38 changes: 38 additions & 0 deletions tools/test_onnxrt_parity_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
set -e

#install dependancies used for parity checks
pip3 install psutil onnx coloredlogs packaging transformers==4.29.2 sympy
TedThemistokleous marked this conversation as resolved.
Show resolved Hide resolved
pip3 install -U numpy==1.21.6
TedThemistokleous marked this conversation as resolved.
Show resolved Hide resolved

#Go to folder with parity checks
cd /workspace/onnxruntime/onnxruntime/test/python/transformers/

#Parity checks asked by microsoft. Ensure these are running and work with MIGraphX changes
python test_parity_gelu.py --no_optimize

python test_parity_layernorm.py --no_optimize

python test_parity_huggingface_gpt_attention.py
14 changes: 1 addition & 13 deletions tools/build_and_test_onnxrt.sh → tools/test_onnxrt_unit_tests.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License checker will flag this. Change to 2024

#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,21 +21,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################

set -e

ulimit -c unlimited

cd /onnxruntime
pip3 install -r requirements-dev.txt
# Add newer cmake to the path
export PATH="/opt/cmake/bin:$PATH"
export CXXFLAGS="-D__HIP_PLATFORM_AMD__=1 -w"
./build.sh --config Release --cmake_extra_defines CMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --skip_tests --rocm_home /opt/rocm --use_migraphx --migraphx_home /opt/rocm --rocm_version=`cat /opt/rocm/.info/version-dev` --allow_running_as_root

cd build/Linux/Release
#Add test launcher for onnxrt tests

echo 'InferenceSessionTests.CheckRunProfilerWithSessionOptions' >> ../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
echo 'InferenceSessionTests.CheckRunProfilerWithSessionOptions2' >> ../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
echo 'InferenceSessionTests.Test3LayerNestedSubgraph' >> ../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
Expand Down
Loading