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

configure_model is incompatible with the BaseFinetuning behavior when fitting #19658

Open
GdoongMathew opened this issue Mar 16, 2024 · 0 comments · May be fixed by #20428
Open

configure_model is incompatible with the BaseFinetuning behavior when fitting #19658

GdoongMathew opened this issue Mar 16, 2024 · 0 comments · May be fixed by #20428
Labels
bug Something isn't working callback: finetuning help wanted Open to be worked on ver: 2.1.x

Comments

@GdoongMathew
Copy link
Contributor

Bug description

Based on the current callback orders, The Finetuning class will always be incompatible with any LightningModule that utilize configure_model method. The current callback sequence is Callback.setup -> LightningModule.configure_model -> LightningModule.configure_optimizers -> Callback.on_fit_start. However, The BaseFinetuning calls freeze_before_training at setup, where modules inside the configure_model has not been instantiated yet.

What version are you seeing the problem on?

v2.1

How to reproduce the bug

from lightning import LightningModule
import torch
from torchvision import models
class MyModel(LightningModule):
    def configure_model(self):
        self.backbone = models.resnet18()
    def configure_optimizers(self):
        return torch.optim.SGD(lr=1e-3)

Error messages and logs

# Error messages and logs here please

Environment

Current environment
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):

More info

No response

@GdoongMathew GdoongMathew added bug Something isn't working needs triage Waiting to be triaged by maintainers labels Mar 16, 2024
@awaelchli awaelchli added help wanted Open to be worked on callback: finetuning and removed needs triage Waiting to be triaged by maintainers labels Mar 19, 2024
@chualanagit chualanagit linked a pull request Nov 18, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working callback: finetuning help wanted Open to be worked on ver: 2.1.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants