Skip to content

MPS: isin_mps_friendly can support 0D tensors#34538

Merged
gante merged 5 commits intohuggingface:mainfrom
gante:is_in_fix
Nov 4, 2024
Merged

MPS: isin_mps_friendly can support 0D tensors#34538
gante merged 5 commits intohuggingface:mainfrom
gante:is_in_fix

Conversation

@gante
Copy link
Contributor

@gante gante commented Oct 31, 2024

What does this PR do?

Fixes #33786

Applies the fix in isin_mps_friendly as suggested by @Swastik-Swarup-Dash here

@gante gante requested a review from ArthurZucker October 31, 2024 15:23
@gante gante changed the title apply fix MPS: isin_mps_friendly can support 0D tensors Oct 31, 2024
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Do we need a patch for this? 🤗

@gante
Copy link
Contributor Author

gante commented Oct 31, 2024

Do we need a patch for this? 🤗

I don't think so, it's quite niche 🤔 If we make a patch, yes, let's include it :D

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Thanks 🤗

Comment on lines +325 to +327
test_elements = torch.tensor(test_elements)
if test_elements.ndim == 0:
test_elements = test_elements.unsqueeze(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we ought to open the issue on pytorch / link the tracker !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On torch >=2.4 this is fixed, i.e. torch.isin is supported with mps

(in other words, this fix only affects older versions of torch) 🤗

@gante gante merged commit 34927b0 into huggingface:main Nov 4, 2024
@gante gante deleted the is_in_fix branch November 4, 2024 16:18
@Swastik-Swarup-Dash
Copy link

Thanks @gante for using my approach.

ArthurZucker pushed a commit that referenced this pull request Nov 5, 2024
* apply fix

* tested

* make fixup
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
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.

mps failure with tts: IndexError: tuple index out of range in pytorch_utils.py

4 participants