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

Detailed implementation of clustered_sparse_dot_product #120

Open
HanielF opened this issue Jan 24, 2023 · 0 comments
Open

Detailed implementation of clustered_sparse_dot_product #120

HanielF opened this issue Jan 24, 2023 · 0 comments

Comments

@HanielF
Copy link

HanielF commented Jan 24, 2023

Could you explain the detailed implementation of clustered_sparse_dot_product in _topk_attention function of ImprovedClusteredAttention class.
I feel a little confused about how to compute QK with the below code snippet

class ImprovedClusteredAttention(Module):
    ......

    def _topk_attention(self, Q, K, V,
                        clusters, counts,
                        topk, topk_values,
                        A_bottomk, softmax_temp,
                        query_lengths):
        N, H, L, E = Q.shape
        _, _, S, _ = K.shape
        _, _, C, k = topk.shape

        # We need to pass the output tensor to initialize to 0
        QK = clustered_sparse_dot_product(
            Q, K, topk,
            clusters, counts,
            query_lengths._lengths.int()
        )
      
      ......
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