MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / run

Function run

subprojects/llama.cpp/scripts/tool_bench.py:204–375  ·  view source on GitHub ↗
(
    output: Annotated[Path, typer.Option(help="Output JSON file")],
    model: Annotated[Optional[str], typer.Option(help="Name of the model to test (server agnostic)")] = None,
    hf: Annotated[Optional[str], typer.Option(help="GGUF huggingface model repo id (+ optional quant) to test w/ llama-server")] = None,
    chat_template: Annotated[Optional[str], typer.Option(help="Chat template override for llama-server")] = None,
    chat_template_file: Annotated[Optional[str], typer.Option(help="Chat template file override for llama-server")] = None,
    ollama: Annotated[Optional[str], typer.Option(help="Ollama model tag to test")] = None,
    llama_baseline: Annotated[Optional[str], typer.Option(help="llama-server baseline binary path to use as baseline")] = None,
    n: Annotated[int, typer.Option(help="Number of times to run each test")] = 10,
    temp: Annotated[Optional[List[float]], typer.Option(help="Set of temperatures to test")] = None,
    top_p: Annotated[Optional[float], typer.Option(help="top_p")] = None,
    top_k: Annotated[Optional[int], typer.Option(help="top_k")] = None,
    ctk: Annotated[Optional[str], typer.Option(help="ctk")] = None,
    ctv: Annotated[Optional[str], typer.Option(help="ctv")] = None,
    fa: Annotated[Optional[bool], typer.Option(help="fa")] = None,
    seed: Annotated[Optional[int], typer.Option(help="Random seed")] = None,
    port: Annotated[int, typer.Option(help="llama-server port")] = 8084,
    force: Annotated[bool, typer.Option(help="Force overwrite of output file")] = False,
    append: Annotated[bool, typer.Option(help="Append to output file")] = False,

    test_hello_world: Annotated[bool, typer.Option(help="Whether to run the hello world test")] = True,
    test_weather: Annotated[bool, typer.Option(help="Whether to run the weather test")] = True,
    test_calc_result: Annotated[bool, typer.Option(help="Whether to run the calc result test")] = False,
)

Source from the content-addressed store, hash-verified

202
203@app.command()
204def run(
205 output: Annotated[Path, typer.Option(help="Output JSON file")],
206 model: Annotated[Optional[str], typer.Option(help="Name of the model to test (server agnostic)")] = None,
207 hf: Annotated[Optional[str], typer.Option(help="GGUF huggingface model repo id (+ optional quant) to test w/ llama-server")] = None,
208 chat_template: Annotated[Optional[str], typer.Option(help="Chat template override for llama-server")] = None,
209 chat_template_file: Annotated[Optional[str], typer.Option(help="Chat template file override for llama-server")] = None,
210 ollama: Annotated[Optional[str], typer.Option(help="Ollama model tag to test")] = None,
211 llama_baseline: Annotated[Optional[str], typer.Option(help="llama-server baseline binary path to use as baseline")] = None,
212 n: Annotated[int, typer.Option(help="Number of times to run each test")] = 10,
213 temp: Annotated[Optional[List[float]], typer.Option(help="Set of temperatures to test")] = None,
214 top_p: Annotated[Optional[float], typer.Option(help="top_p")] = None,
215 top_k: Annotated[Optional[int], typer.Option(help="top_k")] = None,
216 ctk: Annotated[Optional[str], typer.Option(help="ctk")] = None,
217 ctv: Annotated[Optional[str], typer.Option(help="ctv")] = None,
218 fa: Annotated[Optional[bool], typer.Option(help="fa")] = None,
219 seed: Annotated[Optional[int], typer.Option(help="Random seed")] = None,
220 port: Annotated[int, typer.Option(help="llama-server port")] = 8084,
221 force: Annotated[bool, typer.Option(help="Force overwrite of output file")] = False,
222 append: Annotated[bool, typer.Option(help="Append to output file")] = False,
223
224 test_hello_world: Annotated[bool, typer.Option(help="Whether to run the hello world test")] = True,
225 test_weather: Annotated[bool, typer.Option(help="Whether to run the weather test")] = True,
226 test_calc_result: Annotated[bool, typer.Option(help="Whether to run the calc result test")] = False,
227):
228 # Check only one of output and append
229
230 n_predict = 512 # High because of DeepSeek R1
231 # n_ctx = 8192
232 n_ctx = 2048
233
234 if model is None:
235 if hf is not None:
236 model = hf.split("/")[-1]
237 elif ollama is not None:
238 model = ollama
239
240 assert force or append or not output.exists(), f"Output file already exists: {output}; use --force to overwrite"
241
242 with output.open('a' if append else 'w') as output_file:
243
244 def run(server: ServerProcess, *, server_name: str, model_id: str, temp: Optional[float] = None, output_kwargs={}, request_kwargs={}):
245 request_kwargs = {**request_kwargs}
246 if temp is not None:
247 request_kwargs['temperature'] = temp
248 if top_p is not None:
249 request_kwargs['top_p'] = top_p
250 if top_k is not None:
251 request_kwargs['top_k'] = top_k
252 if seed is not None:
253 request_kwargs['seed'] = seed
254
255 request_kwargs['cache_prompt'] = False
256
257 tests = {}
258 if test_hello_world:
259 tests["hello world"] = lambda server: do_test_hello_world(server, **request_kwargs)
260 if test_weather:
261 tests["weather"] = lambda server: do_test_weather(server, **request_kwargs)

Callers

nothing calls this directly

Calls 15

startMethod · 0.95
do_test_hello_worldFunction · 0.90
do_test_weatherFunction · 0.90
do_test_calc_resultFunction · 0.90
ServerProcessClass · 0.90
elapsedFunction · 0.85
setFunction · 0.85
scoped_serverFunction · 0.85
timeMethod · 0.80
splitMethod · 0.65
openMethod · 0.65
appendMethod · 0.65

Tested by

no test coverage detected