From 3fc08b939accf93b9455eb11b839281e349d1931 Mon Sep 17 00:00:00 2001 From: Mohammad Miadh Angkad <176301910+mmangkad@users.noreply.github.com> Date: Sat, 17 Oct 2026 13:22:34 +0800 Subject: [PATCH] [Feat] server-args: Add --enable-hicache alias for --enable-hierarchical-cache (#44849) Co-authored-by: Mohammad Angkad --- docs/docs/advanced_features/server_arguments.mdx | 2 +- python/sglang/srt/arg_groups/fields/memory.py | 5 ++++- .../sglang/srt/utils/server_args_config_parser.py | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/docs/advanced_features/server_arguments.mdx b/docs/docs/advanced_features/server_arguments.mdx index e2082dc951..a09038aba7 100644 --- a/docs/docs/advanced_features/server_arguments.mdx +++ b/docs/docs/advanced_features/server_arguments.mdx @@ -2097,7 +2097,7 @@ Combining `--enable-response-store` with `--disaggregation-mode=prefill` or `dec - `--enable-hierarchical-cache` + `--enable-hierarchical-cache`
`--enable-hicache` Enable hierarchical cache `False` bool flag (set to enable) diff --git a/python/sglang/srt/arg_groups/fields/memory.py b/python/sglang/srt/arg_groups/fields/memory.py index c79a33346a..dd13408888 100644 --- a/python/sglang/srt/arg_groups/fields/memory.py +++ b/python/sglang/srt/arg_groups/fields/memory.py @@ -95,7 +95,10 @@ class Memory(msgspec.Struct): # ------------------------------------------------------------------------- # Hierarchical cache # ------------------------------------------------------------------------- - enable_hierarchical_cache: A[bool, "Enable hierarchical cache"] = False + enable_hierarchical_cache: A[ + bool, + Arg(help="Enable hierarchical cache", aliases=["--enable-hicache"]), + ] = False hicache_host_memory_mode: A[ str, Arg( diff --git a/python/sglang/srt/utils/server_args_config_parser.py b/python/sglang/srt/utils/server_args_config_parser.py index 17724ff7b7..f374019b59 100644 --- a/python/sglang/srt/utils/server_args_config_parser.py +++ b/python/sglang/srt/utils/server_args_config_parser.py @@ -14,6 +14,15 @@ import yaml logger = logging.getLogger(__name__) +def _config_keys(action: argparse.Action) -> set[str]: + # YAML keys may use any long spelling of a flag, not just the one matching dest. + return {action.dest} | { + option[2:].replace("-", "_") + for option in action.option_strings + if option.startswith("--") + } + + class ConfigArgumentMerger: """Handles merging of configuration file arguments with command-line arguments.""" @@ -27,12 +36,13 @@ class ConfigArgumentMerger: if parser is not None: self.parser = parser self.store_true_actions = [ - action.dest + key for action in parser._actions if isinstance(action, argparse._StoreTrueAction) + for key in _config_keys(action) ] self.unsupported_actions = { - a.dest: a + key: a for a in parser._actions if a.option_strings and not isinstance(a, argparse._StoreTrueAction) @@ -40,6 +50,7 @@ class ConfigArgumentMerger: and "--config" not in a.option_strings and "--help" not in a.option_strings and "-h" not in a.option_strings + for key in _config_keys(a) } elif boolean_actions is not None: # Legacy interface for compatibility