-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Enable pytest-xdist for TVM CI #8576
Changes from all commits
5430415
a0b17e1
daa6849
43b9f31
86a6a78
77a870b
870e999
8ad193a
4978c90
cba9358
4166f90
e853b6a
7261c3e
c9e1709
aea9e1e
3b76e38
1ba5b0a
8130e8b
1e0660f
18424f3
392ab8d
5a1aa02
935c520
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,35 @@ export PYTHONPATH="${TVM_PATH}/python" | |
export TVM_PYTEST_RESULT_DIR="${TVM_PATH}/build/pytest-results" | ||
mkdir -p "${TVM_PYTEST_RESULT_DIR}" | ||
|
||
if [ -n "${CI_CPUSET_NUM_CPUS-}" ]; then | ||
# When the # of CPUs has been restricted (e.g. when --cpuset-cpus has been passed to docker by | ||
# docker/bash.sh), explicitly use all available CPUs. This environment variable is set by | ||
# docker/bash.sh when it sets --cpuset-cpus. | ||
PYTEST_NUM_CPUS="${CI_CPUSET_NUM_CPUS}" | ||
else | ||
# Else attempt to use $(nproc) - 1. | ||
PYTEST_NUM_CPUS=$(nproc) | ||
if [ -z "${PYTEST_NUM_CPUS}" ]; then | ||
echo "WARNING: nproc failed; running pytest with only 1 CPU" | ||
PYTEST_NUM_CPUS=1 | ||
elif [ ${PYTEST_NUM_CPUS} -gt 1 ]; then | ||
PYTEST_NUM_CPUS=$(expr ${PYTEST_NUM_CPUS} - 1) # Don't nuke interactive work. | ||
fi | ||
|
||
# Don't use >4 CPUs--in general, we only use 4 CPUs in testing, so we want to retain this | ||
# maximum for the purposes of reproducing the CI. You can still override this by setting | ||
# --cpuset-cpus in docker/bash.sh. | ||
if [ ${PYTEST_NUM_CPUS} -gt 4 ]; then | ||
PYTEST_NUM_CPUS=4 | ||
fi | ||
fi | ||
|
||
function run_pytest() { | ||
local extra_args=( ) | ||
if [ "$1" == "--parallel" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the documentation currently recommends using |
||
extra_args=( -n "${PYTEST_NUM_CPUS}" ) | ||
shift | ||
fi | ||
local ffi_type="$1" | ||
shift | ||
local test_suite_name="$1" | ||
|
@@ -43,8 +71,10 @@ function run_pytest() { | |
exit 2 | ||
fi | ||
TVM_FFI=${ffi_type} python3 -m pytest \ | ||
--timeout=480 \ | ||
-o "junit_suite_name=${test_suite_name}-${ffi_type}" \ | ||
"--junit-xml=${TVM_PYTEST_RESULT_DIR}/${test_suite_name}-${ffi_type}.xml" \ | ||
"--junit-prefix=${ffi_type}" \ | ||
"${extra_args[@]}" \ | ||
"$@" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 4 ?
Also would it be possible for us to specialize run_pytest to for certain subset of tests that we think could benefit from this. i.e. --parallel <some_number> ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 just relates to how we currently allocate Jenkins executors to CI nodes. what i really want to do is make it possible to use $(nproc) here always (so that each node is maximally used). however, initial tests indicate that there is a threshold after which nodes become RAM-limited.
can you clarify your second question? how would we leverage this better in the subset?