|
| 1 | +# Benchmarking LEAP |
| 2 | + |
| 3 | +This guide explains how to benchmark the performance (throughput and latency) of the LEAP inference engine across different transport modes (TCP, UDP, Kernel). |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The `scripts/benchmark.py` script automates the process of setting up a distributed inference ring (currently configured for a 2-node setup: Master + 1 Worker) and measuring performance. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +```bash |
| 12 | +python3 scripts/benchmark.py \ |
| 13 | + --executable <path_to_inference_binary> \ |
| 14 | + --model <path_to_model.bin> \ |
| 15 | + --mode <tcp|udp|kernel> \ |
| 16 | + [--tokenizer <path_to_tokenizer.bin>] \ |
| 17 | + [--steps 100] \ |
| 18 | + [--workers 1] \ |
| 19 | + [--layers 32] \ |
| 20 | + [--manual] \ |
| 21 | + [--next-host <IP>] \ |
| 22 | + [--next-port <PORT>] \ |
| 23 | + [--split <LAYER>] \ |
| 24 | + [--runs 10] |
| 25 | +``` |
| 26 | + |
| 27 | +### Arguments |
| 28 | + |
| 29 | +| Argument | Description | Default | |
| 30 | +|----------|-------------|---------| |
| 31 | +| `--executable` | Path to the compiled `inference` binary. | Required | |
| 32 | +| `--model` | Path to the `.bin` model file. | Required | |
| 33 | +| `--mode` | Transport mode to test (`tcp`, `udp`, `kernel`). | Required | |
| 34 | +| `--tokenizer` | Path to the `tokenizer.bin` file. | Optional | |
| 35 | +| `--steps` | Number of tokens to generate for measurement. | `100` | |
| 36 | +| `--prompt` | Input prompt to use. | "The quick brown..." | |
| 37 | +| `--workers` | Number of worker nodes to spawn (in addition to Master). | `1` | |
| 38 | +| `--layers` | Total number of layers in the model (used for splitting). | `32` | |
| 39 | +| `--manual` | **Manual Mode**: Do not spawn workers, only run Master. | `False` | |
| 40 | +| `--next-host` | IP of the next node in the ring (required for manual mode). | — | |
| 41 | +| `--next-port` | Port of the next node in the ring. | — | |
| 42 | +| `--split` | Layer index where Master stops and Worker starts. | — | |
| 43 | +| `--runs` | Number of benchmark iterations to run. | `10` | |
| 44 | + |
| 45 | +### Examples |
| 46 | + |
| 47 | +**Run TCP mode with 100 iterations:** |
| 48 | + |
| 49 | +```bash |
| 50 | +python3 scripts/benchmark.py \ |
| 51 | + --executable ./cmake-build-release/src/inference/inference \ |
| 52 | + --model models/llama3-8b.bin \ |
| 53 | + --mode tcp \ |
| 54 | + --runs 100 |
| 55 | +``` |
| 56 | + |
| 57 | + |
| 58 | +**Run UDP mode with 3 workers:** |
| 59 | + |
| 60 | +```bash |
| 61 | +python3 scripts/benchmark.py \ |
| 62 | + --executable ./cmake-build-release/src/inference/inference \ |
| 63 | + --model models/llama3-8b.bin \ |
| 64 | + --mode udp \ |
| 65 | + --workers 3 \ |
| 66 | + --layers 32 |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | +**Manual Distributed Mode (Run on Master Node):** |
| 71 | + |
| 72 | +Run this on the Master node after starting the Worker node on `192.168.1.100:9999`. |
| 73 | + |
| 74 | +```bash |
| 75 | +python3 scripts/benchmark.py \ |
| 76 | + --executable ./cmake-build-release/src/inference/inference \ |
| 77 | + --model models/llama3-8b.bin \ |
| 78 | + --manual \ |
| 79 | + --next-host 192.168.1.100 \ |
| 80 | + --next-port 9999 \ |
| 81 | + --split 16 |
| 82 | +``` |
| 83 | + |
| 84 | +## Interpreting Results |
| 85 | + |
| 86 | +The script runs the benchmark `N` times (specified by `--runs`) and outputs detailed statistics: |
| 87 | + |
| 88 | +``` |
| 89 | +Starting benchmark for mode: UDP |
| 90 | +Configuration: 1 Worker(s) + 1 Master |
| 91 | +Executing 100 runs... |
| 92 | +------------------------------------------------------------ |
| 93 | +Run 1/100... Done (48.12 tok/s) |
| 94 | +... |
| 95 | +Run 100/100... Done (49.05 tok/s) |
| 96 | +
|
| 97 | +============================================================ |
| 98 | +METRIC | MEAN | MEDIAN | MIN | MAX | STD DEV |
| 99 | +--------------------------------------------------------------------------- |
| 100 | +Throughput | 48.50 | 48.45 | 45.20 | 51.10 | 1.25 |
| 101 | +Latency (s) | 2.06 | 2.07 | 1.95 | 2.21 | 0.05 |
| 102 | +============================================================ |
| 103 | +Detailed Latency P95: 2.15 s |
| 104 | +``` |
| 105 | + |
| 106 | +- **Throughput**: Tokens per second (Higher is better). |
| 107 | +- **Latency**: Total time to generate the requested number of tokens (Lower is better). |
| 108 | +- **Std Dev**: Lower indicates more stable performance. |
| 109 | + |
| 110 | +## Notes |
| 111 | + |
| 112 | +- **Kernel Mode**: Only works on Linux with the `leap_kmod` module loaded. The script will automatically skip Kernel mode if running on macOS. |
| 113 | +- **Architecture**: The benchmark presently assumes a 2-node setup (Master + 1 Worker). Modification to `benchmark.py` is required for larger ring sizes. |
0 commit comments