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 20, 2022
1 parent 06a282b commit 0665650
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 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,37 @@ 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",
}

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 0665650

Please sign in to comment.