Skip to content

Commit 1fd2e88

Browse files
committed
Fix extraConfig handling and YAML formatting issues in PR llm-d#323
- Replace "#no____config" defaults with "{}" for extraConfig sections - Add conditional_extra_config function to skip empty extraConfig entirely - Add lstrip() calls throughout template to fix YAML indentation - Ensure proper YAML syntax and formatting for all config sections Addresses reviewer Michael's feedback on template structure and formatting.
1 parent 77dd6e3 commit 1fd2e88

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

setup/steps/09_deploy_via_modelservice.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,28 @@ def conditional_volume_config(volume_config: str, field_name: str, indent: int =
4242
return ""
4343

4444

45+
def conditional_extra_config(extra_config: str, indent: int = 2, label: str = "extraConfig") -> str:
46+
"""
47+
Generate extraConfig section only if the config is not empty.
48+
Skip the field entirely if the config is empty or contains only "{}" or "[]".
49+
"""
50+
config_result = functions_add_config(extra_config, indent, label)
51+
if config_result.strip():
52+
return config_result.lstrip() # Remove extra leading whitespace
53+
return ""
54+
55+
4556
def add_config_prep():
4657
"""
4758
Set proper defaults for empty configurations.
4859
Equivalent to the bash add_config_prep function.
4960
"""
5061
# Set defaults for decode extra configs
5162
if not os.environ.get("LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_POD_CONFIG"):
52-
os.environ["LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_POD_CONFIG"] = "#no____config"
63+
os.environ["LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_POD_CONFIG"] = "{}"
5364

5465
if not os.environ.get("LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_CONTAINER_CONFIG"):
55-
os.environ["LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_CONTAINER_CONFIG"] = "#no____config"
66+
os.environ["LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_CONTAINER_CONFIG"] = "{}"
5667

5768
if not os.environ.get("LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_VOLUME_MOUNTS"):
5869
os.environ["LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_VOLUME_MOUNTS"] = "[]"
@@ -62,10 +73,10 @@ def add_config_prep():
6273

6374
# Set defaults for prefill extra configs
6475
if not os.environ.get("LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_POD_CONFIG"):
65-
os.environ["LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_POD_CONFIG"] = "#no____config"
76+
os.environ["LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_POD_CONFIG"] = "{}"
6677

6778
if not os.environ.get("LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_CONTAINER_CONFIG"):
68-
os.environ["LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_CONTAINER_CONFIG"] = "#no____config"
79+
os.environ["LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_CONTAINER_CONFIG"] = "{}"
6980

7081
if not os.environ.get("LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_VOLUME_MOUNTS"):
7182
os.environ["LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_VOLUME_MOUNTS"] = "[]"
@@ -279,24 +290,24 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
279290
data: {decode_data_parallelism}
280291
tensor: {decode_tensor_parallelism}
281292
annotations:
282-
{functions_add_annotations("LLMDBENCH_VLLM_COMMON_ANNOTATIONS")}
293+
{functions_add_annotations("LLMDBENCH_VLLM_COMMON_ANNOTATIONS").lstrip()}
283294
podAnnotations:
284-
{functions_add_annotations("LLMDBENCH_VLLM_MODELSERVICE_DECODE_PODANNOTATIONS")}
285-
{functions_add_config(decode_extra_pod_config, 2, "extraConfig")}
295+
{functions_add_annotations("LLMDBENCH_VLLM_MODELSERVICE_DECODE_PODANNOTATIONS").lstrip()}
296+
{conditional_extra_config(decode_extra_pod_config, 2, "extraConfig")}
286297
containers:
287298
- name: "vllm"
288299
mountModelVolume: {str(mount_model_volume).lower()}
289300
image: "{main_image}"
290301
modelCommand: {decode_model_command}
291302
{add_command(decode_model_command)}
292303
args:
293-
{add_command_line_options(decode_extra_args)}
304+
{add_command_line_options(decode_extra_args).lstrip()}
294305
env:
295306
- name: VLLM_NIXL_SIDE_CHANNEL_HOST
296307
valueFrom:
297308
fieldRef:
298309
fieldPath: status.podIP
299-
{functions_add_additional_env_to_yaml(envvars_to_yaml)}
310+
{functions_add_additional_env_to_yaml(envvars_to_yaml).lstrip()}
300311
resources:
301312
limits:
302313
memory: {decode_cpu_mem}
@@ -330,7 +341,7 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
330341
port: 8200
331342
failureThreshold: 3
332343
periodSeconds: 5
333-
{functions_add_config(decode_extra_container_config, 6)}
344+
{functions_add_config(decode_extra_container_config, 6).lstrip()}
334345
{conditional_volume_config(decode_extra_volume_mounts, "volumeMounts", 4)}
335346
{conditional_volume_config(decode_extra_volumes, "volumes", 2)}
336347
@@ -345,26 +356,26 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
345356
data: {prefill_data_parallelism}
346357
tensor: {prefill_tensor_parallelism}
347358
annotations:
348-
{functions_add_annotations("LLMDBENCH_VLLM_COMMON_ANNOTATIONS")}
359+
{functions_add_annotations("LLMDBENCH_VLLM_COMMON_ANNOTATIONS").lstrip()}
349360
podAnnotations:
350-
{functions_add_annotations("LLMDBENCH_VLLM_MODELSERVICE_PREFILL_PODANNOTATIONS")}
351-
{functions_add_config(prefill_extra_pod_config, 2, "extraConfig")}
361+
{functions_add_annotations("LLMDBENCH_VLLM_MODELSERVICE_PREFILL_PODANNOTATIONS").lstrip()}
362+
{conditional_extra_config(prefill_extra_pod_config, 2, "extraConfig")}
352363
containers:
353364
- name: "vllm"
354365
mountModelVolume: {str(mount_model_volume).lower()}
355366
image: "{main_image}"
356367
modelCommand: {prefill_model_command}
357368
{add_command(prefill_model_command)}
358369
args:
359-
{add_command_line_options(prefill_extra_args)}
370+
{add_command_line_options(prefill_extra_args).lstrip()}
360371
env:
361372
- name: VLLM_IS_PREFILL
362373
value: "1"
363374
- name: VLLM_NIXL_SIDE_CHANNEL_HOST
364375
valueFrom:
365376
fieldRef:
366377
fieldPath: status.podIP
367-
{functions_add_additional_env_to_yaml(envvars_to_yaml)}
378+
{functions_add_additional_env_to_yaml(envvars_to_yaml).lstrip()}
368379
resources:
369380
limits:
370381
memory: {prefill_cpu_mem}
@@ -398,7 +409,7 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
398409
port: {common_inference_port}
399410
failureThreshold: 3
400411
periodSeconds: 5
401-
{functions_add_config(prefill_extra_container_config, 6)}
412+
{functions_add_config(prefill_extra_container_config, 6).lstrip()}
402413
{conditional_volume_config(prefill_extra_volume_mounts, "volumeMounts", 4)}
403414
{conditional_volume_config(prefill_extra_volumes, "volumes", 2)}
404415
"""

0 commit comments

Comments
 (0)