@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 0b51c9bd8b
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[Core] Early return in SlidingWindowManager.remove_skipped_blocks (#27673)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>

Jialin Ouyang committed Oct 28, 2025 at 18:32 UTC 0b51c9bd8b19cee3a494b0f966a6b0a846a40193
1 file changed +6
vllm/v1/core/single_type_kv_cache_manager.py
+6
@@ -394,7 +394,13 @@ class SlidingWindowManager(SingleTypeKVCacheManager):
394 # skipped during the attention computation.
395 last_useful_token = num_computed_tokens - self.sliding_window + 1
396 last_useful_block = last_useful_token // self.block_size
397 + if last_useful_block <= 0:
398 + # Early return if tokens are not enough to fill the sliding window
399 + return
400 blocks = self.req_to_blocks[request_id]
401 + if blocks[last_useful_block - 1] == self._null_block:
402 + # Early return if there are no blocks to remove
403 + return
404 removed_blocks: list[KVCacheBlock] = []
405 for i in range(last_useful_block - 1, -1, -1):
406 if blocks[i] == self._null_block: