The test TestSPSA::test_adv_example_success_rate_linf in torch/tests/test_attacks.py has an assertion bound (self.assertLess(adv_acc, 0.5)) that is too loose. This means potential bug in the code could still pass the original test.
To quantify this I conducted some experiments where I generated multiple mutations of the source code under test and ran each mutant and the original code 100 times to build a distribution of their outputs. I used KS-test to find mutants that produced a different distribution from the original and use those mutants as a proxy for bugs that could be introduced. In the graph below I show the distribution of both the original code and also the mutants with a different distribution.
Here we see that the bound of 0.5 is too loose since the original distribution (in orange) is much less than 0.5. Furthermore in this graph we can observe that there are many mutants (proxy for bugs) that are below the bound as well and that is undesirable since the test should aim to catch potential bugs in code. I quantify the "bug detection" of this assertion by varying the bound in a trade-off graph below.
In this graph, I plot the mutant catch rate (ratio of mutant outputs that fail the test) and the original pass rate (ratio of original output that pass the test). The original bound of 0.5 (red dotted line) has a catch rate of 0.76
To improve this test, I propose to tighten the bound to 0.29 (the blue dotted line). The new bound has a catch rate of 0.88 (+0.12 increase compare to original) while still has >99 % pass rate (test is not flaky, I ran the updated test 500 times and observed >99 % pass rate). I think this is a good balance between improving the bug-detection ability of the test while keep the flakiness of the test low.
Do you guys think this makes sense? Please let me know if this looks good or if you have any other suggestions or questions.
My Environment:
python=3.6.13
pytorch=1.0.1.post2
my cleverhans Experiment SHA:
e5d00e537ce7ad6119ed5a8db1f0e9736d1f6e1d
Hi,
The test
TestSPSA::test_adv_example_success_rate_linf
intorch/tests/test_attacks.py
has an assertion bound (self.assertLess(adv_acc, 0.5)
) that is too loose. This means potential bug in the code could still pass the original test.To quantify this I conducted some experiments where I generated multiple mutations of the source code under test and ran each mutant and the original code 100 times to build a distribution of their outputs. I used KS-test to find mutants that produced a different distribution from the original and use those mutants as a proxy for bugs that could be introduced. In the graph below I show the distribution of both the original code and also the mutants with a different distribution.
Here we see that the bound of
0.5
is too loose since the original distribution (in orange) is much less than0.5
. Furthermore in this graph we can observe that there are many mutants (proxy for bugs) that are below the bound as well and that is undesirable since the test should aim to catch potential bugs in code. I quantify the "bug detection" of this assertion by varying the bound in a trade-off graph below.In this graph, I plot the mutant catch rate (ratio of mutant outputs that fail the test) and the original pass rate (ratio of original output that pass the test). The original bound of
0.5
(red dotted line) has a catch rate of 0.76To improve this test, I propose to tighten the bound to
0.29
(the blue dotted line). The new bound has a catch rate of 0.88 (+0.12 increase compare to original) while still has >99 % pass rate (test is not flaky, I ran the updated test 500 times and observed >99 % pass rate). I think this is a good balance between improving the bug-detection ability of the test while keep the flakiness of the test low.Do you guys think this makes sense? Please let me know if this looks good or if you have any other suggestions or questions.
My Environment:
my cleverhans Experiment SHA:
e5d00e537ce7ad6119ed5a8db1f0e9736d1f6e1d