merge: claude/laptop-profile (RTX 3080 laptop: mapped experts instead of a 50 GB RAM copy, KAR read-only file source, resident RAM budget, regenerated sm_86 resolver image, paired bench harness, docs/laptop-profile.md)
Laptop numbers (indicative, 3 prompts x 2): Original decode 8.15 tok/s / TTFT 7.2 s (KAR PLE), port 2.70 tok/s / 28.4 s; both bottlenecks (serial CPU expert preparation, prompt-path expert copies) are being fixed on claude/pool-zero-copy and claude/prefill-throughput. model-format now denies (instead of forbids) unsafe code for one audited mmap owner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Sample one process's memory and the GPU's VRAM once a second until it exits (laptop profile benches).
|
||||
# monitor.sh PID OUT.tsv
|
||||
# Columns: unix time, VRAM used MiB (nvidia-smi, whole GPU), VmRSS, RssAnon, RssFile, RssShmem, VmLck, VmPin (MiB),
|
||||
# MemAvailable (MiB, whole VM). Prints the peaks when the process is gone.
|
||||
set -u
|
||||
pid="$1"; out="$2"
|
||||
printf 't\tvram\trss\tanon\tfile\tshmem\tlck\tpin\tavail\n' > "$out"
|
||||
field() { awk -v k="$1:" '$1==k {printf "%d", $2/1024}' "/proc/$pid/status" 2>/dev/null; }
|
||||
while kill -0 "$pid" 2>/dev/null; do
|
||||
vram=$(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits 2>/dev/null | head -1)
|
||||
avail=$(awk '$1=="MemAvailable:" {printf "%d", $2/1024}' /proc/meminfo)
|
||||
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$(date +%s)" "${vram:-0}" "$(field VmRSS)" "$(field RssAnon)" \
|
||||
"$(field RssFile)" "$(field RssShmem)" "$(field VmLck)" "$(field VmPin)" "$avail" >> "$out"
|
||||
sleep 1
|
||||
done
|
||||
awk -F'\t' 'NR>1 {for (i=2;i<=9;i++) if ($i+0>m[i]) m[i]=$i+0; if (min==""||$9+0<min) min=$9+0}
|
||||
END {printf "peak MiB: vram=%d rss=%d anon=%d file=%d shmem=%d lck=%d pin=%d; min MemAvailable=%d\n", m[2],m[3],m[4],m[5],m[6],m[7],m[8],min}' "$out"
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the unmodified Original (`strata generate --serve`) on the laptop-profile prompts and record its timings,
|
||||
# outputs and memory (docs/laptop-profile.md).
|
||||
# original_bench.sh LABEL [extra engine args...]
|
||||
# Environment: STRATA (engine binary), MODEL_DIR (the two GGUF shards), PACK (data/iq3_s), MTP (data/mtp-rt),
|
||||
# PROFILE (expert-profile.bin), PROMPTS (one comma-separated token-ID line per prompt), OUT (results dir),
|
||||
# MAX_NEW (128), REPEAT (2), MAX_CONTEXT (8192).
|
||||
# The default arguments are setup.py's for IQ3_S (`--expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5
|
||||
# --mtp`, `--kv int8`), with the conversation cache off so repeats read the whole prompt again (the port's stack
|
||||
# has it off by default too). The low-RAM mode (`--resident-experts`, `--mmap-experts`, ...) is passed as extra args.
|
||||
# Requests are sent one at a time; TTFT is measured here from sending `GEN` to the first `T` line.
|
||||
set -uo pipefail
|
||||
label="$1"; shift
|
||||
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
: "${STRATA:?}" "${MODEL_DIR:?}" "${PACK:?}" "${MTP:?}" "${PROFILE:?}" "${PROMPTS:?}" "${OUT:?}"
|
||||
MAX_NEW="${MAX_NEW:-128}"; REPEAT="${REPEAT:-2}"; MAX_CONTEXT="${MAX_CONTEXT:-8192}"
|
||||
mkdir -p "$OUT"
|
||||
shard1="$MODEL_DIR/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf"
|
||||
shard2="$MODEL_DIR/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf"
|
||||
args=(--serve --pack "$PACK" --native "$shard1" --ple-gguf "$shard2" --expert-profile "$PROFILE"
|
||||
--expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp "$MTP" --max-context "$MAX_CONTEXT"
|
||||
--kv int8 --prompt-cache 0 "$@")
|
||||
echo "strata ${args[*]}" > "$OUT/$label.cmd"
|
||||
mapfile -t prompts < <(grep -v '^[[:space:]]*$' "$PROMPTS")
|
||||
t_start=$EPOCHREALTIME
|
||||
coproc ENGINE { exec "$STRATA" "${args[@]}" 2> "$OUT/$label.stderr"; }
|
||||
pid=$ENGINE_PID
|
||||
bash "$here/monitor.sh" "$pid" "$OUT/$label.mem.tsv" > "$OUT/$label.mem.peak" &
|
||||
mon=$!
|
||||
: > "$OUT/$label.stdout"
|
||||
ready=""
|
||||
while IFS= read -r line <&"${ENGINE[0]}"; do
|
||||
echo "$line" >> "$OUT/$label.stdout"
|
||||
if [[ "$line" == READY* ]]; then ready=1; break; fi
|
||||
done
|
||||
if [[ -z "$ready" ]]; then echo "engine did not become ready"; tail -20 "$OUT/$label.stderr"; exit 1; fi
|
||||
echo "load_s=$(echo "$EPOCHREALTIME - $t_start" | bc)" > "$OUT/$label.timing"
|
||||
for ((pass = 0; pass < REPEAT; pass++)); do
|
||||
for i in "${!prompts[@]}"; do
|
||||
t0=$EPOCHREALTIME; first=""; toks=()
|
||||
echo "GEN $MAX_NEW ${prompts[$i]}" >&"${ENGINE[1]}"
|
||||
while IFS= read -r line <&"${ENGINE[0]}"; do
|
||||
echo "$line" >> "$OUT/$label.stdout"
|
||||
case "$line" in
|
||||
T\ *) [[ -z "$first" ]] && first=$EPOCHREALTIME; toks+=("${line#T }") ;;
|
||||
DONE*) break ;;
|
||||
ERR*) echo "p$((i + 1)) pass=$pass: $line"; break ;;
|
||||
esac
|
||||
done
|
||||
t1=$EPOCHREALTIME
|
||||
ttft=$(echo "(${first:-$t1} - $t0) * 1000" | bc)
|
||||
total=$(echo "($t1 - $t0) * 1000" | bc)
|
||||
# DONE produced prompt prompt_ms decode_ms finish accepted offered resume hits look ram_reads file_reads file_MB
|
||||
read -r _ produced n prompt_ms decode_ms finish acc off resume hits look ram files fmb <<< "$line"
|
||||
printf 'p%d pass=%d prompt=%s produced=%s ttft_ms=%.1f prompt_ms=%s decode_ms=%s total_ms=%.1f prefill_tok_s=%.1f decode_tok_s=%.2f accept=%s/%s hits=%s/%s ram=%s files=%s file_MB=%s finish=%s\n' \
|
||||
$((i + 1)) "$pass" "$n" "$produced" "$ttft" "$prompt_ms" "$decode_ms" "$total" \
|
||||
"$(echo "$n * 1000 / $prompt_ms" | bc -l)" "$(echo "$produced * 1000 / $decode_ms" | bc -l)" \
|
||||
"$acc" "$off" "$hits" "$look" "$ram" "$files" "$fmb" "$finish" | tee -a "$OUT/$label.timing"
|
||||
if [[ $pass -eq 0 ]]; then
|
||||
(IFS=,; echo "output p$((i + 1)): ${toks[*]}") >> "$OUT/$label.outputs"
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo QUIT >&"${ENGINE[1]}"
|
||||
wait "$pid"; rc=$?
|
||||
wait "$mon" || true
|
||||
echo "exit=$rc" >> "$OUT/$label.mem.peak"
|
||||
cat "$OUT/$label.mem.peak"
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user