This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch unity-staging in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 987c962e40ff6ba97cd12e2c94112613e485b39d Author: tqchen <tianqi.tc...@gmail.com> AuthorDate: Wed Feb 1 15:50:41 2023 -0500 [Unity][CI] Unity specific jenkins setup (do not upstream to main) This PR setup a unity specific jenkins with minimum jenkinsfile without sharding and disables most of the tests to reduce overall cost. We can add tests of unty branch by configuring the specific groovy file. --- ci/jenkins/generated/arm_jenkinsfile.groovy | 5 + ci/jenkins/generated/cortexm_jenkinsfile.groovy | 5 + ci/jenkins/generated/cpu_jenkinsfile.groovy | 5 + ci/jenkins/generated/docker_jenkinsfile.groovy | 5 + ci/jenkins/generated/gpu_jenkinsfile.groovy | 5 + ci/jenkins/generated/hexagon_jenkinsfile.groovy | 5 + ci/jenkins/generated/i386_jenkinsfile.groovy | 5 + ci/jenkins/generated/lint_jenkinsfile.groovy | 5 + .../generated/minimal_cross_isa_jenkinsfile.groovy | 5 + ci/jenkins/generated/minimal_jenkinsfile.groovy | 5 + ci/jenkins/generated/riscv_jenkinsfile.groovy | 5 + ci/jenkins/generated/wasm_jenkinsfile.groovy | 5 + ci/jenkins/unity_jenkinsfile.groovy | 243 +++++++++++++++++++++ tests/scripts/unity/README | 2 + tests/scripts/unity/task_python_relax.sh | 37 ++++ tests/scripts/unity/task_python_relax_gpuonly.sh | 25 +++ 16 files changed, 367 insertions(+) diff --git a/ci/jenkins/generated/arm_jenkinsfile.groovy b/ci/jenkins/generated/arm_jenkinsfile.groovy index 2c64e9ab24..80eabf10c2 100644 --- a/ci/jenkins/generated/arm_jenkinsfile.groovy +++ b/ci/jenkins/generated/arm_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/cortexm_jenkinsfile.groovy b/ci/jenkins/generated/cortexm_jenkinsfile.groovy index 25846f5b4b..f063622d1f 100644 --- a/ci/jenkins/generated/cortexm_jenkinsfile.groovy +++ b/ci/jenkins/generated/cortexm_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/cpu_jenkinsfile.groovy b/ci/jenkins/generated/cpu_jenkinsfile.groovy index c9e02ba287..72f887e2df 100644 --- a/ci/jenkins/generated/cpu_jenkinsfile.groovy +++ b/ci/jenkins/generated/cpu_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/docker_jenkinsfile.groovy b/ci/jenkins/generated/docker_jenkinsfile.groovy index 6735bd2321..eb74a41b39 100644 --- a/ci/jenkins/generated/docker_jenkinsfile.groovy +++ b/ci/jenkins/generated/docker_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/gpu_jenkinsfile.groovy b/ci/jenkins/generated/gpu_jenkinsfile.groovy index a5609697af..f32d2f9d9a 100644 --- a/ci/jenkins/generated/gpu_jenkinsfile.groovy +++ b/ci/jenkins/generated/gpu_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/hexagon_jenkinsfile.groovy b/ci/jenkins/generated/hexagon_jenkinsfile.groovy index c2f39a0d08..1303d305c4 100644 --- a/ci/jenkins/generated/hexagon_jenkinsfile.groovy +++ b/ci/jenkins/generated/hexagon_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/i386_jenkinsfile.groovy b/ci/jenkins/generated/i386_jenkinsfile.groovy index 0cadeac33d..95ca985c7e 100644 --- a/ci/jenkins/generated/i386_jenkinsfile.groovy +++ b/ci/jenkins/generated/i386_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/lint_jenkinsfile.groovy b/ci/jenkins/generated/lint_jenkinsfile.groovy index f8dccc8635..6a3099bc8d 100644 --- a/ci/jenkins/generated/lint_jenkinsfile.groovy +++ b/ci/jenkins/generated/lint_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/minimal_cross_isa_jenkinsfile.groovy b/ci/jenkins/generated/minimal_cross_isa_jenkinsfile.groovy index 992a1e3075..aaad70621c 100644 --- a/ci/jenkins/generated/minimal_cross_isa_jenkinsfile.groovy +++ b/ci/jenkins/generated/minimal_cross_isa_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/minimal_jenkinsfile.groovy b/ci/jenkins/generated/minimal_jenkinsfile.groovy index f054f60a3a..f830f62369 100644 --- a/ci/jenkins/generated/minimal_jenkinsfile.groovy +++ b/ci/jenkins/generated/minimal_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/riscv_jenkinsfile.groovy b/ci/jenkins/generated/riscv_jenkinsfile.groovy index 7b9bbe7ad3..a2062cec8f 100644 --- a/ci/jenkins/generated/riscv_jenkinsfile.groovy +++ b/ci/jenkins/generated/riscv_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/generated/wasm_jenkinsfile.groovy b/ci/jenkins/generated/wasm_jenkinsfile.groovy index 8c8ee03886..6f92d5bef4 100644 --- a/ci/jenkins/generated/wasm_jenkinsfile.groovy +++ b/ci/jenkins/generated/wasm_jenkinsfile.groovy @@ -458,6 +458,11 @@ def prepare() { label: 'Check for any docker changes', ) + // unity: Skip less relevant tests + // to reduce ci time and resource cost + // (DO NOT UPSTREAM TO MAIN) + skip_ci = true + if (skip_ci) { // Don't rebuild when skipping CI rebuild_docker_images = false diff --git a/ci/jenkins/unity_jenkinsfile.groovy b/ci/jenkins/unity_jenkinsfile.groovy new file mode 100644 index 0000000000..1a6ac76c31 --- /dev/null +++ b/ci/jenkins/unity_jenkinsfile.groovy @@ -0,0 +1,243 @@ +#!groovy +// -*- mode: groovy -*- + +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Jenkins pipeline +// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/ + +// ============================= IMPORTANT NOTE ============================= +// To keep things simple +// This file is manually updated to maintain unity branch specific builds. +// Please do not send this file to main + + +import org.jenkinsci.plugins.pipeline.modeldefinition.Utils + +// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. --> +ci_lint = 'tlcpack/ci-lint:20221025-182121-e41d0ed6e' +ci_gpu = 'tlcpack/ci-gpu:20221025-182121-e41d0ed6e' +ci_cpu = 'tlcpack/ci-cpu:20221025-182121-e41d0ed6e' +ci_wasm = 'tlcpack/ci-wasm:v0.72' +ci_i386 = 'tlcpack/ci-i386:v0.75' +ci_qemu = 'tlcpack/ci-qemu:v0.11' +ci_arm = 'tlcpack/ci-arm:v0.08' +ci_hexagon = 'tlcpack/ci-hexagon:20221025-182121-e41d0ed6e' +// <--- End of regex-scanned config. + +// Parameters to allow overriding (in Jenkins UI), the images +// to be used by a given build. When provided, they take precedence +// over default values above. +properties([ + parameters([ + string(name: 'ci_lint_param', defaultValue: ''), + string(name: 'ci_cpu_param', defaultValue: ''), + string(name: 'ci_gpu_param', defaultValue: ''), + string(name: 'ci_wasm_param', defaultValue: ''), + string(name: 'ci_i386_param', defaultValue: ''), + string(name: 'ci_qemu_param', defaultValue: ''), + string(name: 'ci_arm_param', defaultValue: ''), + string(name: 'ci_hexagon_param', defaultValue: '') + ]) +]) + +// tvm libraries +tvm_runtime = 'build/libtvm_runtime.so, build/config.cmake' +tvm_lib = 'build/libtvm.so, ' + tvm_runtime +// LLVM upstream lib +tvm_multilib = 'build/libtvm.so, ' + + 'build/libvta_fsim.so, ' + + tvm_runtime + +tvm_multilib_tsim = 'build/libvta_tsim.so, ' + + tvm_multilib + +// command to start a docker container +docker_run = 'docker/bash.sh' +// timeout in minutes +max_time = 240 + +def per_exec_ws(folder) { + return "workspace/exec_${env.EXECUTOR_NUMBER}/" + folder +} + +// initialize source codes +def init_git() { + checkout scm + // Add more info about job node + sh ( + script: './tests/scripts/task_show_node_info.sh', + label: 'Show executor node info', + ) + retry(5) { + timeout(time: 2, unit: 'MINUTES') { + sh (script: 'git submodule update --init -f', label: 'Update git submodules') + } + } +} + +def should_skip_slow_tests(pr_number) { + withCredentials([string( + credentialsId: 'tvm-bot-jenkins-reader', + variable: 'GITHUB_TOKEN', + )]) { + // Exit code of 1 means run slow tests, exit code of 0 means skip slow tests + result = sh ( + returnStatus: true, + script: "./tests/scripts/should_run_slow_tests.py --pr '${pr_number}'", + label: 'Check if CI should run slow tests', + ) + } + return result == 0 +} + +def cancel_previous_build() { + // cancel previous build if it is not on main. + if (env.BRANCH_NAME != 'main') { + def buildNumber = env.BUILD_NUMBER as int + // Milestone API allows us to cancel previous build + // with the same milestone number + if (buildNumber > 1) milestone(buildNumber - 1) + milestone(buildNumber) + } +} + +def should_skip_ci(pr_number) { + withCredentials([string( + credentialsId: 'tvm-bot-jenkins-reader', + variable: 'TOKEN', + )]) { + // Exit code of 1 means run full CI (or the script had an error, so run + // full CI just in case). Exit code of 0 means skip CI. + git_skip_ci_code = sh ( + returnStatus: true, + script: "./tests/scripts/git_skip_ci.py --pr '${pr_number}'", + label: 'Check if CI should be skipped', + ) + } + return git_skip_ci_code == 0 +} + +cancel_previous_build() + +def lint() { +stage('Lint') { + node('CPU') { + // When something is provided in ci_*_param, use it, otherwise default with ci_* + ci_lint = params.ci_lint_param ?: ci_lint + ci_cpu = params.ci_cpu_param ?: ci_cpu + ci_gpu = params.ci_gpu_param ?: ci_gpu + ci_wasm = params.ci_wasm_param ?: ci_wasm + ci_i386 = params.ci_i386_param ?: ci_i386 + ci_qemu = params.ci_qemu_param ?: ci_qemu + ci_arm = params.ci_arm_param ?: ci_arm + ci_hexagon = params.ci_hexagon_param ?: ci_hexagon + + sh (script: """ + echo "Docker images being used in this build:" + echo " ci_lint = ${ci_lint}" + echo " ci_cpu = ${ci_cpu}" + echo " ci_gpu = ${ci_gpu}" + echo " ci_wasm = ${ci_wasm}" + echo " ci_i386 = ${ci_i386}" + echo " ci_qemu = ${ci_qemu}" + echo " ci_arm = ${ci_arm}" + echo " ci_hexagon = ${ci_hexagon}" + """, label: 'Docker image names') + } +} + +stage('Sanity Check') { + timeout(time: max_time, unit: 'MINUTES') { + node('CPU') { + ws(per_exec_ws('tvm/sanity')) { + init_git() + is_docs_only_build = sh ( + returnStatus: true, + script: './tests/scripts/git_change_docs.sh', + label: 'Check for docs only changes', + ) + skip_ci = should_skip_ci(env.CHANGE_ID) + skip_slow_tests = should_skip_slow_tests(env.CHANGE_ID) + sh ( + script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh", + label: 'Run lint', + ) + } + } + } +} +} + +lint() + +// Run make. First try to do an incremental make from a previous workspace in hope to +// accelerate the compilation. If something is wrong, clean the workspace and then +// build from scratch. +def make(docker_type, path, make_flag) { + timeout(time: max_time, unit: 'MINUTES') { + try { + cmake_build(docker_type, path, make_flag) + // always run cpp test when build + // sh "${docker_run} ${docker_type} ./tests/scripts/task_cpp_unittest.sh" + } catch (hudson.AbortException ae) { + // script exited due to user abort, directly throw instead of retry + if (ae.getMessage().contains('script returned exit code 143')) { + throw ae + } + echo 'Incremental compilation failed. Fall back to build from scratch' + sh ( + script: "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh ${path}", + label: 'Clear old cmake workspace', + ) + cmake_build(docker_type, path, make_flag) + cpp_unittest(docker_type) + } + } +} + +// NOTE: limit tests to relax folder for now to allow us to skip some of the tests +// that are mostly related to changes in main. +// This helps to speedup CI time and reduce CI cost. +stage('Build and Test') { + if (is_docs_only_build != 1) { + parallel 'BUILD: GPU': { + node('GPU') { + ws(per_exec_ws('tvm/build-gpu')) { + init_git() + sh "${docker_run} ${ci_gpu} nvidia-smi" + sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh build" + make("${ci_gpu}", 'build', '-j2') + sh "${docker_run} ${ci_gpu} ./tests/scripts/unity/task_python_relax_gpuonly.sh" + } + } + }, + 'BUILD: CPU': { + node('CPU') { + ws(per_exec_ws('tvm/build-cpu')) { + init_git() + sh "${docker_run} ${ci_cpu} ./tests/scripts/task_config_build_cpu.sh build" + make(ci_cpu, 'build', '-j2') + sh "${docker_run} ${ci_cpu} ./tests/scripts/unity/task_python_relax.sh" + } + } + } + } else { + Utils.markStageSkippedForConditional('BUILD: CPU') + } +} diff --git a/tests/scripts/unity/README b/tests/scripts/unity/README new file mode 100644 index 0000000000..42f8c3e040 --- /dev/null +++ b/tests/scripts/unity/README @@ -0,0 +1,2 @@ +This folder contains CI task scripts that are specialized +to unity branch, please do not send to other places. diff --git a/tests/scripts/unity/task_python_relax.sh b/tests/scripts/unity/task_python_relax.sh new file mode 100755 index 0000000000..8869c318fa --- /dev/null +++ b/tests/scripts/unity/task_python_relax.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -euxo pipefail + +source tests/scripts/setup-pytest-env.sh +export PYTHONPATH=${PYTHONPATH}:${TVM_PATH}/apps/extension/python +export LD_LIBRARY_PATH="build:${LD_LIBRARY_PATH:-}" + +# to avoid CI CPU thread throttling. +export TVM_BIND_THREADS=0 +export TVM_NUM_THREADS=2 + +make cython3 + +# Run Relax tests +TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm}" pytest tests/python/relax + +# Run Relax examples +# python3 ./apps/relax_examples/mlp.py +# python3 ./apps/relax_examples/nn_module.py +# python3 ./apps/relax_examples/resnet.py diff --git a/tests/scripts/unity/task_python_relax_gpuonly.sh b/tests/scripts/unity/task_python_relax_gpuonly.sh new file mode 100755 index 0000000000..acbcce44f2 --- /dev/null +++ b/tests/scripts/unity/task_python_relax_gpuonly.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +export TVM_TEST_TARGETS="llvm;cuda" +export PYTEST_ADDOPTS="-m gpu $PYTEST_ADDOPTS" +export TVM_RELAY_TEST_TARGETS="cuda" +export TVM_INTEGRATION_TESTSUITE_NAME=python-integration-gpu +export TVM_INTEGRATION_GPU_ONLY=1 + +./tests/scripts/unity/task_python_relax.sh