|
| 1 | +<!-- SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. --> |
| 2 | +<!-- SPDX-License-Identifier: Apache-2.0 --> |
| 3 | + |
| 4 | +# vLLM Benchmark Harness |
| 5 | + |
| 6 | +The vLLM benchmark harness replays a captured generation trace against one or |
| 7 | +more benchmark candidates. It is a developer tool for comparing engine and |
| 8 | +sampling configurations. It is not part of the main Safe Synthesizer CLI |
| 9 | +workflow. |
| 10 | + |
| 11 | +Run it through `uv` with the full engine environment: |
| 12 | + |
| 13 | +```bash |
| 14 | +uv run --frozen --extra cu129 --extra engine --group dev \ |
| 15 | + python tools/vllm_benchmark.py list |
| 16 | +``` |
| 17 | + |
| 18 | +## Corpus Format |
| 19 | + |
| 20 | +The input corpus is a JSONL file with one header record followed by prompt |
| 21 | +records: |
| 22 | + |
| 23 | +```json |
| 24 | +{"kind": "header", "run_id": "run-1", "pretrained_model": "model-ref", "dataset_schema": {}, "engine_parameters": {}} |
| 25 | +{"kind": "record", "row_index": 0, "prompt": "...", "sampling_params": {"temperature": 0.0}} |
| 26 | +``` |
| 27 | + |
| 28 | +The header supplies the model, optional LoRA path, dataset schema, and captured |
| 29 | +engine parameters. Each record supplies the exact prompt and sampling parameters |
| 30 | +to replay. |
| 31 | + |
| 32 | +## Run a Matrix |
| 33 | + |
| 34 | +Use a preset matrix: |
| 35 | + |
| 36 | +```bash |
| 37 | +uv run --frozen --extra cu129 --extra engine --group dev \ |
| 38 | + python tools/vllm_benchmark.py run \ |
| 39 | + /path/to/trace.jsonl \ |
| 40 | + --output /path/to/benchmark.json \ |
| 41 | + --candidates default_matrix |
| 42 | +``` |
| 43 | + |
| 44 | +Use `list` to see available presets. The `bracketed_ab_*` presets emit repeated |
| 45 | +baseline and candidate runs for noisier comparisons. |
| 46 | + |
| 47 | +Use a custom candidate file when a preset is too broad: |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "candidates": [ |
| 52 | + { |
| 53 | + "name": "baseline", |
| 54 | + "engine_config": {}, |
| 55 | + "sampling_overrides": {"seed": 42} |
| 56 | + } |
| 57 | + ] |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +Then run: |
| 62 | + |
| 63 | +```bash |
| 64 | +uv run --frozen --extra cu129 --extra engine --group dev \ |
| 65 | + python tools/vllm_benchmark.py run \ |
| 66 | + /path/to/trace.jsonl \ |
| 67 | + --output /path/to/benchmark.json \ |
| 68 | + --candidates-file candidates.json |
| 69 | +``` |
| 70 | + |
| 71 | +## Compare And Analyze |
| 72 | + |
| 73 | +Render one benchmark JSON: |
| 74 | + |
| 75 | +```bash |
| 76 | +uv run --frozen --extra cu129 --extra engine --group dev \ |
| 77 | + python tools/vllm_benchmark.py compare /path/to/benchmark.json |
| 78 | +``` |
| 79 | + |
| 80 | +Analyze every `*.json` result in a directory: |
| 81 | + |
| 82 | +```bash |
| 83 | +uv run --frozen --extra cu129 --extra engine --group dev \ |
| 84 | + python tools/vllm_benchmark.py analyze /path/to/results-dir \ |
| 85 | + --cluster-signal auto \ |
| 86 | + --json-out /path/to/analysis.json |
| 87 | +``` |
| 88 | + |
| 89 | +The analyzer reports candidate-run aggregates by condition. It keeps the JSON |
| 90 | +field name `n_cells` for compatibility; in this context a "cell" means one |
| 91 | +candidate run in the benchmark matrix. |
| 92 | + |
| 93 | +Use `--min-runs-per-condition` to raise or lower the refusal threshold. The |
| 94 | +older `--min-cells-per-condition` spelling remains accepted for compatibility. |
| 95 | + |
| 96 | +## WandB Sink |
| 97 | + |
| 98 | +The harness can use WandB as a metrics sink. Each benchmark candidate run becomes |
| 99 | +one WandB run in a shared group. WandB failures do not fail the benchmark; the |
| 100 | +benchmark JSON is still written. |
| 101 | + |
| 102 | +WandB mode defaults to disabled. Use `WANDB_MODE`, `NSS_WANDB_PROJECT`, or |
| 103 | +`WANDB_PROJECT` consistently with the rest of Safe Synthesizer. |
0 commit comments