[Bugfix][HiSparse] Never allocate GPU pages without host backing (#59036)
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> Co-authored-by: Matthew Bonanni <mbonanni@redhat.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Matthew Bonanni
Claude Opus 5.5
parent
e006d761a5
commit
90e13fc757
@@ -1822,6 +1822,14 @@ class VllmConfig:
|
||||
raise ValueError(
|
||||
"HiSparse does not support decode context parallelism."
|
||||
)
|
||||
if not self.scheduler_config.scheduler_reserve_full_isl:
|
||||
# Without it, async loads admitted against free host blocks can
|
||||
# each wait on host pages the others hold, and waiting requests
|
||||
# are never preempted to free them.
|
||||
raise ValueError(
|
||||
"HiSparse requires --scheduler-reserve-full-isl; remove "
|
||||
"--no-scheduler-reserve-full-isl."
|
||||
)
|
||||
if self.model_config is not None and not hasattr(
|
||||
self.model_config.hf_config, "index_topk"
|
||||
):
|
||||
|
||||
@@ -2223,8 +2223,8 @@ class SinkFullAttentionManager(FullAttentionManager):
|
||||
class HiSparseSourceManager(FullAttentionManager):
|
||||
"""Host-tier manager with a private pool; publishes hashes once durable.
|
||||
|
||||
Host capacity is best effort: a page that cannot get a host block keeps a
|
||||
null host entry, so its GPU copy is never written back and stays pinned.
|
||||
Every page gets a host block: allocation fails when the host pool cannot
|
||||
back it, so each GPU-resident page can be written back and later reclaimed.
|
||||
"""
|
||||
|
||||
coordinator: "HiSparseCoordinator | None" = None
|
||||
@@ -2273,44 +2273,21 @@ class HiSparseSourceManager(FullAttentionManager):
|
||||
num_tokens_main_model: int,
|
||||
apply_admission_cap: bool = False,
|
||||
) -> int:
|
||||
if (
|
||||
total_computed_tokens > num_local_computed_tokens
|
||||
or self._has_partial_local_hit(
|
||||
new_computed_blocks, num_local_computed_tokens
|
||||
)
|
||||
):
|
||||
# External loads need real destinations; future GPU-computed pages
|
||||
# remain best effort. Use the same admission sentinel as Mamba.
|
||||
required = super().get_num_blocks_to_allocate(
|
||||
request_id,
|
||||
total_computed_tokens,
|
||||
new_computed_blocks,
|
||||
total_computed_tokens,
|
||||
num_local_computed_tokens,
|
||||
total_computed_tokens,
|
||||
)
|
||||
if required > self.block_pool.get_num_free_blocks():
|
||||
assert self.coordinator is not None
|
||||
assert self.coordinator.gpu_pool is not None
|
||||
return self.coordinator.gpu_pool.num_gpu_blocks + 1
|
||||
return 0
|
||||
|
||||
def allocate_new_blocks(
|
||||
self, request_id: str, num_tokens: int, num_tokens_main_model: int
|
||||
) -> list[KVCacheBlock]:
|
||||
req_blocks = self.req_to_blocks[request_id]
|
||||
num_required = cdiv(num_tokens, self.block_size)
|
||||
num_free = self.block_pool.get_num_free_blocks()
|
||||
if request_id in self._partial_hit_reqs:
|
||||
num_free -= 1
|
||||
fit_blocks = min(num_required, len(req_blocks) + max(0, num_free))
|
||||
new_blocks = super().allocate_new_blocks(
|
||||
required = super().get_num_blocks_to_allocate(
|
||||
request_id,
|
||||
fit_blocks * self.block_size,
|
||||
min(num_tokens_main_model, fit_blocks * self.block_size),
|
||||
num_tokens,
|
||||
new_computed_blocks,
|
||||
total_computed_tokens,
|
||||
num_local_computed_tokens,
|
||||
num_tokens_main_model,
|
||||
)
|
||||
req_blocks.extend([self._null_block] * (num_required - len(req_blocks)))
|
||||
return new_blocks
|
||||
# Host blocks come from a private pool, so they never count against
|
||||
# the GPU pool. Use the same admission sentinel as Mamba instead.
|
||||
if required > self.block_pool.get_num_free_blocks():
|
||||
assert self.coordinator is not None
|
||||
assert self.coordinator.gpu_pool is not None
|
||||
return self.coordinator.gpu_pool.num_gpu_blocks + 1
|
||||
return 0
|
||||
|
||||
def allocate_external_computed_blocks(
|
||||
self,
|
||||
|
||||
@@ -660,10 +660,13 @@ class HiSparseCoordinator:
|
||||
return command
|
||||
|
||||
def has_pending_reclamation(self) -> bool:
|
||||
"""Whether an in-flight spill will free GPU blocks on completion."""
|
||||
"""Whether an in-flight spill will free GPU or host blocks on completion."""
|
||||
return any(
|
||||
pending.page[0] in self.request_states
|
||||
and self._can_read_from_host(pending.page[0])
|
||||
pending.host_block.ref_cnt == 1
|
||||
or (
|
||||
pending.page[0] in self.request_states
|
||||
and self._can_read_from_host(pending.page[0])
|
||||
)
|
||||
for pending in self.pending_spills.values()
|
||||
)
|
||||
|
||||
|
||||
@@ -235,6 +235,14 @@ def create_hisparse_layout(
|
||||
host_num_blocks = host_budget // host_block_stride
|
||||
if host_num_blocks <= 0:
|
||||
raise ValueError("HiSparse has no allocatable host blocks.")
|
||||
# Every computed page needs a host block, so one request at max_model_len
|
||||
# must fit alongside the pool's null block and a copy-on-write tail.
|
||||
min_host_blocks = cdiv(vllm_config.model_config.max_model_len, gpu_block_size) + 2
|
||||
if host_num_blocks < min_host_blocks:
|
||||
raise ValueError(
|
||||
f"HiSparse host pool has {host_num_blocks} blocks but max_model_len "
|
||||
f"needs {min_host_blocks}; increase host_pool_gib."
|
||||
)
|
||||
|
||||
return HiSparseLayout(
|
||||
source_group=source_group,
|
||||
|
||||
Reference in New Issue
Block a user