Skip to content

Commit baec0d4

Browse files
Revert "[Feature] specify model in config.yaml (#14855)" (#15293)
Signed-off-by: DarkLight1337 <[email protected]>
1 parent c21b99b commit baec0d4

File tree

7 files changed

+30
-102
lines changed

7 files changed

+30
-102
lines changed

docs/source/serving/openai_compatible_server.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ For example:
184184
```yaml
185185
# config.yaml
186186

187-
model: meta-llama/Llama-3.1-8B-Instruct
188187
host: "127.0.0.1"
189188
port: 6379
190189
uvicorn-log-level: "info"
@@ -193,13 +192,12 @@ uvicorn-log-level: "info"
193192
To use the above config file:
194193
195194
```bash
196-
vllm serve --config config.yaml
195+
vllm serve SOME_MODEL --config config.yaml
197196
```
198197

199198
:::{note}
200199
In case an argument is supplied simultaneously using command line and the config file, the value from the command line will take precedence.
201200
The order of priorities is `command line > config file values > defaults`.
202-
e.g. `vllm serve SOME_MODEL --config config.yaml`, SOME_MODEL takes precedence over `model` in config file.
203201
:::
204202

205203
## API Reference

tests/config/test_config_with_model.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/conftest.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,15 +1121,3 @@ def pytest_collection_modifyitems(config, items):
11211121
for item in items:
11221122
if "optional" in item.keywords:
11231123
item.add_marker(skip_optional)
1124-
1125-
1126-
@pytest.fixture(scope="session")
1127-
def cli_config_file():
1128-
"""Return the path to the CLI config file."""
1129-
return os.path.join(_TEST_DIR, "config", "test_config.yaml")
1130-
1131-
1132-
@pytest.fixture(scope="session")
1133-
def cli_config_file_with_model():
1134-
"""Return the path to the CLI config file with model."""
1135-
return os.path.join(_TEST_DIR, "config", "test_config_with_model.yaml")
File renamed without changes.

tests/test_utils.py

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010
import torch
11-
from vllm_test_utils.monitor import monitor
11+
from vllm_test_utils import monitor
1212

1313
from vllm.config import ParallelConfig, VllmConfig, set_current_vllm_config
1414
from vllm.utils import (FlexibleArgumentParser, MemorySnapshot,
@@ -140,8 +140,7 @@ def parser():
140140
def parser_with_config():
141141
parser = FlexibleArgumentParser()
142142
parser.add_argument('serve')
143-
parser.add_argument('model_tag', nargs='?')
144-
parser.add_argument('--model', type=str)
143+
parser.add_argument('model_tag')
145144
parser.add_argument('--served-model-name', type=str)
146145
parser.add_argument('--config', type=str)
147146
parser.add_argument('--port', type=int)
@@ -197,29 +196,29 @@ def test_missing_required_argument(parser):
197196
parser.parse_args([])
198197

199198

200-
def test_cli_override_to_config(parser_with_config, cli_config_file):
199+
def test_cli_override_to_config(parser_with_config):
201200
args = parser_with_config.parse_args([
202-
'serve', 'mymodel', '--config', cli_config_file,
201+
'serve', 'mymodel', '--config', './data/test_config.yaml',
203202
'--tensor-parallel-size', '3'
204203
])
205204
assert args.tensor_parallel_size == 3
206205
args = parser_with_config.parse_args([
207206
'serve', 'mymodel', '--tensor-parallel-size', '3', '--config',
208-
cli_config_file
207+
'./data/test_config.yaml'
209208
])
210209
assert args.tensor_parallel_size == 3
211210
assert args.port == 12312
212211
args = parser_with_config.parse_args([
213212
'serve', 'mymodel', '--tensor-parallel-size', '3', '--config',
214-
cli_config_file, '--port', '666'
213+
'./data/test_config.yaml', '--port', '666'
215214
])
216215
assert args.tensor_parallel_size == 3
217216
assert args.port == 666
218217

219218

220-
def test_config_args(parser_with_config, cli_config_file):
219+
def test_config_args(parser_with_config):
221220
args = parser_with_config.parse_args(
222-
['serve', 'mymodel', '--config', cli_config_file])
221+
['serve', 'mymodel', '--config', './data/test_config.yaml'])
223222
assert args.tensor_parallel_size == 2
224223
assert args.trust_remote_code
225224
assert not args.multi_step_stream_outputs
@@ -241,9 +240,10 @@ def test_config_file(parser_with_config):
241240
])
242241

243242

244-
def test_no_model_tag(parser_with_config, cli_config_file):
243+
def test_no_model_tag(parser_with_config):
245244
with pytest.raises(ValueError):
246-
parser_with_config.parse_args(['serve', '--config', cli_config_file])
245+
parser_with_config.parse_args(
246+
['serve', '--config', './data/test_config.yaml'])
247247

248248

249249
# yapf: enable
@@ -476,34 +476,3 @@ def test_swap_dict_values(obj, key1, key2):
476476
assert obj[key1] == original_obj[key2]
477477
else:
478478
assert key1 not in obj
479-
480-
481-
def test_model_specification(parser_with_config,
482-
cli_config_file,
483-
cli_config_file_with_model):
484-
# Test model in CLI takes precedence over config
485-
args = parser_with_config.parse_args([
486-
'serve', 'cli-model', '--config', cli_config_file_with_model
487-
])
488-
assert args.model_tag == 'cli-model'
489-
assert args.served_model_name == 'mymodel'
490-
491-
# Test model from config file works
492-
args = parser_with_config.parse_args([
493-
'serve', '--config', cli_config_file_with_model
494-
])
495-
assert args.model == 'config-model'
496-
assert args.served_model_name == 'mymodel'
497-
498-
# Test no model specified anywhere raises error
499-
with pytest.raises(ValueError, match="No model specified!"):
500-
parser_with_config.parse_args(['serve', '--config', cli_config_file])
501-
502-
# Test other config values are preserved
503-
args = parser_with_config.parse_args([
504-
'serve', 'cli-model', '--config', cli_config_file_with_model
505-
])
506-
assert args.tensor_parallel_size == 2
507-
assert args.trust_remote_code is True
508-
assert args.multi_step_stream_outputs is False
509-
assert args.port == 12312

vllm/entrypoints/cli/serve.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ def __init__(self):
2121

2222
@staticmethod
2323
def cmd(args: argparse.Namespace) -> None:
24-
# If model is specified in CLI (as positional arg), it takes precedence
25-
if hasattr(args, 'model_tag') and args.model_tag is not None:
26-
args.model = args.model_tag
27-
# Otherwise use model from config (already in args.model)
28-
29-
# Check if we have a model specified somewhere
30-
if args.model == EngineArgs.model: # Still has default value
24+
# The default value of `--model`
25+
if args.model != EngineArgs.model:
3126
raise ValueError(
32-
"With `vllm serve`, you should provide the model either as a "
33-
"positional argument or in config file.")
27+
"With `vllm serve`, you should provide the model as a "
28+
"positional argument instead of via the `--model` option.")
29+
30+
# EngineArgs expects the model name to be passed as --model.
31+
args.model = args.model_tag
3432

3533
uvloop.run(run_server(args))
3634

@@ -43,12 +41,10 @@ def subparser_init(
4341
serve_parser = subparsers.add_parser(
4442
"serve",
4543
help="Start the vLLM OpenAI Compatible API server",
46-
usage="vllm serve [model_tag] [options]")
44+
usage="vllm serve <model_tag> [options]")
4745
serve_parser.add_argument("model_tag",
4846
type=str,
49-
nargs='?',
50-
help="The model tag to serve "
51-
"(optional if specified in config)")
47+
help="The model tag to serve")
5248
serve_parser.add_argument(
5349
"--config",
5450
type=str,

vllm/utils.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,29 +1265,19 @@ def _pull_args_from_config(self, args: list[str]) -> list[str]:
12651265
config_args = self._load_config_file(file_path)
12661266

12671267
# 0th index is for {serve,chat,complete}
1268-
# optionally followed by model_tag (only for serve)
1268+
# followed by model_tag (only for serve)
12691269
# followed by config args
12701270
# followed by rest of cli args.
12711271
# maintaining this order will enforce the precedence
12721272
# of cli > config > defaults
12731273
if args[0] == "serve":
1274-
model_in_cli = len(args) > 1 and not args[1].startswith('-')
1275-
model_in_config = any(arg == '--model' for arg in config_args)
1276-
1277-
if not model_in_cli and not model_in_config:
1274+
if index == 1:
12781275
raise ValueError(
1279-
"No model specified! Please specify model either in "
1280-
"command-line arguments or in config file.")
1281-
1282-
if model_in_cli:
1283-
# Model specified as positional arg, keep CLI version
1284-
args = [args[0]] + [
1285-
args[1]
1286-
] + config_args + args[2:index] + args[index + 2:]
1287-
else:
1288-
# No model in CLI, use config if available
1289-
args = [args[0]
1290-
] + config_args + args[1:index] + args[index + 2:]
1276+
"No model_tag specified! Please check your command-line"
1277+
" arguments.")
1278+
args = [args[0]] + [
1279+
args[1]
1280+
] + config_args + args[2:index] + args[index + 2:]
12911281
else:
12921282
args = [args[0]] + config_args + args[1:index] + args[index + 2:]
12931283

@@ -1305,7 +1295,9 @@ def _load_config_file(self, file_path: str) -> list[str]:
13051295
'--port': '12323',
13061296
'--tensor-parallel-size': '4'
13071297
]
1298+
13081299
"""
1300+
13091301
extension: str = file_path.split('.')[-1]
13101302
if extension not in ('yaml', 'yml'):
13111303
raise ValueError(
@@ -1330,15 +1322,7 @@ def _load_config_file(self, file_path: str) -> list[str]:
13301322
if isinstance(action, StoreBoolean)
13311323
]
13321324

1333-
# Skip model from config if it's provided as positional argument
1334-
skip_model = (hasattr(self, '_parsed_args') and self._parsed_args
1335-
and len(self._parsed_args) > 1
1336-
and self._parsed_args[0] == 'serve'
1337-
and not self._parsed_args[1].startswith('-'))
1338-
13391325
for key, value in config.items():
1340-
if skip_model and key == 'model':
1341-
continue
13421326
if isinstance(value, bool) and key not in store_boolean_arguments:
13431327
if value:
13441328
processed_args.append('--' + key)

0 commit comments

Comments
 (0)