Skip to content
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

Misc fixes tests #22

Merged
merged 11 commits into from
Nov 27, 2023
Merged

Misc fixes tests #22

merged 11 commits into from
Nov 27, 2023

Conversation

VRehnberg
Copy link
Collaborator

This is mainly two things:

  1. Solves WaNet probably broken with num_workers > 0 #19
  2. And marks test_train_mahalanobis_advex as flaky

2 is the questionable one. It adds a new dependency to run test-suite and that dependency has questionable maintenance. Additionally, it would be better to just fix test so that it isn't flaky, but I got a bit annoyed and wanted a quick-fix.

Shouldn't need much review. Either cherry-pick only 1 or merge as is.

Summary:
 - don't force num_workers=0 for debug
 - check control_grid instead of warping_field in test_pipeline.py
 - add test for dataloader with num_workers=2 in test_data.py
@VRehnberg
Copy link
Collaborator Author

There are some remaining warnings in tests, mostly from import handling deprecations internally in lightning when I'm using python3.11 but also when deprecation warning for torch.meshgrid, which made me uncertain if we're using it correctly. See pytorch/pytorch#50276

For square images it shouldn't matter, but I'll have to look at it again to be sure that it works in general.

@VRehnberg
Copy link
Collaborator Author

So actually looked at why advex test was flaky and at a first glance it shouldn't be (not strict comparisson)

rob_acc > cfg.success_threshold

but rob_acc in torchattacks is actually in percent https://github.com/Harry24k/adversarial-attacks-pytorch/blob/master/torchattacks/attack.py#L298 so my fix is to scale these to same unit. Possibly we'd like a test that sees that attack can succeed, but with these (basically) untrained models it seems that there are sometimes attacks can't succeed so anything less than 100 % success_threshold could fail then.

@VRehnberg
Copy link
Collaborator Author

Finally no warnings 

==================================================================================== test session starts =====================================================================================
platform linux -- Python 3.11.5, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/vikren/Documents/Private/SERI-MATS/Research/cupbearer
configfile: pytest.ini
collected 35 items                                                                                                                                                                           

tests/test_abstractions.py ............                                                                                                                                                [ 34%]
tests/test_data.py .............                                                                                                                                                       [ 71%]
tests/test_pipeline.py .......                                                                                                                                                         [ 91%]
tests/test_utils.py ...                                                                                                                                                                [100%]

==================================================================================== 35 passed in 10.59s =====================================================================================

@VRehnberg VRehnberg requested a review from ejnnr November 24, 2023 13:16
@VRehnberg VRehnberg linked an issue Nov 24, 2023 that may be closed by this pull request
Copy link
Owner

@ejnnr ejnnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks great! Only thing I noticed is two places where you have a tuple (None,) as the default for log_every_n_steps. I assume that's a typo but wasn't sure enough to just change it and merge. (If it's deliberate and I'm missing something, then at least the type annotation should be different). Feel free to merge after dealing with that!

src/cupbearer/detectors/finetuning.py Outdated Show resolved Hide resolved
src/cupbearer/scripts/conf/train_classifier_conf.py Outdated Show resolved Hide resolved
src/cupbearer/scripts/make_adversarial_examples.py Outdated Show resolved Hide resolved
@VRehnberg VRehnberg merged commit 6e540f8 into ejnnr:main Nov 27, 2023
@VRehnberg VRehnberg deleted the misc-fixes-tests branch November 27, 2023 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WaNet probably broken with num_workers > 0
2 participants