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

No-script TS export, prepared for ONNX export #5653

Merged
merged 30 commits into from
Jan 11, 2023

Conversation

borisfom
Copy link
Collaborator

@borisfom borisfom commented Dec 16, 2022

Signed-off-by: Boris Fomitchev bfomitchev@nvidia.com

What does this PR do ?

Changed unfold to reshape for inference to be able to export in ONNX.
Also using extra hx parameter to LSTM call to work around Pytorch issues with tracing the hx=None.
Now Torchscript export works without any scripting - so I was also able to get rid of unnecessary autocast=False block.
ONNX export still fails due to internal bugs, even though each part of the network is now ONNX-exportable.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
@github-actions github-actions bot added the TTS label Dec 16, 2022
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
@github-actions github-actions bot added the core Changes to NeMo Core label Dec 21, 2022
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
@github-actions github-actions bot added the CI label Dec 23, 2022
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
@borisfom borisfom changed the title Draft: Changed unfold to reshape, merged padding chenges No-script TS export, prepared for ONNX export Jan 6, 2023
Copy link
Collaborator

@titu1994 titu1994 left a comment

Choose a reason for hiding this comment

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

Overall the export changes look fine. Someone from TTS team should check of the code overall works as expected. Fyi @XuesongYang

nemo/collections/tts/modules/common.py Outdated Show resolved Hide resolved
nemo/collections/tts/modules/common.py Outdated Show resolved Hide resolved
nemo/core/classes/exportable.py Outdated Show resolved Hide resolved
@titu1994
Copy link
Collaborator

titu1994 commented Jan 6, 2023

Seems import check fails with _globals from onnx. Put try catch import guard around it

Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
@borisfom borisfom requested a review from titu1994 January 9, 2023 19:46
titu1994
titu1994 previously approved these changes Jan 10, 2023
Copy link
Collaborator

@titu1994 titu1994 left a comment

Choose a reason for hiding this comment

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

Changes look fine, @XuesongYang for final review

tests/collections/tts/test_tts_exportables.py Outdated Show resolved Hide resolved
tests/collections/tts/test_tts_exportables.py Outdated Show resolved Hide resolved
nemo/collections/tts/losses/tacotron2loss.py Outdated Show resolved Hide resolved
nemo/collections/tts/helpers/helpers.py Outdated Show resolved Hide resolved
nemo/collections/tts/modules/radtts.py Show resolved Hide resolved
nemo/collections/tts/modules/radtts.py Outdated Show resolved Hide resolved
nemo/core/classes/exportable.py Show resolved Hide resolved
nemo/core/classes/exportable.py Show resolved Hide resolved
nemo/core/classes/exportable.py Show resolved Hide resolved
nemo/utils/export_utils.py Show resolved Hide resolved
nemo/utils/export_utils.py Show resolved Hide resolved
@XuesongYang XuesongYang merged commit fbdab7b into NVIDIA:main Jan 11, 2023
erastorgueva-nv pushed a commit that referenced this pull request Jan 12, 2023
* Changed unfold to reshape, merged padding chenges
* Almost working ONNX export of RadTTS
* restored radtts function
* Added explicit assume_padded flag
* Fixing attn_mask
* Fixing unfold
* Trying no hx
* Back with hx
* Made fx only for tracing
* Tests annotated
* Fully working no-script TS export, prepared for ONNX export
* Restored no-autocast block, addressed code review
* Fine-tuning autocast option
* Protecting InstanceNorm
* Forcing eval and param freeze on export

Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
Signed-off-by: Elena Rastorgueva <erastorgueva@nvidia.com>
titu1994 pushed a commit to titu1994/NeMo that referenced this pull request Mar 24, 2023
* Changed unfold to reshape, merged padding chenges
* Almost working ONNX export of RadTTS
* restored radtts function
* Added explicit assume_padded flag
* Fixing attn_mask
* Fixing unfold
* Trying no hx
* Back with hx
* Made fx only for tracing
* Tests annotated
* Fully working no-script TS export, prepared for ONNX export
* Restored no-autocast block, addressed code review
* Fine-tuning autocast option
* Protecting InstanceNorm
* Forcing eval and param freeze on export

Signed-off-by: Boris Fomitchev <bfomitchev@nvidia.com>
@redoctopus redoctopus mentioned this pull request May 18, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI core Changes to NeMo Core TTS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants