[Bugfix] Support non-uniform page sizes in KVBlockZeroer (#49704)
Signed-off-by: Elvir Crncevic <elvircrn@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2279575cd9
commit
972848f276
@@ -36,7 +36,8 @@ _FLA_POST_CONV_WARMUP_LENGTHS = (1, 2, 16)
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _ZeroKvWarmupConfig:
|
||||
page_size_el: int
|
||||
seg_page_sizes: torch.Tensor
|
||||
max_chunks: int
|
||||
block_size: int
|
||||
n_segs: int
|
||||
|
||||
@@ -160,9 +161,10 @@ def _zero_kv_warmup_config(runner: object) -> _ZeroKvWarmupConfig | None:
|
||||
if meta is None:
|
||||
return None
|
||||
|
||||
_, page_size_el, block_size, n_segs = meta
|
||||
_, seg_page_sizes, max_chunks, block_size, n_segs = meta
|
||||
return _ZeroKvWarmupConfig(
|
||||
page_size_el=int(page_size_el),
|
||||
seg_page_sizes=seg_page_sizes,
|
||||
max_chunks=int(max_chunks),
|
||||
block_size=int(block_size),
|
||||
n_segs=int(n_segs),
|
||||
)
|
||||
@@ -185,8 +187,9 @@ def _warm_zero_kv_blocks_kernel(
|
||||
from vllm.v1.worker.utils import _zero_kv_blocks_kernel
|
||||
|
||||
max_n_blocks = max(_ZERO_KV_N_BLOCKS)
|
||||
max_page_size = int(config.seg_page_sizes.max().item())
|
||||
scratch = torch.empty(
|
||||
max_n_blocks * config.page_size_el,
|
||||
max_n_blocks * max_page_size,
|
||||
dtype=torch.int32,
|
||||
device=device,
|
||||
)
|
||||
@@ -198,13 +201,14 @@ def _warm_zero_kv_blocks_kernel(
|
||||
|
||||
for n_blocks in _ZERO_KV_N_BLOCKS:
|
||||
block_ids = torch.arange(n_blocks, dtype=torch.int64, device=device)
|
||||
grid = (n_blocks * config.n_segs * (config.page_size_el // config.block_size),)
|
||||
grid = (n_blocks * config.n_segs * config.max_chunks,)
|
||||
_zero_kv_blocks_kernel[grid](
|
||||
seg_addrs,
|
||||
config.seg_page_sizes,
|
||||
block_ids,
|
||||
n_blocks,
|
||||
N_SEGS=config.n_segs,
|
||||
PAGE_SIZE_EL=config.page_size_el,
|
||||
MAX_CHUNKS=config.max_chunks,
|
||||
BLOCK_SIZE=config.block_size,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user