This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch tvm-simplify-jenkins-pytest-sharding in repository https://gitbox.apache.org/repos/asf/tvm.git
commit e74e2d1ebdba8c1a8b9210f20f4c294e1b87279d Author: Tianqi Chen <[email protected]> AuthorDate: Sat Jul 4 23:44:26 2026 +0000 ci: enable automatic pytest parallelism --- docs/contribute/pull_request.rst | 2 +- tests/scripts/setup-pytest-env.sh | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/contribute/pull_request.rst b/docs/contribute/pull_request.rst index 8ee4f2c65a..c645ce2e4d 100644 --- a/docs/contribute/pull_request.rst +++ b/docs/contribute/pull_request.rst @@ -242,7 +242,7 @@ Necessary dependencies: .. code:: bash - pip install --user pytest Cython + pip install --user pytest pytest-xdist Cython If you want to run all tests: diff --git a/tests/scripts/setup-pytest-env.sh b/tests/scripts/setup-pytest-env.sh index 171ddbc2d0..d9e6f27a68 100755 --- a/tests/scripts/setup-pytest-env.sh +++ b/tests/scripts/setup-pytest-env.sh @@ -76,10 +76,18 @@ function run_pytest() { suite_name="${test_suite_name}-${current_shard}-${ffi_type}" - DEFAULT_PARALLELISM=1 + DEFAULT_PARALLELISM=auto - if [[ ! "${extra_args[*]}" == *" -n"* ]] && [[ ! "${extra_args[*]}" == *" -dist"* ]]; then - extra_args+=("-n=$DEFAULT_PARALLELISM") + # Keep the default scoped to run_pytest so nested and one-off pytest + # invocations do not recursively start workers. Explicit options from + # either the environment or the caller remain authoritative. + pytest_args=" ${PYTEST_ADDOPTS:-} ${extra_args[*]} " + if [[ "${pytest_args}" != *" -n"* ]] && + [[ "${pytest_args}" != *" --numprocesses"* ]] && + [[ "${pytest_args}" != *" --dist"* ]] && + [[ "${pytest_args}" != *" -d "* ]] && + [[ "${pytest_args}" != *" --tx"* ]]; then + extra_args+=("-n=$DEFAULT_PARALLELISM" "--dist=loadgroup") fi exit_code=0
