Skip to content

Adds method chaining support to LightningModule.freeze() and LightningModule.unfreeze() by returning self#21469

Merged
bhimrazy merged 7 commits intoLightning-AI:masterfrom
GdoongMathew:feat/freeze_return
Jan 12, 2026
Merged

Adds method chaining support to LightningModule.freeze() and LightningModule.unfreeze() by returning self#21469
bhimrazy merged 7 commits intoLightning-AI:masterfrom
GdoongMathew:feat/freeze_return

Conversation

@GdoongMathew
Copy link
Copy Markdown
Contributor

@GdoongMathew GdoongMathew commented Jan 5, 2026

What does this PR do?

Fixes #21464

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--21469.org.readthedocs.build/en/21469/

@github-actions github-actions Bot added the pl Generic label for PyTorch Lightning package label Jan 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79%. Comparing base (be2e8d0) to head (68b34da).
⚠️ Report is 62 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (be2e8d0) and HEAD (68b34da). Click for more details.

HEAD has 124 uploads less than BASE
Flag BASE (be2e8d0) HEAD (68b34da)
cpu 64 33
python 6 3
lightning_fabric 17 0
pytest 31 0
python3.10 6 3
lightning 29 15
python3.12 18 9
python3.12.7 17 9
python3.13 6 3
python3.11 11 6
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #21469     +/-   ##
=========================================
- Coverage      87%      79%     -8%     
=========================================
  Files         270      267      -3     
  Lines       24059    24004     -55     
=========================================
- Hits        20855    18955   -1900     
- Misses       3204     5049   +1845     

@bhimrazy bhimrazy changed the title return self instance in freeze and unfreeze method Adds method chaining support to LightningModule.freeze() and LightningModule.unfreeze() by returning self Jan 12, 2026
Copy link
Copy Markdown
Collaborator

@bhimrazy bhimrazy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

Nice !

@bhimrazy bhimrazy merged commit 36998f5 into Lightning-AI:master Jan 12, 2026
90 checks passed
@GdoongMathew GdoongMathew deleted the feat/freeze_return branch January 12, 2026 11:43
bhimrazy added a commit to bhimrazy/pytorch-lightning that referenced this pull request Jan 30, 2026
…ningModule.unfreeze()` by returning `self` (Lightning-AI#21469)

* return self instance in `freeze` and `unfreeze` method

* docs: fix docs

* add chlog

* docs: update freeze method docstring to use code-block directive

---------

Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>
Co-authored-by: thomas chaton <thomas@grid.ai>
lantiga pushed a commit that referenced this pull request Jan 30, 2026
…ningModule.unfreeze()` by returning `self` (#21469)

* return self instance in `freeze` and `unfreeze` method

* docs: fix docs

* add chlog

* docs: update freeze method docstring to use code-block directive

---------

Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>
Co-authored-by: thomas chaton <thomas@grid.ai>
Copy link
Copy Markdown

@nderitualexis089-code nderitualexis089-code left a comment

Choose a reason for hiding this comment

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

furious

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pl Generic label for PyTorch Lightning package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return Self type in LightningModule.freeze() and LightningModule.unfreeze method

4 participants