Skip to content

vllm.utils.argparse_utils

Argument parsing utilities for vLLM.

Classes:

Functions:

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:

_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:

    port: 12323
    tensor-parallel-size: 4
$: 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:

    port: 12323
    tensor-parallel-size: 4
returns: ['--port', '12323', '--tensor-parallel-size', '4']

Nested config example:

    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", ...}']

SortedHelpFormatter

Bases: ArgumentDefaultsHelpFormatter, RawDescriptionHelpFormatter

SortedHelpFormatter that sorts arguments by their option strings.

_split_lines(text, width)

  1. Sentences split across lines have their single newlines removed.
  2. Paragraphs and lists are split into separate lines.
  3. 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.