Add non_device_test
pytest mark to filter out non-device tests
#29213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per title.
Many tests in transformers do not use
torch_device
,.to(0)
,.to("cuda")
, etc. and are always run on CPU. These tests are irrelevant for people who would like to run Transformers tests on their device.With this proposed PR, one can now run
pytest tests/ -m "not not_device_test" --collect-only
to filter out non-device tests. We usepytest_collection_modifyitems
in order to both capture the tests defined intest_modeling_common.py
and in subclasses as well (no need to@pytest.mark.not_gpu_test
everywhere) which does not add a significant overhead after tests collection.We prefer a mark
non_device_test
rather thandevice_test
, as people adding new tests may forget to add the device tests in the list. It is safer to be greedy (in a reasonable extent).This now gives
instead of the previous 54481 tests selected.
This is requested by AMD.