-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
[Doc] Add engine args back in to the docs #20674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
89346f9
Stop using `StoreBoolean` in test
hmellor e02fc05
Handle some type checking only imports
hmellor 60cccae
More type checking only imports
hmellor 1176b92
Delay some imports
hmellor cf69bf0
More type checking only imports
hmellor 885f30b
Enforce TOC depth 3 on engine args page
hmellor 510f36a
Ignore generated argparse files that will be created
hmellor b0c24a0
Auto generate Engine Args docs
hmellor 9fce6f4
Fix JSON tip formatting
hmellor a348584
Merge branch 'main' into mkdocs-argparse
hmellor 72e5152
Remove unused variable
hmellor 152b036
Add missing requirement
hmellor f8b8f97
Fix docs build
hmellor db4ea67
Revert changes to reasoning parsers because `DeltaMessage` must be co…
hmellor 71bae46
Revert unrelated change to test_utils.py
hmellor 55259b8
Fix docs build again
hmellor f4d3066
`json_tip` to back to backticks (keep `\n` fixes)
hmellor cbf1062
Remove some `\n` from json tips
hmellor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,7 @@ venv.bak/ | |
|
||
# mkdocs documentation | ||
/site | ||
docs/argparse | ||
docs/examples | ||
|
||
# mypy | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
--- | ||
toc_depth: 3 | ||
--- | ||
|
||
# Engine Arguments | ||
|
||
Engine arguments control the behavior of the vLLM engine. | ||
|
||
- For [offline inference](../serving/offline_inference.md), they are part of the arguments to [LLM][vllm.LLM] class. | ||
- For [online serving](../serving/openai_compatible_server.md), they are part of the arguments to `vllm serve`. | ||
|
||
You can look at [EngineArgs][vllm.engine.arg_utils.EngineArgs] and [AsyncEngineArgs][vllm.engine.arg_utils.AsyncEngineArgs] to see the available engine arguments. | ||
The engine argument classes, [EngineArgs][vllm.engine.arg_utils.EngineArgs] and [AsyncEngineArgs][vllm.engine.arg_utils.AsyncEngineArgs], are a combination of the configuration classes defined in [vllm.config][]. Therefore, if you are interested in developer documentation, we recommend looking at these configuration classes as they are the source of truth for types, defaults and docstrings. | ||
|
||
## `EngineArgs` | ||
|
||
However, these classes are a combination of the configuration classes defined in [vllm.config][]. Therefore, we would recommend you read about them there where they are best documented. | ||
--8<-- "docs/argparse/engine_args.md" | ||
|
||
For offline inference you will have access to these configuration classes and for online serving you can cross-reference the configs with `vllm serve --help`, which has its arguments grouped by config. | ||
## `AsyncEngineArgs` | ||
|
||
!!! note | ||
Additional arguments are available to the [AsyncLLMEngine][vllm.engine.async_llm_engine.AsyncLLMEngine] which is used for online serving. These can be found by running `vllm serve --help` | ||
--8<-- "docs/argparse/async_engine_args.md" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
import logging | ||
import sys | ||
from argparse import SUPPRESS, HelpFormatter | ||
from pathlib import Path | ||
from typing import Literal | ||
from unittest.mock import MagicMock, patch | ||
|
||
ROOT_DIR = Path(__file__).parent.parent.parent.parent | ||
ARGPARSE_DOC_DIR = ROOT_DIR / "docs/argparse" | ||
|
||
sys.path.insert(0, str(ROOT_DIR)) | ||
sys.modules["aiohttp"] = MagicMock() | ||
sys.modules["blake3"] = MagicMock() | ||
sys.modules["vllm._C"] = MagicMock() | ||
|
||
from vllm.engine.arg_utils import AsyncEngineArgs, EngineArgs # noqa: E402 | ||
from vllm.utils import FlexibleArgumentParser # noqa: E402 | ||
|
||
logger = logging.getLogger("mkdocs") | ||
|
||
|
||
class MarkdownFormatter(HelpFormatter): | ||
"""Custom formatter that generates markdown for argument groups.""" | ||
|
||
def __init__(self, prog): | ||
super().__init__(prog, | ||
max_help_position=float('inf'), | ||
width=float('inf')) | ||
self._markdown_output = [] | ||
|
||
def start_section(self, heading): | ||
if heading not in {"positional arguments", "options"}: | ||
self._markdown_output.append(f"\n### {heading}\n\n") | ||
|
||
def end_section(self): | ||
pass | ||
|
||
def add_text(self, text): | ||
if text: | ||
self._markdown_output.append(f"{text.strip()}\n\n") | ||
|
||
def add_usage(self, usage, actions, groups, prefix=None): | ||
pass | ||
|
||
def add_arguments(self, actions): | ||
for action in actions: | ||
|
||
option_strings = f'`{"`, `".join(action.option_strings)}`' | ||
self._markdown_output.append(f"#### {option_strings}\n\n") | ||
|
||
if choices := action.choices: | ||
choices = f'`{"`, `".join(str(c) for c in choices)}`' | ||
self._markdown_output.append( | ||
f"Possible choices: {choices}\n\n") | ||
|
||
self._markdown_output.append(f"{action.help}\n\n") | ||
|
||
if (default := action.default) != SUPPRESS: | ||
self._markdown_output.append(f"Default: `{default}`\n\n") | ||
|
||
def format_help(self): | ||
"""Return the formatted help as markdown.""" | ||
return "".join(self._markdown_output) | ||
|
||
|
||
def create_parser(cls, **kwargs) -> FlexibleArgumentParser: | ||
"""Create a parser for the given class with markdown formatting. | ||
|
||
Args: | ||
cls: The class to create a parser for | ||
**kwargs: Additional keyword arguments to pass to `cls.add_cli_args`. | ||
|
||
Returns: | ||
FlexibleArgumentParser: A parser with markdown formatting for the class. | ||
""" | ||
parser = FlexibleArgumentParser() | ||
parser.formatter_class = MarkdownFormatter | ||
with patch("vllm.config.DeviceConfig.__post_init__"): | ||
return cls.add_cli_args(parser, **kwargs) | ||
|
||
|
||
def on_startup(command: Literal["build", "gh-deploy", "serve"], dirty: bool): | ||
logger.info("Generating argparse documentation") | ||
logger.debug("Root directory: %s", ROOT_DIR.resolve()) | ||
logger.debug("Output directory: %s", ARGPARSE_DOC_DIR.resolve()) | ||
|
||
# Create the ARGPARSE_DOC_DIR if it doesn't exist | ||
if not ARGPARSE_DOC_DIR.exists(): | ||
ARGPARSE_DOC_DIR.mkdir(parents=True) | ||
|
||
# Create parsers to document | ||
parsers = { | ||
"engine_args": create_parser(EngineArgs), | ||
"async_engine_args": create_parser(AsyncEngineArgs, | ||
async_args_only=True), | ||
} | ||
|
||
# Generate documentation for each parser | ||
for stem, parser in parsers.items(): | ||
doc_path = ARGPARSE_DOC_DIR / f"{stem}.md" | ||
with open(doc_path, "w") as f: | ||
f.write(parser.format_help()) | ||
logger.info("Argparse generated: %s", doc_path.relative_to(ROOT_DIR)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- Enables the use of toc_depth in document frontmatter https://github.com/squidfunk/mkdocs-material/issues/4827#issuecomment-1869812019 --> | ||
<li class="md-nav__item"> | ||
<a href="{{ toc_item.url }}" class="md-nav__link"> | ||
<span class="md-ellipsis"> | ||
{{ toc_item.title }} | ||
</span> | ||
</a> | ||
|
||
<!-- Table of contents list --> | ||
{% if toc_item.children %} | ||
<nav class="md-nav" aria-label="{{ toc_item.title | striptags }}"> | ||
<ul class="md-nav__list"> | ||
{% for toc_item in toc_item.children %} | ||
{% if not page.meta.toc_depth or toc_item.level <= page.meta.toc_depth %} | ||
{% include "partials/toc-item.html" %} | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
</nav> | ||
{% endif %} | ||
</li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.