A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 05:30 UTC
[Bugfix] fix when config.yaml config value is list parse error (#23528)
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
rongfu.leng committed
Aug 27, 2025 at 13:54 UTC
8dbf6ed7be3f8602257ce1879825d4b5e3554d67
2 files changed
+48
-2
tests/utils_/test_utils.py
+41
@@ -5,13 +5,17 @@
5
import asyncio
6
import hashlib
7
import json
8
+import os
9
import pickle
10
import socket
11
+import tempfile
12
from collections.abc import AsyncIterator
13
+from pathlib import Path
14
from unittest.mock import patch
15
16
import pytest
17
import torch
18
+import yaml
19
import zmq
20
from transformers import AutoTokenizer
21
from vllm_test_utils.monitor import monitor
@@ -991,3 +995,40 @@ def test_current_stream_multithread():
995
child_thread.join(timeout=5)
996
if child_thread.is_alive():
997
pytest.fail("Child thread failed to exit properly")
998
+
999
+
1000
+def test_load_config_file(tmp_path):
1001
+ # Define the configuration data
1002
+ config_data = {
1003
+ "enable-logging": True,
1004
+ "list-arg": ["item1", "item2"],
1005
+ "port": 12323,
1006
+ "tensor-parallel-size": 4
1007
+ }
1008
+
1009
+ # Write the configuration data to a temporary YAML file
1010
+ config_file_path = tmp_path / "config.yaml"
1011
+ with open(config_file_path, "w") as config_file:
1012
+ yaml.dump(config_data, config_file)
1013
+
1014
+ # Initialize the parser
1015
+ parser = FlexibleArgumentParser()
1016
+
1017
+ # Call the function with the temporary file path
1018
+ processed_args = parser.load_config_file(str(config_file_path))
1019
+
1020
+ # Expected output
1021
+ expected_args = [
1022
+ "--enable-logging",
1023
+ "--list-arg",
1024
+ "item1",
1025
+ "item2",
1026
+ "--port",
1027
+ "12323",
1028
+ "--tensor-parallel-size",
1029
+ "4",
1030
+ ]
1031
+
1032
+ # Assert that the processed arguments match the expected output
1033
+ assert processed_args == expected_args
1034
+ os.remove(str(config_file_path))
vllm/utils/__init__.py
+7
-2
@@ -1974,7 +1974,7 @@ class FlexibleArgumentParser(ArgumentParser):
1974
1975
file_path = args[index + 1]
1976
1977
- config_args = self._load_config_file(file_path)
1977
+ config_args = self.load_config_file(file_path)
1978
1979
# 0th index is for {serve,chat,complete}
1980
# optionally followed by model_tag (only for serve)
@@ -2005,7 +2005,7 @@ class FlexibleArgumentParser(ArgumentParser):
2005
2006
return args
2007
2008
- def _load_config_file(self, file_path: str) -> list[str]:
2008
+ def load_config_file(self, file_path: str) -> list[str]:
2009
"""Loads a yaml file and returns the key value pairs as a
2010
flattened list with argparse like pattern
2011
```yaml
@@ -2046,6 +2046,11 @@ class FlexibleArgumentParser(ArgumentParser):
2046
if isinstance(value, bool) and key not in store_boolean_arguments:
2047
if value:
2048
processed_args.append('--' + key)
2049
+ elif isinstance(value, list):
2050
+ if value:
2051
+ processed_args.append('--' + key)
2052
+ for item in value:
2053
+ processed_args.append(str(item))
2054
else:
2055
processed_args.append('--' + key)
2056
processed_args.append(str(value))