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

[Fix] attn_dropout #123

Merged
merged 5 commits into from
Nov 29, 2021
Merged

[Fix] attn_dropout #123

merged 5 commits into from
Nov 29, 2021

Conversation

blefaudeux
Copy link
Contributor

What does this PR do?

Fixes #122 + adds a unit test to catch faulty dropouts
@fmassa is rewriting some of that part, but in the meantime main should not be knowingly broken

Before submitting

  • Did you have fun?
    • Make sure you had fun coding 🙃
  • Did you read the contributor guideline?
  • Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
    • N/A
  • Did you make sure to update the docs?
    • N/A
  • Did you write any new necessary tests?
    • N/A
  • Did you update the changelog? (if needed)
    • N/A

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 28, 2021
@blefaudeux blefaudeux changed the title [blocksparse] Fix dropout [DRAFT][blocksparse] Fix dropout Nov 28, 2021
@blefaudeux blefaudeux marked this pull request as draft November 29, 2021 01:40
@blefaudeux
Copy link
Contributor Author

@fmassa @dianaml0 turns out that in many case dropout was not applied, not just for blocksparse, a unit test is catching that now :(

@dianaml0
Copy link
Contributor

@fmassa @dianaml0 turns out that in many case dropout was not applied, not just for blocksparse, a unit test is catching that now :(

Oh wow :( Great that you were able to catch that!

@blefaudeux
Copy link
Contributor Author

@fmassa @dianaml0 turns out that in many case dropout was not applied, not just for blocksparse, a unit test is catching that now :(

Oh wow :( Great that you were able to catch that!

maybe a semi-recent change, I think that @fmassa is right in that we should refactor core/. Else for some variant the setting was silently ignored (but not explicitly present in the constructor), so it would just fail for the factory, not as bad but still... Unit tests for the win, this should not happen again

@blefaudeux blefaudeux changed the title [DRAFT][blocksparse] Fix dropout [DRAFT] Fix attn_dropout Nov 29, 2021
Copy link
Contributor

@dianaml0 dianaml0 left a comment

Choose a reason for hiding this comment

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

Really nice catch!

xformers/components/attention/core.py Outdated Show resolved Hide resolved
_ = multi_head(inputs, inputs_shuffled, inputs)
att = multi_head(inputs, inputs_shuffled, inputs)

# Check that dropout actually drops some values
Copy link
Contributor

Choose a reason for hiding this comment

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

Great to have this test now!

xformers/components/attention/linformer.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2021

Codecov Report

Merging #123 (19b802e) into main (71bab94) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   87.56%   87.61%   +0.04%     
==========================================
  Files          50       50              
  Lines        2558     2567       +9     
==========================================
+ Hits         2240     2249       +9     
  Misses        318      318              
Flag Coverage Δ
Python 87.61% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...formers/components/attention/scaled_dot_product.py 94.73% <ø> (ø)
xformers/components/attention/blocksparse.py 94.11% <100.00%> (ø)
xformers/components/attention/core.py 92.12% <100.00%> (+0.06%) ⬆️
xformers/components/attention/fourier_mix.py 100.00% <100.00%> (ø)
xformers/components/attention/global_tokens.py 100.00% <100.00%> (ø)
xformers/components/attention/lambda_layer.py 100.00% <100.00%> (ø)
xformers/components/attention/linformer.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71bab94...19b802e. Read the comment docs.

@blefaudeux blefaudeux marked this pull request as ready for review November 29, 2021 02:54
@blefaudeux blefaudeux changed the title [DRAFT] Fix attn_dropout [Fix] attn_dropout Nov 29, 2021
@blefaudeux blefaudeux merged commit 861493c into main Nov 29, 2021
@blefaudeux blefaudeux deleted the blocksparse_dropout_fix branch November 29, 2021 04:13
xwhan pushed a commit to xwhan/xformers that referenced this pull request Feb 8, 2022
Very small update to doc, command for benchmarking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BlockSparseAttention doesn't use dropout
4 participants