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

Adjust stochastic depth dropout probability calculation #6120

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

anteju
Copy link
Collaborator

@anteju anteju commented Feb 27, 2023

What does this PR do?

This PR adjusts calculation of stochastic depth dropout probability.
Currently, calculation fails for 1-layer ConformerEncoder with the default setup.

The culprit is calculation of the probability in compute_stochastic_depth_drop_probs for linear mode:

layer_drop_probs += [l / (L - 1) * stochastic_depth_drop_prob for l in range(L)]

since in this case L-1 == 0.

Proposed solution

Change calculation for the linear mode to the following

# we start with 1/L * drop_prob and and end with the desired drop probability.
layer_drop_probs += [l / L * stochastic_depth_drop_prob for l in range(1, L + 1)]

This can handle setup with a single layer and is consistent with the probability calculation for the uniform mode.

Example

An example of calculated probabilities:

num_layers = 7
stochastic_depth_start_layer = 3
stochastic_depth_drop_prob = 0.5
layer 0 1 2 3 4 5 6
uniform 0.0 0.0 0.0 0.5 0.5 0.5 0.5
linear original 0.0 0.0 0.0 0.0 0.167 0.333 0.5
linear proposed 0.0 0.0 0.0 0.125 0.25 0.375 0.5

Collection: ASR

Changelog

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

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)

@anteju anteju requested a review from Kipok February 27, 2023 21:19
@github-actions github-actions bot added the ASR label Feb 27, 2023
@anteju anteju marked this pull request as ready for review February 27, 2023 23:57
Copy link
Collaborator

@Kipok Kipok left a comment

Choose a reason for hiding this comment

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

Thanks Ante, looks good!

@anteju anteju merged commit 4651e26 into NVIDIA:main Feb 28, 2023
titu1994 pushed a commit to titu1994/NeMo that referenced this pull request Mar 24, 2023
hsiehjackson pushed a commit to hsiehjackson/NeMo that referenced this pull request Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants