Skip to content

Commit

Permalink
[ci] Default to n=2 for test parallelism
Browse files Browse the repository at this point in the history
This is attempt #2 of apache#12376 which was reverted in apache#12413. The changes
in `plugin.py` should keep all the tests on the same node so sporadic
failures don't happen due to scheduling.
  • Loading branch information
driazati committed Aug 24, 2022
1 parent b4b66e2 commit 10f954a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions python/tvm/testing/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
import tvm
from tvm.testing import utils

try:
from xdist.scheduler.loadscope import LoadScopeScheduling

HAVE_XDIST = True
except ImportError:
HAVE_XDIST = False


MARKERS = {
"gpu": "mark a test as requiring a gpu",
Expand Down Expand Up @@ -319,3 +326,38 @@ def _parametrize_correlated_parameters(metafunc):
names = ",".join(name for name, values in params)
value_sets = zip(*[values for name, values in params])
metafunc.parametrize(names, value_sets, indirect=True, ids=ids)


# pytest-xdist isn't required but is used in CI, so guard on its presence
if HAVE_XDIST:

def pytest_xdist_make_scheduler(config, log):
"""
Serialize certain tests for pytest-xdist that have inter-test
dependencies
"""

class TvmTestScheduler(LoadScopeScheduling):
"""
Scheduler to serializer tests
"""

def _split_scope(self, nodeid):
"""
Returns a specific string for classes of nodeids
"""
# NOTE: these tests contain inter-test dependencies and must be
# serialized
items = {
"test_tvm_testing_features": "functional-tests",
"tests/python/unittest/test_crt": "crt-tests",
"tests/python/driver/tvmc": "tvmc-tests",
}

for nodeid_pattern, suite_name in items.items():
if nodeid_pattern in nodeid:
return suite_name

return nodeid

return TvmTestScheduler(config, log)

0 comments on commit 10f954a

Please sign in to comment.