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 cuDNN sliding window size #1212

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Fix cuDNN sliding window size #1212

merged 4 commits into from
Oct 7, 2024

Conversation

cyanguwa
Copy link
Collaborator

@cyanguwa cyanguwa commented Sep 27, 2024

Description

This PR adjusts the sliding window size in FusedAttention (cuDNN attention) so it's consistent with our support in FlashAttention and UnfusedDotProductAttention.

cuDNN supports sliding window (i - window_size_left, i], exclusive of the i -window_size_left element. By passing window_size_left + 1 to cuDNN, we achieve the same effect as the [i - window_size_left, i] support.

This PR also reduces the window size in our unit tests so any numerical differences between backends will be easier to notice.

Fixes #1197

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refractor

Changes

Please list the changes introduced in this PR:

  • Adjust the window_size passed to cuDNN
  • Test smaller window sizes in unit tests

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: Charlene Yang <8636796+cyanguwa@users.noreply.github.com>
@cyanguwa
Copy link
Collaborator Author

/te-ci pytorch

Signed-off-by: Charlene Yang <8636796+cyanguwa@users.noreply.github.com>
@cyanguwa
Copy link
Collaborator Author

/te-ci pytorch

huanghua1994 pushed a commit to huanghua1994/TransformerEngine that referenced this pull request Oct 1, 2024
Signed-off-by: Hua Huang <huah@nvidia.com>
Copy link
Member

@ksivaman ksivaman left a comment

Choose a reason for hiding this comment

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

Makes sense, LGTM!

@ksivaman
Copy link
Member

ksivaman commented Oct 7, 2024

/te-ci pytorch

@cyanguwa cyanguwa merged commit c3b3cd2 into NVIDIA:main Oct 7, 2024
14 of 15 checks passed
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.

[PyTorch] fused CUDNN attention kernel and sliding window attention
2 participants