Skip to content

Enable possibility to not use past_key_values#241

Merged
echarlaix merged 13 commits into
mainfrom
seq2seq-decoder-without-past
Jul 27, 2022
Merged

Enable possibility to not use past_key_values#241
echarlaix merged 13 commits into
mainfrom
seq2seq-decoder-without-past

Conversation

@echarlaix
Copy link
Copy Markdown
Collaborator

@echarlaix echarlaix commented Jun 27, 2022

In this PR, we add the possibility to not use the precomputed past_key_values during ONNX Runtime inference of Seq2Seq models. This can be interesting for small models / short sequence length or if the user don't want to export the decoder_with_past_model

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

HuggingFaceDocBuilderDev commented Jun 27, 2022

The documentation is not available anymore as the PR was closed or merged.

@echarlaix echarlaix marked this pull request as ready for review July 8, 2022 12:12
Copy link
Copy Markdown
Contributor

@regisss regisss left a comment

Choose a reason for hiding this comment

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

It looks great @echarlaix!!
I just left a few nits regarding comments.

Comment thread optimum/onnxruntime/modeling_seq2seq.py Outdated
Comment thread optimum/onnxruntime/modeling_seq2seq.py Outdated
Comment thread tests/onnxruntime/test_modeling.py Outdated
)
self.encoder_file_name = kwargs.get("last_encoder_model_name", ONNX_ENCODER_NAME)
self.decoder_file_name = kwargs.get("last_decoder_model_name", ONNX_DECODER_NAME)
self.decoder_file_with_past_name = kwargs.get("last_decoder_with_past_model_name", ONNX_DECODER_WITH_PAST_NAME)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should make this None when there is no past_key model file

Copy link
Copy Markdown
Collaborator Author

@echarlaix echarlaix Jul 20, 2022

Choose a reason for hiding this comment

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

self.use_past_key_values is set to True when a decoder_with_past_session is given, False otherwise (it seems equivalent to what you are suggesting)

echarlaix and others added 5 commits July 20, 2022 15:11
Co-authored-by: regisss <15324346+regisss@users.noreply.github.com>
Co-authored-by: regisss <15324346+regisss@users.noreply.github.com>
Co-authored-by: regisss <15324346+regisss@users.noreply.github.com>
@echarlaix echarlaix merged commit 8d64d8a into main Jul 27, 2022
@echarlaix echarlaix deleted the seq2seq-decoder-without-past branch July 27, 2022 08:40
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.

4 participants