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

triton softmax support multi-batch #152

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

triton softmax support multi-batch #152

wants to merge 5 commits into from

Conversation

Gy-Lu
Copy link
Contributor

@Gy-Lu Gy-Lu commented Feb 16, 2023

  1. Support another batch dimension for softmax. In training or batch inference, we may add a batch dimension as the first dimension of some tensors. However, we use the third dimension(tensor.shape[2]) as the head_dim, which would be influenced. In this pr, I modify it to tensor.shape[-3] to solve this problem. CUDA kernel is modified as well.

  2. Enable test_atten_core, this test is skipped by default and never be used.

@Gy-Lu Gy-Lu added the Run Build and Test Run test for pull request label Feb 16, 2023
Copy link
Contributor

@oahzxl oahzxl left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -15,19 +15,19 @@ def _test_softmax_core():

for seq_ in test_seq_:
for dtype in test_dtype:
sample_input = torch.rand(batch_, chunk_, head_, seq_,
sample_input = torch.rand(batch, batch_, chunk_, head_, seq_,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, without the batch dimension it would work correctly as well

@Gy-Lu Gy-Lu changed the title Softmax batch [Do not Merge]Softmax batch Feb 18, 2023
@Gy-Lu
Copy link
Contributor Author

Gy-Lu commented Feb 18, 2023

I found it would fail when the batch dimension comes to 2.

@Gy-Lu
Copy link
Contributor Author

Gy-Lu commented Feb 20, 2023

Update:
It works incorrectly before this commit. For the way getting bias_ptr not supports multi-batch.
And I have fixed the triton version.
CUDA version may support multi-batch one day :(

@Gy-Lu Gy-Lu changed the title [Do not Merge]Softmax batch triton softmax support multi-batch Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run Build and Test Run test for pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants