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 15 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 (333d1cf) to head (11c8be4).

❗ There is a different number of reports uploaded between BASE (333d1cf) and HEAD (11c8be4). Click for more details.

HEAD has 223 uploads less than BASE
Flag BASE (333d1cf) HEAD (11c8be4)
cpu 77 24
lightning_fabric 13 0
pytest 50 0
python3.9 21 6
lightning 59 18
python3.11 19 6
gpu 2 0
python3.10 10 3
python3.12 27 9
pytorch2.1 13 9
pytest-full 29 24
pytorch2.2.2 4 3
pytorch_lightning 7 6
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20428     +/-   ##
=========================================
- Coverage      88%      79%     -9%     
=========================================
  Files         267      264      -3     
  Lines       23274    23219     -55     
=========================================
- Hits        20381    18270   -2111     
- Misses       2893     4949   +2056     

@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!

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 waiting on author Waiting on user action, correction, or update
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