Skip to content

Commit

Permalink
amend function name and comment
Browse files Browse the repository at this point in the history
Signed-off-by: Sungjae Lee <33976427+llsj14@users.noreply.github.com>
  • Loading branch information
llsj14 committed Dec 11, 2024
1 parent 363e3b2 commit 44fb3f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions vllm/commit_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__commit__ = "273da1dab05e25a8fae5ac22cb18eb3785fe2a14"
2 changes: 1 addition & 1 deletion vllm/core/block/prefix_caching_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def _update_seq_hashes(self, seq: Sequence) -> None:

# NOTE: If there are any factors affecting the block besides
# token_ids, they should be added as input to contextual_hash.
contextual_hash = seq.hash_of_block_v2()
contextual_hash = seq.contextual_hash_of_block()

# This has to be kept in sync with the allocator's hash
# calculation.
Expand Down
4 changes: 2 additions & 2 deletions vllm/core/block_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _allocate_sequence(self, seq: Sequence) -> BlockTable:
if seq.get_token_ids():
# NOTE: If there are any factors affecting the block besides
# token_ids, they should be added as input to contextual_hash.
contextual_hash = seq.hash_of_block_v2()
contextual_hash = seq.contextual_hash_of_block()

# Add blocks to the block table only if the sequence is non empty.
block_table.allocate(token_ids=seq.get_token_ids(),
Expand Down Expand Up @@ -243,7 +243,7 @@ def append_slots(
token_ids=block_table.get_unseen_token_ids(seq.get_token_ids()),
num_lookahead_slots=num_lookahead_slots,
num_computed_slots=seq.data.get_num_computed_tokens(),
contextual_hash=seq.hash_of_block_v2(),
contextual_hash=seq.contextual_hash_of_block(),
)
# Return any new copy-on-writes.
new_cows = self.block_allocator.clear_copy_on_writes()
Expand Down
8 changes: 4 additions & 4 deletions vllm/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ def hash_of_block(self, logical_idx: int) -> int:
hashed_tokens = self.data.get_prefix_token_ids(num_tokens)
return hash((hashed_tokens, self.lora_int_id))

def hash_of_block_v2(self) -> int:
# This function is introduced for BlockSpaceManagerV2 and is used with
# prefix caching mode. The final block hash is determined by applying
# token_ids in PrefixCachingBlock under BlockSpaceManagerV2.
def contextual_hash_of_block(self) -> int:
# This function computes a contextual hash for a block, specifically
# designed for prefix caching mode. The final block hash is determined
# by applying token_ids in PrefixCachingBlock.

# NOTE: If there are additional factors influencing the block aside from
# token_ids, include them as input parameters to the hash.
Expand Down

0 comments on commit 44fb3f0

Please sign in to comment.