Re-enable the 80 char line width limit (#3305)
This commit is contained in:
@@ -95,13 +95,15 @@ class BlockAllocator:
|
||||
del self.cached_blocks[block.block_hash]
|
||||
|
||||
def get_num_free_blocks(self) -> int:
|
||||
return self.num_blocks - self.current_num_blocks + self.evictor.num_blocks
|
||||
return (self.num_blocks - self.current_num_blocks +
|
||||
self.evictor.num_blocks)
|
||||
|
||||
def contains_block(self, block_hash: int) -> bool:
|
||||
return block_hash in self.cached_blocks or block_hash in self.evictor
|
||||
|
||||
def update_hash(self, block_hash: int, block: PhysicalTokenBlock):
|
||||
# If caching is enabled, update the hash of block and the cached_blocks dictionary.
|
||||
# If caching is enabled, update the hash of block and the
|
||||
# cached_blocks dictionary.
|
||||
if self.enable_caching:
|
||||
assert not self.contains_block(block_hash)
|
||||
old_hash = block.block_hash
|
||||
@@ -218,10 +220,12 @@ class BlockSpaceManager:
|
||||
seq: Sequence,
|
||||
last_block: PhysicalTokenBlock,
|
||||
) -> PhysicalTokenBlock:
|
||||
# Compute a new hash for the block so that it can be shared by other Sequences
|
||||
# Compute a new hash for the block so that it can be shared by
|
||||
# other Sequences
|
||||
new_hash = seq.hash_of_block(len(seq.logical_token_blocks) - 1)
|
||||
|
||||
# if new_hash is already in the cached table, then free last_block and return the cached version
|
||||
# if new_hash is already in the cached table, then free last_block
|
||||
# and return the cached version
|
||||
if self.gpu_allocator.contains_block(new_hash):
|
||||
self.gpu_allocator.free(last_block)
|
||||
return self.gpu_allocator.allocate(new_hash)
|
||||
@@ -289,7 +293,8 @@ class BlockSpaceManager:
|
||||
assert last_block.device == Device.GPU
|
||||
if last_block.ref_count == 1:
|
||||
# Not shared with other sequences. Appendable.
|
||||
# If the last block is now complete, promote it to a full block so that it can be shared
|
||||
# If the last block is now complete, promote it to a full block so
|
||||
# that it can be shared
|
||||
new_block = self._maybe_promote_last_block(seq, last_block)
|
||||
block_table[-1] = new_block
|
||||
return None
|
||||
|
||||
@@ -39,9 +39,9 @@ class Evictor(ABC):
|
||||
@abstractmethod
|
||||
def remove(self, block_hash: int) -> PhysicalTokenBlock:
|
||||
"""Simply removes the block with the hash value block_hash from the
|
||||
evictor. Caller is responsible for making sure that block_hash is contained
|
||||
in the evictor before calling remove. Should be used to "bring back" blocks
|
||||
that have been freed but not evicted yet.
|
||||
evictor. Caller is responsible for making sure that block_hash is
|
||||
contained in the evictor before calling remove. Should be used to
|
||||
"bring back" blocks that have been freed but not evicted yet.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -214,8 +214,8 @@ class Scheduler:
|
||||
lora_int_id = 0
|
||||
if self.lora_enabled:
|
||||
lora_int_id = seq_group.lora_int_id
|
||||
if lora_int_id > 0 and lora_int_id not in curr_loras and len(
|
||||
curr_loras) >= self.lora_config.max_loras:
|
||||
if (lora_int_id > 0 and lora_int_id not in curr_loras
|
||||
and len(curr_loras) >= self.lora_config.max_loras):
|
||||
# We don't have a space for another LoRA, so
|
||||
# we ignore this request for now.
|
||||
leftover_waiting_sequences.appendleft(seq_group)
|
||||
@@ -309,8 +309,8 @@ class Scheduler:
|
||||
lora_int_id = 0
|
||||
if self.lora_enabled:
|
||||
lora_int_id = seq_group.lora_int_id
|
||||
if lora_int_id > 0 and lora_int_id not in curr_loras and len(
|
||||
curr_loras) >= self.lora_config.max_loras:
|
||||
if (lora_int_id > 0 and lora_int_id not in curr_loras
|
||||
and len(curr_loras) >= self.lora_config.max_loras):
|
||||
# We don't have a space for another LoRA, so
|
||||
# we ignore this request for now.
|
||||
leftover_swapped.appendleft(seq_group)
|
||||
|
||||
Reference in New Issue
Block a user