Files
leleka/scripts/laptop/port_bench.sh
T
Pavlo RatushnyiandClaude Opus 5.5 bbba0f231d bench(laptop): paired Original/port harness on fixed pre-tokenized prompts
* tokenizer example `chat_tokens`: one user turn per line, thinking off, to comma-separated IDs, so both
  engines get exactly the same token IDs (benchmarks/laptop/prompts.txt: 3 prompts, 78-88 tokens).
* leleka-runtime ignored test `original_serve_laptop_bench`: opens the Original serve stack with the
  low-RAM sources (mapped experts, read-only KAR file; resident/memfd still selectable), serves every prompt
  REPEAT times greedily and prints TTFT, prompt/decode phase times, prefill/decode tok/s, memory and the
  output IDs of the first pass.
* scripts/laptop: original_bench.sh drives the unmodified `strata generate --serve` (setup.py's IQ3_S
  arguments, conversation cache off, one GEN at a time, TTFT to the first T line); port_bench.sh runs the
  test; monitor.sh samples process RSS/anon/file/shmem/locked/pinned and GPU VRAM once a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:27:46 +02:00

34 lines
2.2 KiB
Bash

#!/usr/bin/env bash
# Run the port's Original serve stack (laptop profile) on the same pre-tokenized prompts as original_bench.sh.
# port_bench.sh LABEL
# Environment: TEST_BIN (the built leleka-runtime test executable, `cargo test --release -p leleka-runtime
# --features sm86 --lib --no-run`), MODEL_DIR (the two GGUF shards), KAR (read-only archive file) and
# KAR_PROVENANCE, MTP (data/mtp-rt), MTP_STAGING (private 0700 dir), PROMPTS, OUT, CUBLAS12_LIB (dir with
# libcublas.so.12). Every LELEKA_* switch of backend_original_serve_laptop.rs passes through (experts mapped or
# resident, the VRAM tier's LELEKA_ORIGINAL_SERVE_EXPERT_*, MAX_NEW, REPEAT, CPU_WORKERS, ...).
set -uo pipefail
label="$1"; shift
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
: "${TEST_BIN:?}" "${MODEL_DIR:?}" "${KAR:?}" "${KAR_PROVENANCE:?}" "${MTP:?}" "${MTP_STAGING:?}" "${PROMPTS:?}" "${OUT:?}"
mkdir -p "$OUT"
mkdir -p -m 700 "$MTP_STAGING"
export LD_LIBRARY_PATH="${CUBLAS12_LIB:-$(ls -d "$HOME"/cublas-12.9.1.4/x/*/lib | head -1)}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export LELEKA_LAPTOP_BENCH=yes
export LELEKA_STRA169_IQ3S_SHARD0="$MODEL_DIR/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf"
export LELEKA_STRA169_IQ3S_SHARD1="$MODEL_DIR/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf"
export LELEKA_LAPTOP_KAR_FILE="$KAR" LELEKA_STRA169_KAR_PROVENANCE="$KAR_PROVENANCE"
export LELEKA_STRA169_MTP_PACK="$MTP" LELEKA_STRA169_MTP_STAGING="$MTP_STAGING"
export LELEKA_LAPTOP_PROMPT_IDS="$PROMPTS"
env | grep -E '^LELEKA_' | sort > "$OUT/$label.env"
"$TEST_BIN" --ignored --exact backend::original_serve_laptop::original_serve_laptop_bench --nocapture --test-threads 1 \
> "$OUT/$label.stdout" 2> "$OUT/$label.stderr" &
pid=$!
bash "$here/monitor.sh" "$pid" "$OUT/$label.mem.tsv" > "$OUT/$label.mem.peak" &
mon=$!
wait "$pid"; rc=$?
wait "$mon" || true
echo "exit=$rc" >> "$OUT/$label.mem.peak"
grep -hE '^LAPTOP (load|config|request|tier)' "$OUT/$label.stderr" "$OUT/$label.stdout" | sed -E 's/ (VmRSS|VmHWM|RssAnon|RssFile|RssShmem|VmLck|VmPin)=/ \1=/g' | tee "$OUT/$label.timing"
grep -hE '^LAPTOP output' "$OUT/$label.stderr" "$OUT/$label.stdout" | sed 's/^LAPTOP //' > "$OUT/$label.outputs"
cat "$OUT/$label.mem.peak"