[MNT] SIGReg cleanup: dedup tests, backfill docstring, document weights#1925
Open
RecreationalMath wants to merge 4 commits into
Open
[MNT] SIGReg cleanup: dedup tests, backfill docstring, document weights#1925RecreationalMath wants to merge 4 commits into
RecreationalMath wants to merge 4 commits into
Conversation
TestLeJEPALoss.test_forward_gather_distributed_world_size_gt_one was using the pre-1923 mock pattern that only patched torch.distributed.all_reduce. The assertion call_count == 3 passed only because torch.distributed.nn.all_reduce is internally implemented via torch.distributed.all_reduce, so the mock caught both APIs together. Mock the two APIs separately and assert their counts individually (c10d all_reduce: 1 call for num_samples_tensor, nn all_reduce: 2 calls for cos_sum and sin_sum), matching the pattern TestSIGReg uses after lightly-ai#1923.
Added an inline comment explaining the symmetry exploit, the SIGReg integrand (cos_mean - phi)^2 + sin_mean^2 is even in t, so the integral over [-t_max, t_max] equals twice the integral over [0, t_max]. Evaluating at only the non-negative knots and doubling the trapezoidal weights gives the same result while halving the number of knots to evaluate.
18 tasks
gabrielfruet
approved these changes
May 18, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1925 +/- ##
=======================================
Coverage 86.26% 86.26%
=======================================
Files 170 170
Lines 7104 7104
=======================================
Hits 6128 6128
Misses 976 976 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #1916. Four small SIGReg-area improvements in
lightly/loss/lejepa_loss.pyandtests/loss/test_lejepa_loss.py. No production behaviour change.TestSIGRegclass. Refer to this comment. Aligns with the test-layout rule mentioned in this comment: one test file per source file.TestLeJEPALossdistributed test mocks to mirror the patternTestSIGReguses after Fix SIGReg distributed gradient under DDP #1923. Mocktorch.distributed.all_reduceandtorch.distributed.nn.all_reduceseparately, then assert their counts individually (1 and 2) rather than the conflatedcall_count == 3assertion.SIGRegclass docstring withAttributes:andExamples:sections, matching the convention used byDINOLoss,VICRegLoss,BarlowTwinsLoss, etc.Documentation
Tests