Skip to content

feat(help): list all accepted llama.cpp options in --help#1003

Merged
aittalam merged 4 commits into
mozilla-ai:mainfrom
RichardoC:document-args
Jul 2, 2026
Merged

feat(help): list all accepted llama.cpp options in --help#1003
aittalam merged 4 commits into
mozilla-ai:mainfrom
RichardoC:document-args

Conversation

@RichardoC

@RichardoC RichardoC commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Why this PR?

Currently, it's not possible to use just the cli to run a model from a gguf file. Yuo have to consult the upstream docs to work out the correct arguments to pass.

What is this PR?

lamafile --help (and --chat/--cli --help) printed a small, hand-written option list that was missing many flags llamafile actually accepts -- e.g. --top-k, --top-p, --temperature, --ctx-size, --repeat-penalty, -t, --port. Only --server --help was complete, because it fell through to llama.cpp's own usage printer.

Rather than maintain a second copy of the option list (which is what drifted), delegate the full catalogue to the same code path --server --help already uses: common_params_parse() with the llama_example the target mode feeds it at runtime (LLAMA_EXAMPLE_SERVER for server/auto, LLAMA_EXAMPLE_CLI for chat/cli).

Changes:

  • main.cpp: add print_llama_cpp_usage() which calls common_params_parse() to print the categorized llama.cpp option list (common/sampling/spec/ example-specific) and exit(0) on --help. The print_*_help() functions now take a show_full_list_hint bool: the --help path prints the llamafile intro (modes + llamafile-specific flags) and appends the full llama.cpp list; the missing--m error path prints the intro plus a pointer to --help. --server --help is unchanged (still falls through to server_main). The duplicate SERVER/AUTO missing--m arms are collapsed (they printed identical text).
  • tests/integration/tests/test_help.py: new model-free regression tests that invoke every --help variant and assert exit 0, the llamafile identity, the llamafile-specific flags, and that the previously-missing llama.cpp options (--top-k, --top-p, --temperature, --ctx-size, --repeat-penalty, -ngl) now appear. Also covers the missing--m error path.
  • tests/integration/pyproject.toml: register the "help" test marker.

Because the full option list comes from llama.cpp's own parser, --help stays in sync with what llamafile accepts as upstream evolves -- no hand-maintained copy to drift again.

Verified: make check passes (extract_data_uris 19/19, fa_helpers 3/3, gpu_backend 23/23); new pytest tests/integration/tests/test_help.py --executable o//llamafile/llamafile passes 17/17; manual check of all four --help variants confirms --top-k/--top-p/--temperature/--ctx-size/ --repeat-penalty/-ngl now appear alongside the llamafile-specific flags.

Generated with pi 0.80.2 and GLM 5.2

PR Type

  • 🆕 New Feature
  • 📚 Documentation

Relevant issues

Checklist

  • I understand the code I am submitting.
  • I have run this code locally and verified the change.
  • New and existing tests pass locally, or I have explained why tests were not run.
  • Documentation was updated where necessary.
  • If I changed code in llama.cpp/, whisper.cpp/, or stable-diffusion.cpp/, I also updated the matching *.patches/ files.
  • I have read and followed the contribution guidelines.
  • AI Usage:
    • No AI was used.
    • AI was used in an assistive capacity.
    • This PR includes substantial AI-generated content.

AI Usage Information

  • AI Model used: GLM 5.2
  • AI Developer Tool used: pi 0.80.2
  • Any other info you'd like to share: Built in a scratch macos VM

When answering reviewer questions, please respond yourself rather than pasting reviewer comments into an AI system and posting the reply back unchanged.

  • I am an AI Agent filling out this form (check box if true)

llamafile --help (and --chat/--cli --help) printed a small, hand-written
option list that was missing many flags llamafile actually accepts --
e.g. --top-k, --top-p, --temperature, --ctx-size, --repeat-penalty, -t,
--port. Only --server --help was complete, because it fell through to
llama.cpp's own usage printer.

Rather than maintain a second copy of the option list (which is what
drifted), delegate the full catalogue to the same code path --server
--help already uses: common_params_parse() with the llama_example the
target mode feeds it at runtime (LLAMA_EXAMPLE_SERVER for server/auto,
LLAMA_EXAMPLE_CLI for chat/cli).

Changes:
- main.cpp: add print_llama_cpp_usage() which calls common_params_parse()
  to print the categorized llama.cpp option list (common/sampling/spec/
  example-specific) and exit(0) on --help. The print_*_help() functions
  now take a show_full_list_hint bool: the --help path prints the
  llamafile intro (modes + llamafile-specific flags) and appends the
  full llama.cpp list; the missing--m error path prints the intro plus a
  pointer to --help. --server --help is unchanged (still falls through
  to server_main). The duplicate SERVER/AUTO missing--m arms are
  collapsed (they printed identical text).
- tests/integration/tests/test_help.py: new model-free regression tests
  that invoke every --help variant and assert exit 0, the llamafile
  identity, the llamafile-specific flags, and that the previously-missing
  llama.cpp options (--top-k, --top-p, --temperature, --ctx-size,
  --repeat-penalty, -ngl) now appear. Also covers the missing--m error
  path.
- tests/integration/pyproject.toml: register the "help" test marker.

Because the full option list comes from llama.cpp's own parser, --help
stays in sync with what llamafile accepts as upstream evolves -- no
hand-maintained copy to drift again.

Verified: `make check` passes (extract_data_uris 19/19, fa_helpers 3/3,
gpu_backend 23/23); new `pytest tests/integration/tests/test_help.py
--executable o//llamafile/llamafile` passes 17/17; manual check of all
four --help variants confirms --top-k/--top-p/--temperature/--ctx-size/
--repeat-penalty/-ngl now appear alongside the llamafile-specific flags.

Generated with pi 0.80.2 and GLM 5.2
@RichardoC

RichardoC commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Turns out my actual issue was that the options aren't exposed by --chat, only --server and yes this PR fixes that

@aittalam aittalam self-assigned this Jun 28, 2026
Comment thread llamafile/main.cpp
Comment thread llamafile/main.cpp

@aittalam aittalam 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.

Hi @RichardoC , and thank you for making the help system more clear!

I ran the tests and they seem to work both standalone (without provinding any model) and when the models are provided (see below). I think that's great, and I am not too worried about repeating the help tests as one can turn it off (-m "not help") for pre-built models and just run it once with the plain executable, or run it for each model as it is quite fast and does not add a big overhead.

Image Image

Just a minor UX inconsistency: when one runs llamafile --server the help provides examples for all three "run llamafile --server --help", "run llamafile --cli --help", etc rather than just the --server example. I already have a fix for that (adding a server-specific help and activating it in the case section), would you mind testing it and letting me know what you think of it?

@aittalam aittalam merged commit 84e3e1a into mozilla-ai:main Jul 2, 2026
2 checks passed
@aittalam

aittalam commented Jul 2, 2026

Copy link
Copy Markdown
Member

Re-tested and merged, thanks again @RichardoC !

@RichardoC

Copy link
Copy Markdown
Contributor Author

Thanks for sorting all this folks! Sorry about the delay in responses, got busy with work. I'm happy with the changes you folks have made

@RichardoC RichardoC deleted the document-args branch July 2, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants