I noticed an update in vllm==0.9 about integrating the deprecated
option in FlexibleArgumentParser
. See PR#17426 for related changes.
This change caused an error in my code like this
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default="0.0.0.0")
parser.add_argument("--port", type=int, default=5000)
parser.add_argument("--ssl-keyfile", type=str, default=None)
parser.add_argument("--ssl-certfile", type=str, default=None)
parser.add_argument(
"--root-path",
type=str,
default=None,
help="FastAPI root_path when app is behind a path based routing proxy")
parser = AsyncEngineArgs.add_cli_args(parser)
args = parser.parse_args()
engine_args = AsyncEngineArgs.from_cli_args(args)
engine = AsyncLLMEngine.from_engine_args(engine_args)
and it reported some error look like this:
File "/home/aiscuser/.conda/envs/ruler/lib/python3.10/argparse.py", line 1430, in add_argument action = action_class(**kwargs) TypeError: _StoreAction.__init__() got an unexpected keyword argument 'deprecated'
The cause of this error is a FlexibleArgumentParser
should be passed into AsyncEngineArgs.add_cli_args(parser)
, not a ArgumentParser. I have been using this function wrong for a long time. (Of course modern day editors and typecheckers should be able to spot this, but I didn’t pay much attention to this since the original code is copied from NVIDIA/RULER, a popular repo with more than 1.2k star, and it’s been working normal for pass vllm versions until v0.9).
What changed in vllm==0.9
is that in order to support the deprecated
option in python version lower than 3.13
, the FlexibleArgumentParser
overrided the parse_known_args
function. Since the ArgumentParser
does not have a overrided function that deals with the deprecated
option, it caused an error like above.
But this error message does not obvious tell me what went wrong is actually the parser.
This got me thinking if we should let the AsyncEngineArgs.add_cli_args
raise a warning if the input parser is not a FlexibleArgumentParser
rather a normal parser, and convert the input parser to FlexibleArgumentParser
.
I believe this is very helpful for the user experience and debugging if the other people has similar mistakes. If this is worth looking into, I’m very glad to contribute.