Input and Output
Parameter |
Dimension |
Data Type |
Format |
cpu/npu |
Description |
Application Scenario |
|---|---|---|---|---|---|---|
query |
[ntokens, qHiddenSize] |
float16/bf16 |
ND |
npu |
Query matrix. |
Basic scenario |
key |
[ntokens, kHiddenSize] |
float16/bf16 |
ND |
npu |
Key matrix. This parameter is not passed when kvcacheCfg is set to K_BYPASS_V_BYPASS. |
Basic scenario |
value |
[ntokens, vHiddenSize] |
float16/bf16 |
ND |
npu |
Value matrix. This parameter is not passed when kvcacheCfg is set to K_BYPASS_V_BYPASS. |
Basic scenario |
cacheK |
[layerNum, batch, maxSeqLen, kHiddenSize] |
float16/bf16 |
cpu/npu |
|
Basic scenario |
|
cacheV |
[layerNum, batch, maxSeqLen, vhiddenSize] |
float16/bf16 |
npu/cpu |
|
Basic scenario |
|
attentionMask |
|
float16/bf16 |
npu |
The six shapes are described as follows: 1. Same batch or SWA norm mask, square matrix. 2. Square matrix with different batches. 3. Vectors with different batches. 4. Square matrix with different batches in the ALiBi scenario. 5. Square matrix with the same batch in the ALiBi scenario. 6. SWA compress mask. |
Mask scenario |
|
tokenOffset |
[batch] |
int32/uint32 |
ND |
cpu |
Token offset after calculation. |
Basic scenario |
seqLen |
[batch] |
int32/uint32 |
ND |
cpu |
1: incremental or full mode. > 1: full mode. |
Basic scenario |
layerId |
[1] |
int32/uint32 |
ND |
npu |
KV of the cache for calculation. |
Basic scenario |
batchStatus |
[batch] |
int32/uint32 |
ND |
cpu |
Batch to be calculated when the calculable batch function is enabled. |
Scenario of calculable batch control |
logN |
|
float |
ND |
npu |
In the full phase, the value is the logN sequence of the length maxSeqLen. Each request in a batch obtains a value from this vector based on seqlen. In the incremental phase, the value is the logN corresponding to the new request in each batch. This tensor is required when the scale type is logN. |
LogN scenario |
output |
[nTokens, headNum * vHeadSize] |
float16/bf16 |
ND |
npu |
Output. |
Basic scenario |