[Bugfix][Mooncake] Fix per-group block_size/block_hash and group_idx in MooncakeStoreConnector KV events (#44103)
Signed-off-by: Yifan Qiao <yifanqiao@inferact.ai>
This commit is contained in:
@@ -213,7 +213,6 @@ class ReqMeta:
|
||||
current_event: torch.cuda.Event | None = None
|
||||
|
||||
token_ids: list[int] | None = None
|
||||
original_block_size: int | None = None
|
||||
|
||||
@staticmethod
|
||||
def from_request_tracker(
|
||||
@@ -223,7 +222,6 @@ class ReqMeta:
|
||||
skip_save: bool | None = False,
|
||||
block_hashes: list[BlockHash] | None = None,
|
||||
is_last_chunk: bool | None = None,
|
||||
original_block_size: int | None = None,
|
||||
) -> "ReqMeta | None":
|
||||
"""Create ReqMeta from a RequestTracker."""
|
||||
if block_hashes is None:
|
||||
@@ -274,7 +272,6 @@ class ReqMeta:
|
||||
block_hashes=block_hashes,
|
||||
is_last_chunk=is_last_chunk,
|
||||
token_ids=token_ids,
|
||||
original_block_size=original_block_size,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -59,11 +59,7 @@ class MooncakeStoreScheduler:
|
||||
)
|
||||
self.client = LookupKeyClient(vllm_config)
|
||||
|
||||
self.pcp_size = vllm_config.parallel_config.prefill_context_parallel_size
|
||||
self.dcp_size = vllm_config.parallel_config.decode_context_parallel_size
|
||||
self.original_block_size = vllm_config.cache_config.block_size
|
||||
# LCM for multi-group HMA; bs * pcp * dcp for single-group. Matches
|
||||
# the engine's own scheduler block size by construction.
|
||||
# Align with the engine's own scheduler_block_size and hash_block_size.
|
||||
self._block_size, self._hash_block_size = resolve_kv_cache_block_sizes(
|
||||
kv_cache_config, vllm_config
|
||||
)
|
||||
@@ -221,7 +217,6 @@ class MooncakeStoreScheduler:
|
||||
skip_save=force_skip_save,
|
||||
block_hashes=request_real.block_hashes,
|
||||
is_last_chunk=(request_tracker.token_len >= last_chunk_tokens_num),
|
||||
original_block_size=self.original_block_size,
|
||||
)
|
||||
if req_meta is not None:
|
||||
meta.add_request(req_meta)
|
||||
@@ -274,7 +269,6 @@ class MooncakeStoreScheduler:
|
||||
is_last_chunk=(
|
||||
request_tracker.token_len >= last_chunk_tokens_num
|
||||
),
|
||||
original_block_size=self.original_block_size,
|
||||
)
|
||||
else:
|
||||
# Decode/chunked request
|
||||
@@ -312,7 +306,6 @@ class MooncakeStoreScheduler:
|
||||
is_last_chunk=(
|
||||
request_tracker.token_len >= last_chunk_tokens_num
|
||||
),
|
||||
original_block_size=self.original_block_size,
|
||||
)
|
||||
|
||||
if req_meta is not None:
|
||||
|
||||
@@ -507,7 +507,8 @@ class KVCacheStoreSendingThread(KVTransferThread):
|
||||
return True
|
||||
|
||||
def _handle_request(self, req_meta: ReqMeta):
|
||||
# Cache hits are always a multiple of ``lcm_block_size`` tokens
|
||||
# Cache hits are always a multiple of ``lcm_block_size`` tokens, which
|
||||
# is also ``store_mask``'s precondition.
|
||||
lcm_block_size = self.coord.lcm_block_size
|
||||
token_len = req_meta.token_len_chunk // lcm_block_size * lcm_block_size
|
||||
block_ids_per_group = req_meta.block_ids
|
||||
@@ -550,7 +551,7 @@ class KVCacheStoreSendingThread(KVTransferThread):
|
||||
starts.append(start)
|
||||
ends.append(end)
|
||||
keys.append(key.to_string())
|
||||
block_hashes.append(req_meta.block_hashes[chunk_idx])
|
||||
block_hashes.append(BlockHash(bytes.fromhex(key.chunk_hash)))
|
||||
group_indices.append(g_idx)
|
||||
|
||||
# Apply put_step striding for TP
|
||||
@@ -627,10 +628,11 @@ class KVCacheStoreSendingThread(KVTransferThread):
|
||||
block_hashes=[new_block_hashes[idx]],
|
||||
parent_block_hash=prev_key_per_group.get(g_idx),
|
||||
token_ids=token_ids,
|
||||
block_size=req_meta.original_block_size,
|
||||
block_size=db.block_size,
|
||||
lora_id=None,
|
||||
medium="cpu",
|
||||
lora_name=None,
|
||||
group_idx=g_idx,
|
||||
)
|
||||
stored_events.append(stored_event)
|
||||
prev_key_per_group[g_idx] = new_block_hashes[idx]
|
||||
@@ -947,7 +949,6 @@ class MooncakeStoreWorker:
|
||||
"load_async", True
|
||||
)
|
||||
self.cache_config = vllm_config.cache_config
|
||||
self.original_block_size = self.cache_config.block_size
|
||||
self.block_size, self.hash_block_size = resolve_kv_cache_block_sizes(
|
||||
kv_cache_config, vllm_config
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user