Remove deprecated collate functions, model wrappers, and arguments - #2021
Draft
gabrielfruet wants to merge 4 commits into
Draft
Remove deprecated collate functions, model wrappers, and arguments#2021gabrielfruet wants to merge 4 commits into
gabrielfruet wants to merge 4 commits into
Conversation
gabrielfruet
force-pushed
the
claude/lightlyssl-remove-deprecated-6bf61d
branch
from
August 11, 2026 21:31
cd5fa6f to
8df32fe
Compare
Base automatically changed from
gabriel-trn-1734-remove-api-client-from-lightlyssl
to
master
August 14, 2026 19:15
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
force-pushed
the
claude/lightlyssl-remove-deprecated-6bf61d
branch
from
August 17, 2026 12:49
8df32fe to
26f99dc
Compare
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.
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
lightly.data.collate(Base,Image,MultiView,SimCLR,MoCo,MultiCrop,SwaV,DINO,MAE,PIRL,MSN,SMoG,VICReg,VICRegL)lightly.transforms.*TransformplusMultiViewCollatelightly.data.imagenet_normalizelightly.transforms.utils.IMAGENET_NORMALIZEfrom lightly.data.collate import IJEPAMaskCollator— the wholelightly.data.collatemodule goes, and with it the re-export #2020 left behindfrom lightly.data import IJEPAMaskCollatorlightly.models.{BarlowTwins, BYOL, MoCo, NNCLR, SimCLR, SimSiam}lightly.models.modules, as inexamples/lightly.loss.SymNegCosineSimilarityLosslightly.loss.NegativeCosineSimilarityMSNLoss(me_max_weight=...)MSNLoss(regularization_weight=...)GaussianBlur(kernel_size=..., scale=...)and the pass-throughs on the method transformsGaussianBlur(sigmas=...)MemoryBankModule(size=n)MemoryBankModule(size=(n, dim))trainer.weights_summaryin the CLI configtrainer.enable_model_summaryandsummary_callback.max_depthplot_augmented_images(images, collate_function)plot_augmented_images(images, transform), taking aMultiViewTransformWorth knowing
lightly-ssl-trainandlightly-magicbuild aSimCLRTransforminstead of anImageCollateFunction. The augmentations are identical: every key in thecollate:config namespace maps onto aSimCLRTransformargument and all of them are pinned inconfig.yaml. The namespace keeps its name becauselightly-embedreadscollate.input_size.GaussianBlur.__init__is keyword-only now.kernel_sizewas the first positional argument, so removing it would otherwise reinterpretGaussianBlur(0.3)asprob=0.3without complaint.Dropping the blur arguments shifts positional order on roughly 30 public transform classes, so callers passing arguments positionally past that point need keywords.
MemoryBankModuleraisesValueErroron a bare positive intsize. Inferring the feature dimension from the first batch broke distributed training.size=0still disables the bank, soNTXentLoss(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 indocs/sourceto confirm it still resolves.