@@ -42,17 +42,28 @@ def conditional_volume_config(volume_config: str, field_name: str, indent: int =
42
42
return ""
43
43
44
44
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
+
45
56
def add_config_prep ():
46
57
"""
47
58
Set proper defaults for empty configurations.
48
59
Equivalent to the bash add_config_prep function.
49
60
"""
50
61
# Set defaults for decode extra configs
51
62
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" ] = "{} "
53
64
54
65
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" ] = "{} "
56
67
57
68
if not os .environ .get ("LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_VOLUME_MOUNTS" ):
58
69
os .environ ["LLMDBENCH_VLLM_MODELSERVICE_DECODE_EXTRA_VOLUME_MOUNTS" ] = "[]"
@@ -62,10 +73,10 @@ def add_config_prep():
62
73
63
74
# Set defaults for prefill extra configs
64
75
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" ] = "{} "
66
77
67
78
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" ] = "{} "
69
80
70
81
if not os .environ .get ("LLMDBENCH_VLLM_MODELSERVICE_PREFILL_EXTRA_VOLUME_MOUNTS" ):
71
82
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
279
290
data: { decode_data_parallelism }
280
291
tensor: { decode_tensor_parallelism }
281
292
annotations:
282
- { functions_add_annotations ("LLMDBENCH_VLLM_COMMON_ANNOTATIONS" )}
293
+ { functions_add_annotations ("LLMDBENCH_VLLM_COMMON_ANNOTATIONS" ). lstrip () }
283
294
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" )}
286
297
containers:
287
298
- name: "vllm"
288
299
mountModelVolume: { str (mount_model_volume ).lower ()}
289
300
image: "{ main_image } "
290
301
modelCommand: { decode_model_command }
291
302
{ add_command (decode_model_command )}
292
303
args:
293
- { add_command_line_options (decode_extra_args )}
304
+ { add_command_line_options (decode_extra_args ). lstrip () }
294
305
env:
295
306
- name: VLLM_NIXL_SIDE_CHANNEL_HOST
296
307
valueFrom:
297
308
fieldRef:
298
309
fieldPath: status.podIP
299
- { functions_add_additional_env_to_yaml (envvars_to_yaml )}
310
+ { functions_add_additional_env_to_yaml (envvars_to_yaml ). lstrip () }
300
311
resources:
301
312
limits:
302
313
memory: { decode_cpu_mem }
@@ -330,7 +341,7 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
330
341
port: 8200
331
342
failureThreshold: 3
332
343
periodSeconds: 5
333
- { functions_add_config (decode_extra_container_config , 6 )}
344
+ { functions_add_config (decode_extra_container_config , 6 ). lstrip () }
334
345
{ conditional_volume_config (decode_extra_volume_mounts , "volumeMounts" , 4 )}
335
346
{ conditional_volume_config (decode_extra_volumes , "volumes" , 2 )}
336
347
@@ -345,26 +356,26 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
345
356
data: { prefill_data_parallelism }
346
357
tensor: { prefill_tensor_parallelism }
347
358
annotations:
348
- { functions_add_annotations ("LLMDBENCH_VLLM_COMMON_ANNOTATIONS" )}
359
+ { functions_add_annotations ("LLMDBENCH_VLLM_COMMON_ANNOTATIONS" ). lstrip () }
349
360
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" )}
352
363
containers:
353
364
- name: "vllm"
354
365
mountModelVolume: { str (mount_model_volume ).lower ()}
355
366
image: "{ main_image } "
356
367
modelCommand: { prefill_model_command }
357
368
{ add_command (prefill_model_command )}
358
369
args:
359
- { add_command_line_options (prefill_extra_args )}
370
+ { add_command_line_options (prefill_extra_args ). lstrip () }
360
371
env:
361
372
- name: VLLM_IS_PREFILL
362
373
value: "1"
363
374
- name: VLLM_NIXL_SIDE_CHANNEL_HOST
364
375
valueFrom:
365
376
fieldRef:
366
377
fieldPath: status.podIP
367
- { functions_add_additional_env_to_yaml (envvars_to_yaml )}
378
+ { functions_add_additional_env_to_yaml (envvars_to_yaml ). lstrip () }
368
379
resources:
369
380
limits:
370
381
memory: { prefill_cpu_mem }
@@ -398,7 +409,7 @@ def generate_ms_values_yaml(ev: dict, mount_model_volume: bool, rules_file: Path
398
409
port: { common_inference_port }
399
410
failureThreshold: 3
400
411
periodSeconds: 5
401
- { functions_add_config (prefill_extra_container_config , 6 )}
412
+ { functions_add_config (prefill_extra_container_config , 6 ). lstrip () }
402
413
{ conditional_volume_config (prefill_extra_volume_mounts , "volumeMounts" , 4 )}
403
414
{ conditional_volume_config (prefill_extra_volumes , "volumes" , 2 )}
404
415
"""
0 commit comments