[ModelRunnerV2][Hybrid model] Support kernel block size in hybrid model (#38831)
Signed-off-by: MengqingCao <cmq0113@163.com> Signed-off-by: Nick Hill <nickhill123@gmail.com> Signed-off-by: Mengqing Cao <cmq0113@163.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
co-authored by
Nick Hill
parent
381edde1b9
commit
1223732dda
@@ -44,9 +44,7 @@ class BlockTables:
|
||||
for i in range(self.num_kv_cache_groups):
|
||||
max_num_blocks = max_num_blocks_per_group[i] * self.blocks_per_kv_block[i]
|
||||
block_table = StagedWriteTensor(
|
||||
(self.max_num_reqs, max_num_blocks),
|
||||
dtype=torch.int32,
|
||||
device=device,
|
||||
(self.max_num_reqs, max_num_blocks), dtype=torch.int32, device=device
|
||||
)
|
||||
self.block_tables.append(block_table)
|
||||
|
||||
@@ -132,7 +130,6 @@ class BlockTables:
|
||||
self.num_blocks.gpu,
|
||||
self.num_blocks.gpu.stride(0),
|
||||
num_reqs,
|
||||
self.input_block_tables[0].shape[1], # max_num_blocks
|
||||
BLOCK_SIZE=1024, # type: ignore
|
||||
)
|
||||
return tuple(bt[:num_reqs_padded] for bt in self.input_block_tables)
|
||||
@@ -192,7 +189,6 @@ def _gather_block_tables_kernel(
|
||||
num_blocks_ptr, # [num_kv_cache_groups, max_num_reqs]
|
||||
num_blocks_stride,
|
||||
num_reqs, # actual number of requests (for padding)
|
||||
max_num_blocks, # stride for zeroing padded rows
|
||||
BLOCK_SIZE: tl.constexpr,
|
||||
):
|
||||
# kv cache group id
|
||||
@@ -200,6 +196,7 @@ def _gather_block_tables_kernel(
|
||||
batch_idx = tl.program_id(1)
|
||||
|
||||
stride = tl.load(block_table_strides + group_id)
|
||||
max_num_blocks = stride # stride equals max_num_blocks for this group.
|
||||
dst_block_table_ptr = _load_ptr(dst_block_table_ptrs + group_id, tl.int32)
|
||||
dst_row_ptr = dst_block_table_ptr + batch_idx * stride
|
||||
|
||||
|
||||
Reference in New Issue
Block a user