-
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
[UnitTests] Apply correct requires_gpu() pytest marks for parametrized target #8542
[UnitTests] Apply correct requires_gpu() pytest marks for parametrized target #8542
Conversation
Related to #8387. This PR removes the |
python/tvm/testing.py
Outdated
if "target" not in parametrized_args: | ||
# Check if the function is marked with either excluded or | ||
# known failing targets. | ||
for mark in metafunc.definition.iter_markers("parametrize"): |
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.
nit: Better not to use loop-else construct (e.g., https://intoli.com/blog/for-else-in-python/).
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.
No problem, and I can change that. The loop-else reads as cleaner to me, even in the blog post's example, but having a consistent style with the rest of the TVM codebase is far more important so I'll avoid using them.
e7dfbdc
to
8ee0702
Compare
Failures in CI were due to ONNX-specific tests. This PR is now rebased on top of #8574 , which should be merged prior to this PR. |
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.
I don't understand what this is doing, and it's enabled tests that aren't marked to run on GPU, and this freaks me out. I really think we need a full review/doc update/RFC of what on earth the testing parameterization is doing, because I really have no idea how to tell CI where to run or disable certain tests anymore. The fact that we've been silently disabling and enabling tests is terrifying.
Agreed, this ended up being a much larger impact than I had expected, and this PR shouldn't be merged until/unless we have consensus on it. (This comment ended up being a bit longer than I had expected, as I was looking up some history for my own knowledge, and figured I might as well write it down.) Regarding changes to how unit tests are parametrized, when they are marked with
This worked, but allowed for accidentally forgetting an annotation for a target-specific test. This particular PR was motivated by #8387 , which added a missing annotation of I think the source of my misunderstanding was that |
With the parametrized targets, we can explicitly mark the test with |
457dcb3
to
60a2fcb
Compare
60a2fcb
to
eede865
Compare
Added the ONNX cleanup and use of |
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.
LGTM. Agreed that we'll follow up with a user-facing doc on pytest usage. Thanks, @Lunderberg!
Current failure is due to the automatic-marking expected a string, and not a |
Follow-up from apache#8542, to document existing features.
Follow-up from apache#8542, to document existing features.
b4628a7
to
0019d60
Compare
- The onnx tests `test_basic_convinteger`, `test_convinteger_with_padding`, `test_range_float_type_positive_delta_expanded`, and `test_range_int32_type_positive_delta_expanded` don't run correctly on CUDA targets, so they are added to the exclusion. - Parametrized over the relative directory name, rather than the full directory name. This improves readability of the pytest output, and keeps the same parametrized test name across different python version. - Changed the target-specific skips to check the target kind, rather than the full target string.
…d target Prevoiusly, the addition of tvm.testing._target_to_requirement pytest marks was handled by the parametrize_targets function. The _auto_parametrize_target function assumed that a unit test that was already parametrized had all markings needed. If a unit test was explicitly parametrized using @pytest.mark.parametrize, these marks would be missing. In most cases, this explicit use of @pytest.mark.parametrize('target', ...) should be avoided, but has value in the case of marking with multiple parameters with @pytest.mark.parametrize('target,other', ...). This use case isn't yet supported by the tvm.testing.parameters function. Therefore, if this occurs, detect it and add the appropriate marks.
Initial implementation did work correctly with @tvm.testing.parametrize_targets. Also, went through all cases where "target" is used to parametrize on something other than a target string, and renamed.
…argets After merging of the `tvm.testing.parametrize_targets` and `tvm.testing._auto_parametrize_target` code paths, `known_failing_targets` can be used in both cases.
Previously, tvm.testing._target_to_requirement required the argument to be a string. This commit allows it to be either a string or a `tvm.target.Target`.
63344f6
to
ff83bdb
Compare
Bumping to restart CI after #8656 . |
If the unit test has already been parametrized with pytest.params to add parameter-specific marks, respect those existing marks. This can happen in some cases in the CI, uncertain yet what is causing them. Maybe pytest-xdist related, but there's some difficulty in reproducing it locally.
ff83bdb
to
c49a86b
Compare
…d target (apache#8542) * [Onnx][UnitTests] Excluded additional onnx tests - The onnx tests `test_basic_convinteger`, `test_convinteger_with_padding`, `test_range_float_type_positive_delta_expanded`, and `test_range_int32_type_positive_delta_expanded` don't run correctly on CUDA targets, so they are added to the exclusion. - Parametrized over the relative directory name, rather than the full directory name. This improves readability of the pytest output, and keeps the same parametrized test name across different python version. - Changed the target-specific skips to check the target kind, rather than the full target string. * [UnitTests] Apply correct requires_gpu() pytest marks for parametrized target Prevoiusly, the addition of tvm.testing._target_to_requirement pytest marks was handled by the parametrize_targets function. The _auto_parametrize_target function assumed that a unit test that was already parametrized had all markings needed. If a unit test was explicitly parametrized using @pytest.mark.parametrize, these marks would be missing. In most cases, this explicit use of @pytest.mark.parametrize('target', ...) should be avoided, but has value in the case of marking with multiple parameters with @pytest.mark.parametrize('target,other', ...). This use case isn't yet supported by the tvm.testing.parameters function. Therefore, if this occurs, detect it and add the appropriate marks. * [UnitTest] Bugfix, applying requires_* markers to parametrized targets. Initial implementation did work correctly with @tvm.testing.parametrize_targets. Also, went through all cases where "target" is used to parametrize on something other than a target string, and renamed. * [Onnx] Switched from using pytest.skip to tvm.testing.known_failing_targets After merging of the `tvm.testing.parametrize_targets` and `tvm.testing._auto_parametrize_target` code paths, `known_failing_targets` can be used in both cases. * [Testing] Enable `Target` object as argument to _target_to_requirement Previously, tvm.testing._target_to_requirement required the argument to be a string. This commit allows it to be either a string or a `tvm.target.Target`. * [Testing] Auto-target parametrization, handle pytest ParameterSet If the unit test has already been parametrized with pytest.params to add parameter-specific marks, respect those existing marks. This can happen in some cases in the CI, uncertain yet what is causing them. Maybe pytest-xdist related, but there's some difficulty in reproducing it locally. Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
* [Docs] Added documentation on pytest target parametrization. Follow-up from #8542, to document existing features. * [Docs] Updated pytest parametrization documentation following review Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
…d target (apache#8542) * [Onnx][UnitTests] Excluded additional onnx tests - The onnx tests `test_basic_convinteger`, `test_convinteger_with_padding`, `test_range_float_type_positive_delta_expanded`, and `test_range_int32_type_positive_delta_expanded` don't run correctly on CUDA targets, so they are added to the exclusion. - Parametrized over the relative directory name, rather than the full directory name. This improves readability of the pytest output, and keeps the same parametrized test name across different python version. - Changed the target-specific skips to check the target kind, rather than the full target string. * [UnitTests] Apply correct requires_gpu() pytest marks for parametrized target Prevoiusly, the addition of tvm.testing._target_to_requirement pytest marks was handled by the parametrize_targets function. The _auto_parametrize_target function assumed that a unit test that was already parametrized had all markings needed. If a unit test was explicitly parametrized using @pytest.mark.parametrize, these marks would be missing. In most cases, this explicit use of @pytest.mark.parametrize('target', ...) should be avoided, but has value in the case of marking with multiple parameters with @pytest.mark.parametrize('target,other', ...). This use case isn't yet supported by the tvm.testing.parameters function. Therefore, if this occurs, detect it and add the appropriate marks. * [UnitTest] Bugfix, applying requires_* markers to parametrized targets. Initial implementation did work correctly with @tvm.testing.parametrize_targets. Also, went through all cases where "target" is used to parametrize on something other than a target string, and renamed. * [Onnx] Switched from using pytest.skip to tvm.testing.known_failing_targets After merging of the `tvm.testing.parametrize_targets` and `tvm.testing._auto_parametrize_target` code paths, `known_failing_targets` can be used in both cases. * [Testing] Enable `Target` object as argument to _target_to_requirement Previously, tvm.testing._target_to_requirement required the argument to be a string. This commit allows it to be either a string or a `tvm.target.Target`. * [Testing] Auto-target parametrization, handle pytest ParameterSet If the unit test has already been parametrized with pytest.params to add parameter-specific marks, respect those existing marks. This can happen in some cases in the CI, uncertain yet what is causing them. Maybe pytest-xdist related, but there's some difficulty in reproducing it locally. Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
…8638) * [Docs] Added documentation on pytest target parametrization. Follow-up from apache#8542, to document existing features. * [Docs] Updated pytest parametrization documentation following review Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
…d target (apache#8542) * [Onnx][UnitTests] Excluded additional onnx tests - The onnx tests `test_basic_convinteger`, `test_convinteger_with_padding`, `test_range_float_type_positive_delta_expanded`, and `test_range_int32_type_positive_delta_expanded` don't run correctly on CUDA targets, so they are added to the exclusion. - Parametrized over the relative directory name, rather than the full directory name. This improves readability of the pytest output, and keeps the same parametrized test name across different python version. - Changed the target-specific skips to check the target kind, rather than the full target string. * [UnitTests] Apply correct requires_gpu() pytest marks for parametrized target Prevoiusly, the addition of tvm.testing._target_to_requirement pytest marks was handled by the parametrize_targets function. The _auto_parametrize_target function assumed that a unit test that was already parametrized had all markings needed. If a unit test was explicitly parametrized using @pytest.mark.parametrize, these marks would be missing. In most cases, this explicit use of @pytest.mark.parametrize('target', ...) should be avoided, but has value in the case of marking with multiple parameters with @pytest.mark.parametrize('target,other', ...). This use case isn't yet supported by the tvm.testing.parameters function. Therefore, if this occurs, detect it and add the appropriate marks. * [UnitTest] Bugfix, applying requires_* markers to parametrized targets. Initial implementation did work correctly with @tvm.testing.parametrize_targets. Also, went through all cases where "target" is used to parametrize on something other than a target string, and renamed. * [Onnx] Switched from using pytest.skip to tvm.testing.known_failing_targets After merging of the `tvm.testing.parametrize_targets` and `tvm.testing._auto_parametrize_target` code paths, `known_failing_targets` can be used in both cases. * [Testing] Enable `Target` object as argument to _target_to_requirement Previously, tvm.testing._target_to_requirement required the argument to be a string. This commit allows it to be either a string or a `tvm.target.Target`. * [Testing] Auto-target parametrization, handle pytest ParameterSet If the unit test has already been parametrized with pytest.params to add parameter-specific marks, respect those existing marks. This can happen in some cases in the CI, uncertain yet what is causing them. Maybe pytest-xdist related, but there's some difficulty in reproducing it locally. Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
…8638) * [Docs] Added documentation on pytest target parametrization. Follow-up from apache#8542, to document existing features. * [Docs] Updated pytest parametrization documentation following review Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
Previously, the addition of tvm.testing._target_to_requirement pytest marks was handled by the parametrize_targets function. The _auto_parametrize_target function assumed that a unit test that was already parametrized had all markings needed. If a unit test was explicitly parametrized using @pytest.mark.parametrize, these marks would be missing.
In most cases, this explicit use of @pytest.mark.parametrize('target', ...) should be avoided, but has value in the case of marking with multiple parameters with @pytest.mark.parametrize('target,other', ...). This use case isn't yet supported by the tvm.testing.parameters function. Therefore, if this occurs, detect it and add the appropriate marks.