|
7 | 7 |
|
8 | 8 | import yaml
|
9 | 9 |
|
10 |
| -CLI_ARGS_MAIN = [ |
| 10 | +CLI_ARGS_MAIN_PERPLEXITY = [ |
11 | 11 | "batch-size", "cfg-negative-prompt", "cfg-scale", "chunks", "color", "ctx-size", "escape",
|
12 | 12 | "export", "file", "frequency-penalty", "grammar", "grammar-file", "hellaswag",
|
13 | 13 | "hellaswag-tasks", "ignore-eos", "in-prefix", "in-prefix-bos", "in-suffix", "instruct",
|
|
21 | 21 | "temp", "tfs", "top-k", "top-p", "typical", "verbose-prompt"
|
22 | 22 | ]
|
23 | 23 |
|
| 24 | +CLI_ARGS_LLAMA_BENCH = [ |
| 25 | + "batch-size", "memory-f32", "low-vram", "model", "mul-mat-q", "n-gen", "n-gpu-layers", |
| 26 | + "n-prompt", "output", "repetitions", "tensor-split", "threads", "verbose" |
| 27 | +] |
| 28 | + |
| 29 | +CLI_ARGS_SERVER = [ |
| 30 | + "alias", "batch-size", "ctx-size", "embedding", "host", "memory-f32", "lora", "lora-base", |
| 31 | + "low-vram", "main-gpu", "mlock", "model", "n-gpu-layers", "no-mmap", "no-mul-mat-q", "numa", |
| 32 | + "path", "port", "rope-freq-base", "timeout", "rope-freq-scale", "tensor-split", "threads", "verbose" |
| 33 | +] |
| 34 | + |
24 | 35 | description = """Run llama.cpp binaries with presets from YAML file(s).
|
25 |
| -To specify which binary should be run, specify the "binary" property. |
| 36 | +To specify which binary should be run, specify the "binary" property (main, perplexity, llama-bench, and server are supported). |
26 | 37 | To get a preset file template, run a llama.cpp binary with the "--logdir" CLI argument.
|
27 | 38 |
|
28 | 39 | Formatting considerations:
|
|
40 | 51 |
|
41 | 52 | parser = argparse.ArgumentParser(
|
42 | 53 | description=description, usage=usage, epilog=epilog, formatter_class=argparse.RawTextHelpFormatter)
|
| 54 | +parser.add_argument("-bin", "--binary", help="The binary to run.") |
43 | 55 | parser.add_argument("yaml_files", nargs="*",
|
44 | 56 | help="Arbitrary number of YAML files from which to read preset values. "
|
45 | 57 | "If two files specify the same values the later one will be used.")
|
|
59 | 71 | props = {prop.replace("_", "-"): val for prop, val in props.items()}
|
60 | 72 |
|
61 | 73 | binary = props.pop("binary", "main")
|
| 74 | +if known_args.binary: |
| 75 | + binary = known_args.binary |
| 76 | + |
62 | 77 | if os.path.exists(f"./{binary}"):
|
63 | 78 | binary = f"./{binary}"
|
64 | 79 |
|
| 80 | +if binary.endswith("main") or binary.endswith("perplexity"): |
| 81 | + cli_args = CLI_ARGS_MAIN_PERPLEXITY |
| 82 | +elif binary.endswith("llama-bench"): |
| 83 | + cli_args = CLI_ARGS_LLAMA_BENCH |
| 84 | +elif binary.endswith("server"): |
| 85 | + cli_args = CLI_ARGS_SERVER |
| 86 | +else: |
| 87 | + print(f"Unknown binary: {binary}") |
| 88 | + sys.exit(1) |
| 89 | + |
65 | 90 | command_list = [binary]
|
66 | 91 |
|
67 |
| -for cli_arg in CLI_ARGS_MAIN: |
| 92 | +for cli_arg in cli_args: |
68 | 93 | value = props.get(cli_arg, None)
|
69 | 94 |
|
70 | 95 | if not value or value == -1:
|
|
0 commit comments