[BugFix][kv_offload]: Fix kernel block size detection (#35125)
Signed-off-by: Or Ozeri <oro@il.ibm.com>
This commit is contained in:
@@ -259,16 +259,20 @@ class CpuGpuOffloadingHandlers:
|
|||||||
assert gpu_shape[0] == 2
|
assert gpu_shape[0] == 2
|
||||||
split_k_and_v = True
|
split_k_and_v = True
|
||||||
|
|
||||||
try:
|
if has_layers_dim:
|
||||||
kv_cache_stride_order = attn_backend.get_kv_cache_stride_order(
|
# in the cross layers case, the registered kv cache tensor
|
||||||
include_num_layers_dimension=has_layers_dim
|
# shape matches the physical layout, whereas test_shape
|
||||||
)
|
# is the logical layout.
|
||||||
assert len(kv_cache_stride_order) == len(gpu_shape)
|
# To match them, we need to permute test_shape
|
||||||
except (AttributeError, NotImplementedError):
|
try:
|
||||||
kv_cache_stride_order = tuple(range(len(gpu_shape)))
|
kv_cache_stride_order = attn_backend.get_kv_cache_stride_order(
|
||||||
|
include_num_layers_dimension=has_layers_dim
|
||||||
|
)
|
||||||
|
assert len(kv_cache_stride_order) == len(gpu_shape)
|
||||||
|
except (AttributeError, NotImplementedError):
|
||||||
|
kv_cache_stride_order = tuple(range(len(gpu_shape)))
|
||||||
|
|
||||||
# permute test_shape according to stride_order
|
test_shape = tuple(test_shape[i] for i in kv_cache_stride_order)
|
||||||
test_shape = tuple(test_shape[i] for i in kv_cache_stride_order)
|
|
||||||
|
|
||||||
# find block_size (16) dimension index
|
# find block_size (16) dimension index
|
||||||
block_size_idx = test_shape.index(16)
|
block_size_idx = test_shape.index(16)
|
||||||
|
|||||||
Reference in New Issue
Block a user