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

How to optimize two models in a class? #6943

Open
KasenYoung opened this issue Jan 11, 2025 · 0 comments
Open

How to optimize two models in a class? #6943

KasenYoung opened this issue Jan 11, 2025 · 0 comments

Comments

@KasenYoung
Copy link

Thanks a lot for your great work. Now I have a class Model which has two little models.

class Model(nn.Module):
       def __init__(self):
             super().__init__()
             self.model1 = xxx
             self.model2 = xxx

When using accelerate package and deepspeed, it only supports one optimizer. So I have to place the parameters of the two models into one optimizer:

optimizer = optimizer(
      params_to_optimize=[model1.parameters(), model2.parameters()],
      ...,
)

My question is : when I optimize just one model, what should I do? For example, I want to optimize model1, what should I do to prevent model2 to be optimized? Thank you very much for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant