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

Enable RNNT ONNX Export #2510

Merged
merged 41 commits into from Jul 21, 2021
Merged

Enable RNNT ONNX Export #2510

merged 41 commits into from Jul 21, 2021

Conversation

titu1994
Copy link
Collaborator

@titu1994 titu1994 commented Jul 20, 2021

Changelog

  • Enable RNNT Export to ONNX (No torchscript yet)
  • Add inference script for onnx exported rnnt models
  • Update neural types for export
  • Refactor Exportable to be less monolithic
  • Add ExportableEncDecJointModel that is subclass of Exportable

titu1994 and others added 30 commits July 19, 2021 19:42
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
* Add parallel block that supports Jasper-like blocks.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Add Encoder with parallel blocks.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Mark test as unit test.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Support pointwise residual connections to connect layers with different fitlers.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Format source code

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Switch to 1D tensor for dropout weights.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Format source code.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

Co-authored-by: Somshubra Majumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
@lgtm-com
Copy link

lgtm-com bot commented Jul 20, 2021

This pull request introduces 2 alerts and fixes 1 when merging 9d626b0 into d08c7a7 - view on LGTM.com

new alerts:

  • 2 for Modification of dictionary returned by locals()

fixed alerts:

  • 1 for Unused import

@titu1994 titu1994 requested a review from borisfom July 20, 2021 03:04
Signed-off-by: smajumdar <titu1994@gmail.com>
@lgtm-com
Copy link

lgtm-com bot commented Jul 20, 2021

This pull request introduces 2 alerts and fixes 1 when merging 2ebd5dd into d08c7a7 - view on LGTM.com

new alerts:

  • 2 for Modification of dictionary returned by locals()

fixed alerts:

  • 1 for Unused import

Signed-off-by: smajumdar <titu1994@gmail.com>
@lgtm-com
Copy link

lgtm-com bot commented Jul 20, 2021

This pull request introduces 2 alerts and fixes 1 when merging 1abfbea into d08c7a7 - view on LGTM.com

new alerts:

  • 2 for Modification of dictionary returned by locals()

fixed alerts:

  • 1 for Unused import

@@ -62,8 +63,14 @@ def _prepare_for_export(self, **kwargs):
m_count = 0
for m in self.modules():
if isinstance(m, MaskedConv1d):
m.use_mask = False
m_count += 1
if hasattr(self, '_rnnt_export') and self._rnnt_export:
Copy link
Collaborator

@borisfom borisfom Jul 20, 2021

Choose a reason for hiding this comment

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

Why not overriding whole _prepare_for_export for RNNT nets?

Copy link
Collaborator Author

@titu1994 titu1994 Jul 20, 2021

Choose a reason for hiding this comment

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

That's an option, but that would make framework dependent on what type of encoder was used. This way the Conformer and Citrinet can chose to supply seperate input-output types for CTC and RNNT exports while CTC and RNNT export framework remains unaware of what encoder type it is

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I do not see any changes in this PR (nor in main) that would set _rnnt_export attribute - are those part of another PR ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Part of this PR Inside the asr_model.py file (needs to be expanded)

format = self.get_format(output)

# Assign special flag for RNNT export of encoder
self.input_module._rnnt_export = True
Copy link
Collaborator Author

@titu1994 titu1994 Jul 20, 2021

Choose a reason for hiding this comment

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

@borisfom here is where we set it explicitly to the modules. Needs to be before prepare_for_export since samples are already extracted by the time prepare_for_extract is called. (could do with better design but necessary flag to switch from ctc-rnnt onnx export).

Signed-off-by: smajumdar <titu1994@gmail.com>
@lgtm-com
Copy link

lgtm-com bot commented Jul 21, 2021

This pull request introduces 2 alerts and fixes 1 when merging 6dff9b0 into c8f9427 - view on LGTM.com

new alerts:

  • 2 for Modification of dictionary returned by locals()

fixed alerts:

  • 1 for Unused import

Signed-off-by: smajumdar <titu1994@gmail.com>
Signed-off-by: smajumdar <titu1994@gmail.com>
@titu1994 titu1994 merged commit dc69605 into NVIDIA:main Jul 21, 2021
@titu1994 titu1994 deleted the rnnt_export branch July 21, 2021 03:01
@lgtm-com
Copy link

lgtm-com bot commented Jul 21, 2021

This pull request introduces 2 alerts and fixes 1 when merging f6aa380 into c8f9427 - view on LGTM.com

new alerts:

  • 2 for Modification of dictionary returned by locals()

fixed alerts:

  • 1 for Unused import

blisc pushed a commit to blisc/NeMo that referenced this pull request Aug 12, 2021
* Begin export of RNNT models

Signed-off-by: smajumdar <titu1994@gmail.com>

* Prepare export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Refactor Exportable

Signed-off-by: smajumdar <titu1994@gmail.com>

* Enable RNNT export to onnx

Signed-off-by: smajumdar <titu1994@gmail.com>

* RNNT export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Attempt to get stateful inference

Signed-off-by: smajumdar <titu1994@gmail.com>

* Revert changes attempt state fix

Signed-off-by: smajumdar <titu1994@gmail.com>

* Hack together forward pass <FIX LATER>

Signed-off-by: smajumdar <titu1994@gmail.com>

* Return length

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct signature

Signed-off-by: smajumdar <titu1994@gmail.com>

* Prepare stateful

Signed-off-by: smajumdar <titu1994@gmail.com>

* Continie checks for states

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct naming

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct names

Signed-off-by: smajumdar <titu1994@gmail.com>

* Pass trace checks

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update test to be dynamic

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update naming semantic

Signed-off-by: smajumdar <titu1994@gmail.com>

* Initial prototype of RNNT greedy decoding

Signed-off-by: smajumdar <titu1994@gmail.com>

* Fix tracer warnings

Signed-off-by: smajumdar <titu1994@gmail.com>

* Corrected names of outputs for RNNT encoder

Signed-off-by: smajumdar <titu1994@gmail.com>

* Fix export rnnt script

Signed-off-by: smajumdar <titu1994@gmail.com>

* Prototype RNNT forward inference

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update asr export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Runnable inference

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct log softmax for joint

Signed-off-by: smajumdar <titu1994@gmail.com>

* Finish RNNT export to onnx

Signed-off-by: smajumdar <titu1994@gmail.com>

* Fix onnx export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Create parallel version of ConvASREncoder (NVIDIA#2456)

* Add parallel block that supports Jasper-like blocks.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Add Encoder with parallel blocks.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Mark test as unit test.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Support pointwise residual connections to connect layers with different fitlers.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Format source code

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Switch to 1D tensor for dropout weights.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Format source code.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

Co-authored-by: Somshubra Majumdar <titu1994@gmail.com>

* Fix style

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update comments

Signed-off-by: smajumdar <titu1994@gmail.com>

* Freeze the nemo model

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update transcribe script to support RNNT and rnnt model transcriptions

Signed-off-by: smajumdar <titu1994@gmail.com>

* Add threshold

Signed-off-by: smajumdar <titu1994@gmail.com>

* Add warning

Signed-off-by: smajumdar <titu1994@gmail.com>

* Minor fixes

Signed-off-by: smajumdar <titu1994@gmail.com>

* Style fix

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correctly replace forward step

Signed-off-by: smajumdar <titu1994@gmail.com>

* Reset RNNT flag after export is done

Signed-off-by: smajumdar <titu1994@gmail.com>

* Generalize _rnnt_export flag

Signed-off-by: smajumdar <titu1994@gmail.com>

* Generalize _rnnt_export flag

Signed-off-by: smajumdar <titu1994@gmail.com>

Co-authored-by: Aleksei Kalinov <alekseia@nvidia.com>
paarthneekhara pushed a commit to paarthneekhara/NeMo that referenced this pull request Sep 17, 2021
* Begin export of RNNT models

Signed-off-by: smajumdar <titu1994@gmail.com>

* Prepare export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Refactor Exportable

Signed-off-by: smajumdar <titu1994@gmail.com>

* Enable RNNT export to onnx

Signed-off-by: smajumdar <titu1994@gmail.com>

* RNNT export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Attempt to get stateful inference

Signed-off-by: smajumdar <titu1994@gmail.com>

* Revert changes attempt state fix

Signed-off-by: smajumdar <titu1994@gmail.com>

* Hack together forward pass <FIX LATER>

Signed-off-by: smajumdar <titu1994@gmail.com>

* Return length

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct signature

Signed-off-by: smajumdar <titu1994@gmail.com>

* Prepare stateful

Signed-off-by: smajumdar <titu1994@gmail.com>

* Continie checks for states

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct naming

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct names

Signed-off-by: smajumdar <titu1994@gmail.com>

* Pass trace checks

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update test to be dynamic

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update naming semantic

Signed-off-by: smajumdar <titu1994@gmail.com>

* Initial prototype of RNNT greedy decoding

Signed-off-by: smajumdar <titu1994@gmail.com>

* Fix tracer warnings

Signed-off-by: smajumdar <titu1994@gmail.com>

* Corrected names of outputs for RNNT encoder

Signed-off-by: smajumdar <titu1994@gmail.com>

* Fix export rnnt script

Signed-off-by: smajumdar <titu1994@gmail.com>

* Prototype RNNT forward inference

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update asr export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Runnable inference

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correct log softmax for joint

Signed-off-by: smajumdar <titu1994@gmail.com>

* Finish RNNT export to onnx

Signed-off-by: smajumdar <titu1994@gmail.com>

* Fix onnx export

Signed-off-by: smajumdar <titu1994@gmail.com>

* Create parallel version of ConvASREncoder (NVIDIA#2456)

* Add parallel block that supports Jasper-like blocks.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Add Encoder with parallel blocks.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Mark test as unit test.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Support pointwise residual connections to connect layers with different fitlers.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Format source code

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Switch to 1D tensor for dropout weights.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

* Format source code.

Signed-off-by: Aleksei Kalinov <alekseia@nvidia.com>

Co-authored-by: Somshubra Majumdar <titu1994@gmail.com>

* Fix style

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update comments

Signed-off-by: smajumdar <titu1994@gmail.com>

* Freeze the nemo model

Signed-off-by: smajumdar <titu1994@gmail.com>

* Update transcribe script to support RNNT and rnnt model transcriptions

Signed-off-by: smajumdar <titu1994@gmail.com>

* Add threshold

Signed-off-by: smajumdar <titu1994@gmail.com>

* Add warning

Signed-off-by: smajumdar <titu1994@gmail.com>

* Minor fixes

Signed-off-by: smajumdar <titu1994@gmail.com>

* Style fix

Signed-off-by: smajumdar <titu1994@gmail.com>

* Correctly replace forward step

Signed-off-by: smajumdar <titu1994@gmail.com>

* Reset RNNT flag after export is done

Signed-off-by: smajumdar <titu1994@gmail.com>

* Generalize _rnnt_export flag

Signed-off-by: smajumdar <titu1994@gmail.com>

* Generalize _rnnt_export flag

Signed-off-by: smajumdar <titu1994@gmail.com>

Co-authored-by: Aleksei Kalinov <alekseia@nvidia.com>
Signed-off-by: Paarth Neekhara <paarth.n@gmail.com>
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.

None yet

3 participants