Skip to content

llama-bench : accept ranges for integer parameters #13410

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

slaren
Copy link
Member

@slaren slaren commented May 9, 2025

Accept ranges with the syntax start-end[+step] for all integer parameters.

Example:

$ llama-bench -n 0 -p 1-5,10-100+10,256
| model                          |       size |     params | backend    | ngl |            test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | --------------: | -------------------: |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |             pp1 |        171.12 ± 5.78 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |             pp2 |        229.50 ± 6.88 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |             pp3 |       343.37 ± 12.77 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |             pp4 |        433.23 ± 9.29 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |             pp5 |       494.69 ± 12.29 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp10 |        795.65 ± 5.96 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp20 |      1489.93 ± 19.02 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp30 |      2103.04 ± 61.36 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp40 |      2589.35 ± 37.22 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp50 |      2904.41 ± 48.25 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp60 |      3393.16 ± 19.55 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp70 |      3612.60 ± 35.55 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp80 |      4003.98 ± 16.02 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |            pp90 |      4101.49 ± 18.51 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |           pp100 |      4288.92 ± 19.39 |
| llama 7B Q4_0                  |   3.56 GiB |     6.74 B | CUDA       |  99 |           pp256 |      5728.99 ± 13.87 |

for (const auto & t : p) {
ggml_type gt = ggml_type_from_name(t);
if (gt == GGML_TYPE_COUNT) {
try {
Copy link
Member Author

Choose a reason for hiding this comment

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

The only real change here is replacing string_split<int>(argv[i], split_delim) with parse_int_range(argv[i]), the rest of the diff is due to the change in indentation.

@@ -323,7 +347,7 @@ static void print_usage(int /* argc */, char ** argv) {
printf("\n");
printf(
"Multiple values can be given for each parameter by separating them with ',' or by specifying the parameter "
"multiple times.\n");
"multiple times. Ranges can be specified with 'start-end' or 'start-end+step'.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should specify that the ranges are inclusive.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it to first-last+step. Is that clear enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess that also works but I think it would make sense to also rename the variables in the code to match the help.

@JohannesGaessler
Copy link
Collaborator

Would it be possible to support not just linear step sizes but exponential ones as well? So something like -ub 16-128*2 would translate to -ub 16,32,64,128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants