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

[Tracing Issue] Multi-head Latent Attention #792

Closed
4 tasks done
yzh119 opened this issue Feb 6, 2025 · 0 comments
Closed
4 tasks done

[Tracing Issue] Multi-head Latent Attention #792

yzh119 opened this issue Feb 6, 2025 · 0 comments

Comments

@yzh119
Copy link
Collaborator

yzh119 commented Feb 6, 2025

Background

We need two sets of kernels for MLA:

  1. self-attention on ragged tensor, w/o matrix absorption: head_dim_qk=192, head_dim_vo=128
  2. cross-attention on paged-kv cache, w/ matrix absorption: head_dim_qk=576, head_dim_vo=512 (K=V)

and serving engines are expected to use different kernels according to use cases:

  1. For decoding, use 2
  2. For prefilling (w/o prefix-caching), use 1
  3. For incremental prefilling/chunked-prefill, use the 1+2:
    • o_1, lse_1 = cross_attention(c_q, q_pe, c_kv) (c_q: (n, 128, 512), q_pe: (n, 128, 64), c_kv: (n_kv, 576), o_1: (n, 128, 512), lse_1: (n, 128))
    • o_2, lse_2 = self_attention(q, k, v_new) (q: (n, 128, 192), k: (n, 128, 192), v: (n, 128, 128), o_2: (n, 128, 128), lse_2: (n, 128))
    • o, lse = merge(W_UV(o_1), lse_1, o_2, lse_2)

Milestone

@yzh119 yzh119 pinned this issue Feb 6, 2025
@yzh119 yzh119 closed this as completed Feb 23, 2025
@yzh119 yzh119 unpinned this issue Feb 23, 2025
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