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

Adding support for hidden_states and attentions in unbatching support. #14420

Merged
merged 1 commit into from
Nov 19, 2021

Conversation

Narsil
Copy link
Contributor

@Narsil Narsil commented Nov 16, 2021

What does this PR do?

Fixes #14414

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

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.

Cool, thanks @Narsil

@require_torch
def test_unbatch_attentions_hidden_states(self):
model = DistilBertForSequenceClassification.from_pretrained(
"Narsil/tiny-distilbert-sequence-classification", output_hidden_states=True, output_attentions=True
Copy link
Member

Choose a reason for hiding this comment

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

Can this leverage the one from hf-internal-testing, or is there a reason you favor this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is not tiny-distilbert in hf-internal-testing, only the random one.
Happy to upload it if you want (as well as all the other Narsil specific tests that probably all belong in hf-internal-testing.

For instance this one was just copied from the text-classification tests.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but the random has random weights but actually has the weights so it wouldn't be initialized randomly every time you load it in memory.

It shouldn't be an issue here given that you're only checking the length of outputs, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I am using these also in other tests, are you ok if I merge this PR, then open another PR to remove Narsil/ models from a bit everywhere (some check actual output values)

@Narsil Narsil merged commit 81fe8af into huggingface:master Nov 19, 2021
@Narsil Narsil deleted the handle_more_type_of_batches branch November 19, 2021 15:02
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 2022
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.

Pipelines fails with IndexError using Bert model with outputs and batch size >= 16
2 participants