Download scripts/run_perf.sh from sambit9238/Inkling-2-Mini-NVFP4-M2: direct link, hf CLI and curl.
- Browser
- Download file 5.5 kB
-
https://huggingface.co/sambit9238/Inkling-2-Mini-NVFP4-M2/resolve/main/scripts/run_perf.sh
- Command line
-
hf download hf://sambit9238/Inkling-2-Mini-NVFP4-M2/scripts/run_perf.sh
-
curl -L -o run_perf.sh https://huggingface.co/sambit9238/Inkling-2-Mini-NVFP4-M2/resolve/main/scripts/run_perf.sh
5.5 kB
| # Perf against the already-running vLLM server container: batch-1 decode, prefill at 2k/32k, throughput at c=8/32, | |
| # plus spec-decode acceptance scraped from /metrics before/after. | |
| # Usage: run_perf.sh LABEL (env: NAME, PORT, SERVED_NAME, MODEL_DIR (tokenizer), SPEC (label only), REASONING_EFFORT) | |
| # Runs `vllm bench serve` inside the server container via docker exec (so the same image/version is used). | |
| # Results: results/<LABEL>/perf/*.json and perf_summary.json. LABEL should encode the config, e.g. official_mtp1. | |
| set -euo pipefail | |
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| LABEL="${1:?LABEL}" | |
| NAME="${NAME:-inkling-vllm}" | |
| PORT="${PORT:-8000}" | |
| SERVED_NAME="${SERVED_NAME:-inkling}" | |
| OUT="$ROOT/results/$LABEL/perf" | |
| mkdir -p "$OUT" | |
| PY="${EVAL_PY:-$ROOT/.venv-eval/bin/python}" | |
| BASE="http://localhost:8000" # inside the container | |
| scrape() { # snapshot all spec_decode counters | |
| curl -sf "localhost:${PORT}/metrics" | grep -E '^vllm:spec_decode' > "$OUT/metrics_$1.txt" || : > "$OUT/metrics_$1.txt" | |
| } | |
| bench() { # name in out conc prompts [backend endpoint] | |
| echo "=== bench $1 ($LABEL) ===" | |
| docker exec "$NAME" vllm bench serve \ | |
| --backend "${6:-openai-chat}" --endpoint "${7:-/v1/chat/completions}" \ | |
| --model "$SERVED_NAME" --tokenizer /model --base-url "$BASE" \ | |
| --dataset-name random --random-input-len "$2" --random-output-len "$3" --ignore-eos \ | |
| --max-concurrency "$4" --num-prompts "$5" --seed 42 \ | |
| --extra-body "{\"chat_template_kwargs\": {\"reasoning_effort\": \"${REASONING_EFFORT:-low}\"}}" \ | |
| --save-result --result-dir /tmp/bench --result-filename "$1.json" | |
| docker cp "$NAME:/tmp/bench/$1.json" "$OUT/$1.json" | |
| } | |
| # the image lacks vllm[bench] extras | |
| docker exec "$NAME" python3 -m pip install -q pandas datasets >/dev/null 2>&1 || true | |
| bench warmup 512 64 4 8 | |
| # realistic-text decode at batch 1: DSpark acceptance on random tokens is ~0, so MTP speed/acceptance come from this one | |
| docker cp "$ROOT/configs/decode_prompts.jsonl" "$NAME:/tmp/decode_prompts.jsonl" | |
| scrape before | |
| echo "=== bench decode_real_c1 ($LABEL) ===" | |
| docker exec "$NAME" vllm bench serve \ | |
| --backend openai-chat --endpoint /v1/chat/completions \ | |
| --model "$SERVED_NAME" --tokenizer /model --base-url "$BASE" \ | |
| --dataset-name custom --dataset-path /tmp/decode_prompts.jsonl --custom-output-len 512 --ignore-eos \ | |
| --max-concurrency 1 --num-prompts 16 --seed 42 \ | |
| --extra-body "{\"chat_template_kwargs\": {\"reasoning_effort\": \"${REASONING_EFFORT:-low}\"}}" \ | |
| --save-result --result-dir /tmp/bench --result-filename decode_real_c1.json | |
| docker cp "$NAME:/tmp/bench/decode_real_c1.json" "$OUT/decode_real_c1.json" | |
| scrape mid | |
| bench decode_c1 1024 512 1 8 | |
| bench prefill_2k 2048 1 1 8 openai /v1/completions | |
| bench prefill_32k 32768 1 1 4 openai /v1/completions | |
| bench thr_c8 1024 512 8 32 | |
| bench thr_c32 1024 512 32 64 | |
| scrape after | |
| docker logs "$NAME" 2>&1 | grep -iE "model loading took|KV cache|maximum concurrency|memory" > "$OUT/server_memory.log" || true | |
| "$PY" - "$OUT" "$LABEL" "${SPEC:-unknown}" <<'PYEOF' | |
| import json, re, sys | |
| from pathlib import Path | |
| out, label, spec = Path(sys.argv[1]), sys.argv[2], sys.argv[3] | |
| def counters(p: Path) -> dict[str, float]: | |
| d: dict[str, float] = {} | |
| for line in p.read_text().splitlines(): | |
| m = re.match(r"(vllm:spec_decode\w*?)(\{[^}]*\})?\s+([0-9.eE+-]+)$", line) | |
| if not m: | |
| continue | |
| name, labels, val = m.groups() | |
| # Keep per-position series separate, sum duplicate engine/model labels otherwise. | |
| key = name + (labels if "position" in (labels or "") else "") | |
| d[key] = d.get(key, 0.0) + float(val) | |
| return d | |
| b, a = counters(out / "metrics_before.txt"), counters(out / "metrics_mid.txt") # acceptance on realistic text only | |
| delta = {k: a[k] - b.get(k, 0.0) for k in a} | |
| res: dict = {"label": label, "spec": spec, "spec_decode_delta": delta} | |
| # Metric names are version dependent; confirm against metrics_after.txt on the real server. | |
| drafts = next((v for k, v in delta.items() if k.startswith("vllm:spec_decode_num_drafts")), None) | |
| draft_toks = next((v for k, v in delta.items() if k.startswith("vllm:spec_decode_num_draft_tokens")), None) | |
| acc_toks = next((v for k, v in delta.items() if k.startswith("vllm:spec_decode_num_accepted_tokens") and "position" not in k), None) | |
| if draft_toks: | |
| res["acceptance_rate"] = acc_toks / draft_toks | |
| if drafts: | |
| res["mean_accepted_per_draft"] = acc_toks / drafts | |
| res["mean_acceptance_length"] = 1 + acc_toks / drafts | |
| for name in ("decode_real_c1", "decode_c1", "prefill_2k", "prefill_32k", "thr_c8", "thr_c32"): | |
| f = out / f"{name}.json" | |
| if f.exists(): | |
| j = json.loads(f.read_text()) | |
| res[name] = { | |
| k: j.get(k) | |
| for k in ("output_throughput", "total_token_throughput", "request_throughput", | |
| "mean_ttft_ms", "median_ttft_ms", "mean_tpot_ms", "median_tpot_ms", "completed") | |
| } | |
| for name in ("decode_real_c1", "decode_c1"): | |
| if name in res and res[name].get("median_tpot_ms"): | |
| res[f"{name}_tok_s"] = 1000.0 / res[name]["median_tpot_ms"] | |
| for name, n in (("prefill_2k", 2048), ("prefill_32k", 32768)): | |
| if name in res and res[name].get("median_ttft_ms"): | |
| res[f"{name}_tok_s"] = n / (res[name]["median_ttft_ms"] / 1000.0) | |
| (out / "perf_summary.json").write_text(json.dumps(res, indent=2) + "\n") | |
| print(json.dumps({k: v for k, v in res.items() if k != "spec_decode_delta"}, indent=1)) | |
| PYEOF | |
| echo "done $LABEL" | |