vllm.utils.argparse_utils
¶
Argument parsing utilities for vLLM.
Classes:
-
EnableDisableAction–BooleanOptionalActionthat pairs--enable-xwith--disable-x. -
FlexibleArgumentParser–ArgumentParser that allows both underscore and dash in names.
-
SortedHelpFormatter–SortedHelpFormatter that sorts arguments by their option strings.
Functions:
-
human_readable_int–Parse human-readable integers like '1k', '2M', etc.
-
human_readable_int_or_auto–Parse human-readable integers like '1k', '2M', etc.
-
summary_line–Return the first paragraph of a config docstring as a single line.
EnableDisableAction
¶
Bases: BooleanOptionalAction
BooleanOptionalAction that pairs --enable-x with --disable-x.
--no-enable-x and --no-disable-x are still accepted for backwards
compatibility, but are hidden from help.
FlexibleArgumentParser
¶
Bases: ArgumentParser
ArgumentParser that allows both underscore and dash in names.
Methods:
-
load_config_file–Loads a yaml file and returns the key value pairs as a
_pull_args_from_config(args)
¶
Method to pull arguments specified in the config file into the command-line args variable.
The arguments in config file will be inserted between the argument list.
Example:
$: vllm {serve,chat,complete} "facebook/opt-12B" \
--config config.yaml -tp 2
$: args = [
"serve,chat,complete",
"facebook/opt-12B",
'--config', 'config.yaml',
'-tp', '2'
]
$: args = [
"serve,chat,complete",
"facebook/opt-12B",
'--port', '12323',
'--tensor-parallel-size', '4',
'-tp', '2'
]
Please note how the config args are inserted after the sub command. this way the order of priorities is maintained when these are args parsed by super().
load_config_file(file_path)
¶
Loads a yaml file and returns the key value pairs as a flattened list with argparse like pattern.
Supports both flat configs and nested YAML structures.
Flat config example:
returns: ['--port', '12323', '--tensor-parallel-size', '4']Nested config example:
returns: ['--compilation-config', '{"pass_config": {"fuse_allreduce_rms": true}}', '--speculative-config', '{"model": "nvidia/gpt-oss-120b-Eagle3-v2", ...}']
SortedHelpFormatter
¶
Bases: ArgumentDefaultsHelpFormatter, RawDescriptionHelpFormatter
SortedHelpFormatter that sorts arguments by their option strings.
_split_lines(text, width)
¶
- Sentences split across lines have their single newlines removed.
- Paragraphs and lists are split into separate lines.
- Each line is wrapped to the specified width (width of terminal).
human_readable_int(value)
¶
Parse human-readable integers like '1k', '2M', etc. Including decimal values with decimal multipliers.
Examples: - '1k' -> 1,000 - '1K' -> 1,024 - '25.6k' -> 25,600
human_readable_int_or_auto(value)
¶
Parse human-readable integers like '1k', '2M', etc. Including decimal values with decimal multipliers. Also accepts -1 or 'auto' as a special value for auto-detection.
Examples: - '1k' -> 1,000 - '1K' -> 1,024 - '25.6k' -> 25,600 - '-1' or 'auto' -> -1 (special value for auto-detection)
summary_line(description)
¶
Return the first paragraph of a config docstring as a single line.