Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
ca196918
Unverified
Commit
ca196918
authored
Jan 28, 2026
by
Michael Goin
Committed by
GitHub
Jan 28, 2026
Browse files
[UX] Enable nested configs in config yaml files (#33193)
parent
ab597c86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
7 deletions
+70
-7
tests/utils_/test_argparse_utils.py
tests/utils_/test_argparse_utils.py
+44
-0
vllm/utils/argparse_utils.py
vllm/utils/argparse_utils.py
+26
-7
No files found.
tests/utils_/test_argparse_utils.py
View file @
ca196918
...
@@ -379,6 +379,50 @@ def test_load_config_file(tmp_path):
...
@@ -379,6 +379,50 @@ def test_load_config_file(tmp_path):
os
.
remove
(
str
(
config_file_path
))
os
.
remove
(
str
(
config_file_path
))
def
test_load_config_file_nested
(
tmp_path
):
"""Test that nested dicts in YAML config are converted to JSON strings."""
config_data
=
{
"port"
:
8000
,
"compilation-config"
:
{
"pass_config"
:
{
"fuse_allreduce_rms"
:
True
},
},
}
config_file_path
=
tmp_path
/
"nested_config.yaml"
with
open
(
config_file_path
,
"w"
)
as
f
:
yaml
.
dump
(
config_data
,
f
)
parser
=
FlexibleArgumentParser
()
processed_args
=
parser
.
load_config_file
(
str
(
config_file_path
))
assert
processed_args
[
processed_args
.
index
(
"--port"
)
+
1
]
==
"8000"
cc_value
=
json
.
loads
(
processed_args
[
processed_args
.
index
(
"--compilation-config"
)
+
1
]
)
assert
cc_value
==
{
"pass_config"
:
{
"fuse_allreduce_rms"
:
True
}}
def
test_nested_config_end_to_end
(
tmp_path
):
"""Test end-to-end parsing of nested configs in YAML files."""
config_data
=
{
"compilation-config"
:
{
"mode"
:
3
,
"pass_config"
:
{
"fuse_allreduce_rms"
:
True
},
},
}
config_file_path
=
tmp_path
/
"nested_config.yaml"
with
open
(
config_file_path
,
"w"
)
as
f
:
yaml
.
dump
(
config_data
,
f
)
parser
=
FlexibleArgumentParser
()
parser
.
add_argument
(
"-cc"
,
"--compilation-config"
,
type
=
json
.
loads
)
args
=
parser
.
parse_args
([
"--config"
,
str
(
config_file_path
)])
assert
args
.
compilation_config
==
{
"mode"
:
3
,
"pass_config"
:
{
"fuse_allreduce_rms"
:
True
},
}
def
test_compilation_mode_string_values
(
parser
):
def
test_compilation_mode_string_values
(
parser
):
"""Test that -cc.mode accepts both integer and string mode values."""
"""Test that -cc.mode accepts both integer and string mode values."""
args
=
parser
.
parse_args
([
"-cc.mode"
,
"0"
])
args
=
parser
.
parse_args
([
"-cc.mode"
,
"0"
])
...
...
vllm/utils/argparse_utils.py
View file @
ca196918
...
@@ -444,16 +444,30 @@ class FlexibleArgumentParser(ArgumentParser):
...
@@ -444,16 +444,30 @@ class FlexibleArgumentParser(ArgumentParser):
def
load_config_file
(
self
,
file_path
:
str
)
->
list
[
str
]:
def
load_config_file
(
self
,
file_path
:
str
)
->
list
[
str
]:
"""Loads a yaml file and returns the key value pairs as a
"""Loads a yaml file and returns the key value pairs as a
flattened list with argparse like pattern
flattened list with argparse like pattern.
Supports both flat configs and nested YAML structures.
Flat config example:
```yaml
```yaml
port: 12323
port: 12323
tensor-parallel-size: 4
tensor-parallel-size: 4
```
```
returns:
returns:
processed_args: list[str] = [
['--port', '12323', '--tensor-parallel-size', '4']
'--port': '12323',
'--tensor-parallel-size': '4'
Nested config example:
]
```yaml
compilation-config:
pass_config:
fuse_allreduce_rms: true
speculative-config:
model: "nvidia/gpt-oss-120b-Eagle3-v2"
num_speculative_tokens: 3
```
returns:
['--compilation-config', '{"pass_config": {"fuse_allreduce_rms": true}}',
'--speculative-config', '{"model": "nvidia/gpt-oss-120b-Eagle3-v2", ...}']
"""
"""
extension
:
str
=
file_path
.
split
(
"."
)[
-
1
]
extension
:
str
=
file_path
.
split
(
"."
)[
-
1
]
if
extension
not
in
(
"yaml"
,
"yml"
):
if
extension
not
in
(
"yaml"
,
"yml"
):
...
@@ -461,10 +475,10 @@ class FlexibleArgumentParser(ArgumentParser):
...
@@ -461,10 +475,10 @@ class FlexibleArgumentParser(ArgumentParser):
f
"Config file must be of a yaml/yml type.
{
extension
}
supplied"
f
"Config file must be of a yaml/yml type.
{
extension
}
supplied"
)
)
#
only expecting a flat dictionary of atomic type
s
#
Supports both flat configs and nested dict
s
processed_args
:
list
[
str
]
=
[]
processed_args
:
list
[
str
]
=
[]
config
:
dict
[
str
,
int
|
str
]
=
{}
config
:
dict
[
str
,
Any
]
=
{}
try
:
try
:
with
open
(
file_path
)
as
config_file
:
with
open
(
file_path
)
as
config_file
:
config
=
yaml
.
safe_load
(
config_file
)
config
=
yaml
.
safe_load
(
config_file
)
...
@@ -484,6 +498,11 @@ class FlexibleArgumentParser(ArgumentParser):
...
@@ -484,6 +498,11 @@ class FlexibleArgumentParser(ArgumentParser):
processed_args
.
append
(
"--"
+
key
)
processed_args
.
append
(
"--"
+
key
)
for
item
in
value
:
for
item
in
value
:
processed_args
.
append
(
str
(
item
))
processed_args
.
append
(
str
(
item
))
elif
isinstance
(
value
,
dict
):
# Convert nested dicts to JSON strings so they can be parsed
# by the existing JSON argument parsing machinery.
processed_args
.
append
(
"--"
+
key
)
processed_args
.
append
(
json
.
dumps
(
value
))
else
:
else
:
processed_args
.
append
(
"--"
+
key
)
processed_args
.
append
(
"--"
+
key
)
processed_args
.
append
(
str
(
value
))
processed_args
.
append
(
str
(
value
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment