-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
add num_splist for flash_attn_bwd and FlashAttnUnpaddedGradKernel #56363
Merged
Xreki
merged 10 commits into
PaddlePaddle:develop
from
AnnaTrainingG:flash_bwd_num_splits
Sep 4, 2023
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b742184
add num_splist for flash_attn_bwd and FlashAttnUnpaddedGradKernel
AnnaTrainingG 5a5c307
update
AnnaTrainingG 7d9ce2f
update
AnnaTrainingG 814b9c5
Add assertTrue
AnnaTrainingG ded6af8
Update submodule to a specific commit
AnnaTrainingG 063f8f3
update test
AnnaTrainingG 51817ec
update
AnnaTrainingG 7dd1f71
update
AnnaTrainingG 75ff6f8
update
AnnaTrainingG 8b585ab
update
AnnaTrainingG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,17 +191,13 @@ def test_unpadded(self): | |
fetches_result[0], out_, rtol=5e-03, atol=1e-03 | ||
) | ||
|
||
def test_all(self): | ||
def flash_attn_compute(self, query, key, value): | ||
print( | ||
f"Test case shape {self.shape} dtype {self.dtype} causal {self.causal}" | ||
) | ||
# test dynamic | ||
paddle.disable_static() | ||
|
||
query = np.random.random(self.shape) | ||
key = np.random.random(self.shape) | ||
value = np.random.random(self.shape) | ||
|
||
q = paddle.to_tensor( | ||
query, place=self.place, dtype=self.dtype, stop_gradient=False | ||
) | ||
|
@@ -306,6 +302,29 @@ def test_all(self): | |
np.testing.assert_allclose( | ||
fetches_result[0], out_, rtol=5e-03, atol=1e-03 | ||
) | ||
return out, out_, fetches_result[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
def test_all(self): | ||
query = np.random.random(self.shape) | ||
key = np.random.random(self.shape) | ||
value = np.random.random(self.shape) | ||
out, out_, _ = self.flash_attn_compute(query, key, value) | ||
|
||
def test_all_flag(self): | ||
paddle.set_flags({'FLAGS_cudnn_deterministic': 1}) | ||
query = np.random.random(self.shape) | ||
key = np.random.random(self.shape) | ||
value = np.random.random(self.shape) | ||
|
||
out1, out1_, fetches_result1 = self.flash_attn_compute( | ||
query, key, value | ||
) | ||
out2, out2_, fetches_result2 = self.flash_attn_compute( | ||
query, key, value | ||
) | ||
self.assertTrue(np.equal(out1.numpy(), out2.numpy()).all()) | ||
self.assertTrue(np.equal(fetches_result1, fetches_result2).all()) | ||
paddle.set_flags({'FLAGS_cudnn_deterministic': 0}) | ||
|
||
|
||
@unittest.skipIf( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
封装成一个函数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done