NeMo icon indicating copy to clipboard operation
NeMo copied to clipboard

[TTS] Fix: Tacotron2 decoder inference thread-safety bug

Open pskrunner14 opened this issue 4 years ago • 0 comments

What does this PR do?

This PR makes Tacotron2 decoder module inference thread-safe and avoids unintentional side-effects that can occur due to concurrent invocation of the function.

Collection: TTS

Changelog

  • Encapsulated the mutable internal decoder states into a dataclass called DecoderStates
  • Initialize new local DecoderStates object at every invocation of Tacotron2 Decoder module inference instead of shared variable states.
  • Decode method writes to said local Decoder states instead of overwriting shared variable states.

Usage

Usage hasn't changed but this PR prevents RuntimeError or prediction quality issues from happening due to crosstalk between threads when making multi-threaded invocations of the Tacotron2 Inference method in eval mode.

Before your PR is "Ready for review"

Pre checks:

  • [x] Make sure you read and followed Contributor guidelines
  • [x] Did you write any new necessary tests? No
  • [x] Did you add or update any necessary documentation? No
  • [x] Does the PR affect components that are optional to install? No
  • [x] Reviewer: Does the PR have correct import guards for all optional libraries? N/A

PR Type:

  • [x] Bugfix

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

  • This PR fixes #3797

pskrunner14 avatar Mar 05 '22 13:03 pskrunner14