[PD] Preserve decode KV across retraction in HiCache (#34801)

Co-authored-by: cctry <cctry@fb.com>
This commit is contained in:
cctry
2026-08-17 08:49:11 -07:00
committed by GitHub
co-authored by cctry
parent af743371cc
commit 2e7c85da68
15 changed files with 779 additions and 34 deletions
+57 -3
View File
@@ -2653,10 +2653,10 @@ class ServerArgs:
False
)
hicache_ratio: A[
float,
"The ratio of the size of host KV cache memory pool to the size of device pool.",
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.",
NS("memory"),
] = 2.0
] = None
hicache_size: A[
int,
"The size of host KV cache memory pool in gigabytes, which will override the hicache_ratio if set.",
@@ -3115,6 +3115,19 @@ class ServerArgs:
"Enable async KV cache offloading on decode server (PD mode).",
NS("disagg"),
] = False
disaggregation_decode_retraction_backup: A[
Optional[str],
Arg(
help=(
"Storage backend for KV preserved across PD decode retraction. "
"'cpu_tensor' uses per-request CPU tensors. 'host_pool' uses "
"a reserved HiCache pool and does not fall back on exhaustion. "
"If omitted, the backend is inferred from the decode KV pool."
),
choices=["cpu_tensor", "host_pool"],
),
NS("disagg"),
] = None
num_reserved_decode_tokens: A[
int,
"Number of decode tokens that will have memory reserved when adding new request to the running batch.",
@@ -3589,6 +3602,7 @@ class ServerArgs:
self._handle_moe_runner_backend_alias()
self._handle_return_hidden_states_mode()
self._handle_media_url_security()
self._handle_hicache_ratio_default()
if self.model_path.lower() in ["none", "dummy"]:
return
@@ -7335,6 +7349,10 @@ class ServerArgs:
"workloads and backends may be supported in a future change."
)
def _handle_hicache_ratio_default(self):
if self.hicache_ratio is None and self.disaggregation_mode != "decode":
self.hicache_ratio = 2.0
def _handle_hicache(self):
"""Normalize hicache-related knobs into a valid runtime configuration.
@@ -7346,6 +7364,10 @@ class ServerArgs:
if not (
self.enable_hierarchical_cache
or self.disaggregation_decode_enable_offload_kvcache
or (
self.disaggregation_mode == "decode"
and self.disaggregation_decode_retraction_backup in (None, "host_pool")
)
):
return
@@ -8084,6 +8106,32 @@ class ServerArgs:
envs.SGLANG_OPT_FP8_WO_A_GEMM.set(False)
def _handle_cache_compatibility(self):
if (
self.disaggregation_decode_retraction_backup == "host_pool"
and self.disaggregation_mode != "decode"
):
raise ValueError(
"--disaggregation-decode-retraction-backup=host_pool is only "
"supported on a PD decode server."
)
if (
self.disaggregation_decode_retraction_backup == "host_pool"
and self.dcp_size > 1
):
raise ValueError(
"--disaggregation-decode-retraction-backup=host_pool does not "
"support --dcp-size > 1."
)
if (
self.disaggregation_decode_retraction_backup == "host_pool"
and self.enable_priority_scheduling
and not self.disable_priority_preemption
):
raise ValueError(
"--disaggregation-decode-retraction-backup=host_pool requires "
"--disable-priority-preemption when priority scheduling is enabled."
)
if self.enable_hierarchical_cache and self.disable_radix_cache:
raise ValueError(
"The arguments enable-hierarchical-cache and disable-radix-cache are mutually exclusive "
@@ -8099,6 +8147,12 @@ class ServerArgs:
raise ValueError(
"The argument disaggregation-decode-enable-offload-kvcache is only supported when hicache-storage-backend is provided."
)
if self.disaggregation_decode_retraction_backup == "host_pool":
raise ValueError(
"The arguments disaggregation-decode-enable-offload-kvcache and "
"disaggregation-decode-retraction-backup=host_pool are mutually exclusive: "
"both build a decode host pool."
)
# Validate the effective ratio: model branches may declare a reset
# (e.g. Step3p forces 1.0 under hierarchical cache) that supersedes