Skip to content

Add ReSSL - #455

Open
chrisbutulis wants to merge 12 commits into
galilai-group:mainfrom
chrisbutulis:add-ressl
Open

chrisbutulis wants to merge 12 commits into
galilai-group:mainfrom
chrisbutulis:add-ressl

Conversation

@chrisbutulis

@chrisbutulis chrisbutulis commented Oct 4, 2026 •

Copy link
Copy Markdown

Description

This PR adds an implementation of ReSSL (Relational Self-Supervised Learning), introduced in Zheng et al., NeurIPS 2021.

ReSSL learns visual representations by matching the similarity distributions of a student and momentum-updated teacher over a memory queue of teacher embeddings. Unlike instance-discrimination approaches, ReSSL transfers relational information between samples using weakly augmented teacher views and strongly augmented student views.

The implementation supports both the standalone method API and the composable stable_pretraining.forward interface.

Benchmark

Evaluated ReSSL on CIFAR-10 using a ResNet-18 backbone to compare performance with the original paper. Achieved results between 90.11 and 90.28 top-1 accuracy using linear evaluation after 200 epochs of pretraining.

Tests

Added unit tests for the loss, EMA behavior, queue operations, gradient flow, and distributed training, including Lightning DDP integration. All ReSSL tests pass locally.

Planned Work

  • Add the ReSSL relational loss
  • Add the dict-based forward function
  • Add the full ReSSL method class and public exports
  • Add EMA teacher and queue support required by ReSSL
  • Add CPU unit tests
  • Run a small validation experiment
  • Update the method catalog and release notes for the completed implementation

Checklist

  • I have read the Contributing document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR to the RELEASES.rst file.

@chrisbutulis chrisbutulis changed the title [WIP] Add ReSSL Add ReSSL Oct 16, 2026
@chrisbutulis
chrisbutulis marked this pull request as draft October 16, 2026 22:07
@chrisbutulis
chrisbutulis marked this pull request as ready for review October 16, 2026 22:08

@Leon-Leyang Leon-Leyang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @chrisbutulis, I've gone through the PR. Please check the issues below:

  • stable_pretraining/methods/ressl.py:136: ReSSL.forward takes (weak_augmentation, contrastive_augmentation) and repeats the steps of ressl (stable_pretraining/forward.py:537). It should take (batch, stage) and return a dict with "loss", calling the forward function instead of repeating it.
  • stable_pretraining/__init__.py: ReSSL isn't exported from the top-level package (_LAZY_ATTRS, __all__, stable_pretraining/__init__.pyi).
  • stable_pretraining/utils/ressl.py:6: gather_teacher_keys reimplements all_gather (stable_pretraining/utils/distributed.py:234), which MoCov3 already uses for the same purpose (stable_pretraining/methods/mocov3.py:55).
  • stable_pretraining/tests/unit/test_ressl.py: no test trains ReSSL through spt.Manager (a small model and a few training steps are enough) and resumes from a checkpoint, showing that the EMA teacher (with its BatchNorm statistics) and the queue survive the resume.
  • stable_pretraining/tests/unit/test_ressl.py: no test checks that ReSSLLoss and its gradients stay finite on extreme inputs.
  • stable_pretraining/backbone/split_batchnorm.py:12: the new public SplitBatchNorm has no tests.
  • benchmarks/cifar10/ressl-resnet18-lineareval.py: the reported 90.11–90.28 range comes from several linear-evaluation runs, but the description doesn't say which settings (branch, schedule, learning rate) each used. Please make the script's defaults reproduce the reported result, or state the exact commands.
  • METHODS.md:46: the forward-function column is — although the PR adds ressl, and the key-callbacks column lists OnlineQueue, which ReSSL doesn't use.
  • docs/source/api/: ReSSL, the ressl forward function and ReSSLLoss aren't listed in methods.rst, forward.rst and losses.rst.
  • RELEASES.rst:20: the ReSSL entry is indented under the VISReg entry, so it renders as part of it.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.11111% with 8 lines in your changes missing coverage. Please review.

@@            Coverage Diff             @@
##             main     #455      +/-   ##
==========================================
- Coverage   98.17%   98.13%   -0.04%     
==========================================
  Files         163      167       +4     
  Lines       16406    16496      +90     
==========================================
+ Hits        16107    16189      +82     
- Misses        299      307       +8     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

2 participants