Skip to content

vllm.v1.attention.ops.xpu_mla_sparse

Functions:

triton_bf16_mla_sparse_interface(q, kv, indices, sm_scale, d_v=512, block_dpe=64, attn_sink=None)

Sparse MLA attention over a BF16 latent KV cache, using Triton.

Parameters:

  • q

    (Tensor) –

    Query tensor, [num_tokens, num_heads_q, dim_qk].

  • kv

    (Tensor) –

    Latent KV cache tensor.

  • indices

    (Tensor) –

    Sparse KV indices selected for each query token.

  • sm_scale

    (float) –

    Softmax scale applied to the QK product.

  • d_v

    (int, default: 512 ) –

    Size of the value dimension.

  • block_dpe

    (int, default: 64 ) –

    Size of positional embedding portion of dim_qk. Set to 0 when q/kv contain only the nope latent (e.g. DSv4 prefill where RoPE is not split out).

  • attn_sink

    (Tensor | None, default: None ) –

    Optional per-head fp32 sink logit added to the softmax denominator (DSv4). It must be on q's device, contiguous and at least num_heads_q long (extra padded entries are ignored). -inf entries are a no-op. The returned softmax_lse and max_logits are over the selected keys only and exclude the sink, so do not merge them with other partial results as if they included it.

Returns:

  • Tensor –

    out [num_tokens, num_heads_q, d_v], max_logits

  • Tensor –

    [num_tokens, num_heads_q] and the logsumexp lse

  • Tensor –

    [num_tokens, num_heads_q].