fix: fail fast for CP HiCache storage args

This commit is contained in:
2026-05-08 00:55:35 +08:00
parent 54f8cab7e7
commit da4994ec26
2 changed files with 25 additions and 43 deletions

View File

@@ -751,6 +751,9 @@ class ServerArgs:
# Validate SSL arguments early (before dummy-model short-circuit).
self._handle_ssl_validation()
# Validate CP shared KV constraints early (before dummy-model short-circuit).
self._handle_cp_shared_kv_validation()
if self.model_path.lower() in ["none", "dummy"]:
# Skip for dummy models
return
@@ -904,6 +907,16 @@ class ServerArgs:
"to be specified."
)
def _handle_cp_shared_kv_validation(self):
assert not (
self.enable_nsa_prefill_cp_shared_kv
and self.hicache_storage_backend is not None
), (
"enable_nsa_prefill_cp_shared_kv does not support "
"hicache_storage_backend in the host-only CP HiCache stage. "
"Disable hicache_storage_backend or disable CP shared KV."
)
def _handle_deprecated_args(self):
# Handle deprecated tool call parsers
deprecated_tool_call_parsers = {"qwen25": "qwen", "glm45": "glm"}
@@ -1457,15 +1470,6 @@ class ServerArgs:
def _handle_model_specific_adjustments(self):
from sglang.srt.configs.model_config import is_deepseek_nsa
assert not (
self.enable_nsa_prefill_cp_shared_kv
and self.hicache_storage_backend is not None
), (
"enable_nsa_prefill_cp_shared_kv does not support "
"hicache_storage_backend in the host-only CP HiCache stage. "
"Disable hicache_storage_backend or disable CP shared KV."
)
if parse_connector_type(self.model_path) == ConnectorType.INSTANCE:
return

View File

@@ -372,50 +372,28 @@ class TestHiCacheArgs(CustomTestCase):
self.assertEqual(args.decode_attention_backend, expected_decode_backend)
def test_cp_shared_kv_rejects_hicache_storage_backend(self):
args = self._make_args(
enable_hierarchical_cache=True,
enable_nsa_prefill_context_parallel=True,
enable_nsa_prefill_cp_shared_kv=True,
nsa_prefill_cp_mode="in-seq-split",
disaggregation_mode=None,
page_size=64,
enable_hisparse=False,
hicache_storage_backend="mooncake",
tp_size=8,
)
pre_call_state = (
args.enable_dp_attention,
args.moe_dense_tp_size,
args.moe_a2a_backend,
args.ep_size,
args.attn_cp_size,
args.page_size,
)
with (
self.assertRaisesRegex(
AssertionError,
"enable_nsa_prefill_cp_shared_kv.*hicache_storage_backend",
),
patch.object(
args,
ServerArgs,
"get_model_config",
side_effect=AssertionError("get_model_config should not be called"),
),
):
args._handle_model_specific_adjustments()
self.assertEqual(
pre_call_state,
(
args.enable_dp_attention,
args.moe_dense_tp_size,
args.moe_a2a_backend,
args.ep_size,
args.attn_cp_size,
args.page_size,
),
)
ServerArgs(
model_path="dummy",
enable_hierarchical_cache=True,
enable_nsa_prefill_context_parallel=True,
enable_nsa_prefill_cp_shared_kv=True,
nsa_prefill_cp_mode="in-seq-split",
disaggregation_mode="null",
page_size=64,
enable_hisparse=False,
hicache_storage_backend="mooncake",
)
def test_hicache_io_backend_and_mem_layout_compatibility(self):
cases = [