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

Sentence Transformers T5 GPU issue #50

Merged
merged 1 commit into from
Mar 2, 2023
Merged

Sentence Transformers T5 GPU issue #50

merged 1 commit into from
Mar 2, 2023

Conversation

antas-marcin
Copy link
Contributor

No description provided.

@antas-marcin antas-marcin requested a review from trengrj March 1, 2023 08:05
@antas-marcin antas-marcin changed the title Sentence Transformers T5 GPU issue #45 Sentence Transformers T5 GPU issue Mar 1, 2023
Copy link
Member

@trengrj trengrj 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. We should add CI/CD smoke tests with GPU for this model

Comment on lines +203 to +206
if self.cuda:
labels = torch.tensor(labels).to(self.cuda_core)
else:
labels = torch.tensor(labels)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking of refactoring this code into this, would this still work?

labels = torch.tensor(labels)
if self.cuda:
    labels = labels.to(self.cuda_core)

Comment on lines +138 to +145
if self.cuda:
sum_embeddings = torch.sum(embeddings * input_mask_expanded, 1).to(self.cuda_core)
sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9).to(self.cuda_core)
return sum_embeddings, sum_mask
else:
sum_embeddings = torch.sum(embeddings * input_mask_expanded, 1)
sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9)
return sum_embeddings, sum_mask
Copy link
Contributor Author

@antas-marcin antas-marcin Mar 2, 2023

Choose a reason for hiding this comment

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

and this portion of code I'm thinking of refactoring to:

sum_embeddings = torch.sum(embeddings * input_mask_expanded, 1)
if self.cuda:
    sum_embeddings = sum_embeddings.to(self.cuda_core)

sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9)
if self.cuda:
    sum_mask = sum_mask.to(self.cuda_core)

return sum_embeddings, sum_mask

@antas-marcin antas-marcin merged commit 96f842b into main Mar 2, 2023
@antas-marcin antas-marcin deleted the t5-gpu-issue branch March 2, 2023 08:05
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

Successfully merging this pull request may close these issues.

2 participants