-
Notifications
You must be signed in to change notification settings - Fork 402
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
Add Test strategy #688
Add Test strategy #688
Changes from all commits
2e71759
17578f6
3131b5a
7f51e99
27aa6c2
258da03
b4dae4d
8439b4a
30b4ea7
2f5dc34
2dfe6c8
2e9f235
70bce49
938ceee
7922860
0f49516
f6eaf38
7635ddf
debcd8f
f9d300d
4eb16e8
25a48c9
df21357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
from torch import tensor | ||
|
||
from tests.helpers import seed_all | ||
from tests.helpers.testers import NUM_BATCHES, MetricTester | ||
from tests.helpers.testers import NUM_BATCHES, MetricTester, MetricTesterDDPCases | ||
from torchmetrics.classification.auc import AUC | ||
from torchmetrics.functional import auc | ||
|
||
|
@@ -55,22 +55,29 @@ def sk_auc(x, y, reorder=False): | |
|
||
@pytest.mark.parametrize("x, y", _examples) | ||
class TestAUC(MetricTester): | ||
@pytest.mark.parametrize("ddp", [False]) | ||
@pytest.mark.parametrize(MetricTesterDDPCases.name_strategy(), MetricTesterDDPCases.cases_strategy()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DDP apparently fails and therefore was probably excluded in the tests, yet there is no mention in the docs, that DDP is not supported. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Borda @SkafteNicki any idea how to handle this? removing the full ddp/device strategy and opening an issue to fix auc would be my recommendation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its hard for me to remember, but basically AUC needs ordered input to be working and while we are testing on ordered input when we move to |
||
@pytest.mark.parametrize("dist_sync_on_step", [True, False]) | ||
def test_auc(self, x, y, ddp, dist_sync_on_step): | ||
def test_auc(self, x, y, ddp, dist_sync_on_step, device): | ||
self.run_class_metric_test( | ||
ddp=ddp, | ||
preds=x, | ||
target=y, | ||
metric_class=AUC, | ||
sk_metric=sk_auc, | ||
dist_sync_on_step=dist_sync_on_step, | ||
device=device, | ||
) | ||
|
||
@pytest.mark.parametrize(MetricTesterDDPCases.name_device(), MetricTesterDDPCases.cases_device()) | ||
@pytest.mark.parametrize("reorder", [True, False]) | ||
def test_auc_functional(self, x, y, reorder): | ||
def test_auc_functional(self, x, y, reorder, device): | ||
self.run_functional_metric_test( | ||
x, y, metric_functional=auc, sk_metric=partial(sk_auc, reorder=reorder), metric_args={"reorder": reorder} | ||
x, | ||
y, | ||
metric_functional=auc, | ||
sk_metric=partial(sk_auc, reorder=reorder), | ||
device=device, | ||
metric_args={"reorder": reorder}, | ||
) | ||
|
||
@pytest.mark.parametrize("reorder", [True, False]) | ||
|
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 would say it is cleaner if it will be a constant or function returning tuple:
and later:
@pytest.mark.parametrize(*ddp_name_options())
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.
but anyway why is this needed?
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.
The reason I added this stategy was that now all available test cases are generated and you can explicitly test them locally. This way you can guarantee full coverage, don't depend on the ci machines or some launch flags and each test states on which device it runs. This way you dont have to check the machine stats to e.g. find out, if a test failed on single or multi gpu.
In order to optimize the tests, having an additional skip condition with an env var could achieve the same. Especially for test optimization you could then run ddp=false on a machine with a single gpu and ddp=True on one with multiple.
I'm fine putting it into a single function, my idea was to stick with two parameter style of
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.
I agree with @Borda that it would be better to return a tuple there.
For the general purpose: I think we should split this between arguments for every test (like devices and maybe also ddp strategies) for which we should use pytest fixtures (that's what they are there for) and then you could call
pytest --devices=XX tests
. For test-specific arguments this approach is fine IMOThere 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'm unsure how to continue with this. Any suggestions?