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

feature(models): Add model comm group to predict_step #77

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

cathalobrien
Copy link
Contributor

Small change to allow predict_step to take an optional model_comm_group, like model.forward does.

This is needed for parallel-inference, which calls predict_step

japols
japols previously approved these changes Jan 14, 2025
Copy link
Member

@japols japols left a comment

Choose a reason for hiding this comment

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

Looks good to me

HCookie
HCookie previously approved these changes Jan 14, 2025
@@ -94,7 +96,7 @@ def _build_model(self) -> None:
# Use the forward method of the model directly
self.forward = self.model.forward

def predict_step(self, batch: torch.Tensor) -> torch.Tensor:
def predict_step(self, batch: torch.Tensor, model_comm_group: Optional[ProcessGroup] = None) -> torch.Tensor:
Copy link
Member

Choose a reason for hiding this comment

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

Can we also add a **kwargs here for future proofing? Then we don't need any logic in inference to maintain backwards compatibility when new optionals are added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be my pleasure. And then pass that to self()?

Copy link
Member

Choose a reason for hiding this comment

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

I would not pass it to self, so that that remains explicit. Passing kwargs blindly to sub-functions is something we should try to avoid in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmertes like so?

@cathalobrien cathalobrien dismissed stale reviews from HCookie and japols via fdd92e6 January 15, 2025 12:49
@HCookie HCookie changed the title Predict_step can take model comm group now feature(models): Add model comm group to predict_step Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Now In Progress
Development

Successfully merging this pull request may close these issues.

4 participants