[HiCache] Buffer-only mode for HiCache host memory layer (#34798)
This commit is contained in:
@@ -2668,14 +2668,22 @@ class ServerArgs:
|
||||
enable_hierarchical_cache: A[bool, "Enable hierarchical cache", NS("memory")] = (
|
||||
False
|
||||
)
|
||||
hicache_host_memory_mode: A[
|
||||
str,
|
||||
Arg(
|
||||
help="Whether host memory is a persistent HiCache tier (cache) or a transient staging buffer between GPU and the storage backend (buffer_only). buffer_only requires --hicache-storage-backend.",
|
||||
choices=["cache", "buffer_only"],
|
||||
),
|
||||
NS("memory"),
|
||||
] = "cache"
|
||||
hicache_ratio: A[
|
||||
Optional[float],
|
||||
"The ratio of the size of host KV cache memory pool to the size of device pool. Defaults to 2.0, or 1.0 for host-pool decode retraction.",
|
||||
"The ratio of the size of host KV cache memory pool to the size of device pool. Defaults to 2.0 in cache mode, 1.2 in buffer_only mode, or 1.0 for host-pool decode retraction.",
|
||||
NS("memory"),
|
||||
] = None
|
||||
hicache_size: A[
|
||||
int,
|
||||
"The size of host KV cache memory pool in gigabytes, which will override the hicache_ratio if set.",
|
||||
"The size of host KV cache memory pool in gigabytes. Overrides --hicache-ratio in either host memory mode.",
|
||||
NS("memory"),
|
||||
] = 0
|
||||
hicache_write_policy: A[
|
||||
@@ -2714,6 +2722,7 @@ class ServerArgs:
|
||||
help="The storage backend for hierarchical KV cache. Built-in backends: file, mooncake, hf3fs, nixl, aibrix. For dynamic backend, use --hicache-storage-backend-extra-config to specify: backend_name (custom name), module_path (Python module path), class_name (backend class name).",
|
||||
choices=[
|
||||
"file",
|
||||
"sim",
|
||||
"mooncake",
|
||||
"hf3fs",
|
||||
"nixl",
|
||||
@@ -7393,8 +7402,20 @@ class ServerArgs:
|
||||
)
|
||||
|
||||
def _handle_hicache_ratio_default(self):
|
||||
"""Default the host/device ratio per host memory mode.
|
||||
|
||||
Runs before the dummy-model boundary: direct HostKVCache consumers
|
||||
(unit fixtures, dummy-model launches) must never see a None ratio.
|
||||
buffer_only stages in flight rather than retaining, so it needs only
|
||||
enough to cover the write backlog plus parked prefetches.
|
||||
|
||||
A decode server keeps the ratio unset here: kv_cache_builder resolves
|
||||
it against the retraction-backup backend (1.0 for host_pool, else 2.0).
|
||||
"""
|
||||
if self.hicache_ratio is None and self.disaggregation_mode != "decode":
|
||||
self.hicache_ratio = 2.0
|
||||
self.hicache_ratio = (
|
||||
1.2 if self.hicache_host_memory_mode == "buffer_only" else 2.0
|
||||
)
|
||||
|
||||
def _handle_hicache(self):
|
||||
"""Normalize hicache-related knobs into a valid runtime configuration.
|
||||
@@ -7414,6 +7435,8 @@ class ServerArgs:
|
||||
):
|
||||
return
|
||||
|
||||
self._validate_hicache_host_memory_mode()
|
||||
|
||||
# Step 1: Initial layout-io compatibility normalization.
|
||||
self._resolve_layout_io_compatibility()
|
||||
|
||||
@@ -7423,6 +7446,51 @@ class ServerArgs:
|
||||
# Step 3: DCP compatibility for the L2 (device<->host) path.
|
||||
self._resolve_hicache_dcp_compatibility()
|
||||
|
||||
def _validate_hicache_host_memory_mode(self):
|
||||
if self.hicache_host_memory_mode not in ("cache", "buffer_only"):
|
||||
raise ValueError(
|
||||
"hicache_host_memory_mode must be 'cache' or 'buffer_only', "
|
||||
f"got {self.hicache_host_memory_mode!r}"
|
||||
)
|
||||
|
||||
# Both modes are defaulted upstream (a decode server resolves the
|
||||
# ratio later, in kv_cache_builder), so this fires only if that
|
||||
# defaulting regresses -- never build an unsized host pool.
|
||||
if (
|
||||
self.hicache_size <= 0
|
||||
and self.hicache_ratio is None
|
||||
and self.disaggregation_mode != "decode"
|
||||
):
|
||||
raise ValueError(
|
||||
f"--hicache-host-memory-mode {self.hicache_host_memory_mode} "
|
||||
"requires a host pool size: pass --hicache-size or "
|
||||
"--hicache-ratio."
|
||||
)
|
||||
|
||||
if self.hicache_host_memory_mode == "cache":
|
||||
return
|
||||
|
||||
if self.hicache_storage_backend is None:
|
||||
raise ValueError(
|
||||
"--hicache-host-memory-mode buffer_only requires a storage backend "
|
||||
"(--hicache-storage-backend): host memory is only a staging buffer "
|
||||
"and all cached data lives in storage."
|
||||
)
|
||||
if self.hicache_write_policy == "write_back":
|
||||
raise ValueError(
|
||||
"--hicache-host-memory-mode buffer_only does not support "
|
||||
"--hicache-write-policy write_back; use write_through or "
|
||||
"write_through_selective."
|
||||
)
|
||||
if self.disaggregation_mode == "decode":
|
||||
raise ValueError(
|
||||
"--hicache-host-memory-mode buffer_only is not supported on "
|
||||
"decode instances: the decode-side prefetch and offload paths "
|
||||
"bypass the buffer-mode pipeline, fetching without its prefix "
|
||||
"context and never consuming its staged holds. Prefill "
|
||||
"instances share the standard scheduler path and are supported."
|
||||
)
|
||||
|
||||
def _resolve_hicache_dcp_compatibility(self):
|
||||
if self.dcp_size <= 1 or not self.enable_hierarchical_cache:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user