MLA Parallel Decoding

Description

Performs parallel decoding in the MLA scenario.

How to Enable

  • Set calcType to CALC_TYPE_SPEC.
  • mlaVHeadSize > 0

Input

Parameter

Dimension

Data Type

Format

cpu or npu

Description

Application Scenario

query

[num_tokens, num_head, head_size]

float16/bf16

ND

npu

query of each batch is combined along the num_tokens axis.

Basic scenario

keyCache

[num_blocks, block_size, kv_head_num, head_size_k]

float16/bf16

ND

npu

kcache.

Basic scenario

blockTables

[num_tokens, max_num_blocks_per_query]

int32

ND

npu

Block table of kvcache of each query. The first dimension is the token index, and the second dimension indicates the block index.

Basic scenario

contextLens

[batch]

int32

ND

cpu

Number of key/value tokens of each query.

Basic scenario

mask

[num_tokens (combined axis), max_seqlen]

float16/bf16

ND

npu

This parameter is required when maskType is not set to UNDEFINED.

Mask scenario

qSeqLens

[batch]

int32

ND

cpu

seqLen of each batch when parallel decoding is enabled.

Parallel decoding scenario

Output

Parameter

Dimension

Data Type

Format

cpu or npu

Description

Application Scenario

attnOut

[num_tokens, num_head, head_size_v]

float16/bf16

ND

npu

Query output after computation.

Basic scenario

Restrictions

  • The restrictions are the same as those of the MLA merging input (embed size limit).
  • The values in qSeqlen must be greater than or equal to 1, and they cannot be all 1 in the MTP scenario.
  • maskType can be UNDEFINED or MASK_TYPE_SPEC.
  • Only MQA scenarios are supported in MLA.
  • The value range of head_num is (0, 256], the value range of head_size and head_size_k is (0, 576], and the value range of blocksize is (0, 128].