Unverified Commit 19e8a165 authored by Hongkuan Zhou's avatar Hongkuan Zhou Committed by GitHub
Browse files

fix: strip None args when profiler generating configs (#6882)


Signed-off-by: default avatarhongkuanz <hongkuanz@nvidia.com>
parent bb79b7de
...@@ -141,6 +141,29 @@ def remove_valued_arguments(args: list[str], key: str) -> list[str]: ...@@ -141,6 +141,29 @@ def remove_valued_arguments(args: list[str], key: str) -> list[str]:
return args return args
def sanitize_cli_args(args: list[str]) -> list[str]:
"""Strip valued arguments whose value is the literal string ``"None"``.
AIC's rule engine uses Jinja2 ``compile_expression`` which converts
undefined variables to Python ``None``. When that ``None`` is
serialized into CLI args it becomes the four-character string
``"None"``, which is never a valid CLI value and causes backends
(e.g. sglang ``--kv-cache-dtype None``) to reject the argument.
"""
result = list(args)
i = 0
while i < len(result) - 1:
if result[i].startswith("--") and result[i + 1] == "None":
logger.warning(
"Stripping CLI arg %s with invalid value 'None'",
result[i],
)
del result[i : i + 2]
else:
i += 1
return result
def append_argument(args: list[str], to_append) -> list[str]: def append_argument(args: list[str], to_append) -> list[str]:
idx = find_arg_index(args) idx = find_arg_index(args)
if isinstance(to_append, list): if isinstance(to_append, list):
......
...@@ -27,6 +27,7 @@ from dynamo.profiler.utils.config import ( ...@@ -27,6 +27,7 @@ from dynamo.profiler.utils.config import (
ServiceResources, ServiceResources,
break_arguments, break_arguments,
get_service_name_by_type, get_service_name_by_type,
sanitize_cli_args,
set_argument_value, set_argument_value,
update_image, update_image,
) )
...@@ -562,7 +563,7 @@ class BaseConfigModifier: ...@@ -562,7 +563,7 @@ class BaseConfigModifier:
service.resources.limits["gpu"] = str(gpus) service.resources.limits["gpu"] = str(gpus)
if service.extraPodSpec and service.extraPodSpec.mainContainer: if service.extraPodSpec and service.extraPodSpec.mainContainer:
service.extraPodSpec.mainContainer.args = list(cli_args) service.extraPodSpec.mainContainer.args = sanitize_cli_args(list(cli_args))
@classmethod @classmethod
def _apply_disagg_workers( def _apply_disagg_workers(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment