Skip to content

Conversation

@chrsmcgrr
Copy link
Contributor

What does this PR do?

Fixes #34022 by implementing the masking of the hidden states using an elementwise multiplication rather than indexing with assignment.

The torch.export functionality seems to mark the tensor as frozen even though the update is legal.

This change is a workaround for now to allow the export of the model as a FxGraph. Further investigation is required to find the real solution in pytorch.

Tagging:
@ylacombe, @eustlb

Please let me know if someone else is more appropriate to review this PR.

Resolves the issue described in huggingface#34022 by implementing the
masking of the hidden states using an elementwise multiplication
rather than indexing with assignment.

The torch.export functionality seems to mark the tensor as frozen
even though the update is legal.

This change is a workaround for now to allow the export of the
model as a FxGraph. Further investigation is required to find
the real solution in pytorch.
@chrsmcgrr chrsmcgrr force-pushed the fix-wav2vec2-torch-export branch from 2f745d4 to fc9d68b Compare October 8, 2024 09:34
Copy link
Contributor

@ylacombe ylacombe left a comment

Choose a reason for hiding this comment

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

This LGTM, but I'd like another opinion for a torch compile expert as well!

Maybe @gante or @zucchini-nlp ? Thanks for your help

@zucchini-nlp
Copy link
Member

Seems okey to me, compile stuff usually complain on in-place modification to tensor

@ylacombe ylacombe requested a review from LysandreJik October 14, 2024 10:38
@ylacombe
Copy link
Contributor

Thanks @zucchini-nlp, requesting a core maintainer review then !

Copy link
Contributor

@ylacombe ylacombe left a comment

Choose a reason for hiding this comment

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

Let's run slow tests just in case. You can do it by pushing an empty commit like this: git commit --allow-empty -m "[run-slow] hubert, unispeech, unispeech_sat, wav2vec2"

@chrsmcgrr
Copy link
Contributor Author

@ylacombe @zucchini-nlp these errors seem unrelated to the slow tests. Is this expected?

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Ok, thanks! @ylacombe feel free to merge once you're satisfied with the tests

@gante
Copy link
Contributor

gante commented Oct 17, 2024

LGTM 👍

(I've rerun CI in case it was a transient error)

@gante gante merged commit b57c7bc into huggingface:main Oct 17, 2024
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
* fix(Wav2Vec2ForCTC): torch export

Resolves the issue described in huggingface#34022 by implementing the
masking of the hidden states using an elementwise multiplication
rather than indexing with assignment.

The torch.export functionality seems to mark the tensor as frozen
even though the update is legal.

This change is a workaround for now to allow the export of the
model as a FxGraph. Further investigation is required to find
the real solution in pytorch.

* [run-slow] hubert, unispeech, unispeech_sat, wav2vec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wav2vec2] torch.export error in Wav2Vec2ForCTC

5 participants