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

Blocksparse.matmul result does not align with torch #4709

Open
oleksost opened this issue Sep 11, 2024 · 0 comments
Open

Blocksparse.matmul result does not align with torch #4709

oleksost opened this issue Sep 11, 2024 · 0 comments

Comments

@oleksost
Copy link

Hello,
in the following code the result returned by triton.ops.blocksparse.matmul and torch.einsum do not align (please nolayout consists of all ones).

My understanding is that both outputs should be the same.

Thank you in advance!

import torch
from triton.ops.blocksparse.matmul import matmul

NumHeads, SeqLen, BlockSize, Embed = 1, 64, 32, 128
layout = torch.ones(NumHeads, Embed // BlockSize, SeqLen // BlockSize).long()
q = torch.randn((1, NumHeads, SeqLen, Embed), dtype=torch.float32).contiguous().to('cuda')
k = torch.randn((1, NumHeads, Embed, SeqLen), dtype=torch.float32).contiguous().to('cuda')

mm = matmul(layout, BlockSize, mode='dds', device='cuda')
o_tn = mm(q,k)
o_torch = torch.einsum('bhsd,bhdo->bhso', q, k)

torch.allclose(o_tn, o_torch, atol=1e-1)    
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

No branches or pull requests

1 participant