@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 606b00e80f
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

[bugfix][DCP] fix block_size of hash in DCP prefix caching (#26296)

Signed-off-by: Chen Zhang <zhangch99@outlook.com>

Chen Zhang committed Oct 10, 2025 at 18:02 UTC 606b00e80f32698544b117f6c8fbf9265eae61dc
5 files changed +12 -10
tests/v1/core/test_scheduler.py
+1
@@ -1411,6 +1411,7 @@ def create_scheduler_with_priority(
1411 kv_cache_config=kv_cache_config,
1412 log_stats=True,
1413 structured_output_manager=StructuredOutputManager(vllm_config),
1414 + block_size=block_size,
1415 )
1416
1417
tests/v1/core/utils.py
+1
@@ -129,6 +129,7 @@ def create_scheduler(
129 return scheduler_cls(
130 vllm_config=vllm_config,
131 kv_cache_config=kv_cache_config,
132 + block_size=block_size,
133 log_stats=True,
134 structured_output_manager=StructuredOutputManager(vllm_config),
135 )
tests/v1/kv_connector/unit/utils.py
+1
@@ -138,6 +138,7 @@ def create_scheduler(
138 kv_cache_config=kv_cache_config,
139 log_stats=True,
140 structured_output_manager=StructuredOutputManager(vllm_config),
141 + block_size=block_size,
142 )
143
144
vllm/v1/core/sched/scheduler.py
+2 -8
@@ -45,6 +45,7 @@ class Scheduler(SchedulerInterface):
45 vllm_config: VllmConfig,
46 kv_cache_config: KVCacheConfig,
47 structured_output_manager: StructuredOutputManager,
48 + block_size: int,
49 mm_registry: MultiModalRegistry = MULTIMODAL_REGISTRY,
50 include_finished_set: bool = False,
51 log_stats: bool = False,
@@ -101,15 +102,8 @@ class Scheduler(SchedulerInterface):
102 num_gpu_blocks = self.cache_config.num_gpu_blocks
103 assert num_gpu_blocks is not None and num_gpu_blocks > 0
104
104 - self.block_size = self.cache_config.block_size
105 -
105 + self.block_size = block_size
106 self.dcp_world_size = vllm_config.parallel_config.decode_context_parallel_size
107 - # Note(hc): The scheduler’s block_size must be multiplied
108 - # by dcp_world_size, since block hashes are computed on the
109 - # original full token sequence at a granularity of
110 - # original_block_size × dcp_world_size.
111 - if self.dcp_world_size > 1:
112 - self.block_size *= self.dcp_world_size
107
108 # req_id -> Request
109 self.requests: dict[str, Request] = {}
vllm/v1/engine/core.py
+7 -2
@@ -142,12 +142,18 @@ class EngineCore:
142 logger.info("Disabling chunked prefill for model without KVCache")
143 vllm_config.scheduler_config.chunked_prefill_enabled = False
144
145 + scheduler_block_size = (
146 + vllm_config.cache_config.block_size
147 + * vllm_config.parallel_config.decode_context_parallel_size
148 + )
149 +
150 self.scheduler: SchedulerInterface = Scheduler(
151 vllm_config=vllm_config,
152 kv_cache_config=kv_cache_config,
153 structured_output_manager=self.structured_output_manager,
154 include_finished_set=vllm_config.parallel_config.data_parallel_size > 1,
155 log_stats=self.log_stats,
156 + block_size=scheduler_block_size,
157 )
158 self.use_spec_decode = vllm_config.speculative_config is not None
159 if self.scheduler.connector is not None: # type: ignore
@@ -177,14 +183,13 @@ class EngineCore:
183 self.vllm_config.cache_config.enable_prefix_caching
184 or self.scheduler.get_kv_connector() is not None
185 ):
180 - block_size = vllm_config.cache_config.block_size
186 caching_hash_fn = get_hash_fn_by_name(
187 vllm_config.cache_config.prefix_caching_hash_algo
188 )
189 init_none_hash(caching_hash_fn)
190
191 self.request_block_hasher = get_request_block_hasher(
187 - block_size, caching_hash_fn
192 + scheduler_block_size, caching_hash_fn
193 )
194
195 self.step_fn = (