Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tensorrt_llm/runtime/kv_cache_manager_v2/_core/_kv_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
div_up,
expect_type,
filled_list,
intersect,
make_typed,
map_optional,
stream_wait_events,
Expand Down Expand Up @@ -706,7 +707,10 @@ def resize(self, capacity: int | None, history_length: int | None = None) -> boo
continue
stale_beg, stale_end = stale_ranges[lc]
if enable_scratch:
num_scratch_blocks = len(scratch_ranges[lc])
# Only newly added blocks consume slots below; scratch range may
# extend before old_num_blocks when history_length < old_capacity.
new_block_range = HalfOpenRange(old_num_blocks, new_num_blocks)
num_scratch_blocks = len(intersect(scratch_ranges[lc], new_block_range))
Comment thread
lowsfer marked this conversation as resolved.
Outdated
num_new_normal_blocks = (new_num_blocks - old_num_blocks) - num_scratch_blocks
Comment thread
lowsfer marked this conversation as resolved.
Outdated
num_new_slots[lc] = num_new_normal_blocks * beam_width
else:
Expand Down
Loading