Skip to content

[Doc] Fix %% rendering in CLI reference for --safetensors-load-strategy#46335

Open
lizzzcai wants to merge 2 commits into
vllm-project:mainfrom
lizzzcai:fix/safetensors-load-strategy-doc-percent
Open

[Doc] Fix %% rendering in CLI reference for --safetensors-load-strategy#46335
lizzzcai wants to merge 2 commits into
vllm-project:mainfrom
lizzzcai:fix/safetensors-load-strategy-doc-percent

Conversation

@lizzzcai

Copy link
Copy Markdown
Contributor

Summary

While exploring the --safetensors-load-strategy feature, I noticed the CLI reference docs showed 90%%%% instead of 90%.

Root cause

arg_utils.py escapes %%% in docstring-derived help text for argparse. MarkdownFormatter.add_arguments in generate_argparse.py reads action.help directly, bypassing _expand_help which would normally unescape %%%. Additionally, the load.py docstring had 90%% instead of 90%, causing a double-escape to 90%%%% in the rendered output.

Changes

  • vllm/config/load.py: 90%%90% in docstring
  • docs/mkdocs/hooks/generate_argparse.py: unescape %%% in MarkdownFormatter.add_arguments before writing markdown

As a side effect, this also fixes --bin-by in the benchmark CLI reference which was showing request_throughput%%1 instead of the correct request_throughput%1.

Verification

Served docs locally with API_AUTONAV_EXCLUDE=vllm mkdocs serve and confirmed:

None (default): Uses memory-mapped (lazy) loading. When an NFS filesystem is
detected and the total checkpoint size fits within 90% of available RAM,
prefetching is enabled automatically.

Notes

  • No existing open PR addresses this (searched for safetensors, generate_argparse, %%)
  • AI assistance (Claude) was used to investigate and implement this fix

@mergify

mergify Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--46335.org.readthedocs.build/en/46335/

@mergify mergify Bot added the documentation Improvements or additions to documentation label Jun 22, 2026
lizzzcai added 2 commits June 22, 2026 12:16
The docstring is read by arg_utils.py which already escapes % to %%
for argparse, so the source must contain a literal %. The stray %%
was rendering as 90%%% in the generated docs.

Co-authored-by: Claude
Signed-off-by: Lize Cai <lize.cai@sap.com>
MarkdownFormatter.add_arguments reads action.help directly, bypassing
_expand_help which would normally unescape %% -> %. arg_utils.py escapes
all % to %% for argparse, so without this fix any percent sign in a
docstring-derived help string renders as %% in the docs.

Co-authored-by: Claude
Signed-off-by: Lize Cai <lize.cai@sap.com>
@lizzzcai lizzzcai force-pushed the fix/safetensors-load-strategy-doc-percent branch from dd77924 to 0b855b0 Compare June 22, 2026 04:16

@yewentao256 yewentao256 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work!


if action.help:
help_dd = ":" + textwrap.indent(action.help, " ")[1:]
help_text = action.help.replace("%%", "%")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is needed? Shall we fix the source instead of editing text directly here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yewentao256 Thanks for the review.

The root cause is that arg_utils.py:319 unconditionally escapes %%% for all docstring-derived help text:

help = help.replace("%", "%%")

This is needed for terminal --help because argparse's _expand_help does help % params, which collapses %%% as a side effect:

"90%% of RAM" % {"default": None}  # → "90% of RAM" 

But MarkdownFormatter.add_arguments bypasses _expand_help and reads action.help directly, so %% is never unescaped. This affects multiple args today — --safetensors-load-strategy, --gpu-memory-utilization, and --cp-kv-cache-interleave-size.

Two options:

Option 1 — Fix in generate_argparse.py (current approach): unescape %%% in MarkdownFormatter. Systemic — covers all current and future docstrings with %.

Option 2 — Fix in arg_utils.py: skip escaping when running under mkdocs, since _expand_help is never called in that path:

IS_MKDOCS = (
    sys.argv[0].endswith("mkdocs")
    or sys.argv[0].endswith("mkdocs/__main__.py")
)

if not IS_MKDOCS:
    help = help.replace("%", "%%")

Happy to switch to Option 2 if preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants