Drop env-gated CP HiCache page-index validator
The ported 44ba832 added _validate_cp_hicache_page_indices gated on envs.SGLANG_DEBUG_HICACHE_VALIDATE, but that env was introduced by 97a9f850c (not on this branch). Calling _write_cp / load_cp crashed: AttributeError: 'Envs' object has no attribute 'SGLANG_DEBUG_HICACHE_VALIDATE' The validator is purely defensive (page-alignment holds by construction in HostKVCache.alloc and CpSharedKVLayout.logical_locs_to_physical), so remove the function entirely along with its 4 call sites in _write_cp and load_cp. The wrapping try/except blocks existed solely to free allocations when validation raised; with no raising call inside, they become dead and are removed too. Stale imports (envs, validate_page_aligned_token_indices) dropped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,6 @@ from sglang.srt.distributed import (
|
||||
get_tensor_model_parallel_rank,
|
||||
get_tensor_model_parallel_world_size,
|
||||
)
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.layers.dp_attention import (
|
||||
get_attention_dp_rank,
|
||||
get_attention_tp_rank,
|
||||
@@ -41,7 +40,6 @@ from sglang.srt.layers.dp_attention import (
|
||||
)
|
||||
from sglang.srt.mem_cache.cp_shared_kv_layout import CpSharedKVLayout
|
||||
from sglang.srt.mem_cache.memory_pool import MLATokenToKVPool, NSATokenToKVPool
|
||||
from sglang.srt.mem_cache.page_index_utils import validate_page_aligned_token_indices
|
||||
from sglang.srt.utils import get_device_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -832,18 +830,6 @@ class HiCacheController:
|
||||
event.record()
|
||||
self.ack_load_queue.append(HiCacheAck(event, event, [node_id]))
|
||||
|
||||
def _validate_cp_hicache_page_indices(
|
||||
self,
|
||||
host_indices: torch.Tensor,
|
||||
device_indices: torch.Tensor,
|
||||
) -> None:
|
||||
if not envs.SGLANG_DEBUG_HICACHE_VALIDATE.get():
|
||||
return
|
||||
validate_page_aligned_token_indices(
|
||||
device_indices, self.page_size, "physical_device_indices"
|
||||
)
|
||||
validate_page_aligned_token_indices(host_indices, self.page_size, "host_indices")
|
||||
|
||||
def _write_cp(
|
||||
self,
|
||||
device_indices: torch.Tensor,
|
||||
@@ -922,17 +908,6 @@ class HiCacheController:
|
||||
return HiCacheWriteFailure(
|
||||
required_host_slots=len(physical_device_indices)
|
||||
)
|
||||
try:
|
||||
self._validate_cp_hicache_page_indices(host_indices, physical_device_indices)
|
||||
if draft_host_indices is not None:
|
||||
self._validate_cp_hicache_page_indices(
|
||||
draft_host_indices, physical_device_indices
|
||||
)
|
||||
except Exception:
|
||||
self.mem_pool_host.free(host_indices)
|
||||
if draft_host_indices is not None:
|
||||
self.draft_mem_pool_host.free(draft_host_indices)
|
||||
raise
|
||||
|
||||
self.write_queue.append(
|
||||
CacheOperation(host_indices, physical_device_indices, node_id, priority)
|
||||
@@ -1091,21 +1066,9 @@ class HiCacheController:
|
||||
|
||||
host_indices = torch.cat(host_chunks)
|
||||
physical_device_indices = torch.cat(physical_chunks)
|
||||
try:
|
||||
self._validate_cp_hicache_page_indices(host_indices, physical_device_indices)
|
||||
except Exception:
|
||||
self.mem_pool_device_allocator.free(device_indices)
|
||||
raise
|
||||
draft_host_indices = None
|
||||
if self.has_draft_hicache:
|
||||
draft_host_indices = torch.cat(draft_host_chunks)
|
||||
try:
|
||||
self._validate_cp_hicache_page_indices(
|
||||
draft_host_indices, physical_device_indices
|
||||
)
|
||||
except Exception:
|
||||
self.mem_pool_device_allocator.free(device_indices)
|
||||
raise
|
||||
|
||||
self.load_queue.append(
|
||||
CacheOperation(
|
||||
|
||||
Reference in New Issue
Block a user