Enabling the Multi-Head Compression Function in the Rope Scenario
compressType=COMPRESS_TYPE_KVHEAD_ROPE, kvCacheCfg=K_CACHE_V_CACHE
Input
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
key |
[num_tokens, num_head, head_size] |
float16/bf16 |
ND |
Key of multiple tokens in the current step. The last dimension must be a multiple of 32. |
value |
[num_tokens, num_head, head_size] |
float16/bf16 |
ND |
Value of multiple tokens in the current step. The last dimension must be a multiple of 32. |
keyCache |
[num_blocks, block_size, 1, head_size] |
float16/bf16 |
ND |
All key caches. |
valueCache |
[num_blocks, block_size, 1, head_size] |
float16/bf16 |
ND |
All value caches. |
slotMapping |
[batch*num_head] |
int32 |
ND |
|
wins |
[batch*num_head] |
int32 |
ND |
Compression. wins[i] < seqLens[floor(i/num_head)]. The value in wins must be greater than or equal to 0. If the value is 0, compression is not performed. |
seqLens |
[batch] |
int32 |
ND |
Actual seqLen of each batch. The internal value is greater than 0. |
offsetIndex |
[batch*num_head] |
int32 |
ND |
Compression start point of each head of each batch. The value range is [-1, seqLens[i]-wins[i]]. If the value is -1, compression is not performed. There is no requirement on the value of wins. |
Output
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
keyCacheOut |
[num_blocks, block_size, 1, head_size] |
float16/bf16 |
ND |
All key caches. The address is the same as that of the input keyCache. |
valueCacheOut |
[num_blocks, block_size, 1, head_size] |
float16/bf16 |
ND |
All value caches. The address is the same as that of valueCache. |