lightly-ai / lightly

A python library for self-supervised learning on images.
https://docs.lightly.ai/self-supervised-learning/
MIT License
2.83k stars 246 forks source link

Malte lig 4952 add test for all components using gatherlayer #1540

Closed MalteEbner closed 1 month ago

MalteEbner commented 1 month ago

Tests for losses

Aligning the import style is another topic. Here it is a bit more difficult, as there is the name clash between lightly.utils.dist and torch.dist. Currently some files import the one and some the other as dist.

Test for Benchmark module

Added test_dist__gather__benchmark_module.py for benchmarking the BenchmarkModule. Also fixed bug in the BenchmarkModule.on_validation_epoch_start: As the self.dataloader_kNN is not split by the DDP, all devices have the full dataloader and no gathering is necessary.

Other changes

Some typing updates

Missing

No missing test for lightly.utils.dist.gather

All usages of lightly.utils.dist.gather are covered now (except VICRegLLoss): image image

Missing test for other DDP functions

We also have more gather-like functions, e.g. concat_all_gather in lightly/models/utils.py. image

And the kNN also use some gather functions: image

However, these are out of scope for this issue.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.19%. Comparing base (c890e10) to head (bbc2958).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1540 +/- ## ========================================== + Coverage 81.96% 82.19% +0.23% ========================================== Files 144 144 Lines 6094 6073 -21 ========================================== - Hits 4995 4992 -3 + Misses 1099 1081 -18 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.