Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call configure_module before freeze_before_training #20428

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

chualanagit
Copy link
Contributor

@chualanagit chualanagit commented Nov 18, 2024

What does this PR do?

Fixes #19658

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

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Nov 18, 2024
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79%. Comparing base (60289d7) to head (c20c173).

❗ There is a different number of reports uploaded between BASE (60289d7) and HEAD (c20c173). Click for more details.

HEAD has 102 uploads less than BASE
Flag BASE (60289d7) HEAD (c20c173)
cpu 48 24
lightning 37 18
pytest 26 0
python3.9 12 6
lightning_fabric 7 0
python3.11 12 6
python3.10 6 3
python3.12 18 9
gpu 2 0
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20428     +/-   ##
=========================================
- Coverage      88%      79%     -9%     
=========================================
  Files         267      264      -3     
  Lines       23382    23327     -55     
=========================================
- Hits        20479    18364   -2115     
- Misses       2903     4963   +2060     

@lantiga
Copy link
Collaborator

lantiga commented Nov 18, 2024

Thank you @chualanagit

We need to make sure configure_model is not called twice:
https://github.com/Lightning-AI/pytorch-lightning/blob/master/src/lightning/pytorch/trainer/trainer.py#L945

is that the case?

@lantiga lantiga added the waiting on author Waiting on user action, correction, or update label Nov 18, 2024
@chualanagit chualanagit changed the title [wip] Call configure_module before freeze_before_training Call configure_module before freeze_before_training Nov 22, 2024
@chualanagit chualanagit changed the title Call configure_module before freeze_before_training [wip] Call configure_module before freeze_before_training Nov 22, 2024
@lantiga
Copy link
Collaborator

lantiga commented Nov 25, 2024

The current change is messing with assumptions on how hooks are called internally and how progress is tracked, I don't think this is going to work.

I think should introduce a different hook instead (configure_model) that gets called after configure_model and we can then change fine tuning to use that if the module overrides it.

@chualanagit
Copy link
Contributor Author

configure_model

I double checked all the tests that failed, seems like all the failures are identical, failing on assertion that setup() needs to be called before configure_model(). I wonder if the assertions themselves need to be changed? There seem to be no other errors caught by any other test cases can that indicates this change leads to any logical failures in the library. Pushing a change to modify the assertion order in the test_hooks.py files and see if any other tests are failing.

@lantiga lantiga changed the title [wip] Call configure_module before freeze_before_training Call configure_module before freeze_before_training Nov 25, 2024
@chualanagit
Copy link
Contributor Author

chualanagit commented Nov 26, 2024

f the assertions themselves need to be changed? There seem to be no other errors caught by any other test cases can that indicates this change leads to any logical failures in the library. Pushing a change to modify the assertion order in the test_hooks.py files and see if any other tests are failing

seems like no other errors are raised, wondering if anyone knows of any reason why configure_model hook should not be called before setup hook? cc @lantiga

@chualanagit
Copy link
Contributor Author

@lantiga quick question, how reliable in general are the CI tests? I have definitely seen transient errors that show up on a specific commit and disappear in another before. Also seen before that a PR was merged when some CI tests are still failing. Would love to learn more for future contributions, thanks!

@lantiga
Copy link
Collaborator

lantiga commented Dec 5, 2024

hey @chualanagit we made improvements to CI stability last week, but this is a complex project with lots of tests on multiple backends, so things may run into hiccups (help very welcome there :-) )

@lantiga lantiga removed the waiting on author Waiting on user action, correction, or update label Dec 11, 2024
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.

configure_model is incompatible with the BaseFinetuning behavior when fitting
2 participants