Skip to content

MT5 onnx conversion for beam search#11958

Merged
tianleiwu merged 5 commits intomasterfrom
tlwu/t5_external_data
Jun 23, 2022
Merged

MT5 onnx conversion for beam search#11958
tianleiwu merged 5 commits intomasterfrom
tlwu/t5_external_data

Conversation

@tianleiwu
Copy link
Contributor

@tianleiwu tianleiwu commented Jun 23, 2022

Description:
Support mT5 model to onnx conversion for beam search like:

python convert_beam_search.py -m google/mt5-large --model_type mt5 --output mt5-large-beamsearch.onnx -e

The output will have two files (like mt5-large-beamsearch.onnx and mt5-large-beamsearch.onnx.data) when external data format (-e) is used.

Note: please install ONNX 1.12 package for this. Otherwise, you might encounter error like 'Message onnx.ModelProto exceeds maximum protobuf size of 2GB:' during saving the output model.

Some intermediate encoder or decoder onnx models can be found in ./google, and those files are not needed (They are preserved for debugging purpose).

Right now the model can run, but max diff could be like 8e-3 for encoder or decoder, which could cause beam search result difference between PyTorch and ORT. That's a separate issue for pytorch exporter.

Motivation and Context

  • Why is this change required? What problem does it solve?
  • If it fixes an open issue, please link to the issue here.

Related issues: #11813, #11848

@tianleiwu tianleiwu requested a review from wangyems June 23, 2022 00:07
@lgtm-com
Copy link

lgtm-com bot commented Jun 23, 2022

This pull request introduces 1 alert when merging fe6605d into e24349b - view on LGTM.com

new alerts:

  • 1 for Unused import

@@ -217,6 +228,7 @@ def export_onnx_models(

def main():
Copy link
Contributor

@wangyems wangyems Jun 23, 2022

Choose a reason for hiding this comment

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

maybe comment/assert somewhere that onnx>=1.12 is needed for subgraph proto > 2G case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Let me add a check of ONNX version in next PR.

Copy link
Contributor

@wangyems wangyems left a comment

Choose a reason for hiding this comment

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

lgtm

@tianleiwu tianleiwu merged commit 2c4e4b6 into master Jun 23, 2022
@tianleiwu tianleiwu deleted the tlwu/t5_external_data branch June 23, 2022 17:23
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