Skip to content

Remove deprecated collate functions, model wrappers, and arguments - #2021

Draft
gabrielfruet wants to merge 4 commits into
masterfrom
claude/lightlyssl-remove-deprecated-6bf61d
Draft

Remove deprecated collate functions, model wrappers, and arguments#2021
gabrielfruet wants to merge 4 commits into
masterfrom
claude/lightlyssl-remove-deprecated-6bf61d

Conversation

@gabrielfruet

@gabrielfruet gabrielfruet commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Removes the deprecated collate functions, the high-level model wrappers, SymNegCosineSimilarityLoss, and a set of deprecated arguments. All of it has warned since 1.3.0 or 1.4.0.

Breaking change — needs a minor version bump at release, which is not part of this PR.

Rebased onto master now that #1939 and #2020 have landed; the diff is this PR's own four commits.

Migration

Removed Replacement
every collate function in lightly.data.collate (Base, Image, MultiView, SimCLR, MoCo, MultiCrop, SwaV, DINO, MAE, PIRL, MSN, SMoG, VICReg, VICRegL) the matching lightly.transforms.*Transform plus MultiViewCollate
lightly.data.imagenet_normalize lightly.transforms.utils.IMAGENET_NORMALIZE
from lightly.data.collate import IJEPAMaskCollator — the whole lightly.data.collate module goes, and with it the re-export #2020 left behind from lightly.data import IJEPAMaskCollator
lightly.models.{BarlowTwins, BYOL, MoCo, NNCLR, SimCLR, SimSiam} heads from lightly.models.modules, as in examples/
lightly.loss.SymNegCosineSimilarityLoss lightly.loss.NegativeCosineSimilarity
MSNLoss(me_max_weight=...) MSNLoss(regularization_weight=...)
GaussianBlur(kernel_size=..., scale=...) and the pass-throughs on the method transforms GaussianBlur(sigmas=...)
MemoryBankModule(size=n) MemoryBankModule(size=(n, dim))
trainer.weights_summary in the CLI config trainer.enable_model_summary and summary_callback.max_depth
plot_augmented_images(images, collate_function) plot_augmented_images(images, transform), taking a MultiViewTransform

Worth knowing

lightly-ssl-train and lightly-magic build a SimCLRTransform instead of an ImageCollateFunction. The augmentations are identical: every key in the collate: config namespace maps onto a SimCLRTransform argument and all of them are pinned in config.yaml. The namespace keeps its name because lightly-embed reads collate.input_size.

GaussianBlur.__init__ is keyword-only now. kernel_size was the first positional argument, so removing it would otherwise reinterpret GaussianBlur(0.3) as prob=0.3 without complaint.

Dropping the blur arguments shifts positional order on roughly 30 public transform classes, so callers passing arguments positionally past that point need keywords.

MemoryBankModule raises ValueError on a bare positive int size. Inferring the feature dimension from the first batch broke distributed training. size=0 still disables the bank, so NTXentLoss(memory_bank_size=0) is unaffected.

Testing

Full pytest suite after the rebase: 1397 passed, 226 skipped. ruff format-check and lint are clean. The one failure, tests/utils/test_dist__gather__losses.py::test_loss_dcl, is the macOS DDP hang from #1917 and fails identically on an unmodified master checkout.

mypy and the Sphinx docs build don't run on this machine — mypy 1.4.1 crashes on the numpy 2.5.1 stubs, and Sphinx wants imghdr, which Python 3.13 removed. Instead I imported every autodoc target in docs/source to confirm it still resolves.

@gabrielfruet
gabrielfruet force-pushed the claude/lightlyssl-remove-deprecated-6bf61d branch from cd5fa6f to 8df32fe Compare August 11, 2026 21:31
Base automatically changed from gabriel-trn-1734-remove-api-client-from-lightlyssl to master August 14, 2026 19:15
gabrielfruet and others added 4 commits August 17, 2026 09:43
Collate functions have warned since v1.4.0. Transforms plus MultiViewCollate
replace them.

lightly-ssl-train now builds a SimCLRTransform from the collate: config
namespace instead of an ImageCollateFunction. Every key maps onto a
SimCLRTransform argument and all of them are pinned in config.yaml, so the
augmentations are unchanged. The namespace keeps its name because
lightly-embed reads collate.input_size.

plot_augmented_images takes a MultiViewTransform. The view transforms wrap a
T.Compose rather than subclassing it, so apply_transform_without_normalize
needs to unwrap them, otherwise it returns normalized tensors instead of PIL
images.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
BarlowTwins, BYOL, MoCo, NNCLR, SimCLR and SimSiam have warned since they
were marked for removal in 1.3.0. Build models from the heads in
lightly.models.modules instead, as the examples do.

_momentum.py goes with them; BYOL and MoCo were its only users.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both arguments have warned since 1.4.0 and were ignored after warning, so
removing them changes no augmentation output. The pass-through arguments in
the method transforms go with them.

FDATransform defaulted kernel_size to 23 rather than None, so constructing
one emitted two DeprecationWarnings. That is gone now.

GaussianBlur.__init__ is keyword-only. kernel_size was the first positional
argument, so dropping it would otherwise reinterpret GaussianBlur(0.3) as
prob=0.3.

detcon_transform keeps its kernel_size: it feeds torchvision's GaussianBlur,
which is a different argument.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- MSNLoss(me_max_weight=): use regularization_weight
- SymNegCosineSimilarityLoss: use NegativeCosineSimilarity
- MemoryBankModule bare positive int size: pass (num_features, dim). size=0
  still disables the bank, so NTXentLoss(memory_bank_size=0) is unaffected.
  Inferring the feature dimension from the first batch broke distributed
  training, so it now raises instead of warning, and the bank is allocated
  in __init__.
- trainer.weights_summary: use trainer.enable_model_summary and
  summary_callback.max_depth

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gabrielfruet
gabrielfruet force-pushed the claude/lightlyssl-remove-deprecated-6bf61d branch from 8df32fe to 26f99dc Compare August 17, 2026 12:49
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.

1 participant