KBaba7/llama.cpp
0
1# Server tests2 3Python based server tests scenario using [pytest](https://docs.pytest.org/en/stable/).4 5Tests target GitHub workflows job runners with 4 vCPU.6 7Note: If the host architecture inference speed is faster than GitHub runners one, parallel scenario may randomly fail.8To mitigate it, you can increase values in `n_predict`, `kv_size`.9 10### Install dependencies11 12`pip install -r requirements.txt`13 14### Run tests15 161. Build the server17 18```shell19cd ../../..20cmake -B build -DLLAMA_CURL=ON21cmake --build build --target llama-server22```23 242. Start the test: `./tests.sh`25 26It's possible to override some scenario steps values with environment variables:27 28| variable | description |29|--------------------------|------------------------------------------------------------------------------------------------|30| `PORT` | `context.server_port` to set the listening port of the server during scenario, default: `8080` |31| `LLAMA_SERVER_BIN_PATH` | to change the server binary path, default: `../../../build/bin/llama-server` |32| `DEBUG` | to enable steps and server verbose mode `--verbose` |33| `N_GPU_LAYERS` | number of model layers to offload to VRAM `-ngl --n-gpu-layers` |34| `LLAMA_CACHE` | by default server tests re-download models to the `tmp` subfolder. Set this to your cache (e.g. `$HOME/Library/Caches/llama.cpp` on Mac or `$HOME/.cache/llama.cpp` on Unix) to avoid this |35 36To run slow tests (will download many models, make sure to set `LLAMA_CACHE` if needed):37 38```shell39SLOW_TESTS=1 ./tests.sh40```41 42To run with stdout/stderr display in real time (verbose output, but useful for debugging):43 44```shell45DEBUG=1 ./tests.sh -s -v -x46```47 48To run all the tests in a file:49 50```shell51./tests.sh unit/test_chat_completion.py.py -v -x52```53 54To run a single test:55 56```shell57./tests.sh unit/test_chat_completion.py::test_invalid_chat_completion_req58```59 60Hint: You can compile and run test in single command, useful for local developement:61 62```shell63cmake --build build -j --target llama-server && ./examples/server/tests/tests.sh64```65 66To see all available arguments, please refer to [pytest documentation](https://docs.pytest.org/en/stable/how-to/usage.html)67 