Merge branch 'main' into claude/speed-vs-strata-08143a

This commit is contained in:
Pavlo Ratushnyi
2026-11-11 01:22:25 +01:00
184 changed files with 23975 additions and 648 deletions
+143
View File
@@ -0,0 +1,143 @@
#!/usr/bin/env bash
# Prefill fixed-latency A/B driver (docs/prefill-throughput.md, "Prefill fixed latency per request"): a copy of the speed program's spd_ab_job.sh
# (scripts/e2e/codex/speed) that runs against its own package, state and prefix directories, so it never touches the codex-compare release state.
# The SAME recorded Codex prompts are replayed through the packaged stack; a variant is named NAME or NAME.BLOCK (A.1 L.1 L.2 A.2 ...), BLOCK only names the output directory.
# replay_hash.py (next to this file in the server tools dir) records the sha256 of each request's output.
# HOLDER JOB (inherits the sealed KAR memfd). Test tooling, never in serving.
# PF_VARIANTS space separated variant names (default "A L")
# PF_CELLS recorded cells to replay, in order (default VANL/nestng-crm-r2 of the codex-compare run)
# PF_OUT result directory (default $PL/runs/main)
# PF_MAX requests per cell (default all)
# PF_ROOT the task directory (default /data/leleka-e2e/prefill-latency): pkg/bin (binaries under test), state/, prefix/, tools/
# PF_CLIENT the client script in the tools directory (default replay_hash.py; pf_probe.py = the empty-request probe of ledger rows A1-A3)
# PF_PKG the package directory (default $PF_ROOT/pkg): bin/ and SHA256SUMS; lets a second build run next to the first
# Variants (engine environment of the `leleka up` process):
# A shipped (the prompt loan is the full 8192-row loan for every chunk)
# L the prompt loan ladder: LELEKA_PREFILL_LOAN_TIERS=1 (a chunk of at most 512 / 2048 rows borrows and refills a smaller loan)
# AR as A with LELEKA_TRACE_PREFILL_R=1: one PREFILL-R line (FNV-1a of every bit of the chunk's final residual) per chunk, the identity record
# LR as L with LELEKA_TRACE_PREFILL_R=1
# P as A with the step profile (LELEKA_SERVE_PROFILE=1: one `DBG profile request` line of host spans per request)
# LP as L with the step profile
# LT as L with the bring-up trace (LELEKA_BRINGUP_TRACE=1: the driver error behind a failed chunk)
# C as A with the draft chain pipeline (LELEKA_DRAFT_CHAIN_PIPELINE=1: the chain steps enqueued back to back, one drain)
# DT as A with LELEKA_TRACE_DRAFT=1 (the draft-round identity lines) MC draft check merge (LELEKA_DRAFT_CHECK_MERGE=1) MT = MC + DT MCP = MC + profile
# RG decode graph reuse across requests (LELEKA_DECODE_GRAPH_REUSE=1) RGP = RG + profile RGT = RG + draft trace
# GT prefill GDN tensor-core scan (LELEKA_PREFILL_GDN_TC=1, EXPERIMENTAL, lossy) GTP = GT + profile GTD = GT + draft trace
# PF/PA parking fast / async (+P: with profile) X = chain pipeline + check merge + parking fast (the group of host/draft switches) XT = X + DT
# CP as C with the step profile AP as A with the step profile (the pair for the host spans of the draft)
set -uo pipefail
PL=${PF_ROOT:-/data/leleka-e2e/prefill-latency}
CMP=/data/leleka-e2e/codex-compare
RUN=${PF_OUT:-$PL/runs/main}
VARS=${PF_VARIANTS:-"A L"}
MAXR=${PF_MAX:-0}
CELLS=${PF_CELLS:-"$CMP/runs/main/VANL/nestng-crm-r2"}
LOCK=/data/leleka-e2e/gpu.lock
G=$HOME/work/gpu-runs
CUBLAS=$HOME/cuda-toolkits/cublas-12.9.1.4/lib
FD=${LELEKA_STRA169_KAR_FD:-}
mkdir -p "$RUN"
exec > >(tee -a "$RUN/job-$(date -u +%H%M%S).log") 2>&1
log() { echo "[pf $(date -u +%T)] $*"; }
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >>/data/leleka-e2e/decode/notes.md; }
readlink "/proc/self/fd/$FD" 2>/dev/null | grep -q '^/memfd:' || { echo "needs the holder's sealed memfd"; exit 3; }
# Guard: the shipped profiles read only the PLE extents (~15 GiB, memfd_extents ple_only). A holder that sealed the whole archive (every holder window ends with the FULL
# single-copy-holder.sh) makes `leleka up` refuse ("a second copy of model bytes") and inflates host memory. Allocated size of the inherited memfd, in GiB:
ALLOC_GIB=$(( $(stat -L -c %b "/proc/self/fd/$FD") / 2097152 ))
log "inherited memfd: $ALLOC_GIB GiB allocated"
if [ "${PF_ALLOW_FULL_MEMFD:-0}" != 1 ] && [ "$ALLOC_GIB" -gt "${PF_MEMFD_MAX_GIB:-20}" ]; then
# newest .running: stale ones of killed jobs exist
JOBF=$(ls -t "$G"/holder2/jobs/*.running 2>/dev/null | head -1); JOBN=$(basename "${JOBF%.running}")
[ -n "$JOBN" ] || { echo "memfd is not sparse and the queue entry of this job is unknown"; exit 3; }
log "memfd is not sparse ($ALLOC_GIB GiB > ${PF_MEMFD_MAX_GIB:-20}): restarting the lab holder sparse and queueing $JOBN again"
touch "$G/holder2/jobs/STOP"
( eval "exec ${FD}>&-"; setsid nohup bash "$PL/tools/pf_sparse_requeue.sh" "$JOBN" > "$PL/window-requeue-$JOBN.launch" 2>&1 < /dev/null & )
exit 0
fi
[ -d "$G/MODEL.lock" ] || { echo "MODEL.lock is not held"; exit 3; }
PKG=${PF_PKG:-$PL/pkg}
AS=$CMP/ours-assets; ST=$PL/state; PFX=$PL/prefix; BIN=$PKG/bin
[ -x "$BIN/leleka" ] && [ -f "$ST/leleka.json" ] || { echo "the prefill-latency package or state is not prepared"; exit 3; }
(cd "$BIN" && sha256sum -c ../SHA256SUMS >/dev/null 2>&1) || { echo "the package binaries do not match $PKG/SHA256SUMS"; exit 3; }
got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "prefill-latency $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; }
SUP_PID=; MON_PID=
stop_stack() { if [ -n "$SUP_PID" ] && kill -0 "$SUP_PID" 2>/dev/null; then kill -TERM "$SUP_PID" 2>/dev/null; for _ in $(seq 1 120); do kill -0 "$SUP_PID" 2>/dev/null || break; sleep 2; done; fi; SUP_PID=; }
cleanup() { stop_stack; [ -n "$MON_PID" ] && kill "$MON_PID" 2>/dev/null; pkill -KILL -f "$PFX/bin/" 2>/dev/null; sleep 3; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; note "prefill-latency job ended: $RUN"; }
trap cleanup EXIT
note "prefill-latency job started: variants [$VARS] cells [$CELLS] out $RUN"
[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; }
export LD_LIBRARY_PATH=$CUBLAS:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
COMMON="--assets $AS --state-dir $ST --prefix $PFX --bin-src $BIN --cublas-dir $CUBLAS --trust-archive --kar-fd $FD"
for v in $VARS; do
D=$RUN/$v; mkdir -p "$D"; vb=${v%%.*}
[ -f "$D/replay.jsonl" ] && { log "variant $v already done: skipped"; continue; }
unset LELEKA_PREFILL_LOAN_TIERS LELEKA_TRACE_PREFILL_R LELEKA_SERVE_PROFILE STRATA_VERIFY_PROFILE LELEKA_REFILL_DEFER LELEKA_BRINGUP_TRACE LELEKA_DRAFT_CHAIN_PIPELINE LELEKA_PREFIX_PARK_FAST LELEKA_PREFIX_PARK_ASYNC LELEKA_DRAFT_CHECK_MERGE LELEKA_TRACE_DRAFT LELEKA_PREFILL_GDN_TC LELEKA_DECODE_GRAPH_REUSE LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA LELEKA_PREFILL_ROUTE_TRACE STRATA_PREFILL_STREAM_MIN LELEKA_PREFILL_RING_PREFETCH LELEKA_PREFILL_RING_PREFETCH_WINDOW LELEKA_PREFILL_RING_PREFETCH_DETACH LELEKA_REFILL_BATCH LELEKA_REFILL_DEFER LELEKA_TRACE_DRIVER_ERRORS
case $vb in
A) ;;
L) export LELEKA_PREFILL_LOAN_TIERS=1;;
AR) export LELEKA_TRACE_PREFILL_R=1;;
LR) export LELEKA_PREFILL_LOAN_TIERS=1 LELEKA_TRACE_PREFILL_R=1;;
P) export LELEKA_SERVE_PROFILE=1;;
LP) export LELEKA_PREFILL_LOAN_TIERS=1 LELEKA_SERVE_PROFILE=1;;
LT) export LELEKA_PREFILL_LOAN_TIERS=1 LELEKA_BRINGUP_TRACE=1;;
C) export LELEKA_DRAFT_CHAIN_PIPELINE=1;;
CP) export LELEKA_DRAFT_CHAIN_PIPELINE=1 LELEKA_SERVE_PROFILE=1;;
AP) export LELEKA_SERVE_PROFILE=1;;
SP1) export STRATA_PREFILL_STREAM_MIN=1024 LELEKA_SERVE_PROFILE=1;; # chunks of 1024+ rows use the expert stream (vanilla default)
SP2) export STRATA_PREFILL_STREAM_MIN=256 LELEKA_SERVE_PROFILE=1;;
SR) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_TRACE_PREFILL_R=1;;
# the stream threshold of the 5090 profiles is part of the base for the prefetch and refill-batch arms
FR) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_TRACE_PREFILL_R=1;;
FP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;;
PE) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_DRIVER_ERRORS=1;;
PED) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_PREFILL_RING_PREFETCH_DETACH=1 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_DRIVER_ERRORS=1;;
PEDP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_PREFILL_RING_PREFETCH_DETACH=1 LELEKA_SERVE_PROFILE=1;;
PEP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_SERVE_PROFILE=1;;
PET) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_TRACE_DRIVER_ERRORS=1 LELEKA_SERVE_PROFILE=1;;
RB) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_REFILL_BATCH=1 LELEKA_TRACE_PREFILL_R=1;;
RBP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_REFILL_BATCH=1 LELEKA_SERVE_PROFILE=1;;
SRP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;;
APR) export LELEKA_SERVE_PROFILE=1 LELEKA_PREFILL_ROUTE_TRACE=1;;
RG) export LELEKA_DECODE_GRAPH_REUSE=1;;
RGP) export LELEKA_DECODE_GRAPH_REUSE=1 LELEKA_SERVE_PROFILE=1;;
RGT) export LELEKA_DECODE_GRAPH_REUSE=1 LELEKA_TRACE_DRAFT=1;;
GT) export LELEKA_PREFILL_GDN_TC=1;;
GTP) export LELEKA_PREFILL_GDN_TC=1 LELEKA_SERVE_PROFILE=1;;
GTD) export LELEKA_PREFILL_GDN_TC=1 LELEKA_TRACE_DRAFT=1;;
DT) export LELEKA_TRACE_DRAFT=1;;
MC) export LELEKA_DRAFT_CHECK_MERGE=1;;
MT) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_TRACE_DRAFT=1;;
MCP) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_SERVE_PROFILE=1;;
X) export LELEKA_DRAFT_CHAIN_PIPELINE=1 LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1;;
XT) export LELEKA_DRAFT_CHAIN_PIPELINE=1 LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_TRACE_DRAFT=1;;
Y) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_DECODE_GRAPH_REUSE=1;;
YP) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_DECODE_GRAPH_REUSE=1 STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;;
YRP) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_DECODE_GRAPH_REUSE=1 LELEKA_REFILL_DEFER=1 STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;;
DSP) export LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA=40000 LELEKA_SERVE_PROFILE=1;; # diagnostic, WRONG outputs: how much of moe.ring is bytes
PF) export LELEKA_PREFIX_PARK_FAST=1;;
PA) export LELEKA_PREFIX_PARK_FAST=1 LELEKA_PREFIX_PARK_ASYNC=1;;
PFP) export LELEKA_PREFIX_PARK_FAST=1 LELEKA_SERVE_PROFILE=1;;
PAP) export LELEKA_PREFIX_PARK_FAST=1 LELEKA_PREFIX_PARK_ASYNC=1 LELEKA_SERVE_PROFILE=1;;
*) echo "unknown variant $v"; continue;;
esac
export LELEKA_SPEC_STATS=1
: >"$ST/logs/engine.log" 2>/dev/null
nvidia-smi --query-gpu=timestamp,temperature.gpu,clocks.sm,clocks.mem,power.draw,utilization.gpu --format=csv -l 10 >"$D/mon.csv" 2>/dev/null & MON_PID=$!
log "variant $v: leleka up --foreground"
t0=$(date +%s)
setsid "$BIN/leleka" up --foreground $COMMON --timeout-s 1800 >"$D/up-foreground.txt" 2>&1 &
SUP_PID=$!
ready=0
for _ in $(seq 1 700); do "$PFX/bin/leleka" status --state-dir "$ST" >/dev/null 2>&1 && { ready=1; break; }; kill -0 "$SUP_PID" 2>/dev/null || break; sleep 3; done
[ $ready = 1 ] || { log "variant $v NOT READY"; tail -20 "$D/up-foreground.txt" | cut -c1-240; stop_stack; kill "$MON_PID" 2>/dev/null; continue; }
log "ready after $(( $(date +%s) - t0 )) s"
"$PFX/bin/leleka" status --state-dir "$ST" --json >"$D/status.json" 2>&1
args=(); for c in $CELLS; do args+=(--cell "$c"); done
python3 -I "$PL/tools/${PF_CLIENT:-replay_hash.py}" "${args[@]}" --url http://127.0.0.1:8081 --model qwen-iq3 --key-file "$ST/api-key" --out "$D/replay.jsonl" --max-requests "$MAXR" >"$D/replay.out" 2>&1
log "replay rc=$? $(wc -l <"$D/replay.jsonl") requests"
cp "$ST/logs/engine.log" "$D/engine.log" 2>/dev/null; cp "$ST/logs/requests.log" "$D/requests.log" 2>/dev/null
stop_stack; kill "$MON_PID" 2>/dev/null; MON_PID=
sleep 5
done
log "done"
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/env bash
# Prefill fixed-latency program: one full Codex session block (smoke-mini warm-up, then the requested tasks) of OUR stack from the prefill-latency
# package (pkg/bin, own state and prefix, never the codex-compare release state). A copy of the `ours` arm of compare/cmp_codex_job.sh.
# HOLDER JOB (inherits the sealed KAR memfd). Test tooling, never in serving.
# PF_VAR result variant name, one directory under $PF_RUN (default LEL-A)
# PF_ENV engine environment of the `leleka up` process, space separated NAME=VALUE (default none = shipped)
# LEL-A: none (shipped, the prompt loan is the full 8192-row loan) LEL-L: LELEKA_PREFILL_LOAN_TIERS=1
# PF_TASKS tasks (default "nestng-crm") PF_REPS repetitions (default "1") PF_WALL cell wall limit s (3000) PF_ROUNDS round cap (150)
# PF_RUN result directory (default $PL/runs/codex) PF_ROOT task directory (default /data/leleka-e2e/prefill-latency)
# Cells: cell.py of the codex-compare study (logging proxy, temperature 0 injected, real Codex CLI, task acceptance), identical to the LEL/VAN/VANL cells.
set -uo pipefail
PL=${PF_ROOT:-/data/leleka-e2e/prefill-latency}
CMP=/data/leleka-e2e/codex-compare
VAR=${PF_VAR:-LEL-A}
TASKS=${PF_TASKS:-nestng-crm}; REPS=${PF_REPS:-1}
RUN=${PF_RUN:-$PL/runs/codex}
WALL=${PF_WALL:-3000}; ROUNDS=${PF_ROUNDS:-150}
TASKS_ROOT=$CMP/tasks; CELLPY=$CMP/delta/cell.py
CODEX=/home/para/work/codex-e2e/bin/codex
LOCK=/data/leleka-e2e/gpu.lock
G=$HOME/work/gpu-runs
CUBLAS=$HOME/cuda-toolkits/cublas-12.9.1.4/lib
NODE_BIN=$(ls -d "$CMP"/toolchain/node-v*-linux-x64/bin 2>/dev/null | tail -1)
NM=$CMP/nm
BLK=$(echo "$REPS" | tr ' ' '+')
mkdir -p "$RUN/$VAR"
exec > >(tee -a "$RUN/job-$VAR-r$BLK.log") 2>&1
log() { echo "[pfc $VAR $(date -u +%T)] $*"; }
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >>/data/leleka-e2e/decode/notes.md; }
AS=$CMP/ours-assets; ST=$PL/state; PFX=$PL/prefix; BIN=$PL/pkg/bin
FD=${LELEKA_STRA169_KAR_FD:-}
( cd "$CMP" && sha256sum --quiet -c INSTALL.sha256 ) || { echo "installed tools differ from INSTALL.sha256"; exit 3; }
python3 -I "$CMP/delta/taskfile.py" check "$TASKS_ROOT" >"$RUN/tasks-check-$VAR.txt" 2>&1 || { echo "task files differ from their manifest"; exit 3; }
[ -f "$CMP/toolchain/NESTNG_OK" ] && [ -d "$NM/backend/node_modules" ] || { echo "nestng-crm toolchain is not ready"; exit 3; }
[ -x "$CODEX" ] && [ -n "$NODE_BIN" ] && [ -x "$NODE_BIN/node" ] || { echo "no codex or node toolchain"; exit 3; }
[ -x "$BIN/leleka" ] && [ -f "$ST/leleka.json" ] || { echo "the prefill-latency package or state is not prepared"; exit 3; }
(cd "$PL/pkg/bin" && sha256sum -c ../SHA256SUMS >/dev/null 2>&1) || { echo "the package binaries do not match $PL/pkg/SHA256SUMS"; exit 3; }
readlink "/proc/self/fd/$FD" 2>/dev/null | grep -q '^/memfd:' || { echo "needs the holder's sealed memfd"; exit 3; }
[ -d "$G/MODEL.lock" ] || { echo "MODEL.lock is not held"; exit 3; }
got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "prefill-codex $VAR $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; }
SUP_PID=; MON_PID=; PSI_PID=; TAIL_PID=
stop_stack() { if [ -n "$SUP_PID" ] && kill -0 "$SUP_PID" 2>/dev/null; then kill -TERM "$SUP_PID" 2>/dev/null; for _ in $(seq 1 120); do kill -0 "$SUP_PID" 2>/dev/null || break; sleep 2; done; fi; SUP_PID=; }
cleanup() { stop_stack; [ -n "$MON_PID" ] && kill "$MON_PID" 2>/dev/null; [ -n "$PSI_PID" ] && kill "$PSI_PID" 2>/dev/null; [ -n "$TAIL_PID" ] && pkill -P "$TAIL_PID" 2>/dev/null; pkill -KILL -f "$PFX/bin/" 2>/dev/null; sleep 3; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; note "prefill codex block $VAR ended: $RUN"; }
trap cleanup EXIT
note "prefill codex block $VAR started: $RUN tasks=[$TASKS] reps=[$REPS] env=[${PF_ENV:-}]"
[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; }
if pgrep -u "$USER" -x 'leleka-inference|strata-next|leleka-daemon' >/dev/null; then echo "a stack process exists"; exit 3; fi
for p in 18766 18080 8081 8090; do ss -ltn "sport = :$p" 2>/dev/null | grep -q LISTEN && { echo "port $p in use"; exit 3; }; done
export LD_LIBRARY_PATH=$CUBLAS:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
export PATH=$NODE_BIN:$PATH NG_CLI_ANALYTICS=false npm_config_cache=/tmp/cmp-npm-cache npm_config_update_notifier=false npm_config_fund=false npm_config_audit=false CI=1
unset LELEKA_PREFILL_LOAN_TIERS LELEKA_TRACE_PREFILL_R LELEKA_SERVE_PROFILE LELEKA_REFILL_DEFER LELEKA_BRINGUP_TRACE
for kv in ${PF_ENV:-}; do export "$kv"; done
export LELEKA_SPEC_STATS=1
STK=$RUN/$VAR/stack-r$BLK; mkdir -p "$STK"
{ date -u +%FT%TZ; uname -r; nvidia-smi --query-gpu=name,driver_version,power.limit --format=csv,noheader; free -g | sed -n 2p; cat "$PL/pkg/COMMIT.txt"; env | grep -E '^(LELEKA_|STRATA_)' | grep -v KEY | sort; } | tee "$STK/host.txt"
nvidia-smi --query-gpu=timestamp,temperature.gpu,clocks.sm,clocks.mem,power.draw,utilization.gpu --format=csv -l 10 >"$STK/mon.csv" 2>/dev/null & MON_PID=$!
# Host memory counters (pf_memstat.sh: memstat.csv every 0.25 s, memstat.mem.csv every 15 s): a stall of the host-only spans (`input`, `other`) is matched against them by the request timestamps.
bash "$PL/tools/pf_memstat.sh" "$STK/memstat" & PSI_PID=$!
# The engine log rotates at 16 MiB and the rotated files are overwritten by the next run: keep the profile lines of the whole session (epoch ms first).
( tail -n 0 -F "$ST/logs/engine.log" 2>/dev/null | grep --line-buffered -a -E 'PREFILL-PROFILE|DBG profile request|"ev":"request"' | while IFS= read -r l; do echo "$(date +%s%3N) $l"; done ) >"$STK/prof.log" 2>/dev/null & TAIL_PID=$!
COMMON="--assets $AS --state-dir $ST --prefix $PFX --bin-src $BIN --cublas-dir $CUBLAS --trust-archive --kar-fd $FD"
: >"$ST/logs/engine.log" 2>/dev/null
t0=$(date +%s)
setsid "$BIN/leleka" up --foreground $COMMON --timeout-s 1800 >"$STK/up-foreground.txt" 2>&1 &
SUP_PID=$!
ready=0
for _ in $(seq 1 700); do "$PFX/bin/leleka" status --state-dir "$ST" >/dev/null 2>&1 && { ready=1; break; }; kill -0 "$SUP_PID" 2>/dev/null || break; sleep 3; done
[ $ready = 1 ] || { log "NOT READY"; tail -20 "$STK/up-foreground.txt" | cut -c1-240; exit 7; }
log "ready after $(( $(date +%s) - t0 )) s"
"$PFX/bin/leleka" status --state-dir "$ST" --json >"$STK/status.json" 2>&1
KEY=$(cat "$ST/api-key")
for rep in $REPS; do
list="smoke-mini $TASKS"
for task in $list; do
CELL=$RUN/$VAR/$task-r$rep; [ "$task" = smoke-mini ] && CELL=$RUN/$VAR/smoke-mini-r$((100 + rep))
[ -f "$CELL/cell.json" ] && { log "cell $CELL already done: skipped"; continue; }
link=""; [ "$task" = nestng-crm ] && link="--link-tree backend/node_modules=$NM/backend/node_modules --link-tree frontend/node_modules=$NM/frontend/node_modules"
t1=$(date +%s)
E2E_API_KEY=$KEY CLD_CODEX=$CODEX timeout $((WALL + 900)) python3 -I "$CELLPY" --cell-dir "$CELL" --variant "$VAR" --task "$task" \
--rep "$([ "$task" = smoke-mini ] && echo $((100 + rep)) || echo $rep)" --tasks-root "$TASKS_ROOT" --upstream http://127.0.0.1:8081 --upstream-model qwen-iq3 \
--codex-bin "$CODEX" --wall-limit "$WALL" --max-rounds "$ROUNDS" --engine-log "$ST/logs/engine.log" --active-dir "$RUN/active-$VAR" \
--config-extra 'model_auto_compact_token_limit = 100000000' $link >"$CELL.out" 2>&1
log "cell $VAR $task r$rep rc=$? $(( $(date +%s) - t1 )) s: $(tail -1 "$CELL.out" | cut -c1-200)"
done
done
cp "$ST/logs/engine.log" "$STK/engine.log" 2>/dev/null; cp "$ST/logs/requests.log" "$STK/requests.log" 2>/dev/null
stop_stack
log "done"
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# GPU-ignored unit tests of the driver crate (`cargo test -p leleka-cuda-driver --features cuda-driver --lib`), run from the release test binary of a package.
# HOLDER JOB (same GPU lock and holder checks as pf_ab_job.sh). Test tooling, never in serving.
# PF_TEST_BIN the test binary (built with `cargo test --release --no-run`; sha256 is recorded in the log)
# PF_TEST_FILTERS space separated test name filters; each runs as `BIN --ignored --test-threads=1 --nocapture FILTER`
# PF_OUT result directory (one <filter>.log per filter and a summary.txt)
set -uo pipefail
RUN=${PF_OUT:?}
BIN=${PF_TEST_BIN:?}
FILTERS=${PF_TEST_FILTERS:?}
LOCK=/data/leleka-e2e/gpu.lock
G=$HOME/work/gpu-runs
CUBLAS=$HOME/cuda-toolkits/cublas-12.9.1.4/lib
FD=${LELEKA_STRA169_KAR_FD:-}
mkdir -p "$RUN"
exec > >(tee -a "$RUN/job-$(date -u +%H%M%S).log") 2>&1
log() { echo "[pf $(date -u +%T)] $*"; }
readlink "/proc/self/fd/$FD" 2>/dev/null | grep -q '^/memfd:' || { echo "needs the holder's sealed memfd"; exit 3; }
[ -d "$G/MODEL.lock" ] || { echo "MODEL.lock is not held"; exit 3; }
[ -x "$BIN" ] || { echo "no test binary $BIN"; exit 3; }
got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "prefill-latency $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; }
cleanup() { rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; }
trap cleanup EXIT
[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; }
export LD_LIBRARY_PATH=$CUBLAS:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
log "binary $(sha256sum "$BIN" | cut -c1-16) filters [$FILTERS]"
: > "$RUN/summary.txt"
for f in $FILTERS; do
nice -n 5 "$BIN" --ignored --test-threads=1 --nocapture "$f" > "$RUN/$f.log" 2>&1; rc=$?
echo "$f rc=$rc $(grep -a -E '^test result' "$RUN/$f.log" | tail -1)" | tee -a "$RUN/summary.txt"
done
log done
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# The lab holder with the SPARSE seal (`--sparse-ple`: the 14.9 GiB the serve path reads), HOLDER_MEMFD=full for the old full 55.3 GB copy. Same as scripts/e2e/decode/single-copy-holder.sh
# of the repository (claude/single-copy-ram 9c77d603d); the Python queue process stays /data/leleka-e2e/single-copy/tools/single-copy-holder.py. Same MODEL.lock contract.
set -u
BIN=${1:-/data/leleka-e2e/decode/dt/bin-singlecopy}
T=/data/leleka-e2e/single-copy/tools
KAR=/home/para/work/leleka/models/leleka-gates/assets/qwen-iq3-s-l2-v4.kar
JOBS=$HOME/work/gpu-runs/holder2/jobs
until mkdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null; do sleep 20; done
trap 'rmdir "$HOME/work/gpu-runs/MODEL.lock"' EXIT
cd "$HOME/work/gpu-runs/holder2" || exit 1
rm -f "$JOBS/READY"
exec_start=$(date +%s)
SPARSE=--sparse-ple; [ "${HOLDER_MEMFD:-sparse}" = full ] && SPARSE=
LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} "$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 $SPARSE -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS"
echo "holder3 ended rc=$? after $(( $(date +%s) - exec_start )) s"
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Safety net of the lab queue (test tooling, never in serving): the holder (the queue executor, `single-copy-holder.py` under `seal-exec`) must
# answer. Every 60 s: if no holder process runs, no window script is about to start one (jobs/STOP, a *_window.sh process, a running
# pf_holder_sparse.sh) and the condition held for two checks in a row, start the SPARSE holder (`pf_holder_sparse.sh`), wait for jobs/READY,
# and write the alert to decode/notes.md (also when READY does not come in 10 minutes: then the next round tries again).
# Cause of the 2026-11-10 19:20-20:20 idle GPU: a window script ran `nohup HOLDER_MEMFD=sparse bash ...` (the variable is not a command), the holder never came back.
set -u
PL=/data/leleka-e2e/prefill-latency
H=$HOME/work/gpu-runs/holder2
NOTES=/data/leleka-e2e/decode/notes.md
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] holder watchdog: $*" >> "$NOTES"; }
holder_up() { pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py|pf_holder_sparse\.sh|leleka seal-exec' >/dev/null; }
window_pending() { [ -e "$H/jobs/STOP" ] || pgrep -u "$USER" -f '_window\.sh' >/dev/null; }
misses=0
while true; do
if holder_up || window_pending; then misses=0; sleep 60; continue; fi
misses=$((misses + 1))
if [ "$misses" -lt 2 ]; then sleep 60; continue; fi
note "no holder process and no window pending for two checks: starting the sparse holder (holder3.out = $(tail -c 160 "$H/holder3.out" 2>/dev/null | tr '\n' ' '))"
rm -f "$H/jobs/READY"
( cd "$H" && HOLDER_MEMFD=sparse setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & )
for _ in $(seq 1 120); do [ -f "$H/jobs/READY" ] && break; sleep 5; done
if [ -f "$H/jobs/READY" ]; then note "holder ready: $(grep -a 'holder3 ready' "$H/holder3.out" | tail -1)"; else note "ALERT holder not ready after 10 min; $(tail -c 200 "$H/holder3.out" | tr '\n' ' ')"; fi
misses=0
done
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Prefill fixed-latency program: restart the lab holder with a SPARSE sealed memfd (docs/design/single-copy-ram-2026-11-09.md, step 1) and record what it frees.
# A holder-free window started DETACHED by a queue stub that has touched jobs/STOP and closed the holder's descriptor. Test tooling, never in serving. pf_holder_window.sh LABEL [full]
# 1. waits until the lab holder has ended and its memfd is gone; 2. records the host memory (before); 3. starts the holder with the sparse seal (the `full` argument: the old full copy);
# 4. waits for jobs/READY and records the host memory (after) and the holder's `ready ... allocated=` line. Records: $PL/runs/holder/LABEL.txt, notes.md.
set -u
LABEL=${1:-holder}; FORM=${2:-sparse}
PL=/data/leleka-e2e/prefill-latency
H=$HOME/work/gpu-runs/holder2
NOTES=/data/leleka-e2e/decode/notes.md
OUT=$PL/runs/holder; mkdir -p "$OUT"
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >> "$NOTES"; }
snap() { echo "== $1 $(date -u +%FT%TZ)"; grep -E '^(MemTotal|MemFree|MemAvailable|Cached|Shmem|AnonPages|Mapped):' /proc/meminfo; head -2 /proc/pressure/memory; grep -E '^(allocstall_normal|allocstall_movable|pgscan_direct|compact_stall|workingset_refault_file) ' /proc/vmstat; }
holder_up() { pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; }
note "holder window $LABEL: waiting for the holder to end (jobs/STOP is set), then a $FORM holder"
for _ in $(seq 1 1440); do if ! holder_up && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi; sleep 5; done
if holder_up; then note "holder window $LABEL: the holder did not end in 2 h, giving up"; exit 3; fi
sleep 5
{ snap before; } >"$OUT/$LABEL.txt" 2>&1
rm -f "$H/jobs/STOP" "$H/jobs/READY"
( cd "$H" && unset CMP_ARM CMP_TASKS CMP_OPTIONAL CMP_REPS CMP_VANILLA_LOSSY CMP_WALL CMP_ROUNDS CMP_RUN CMP_TARBALL PF_VAR PF_ENV PF_REPS PF_TASKS PF_RUN \
&& HOLDER_MEMFD=$FORM setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & )
for _ in $(seq 1 360); do [ -f "$H/jobs/READY" ] && break; sleep 5; done
sleep 20
{ snap after; echo "== holder3.out"; grep -a "holder3 ready\|sealed memfd" "$H/holder3.out"; } >>"$OUT/$LABEL.txt" 2>&1
note "holder window $LABEL: $FORM holder started; $(grep -a 'holder3 ready' "$H/holder3.out" | tail -1); Shmem $(awk '/^Shmem:/{printf "%.1f GiB", $2/1048576}' /proc/meminfo), MemAvailable $(awk '/^MemAvailable:/{printf "%.1f GiB", $2/1048576}' /proc/meminfo); record $OUT/$LABEL.txt"
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Prefill fixed-latency program: host memory sampler, one per session (test tooling, never in serving). pf_memstat.sh OUT_PREFIX
# OUT_PREFIX.csv every 0.25 s: epoch_ms, PSI memory some/full total (us), direct-reclaim stalls (sum of allocstall_*), major faults, direct scans,
# compaction stalls (system wide), then the engine process: pid, major faults, minor faults, then PSI cpu some total (us) and the summed run-queue wait
# (run_delay, ns) of all threads of the engine process, then PSI io some total (us) and the engine's syscr/read_bytes (unset when unreadable)
# OUT_PREFIX.mem.csv every 15 s: epoch_ms, MemAvailable, MemFree, Cached, Shmem, Mapped, Active(file), Inactive(file) (kB), engine RssAnon, RssFile, RssShmem (kB)
# The engine process is the leleka-inference (ours) or the vanilla Strata engine binary, found by name; 0 when none runs.
OUT=${1:?OUT_PREFIX}
engine_pid() { pgrep -u "$USER" -f 'leleka-inference|components/engine/[^ ]*/strata' 2>/dev/null | head -1; }
pid=; n=0
while :; do
{ [ -n "$pid" ] && [ -r "/proc/$pid/stat" ]; } || pid=$(engine_pid)
sys=$(awk '/^allocstall_/{a+=$2} /^pgmajfault /{m=$2} /^pgscan_direct /{d=$2} /^compact_stall /{c=$2} END{print a","m","d","c}' /proc/vmstat)
psi=$(awk '/^some/{split($5,s,"=")} /^full/{split($5,f,"=")} END{print s[2]","f[2]}' /proc/pressure/memory 2>/dev/null)
proc=0,0,0; [ -n "$pid" ] && proc=$(awk -v p="$pid" '{sub(/^[^)]*\) /,""); split($0,a," "); print p","a[10]","a[8]}' "/proc/$pid/stat" 2>/dev/null || echo "$pid,0,0")
cpu=$(awk '/^some/{split($5,s,"=")} END{print s[2]}' /proc/pressure/cpu 2>/dev/null)
rd=0; [ -n "$pid" ] && rd=$(cat /proc/"$pid"/task/*/schedstat 2>/dev/null | awk '{d+=$2} END{print d+0}')
io=$(awk '/^some/{split($5,s,"=")} END{print s[2]}' /proc/pressure/io 2>/dev/null)
rb=0; [ -n "$pid" ] && rb=$(awk '/^(read_bytes|syscr):/{printf "%s%s",(c++?"/":""),$2}' "/proc/$pid/io" 2>/dev/null)
echo "$(date +%s%3N),$psi,$sys,$proc,$cpu,$rd,$io,${rb:-0}" >>"$OUT.csv"
if [ $((n % 60)) = 0 ]; then
mi=$(awk '{v[$1]=$2} END{print v["MemAvailable:"]","v["MemFree:"]","v["Cached:"]","v["Shmem:"]","v["Mapped:"]","v["Active(file):"]","v["Inactive(file):"]}' /proc/meminfo)
rs=0,0,0; [ -n "$pid" ] && rs=$(awk '/^RssAnon:/{a=$2} /^RssFile:/{f=$2} /^RssShmem:/{s=$2} END{print a","f","s}' "/proc/$pid/status" 2>/dev/null)
echo "$(date +%s%3N),$mi,$rs" >>"$OUT.mem.csv"
fi
n=$((n + 1)); sleep 0.25
done
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
"""Prefill fixed-latency program, step-ledger rows A1-A3 and B2: the "empty request" probe (test tooling, stdlib only).
A stack under test answers requests that do almost no model work, so what is left is the path of a request INTO the engine (HTTP and gateway, tokenizer and
prompt assembly, prefix-cache lookup and import) and the first token:
tiny a one-line prompt, one output token -> floor of HTTP + gateway + tokenizer + first token
cold request SEQ of a recorded cell as recorded, one output token (the prompt is read, not cached; not a probe of the intake, a reference)
cached the same body again, REPS times, one output token -> intake + tokenizer of a long prompt + prefix-cache lookup/import + first token
tiny again, REPS times
Same body and same client for every stack (the recorded forward bodies of a codex-compare cell, like replay_hash.py), so the differences are the stacks'.
One JSON line per request: probe, i, wall and first-event seconds, input/cached/output tokens. Usage:
pf_probe.py --cell DIR --url http://127.0.0.1:8081 --model qwen-iq3 --key-file FILE --out probe.jsonl [--seq 29] [--reps 5]
"""
import argparse
import gzip
import json
import os
import sys
import time
import urllib.error
import urllib.request
def send(url, hdr, body, timeout):
data = json.dumps(body).encode()
t0 = time.time()
rec = {"req_bytes": len(data)}
try:
req = urllib.request.Request(url.rstrip("/") + "/v1/responses", data=data, headers=hdr, method="POST")
with urllib.request.urlopen(req, timeout=timeout) as r:
rec["status"] = r.status
first = None
last = b""
for line in r:
if first is None:
first = time.time() - t0
if line.startswith(b"data:") and b"response.completed" in line:
last = line
rec["t_first_s"] = round(first or 0, 4)
if last:
u = json.loads(last[5:]).get("response", {}).get("usage", {})
rec["input_tokens"] = u.get("input_tokens")
rec["output_tokens"] = u.get("output_tokens")
rec["cached_tokens"] = (u.get("input_tokens_details") or {}).get("cached_tokens")
except urllib.error.HTTPError as e:
rec["error"] = "HTTP %d %s" % (e.code, e.read()[:300].decode("utf-8", "replace"))
except Exception as e: # recorded, the probe goes on
rec["error"] = repr(e)[:200]
rec["wall_s"] = round(time.time() - t0, 4)
return rec
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--cell", action="append", required=True)
ap.add_argument("--url", required=True)
ap.add_argument("--model", required=True)
ap.add_argument("--key-file", default="")
ap.add_argument("--out", required=True)
ap.add_argument("--max-requests", type=int, default=0, help="accepted for the replay_hash.py command line; unused")
ap.add_argument("--seq", type=int, default=29, help="1-based number of the recorded request used as the long prompt")
ap.add_argument("--reps", type=int, default=5)
ap.add_argument("--timeout", type=int, default=900)
a = ap.parse_args()
key = open(a.key_file).read().strip() if a.key_file else ""
rounds = os.path.join(a.cell[0], "proxy", "rounds")
names = sorted(n for n in os.listdir(rounds) if n.endswith(".fwd.json.gz"))
body = json.loads(gzip.open(os.path.join(rounds, names[a.seq - 1])).read())
body["model"] = a.model
body["temperature"] = 0.0
body["max_output_tokens"] = 1
# a vanilla session's reasoning blob is refused by Leleka (HTTP 400); its own sessions keep None there
for it in body.get("input") or []:
if isinstance(it, dict) and it.get("type") == "reasoning" and it.get("encrypted_content"):
it["encrypted_content"] = None
sid = body.get("prompt_cache_key") or ""
hdr = {"Content-Type": "application/json", "Accept": "text/event-stream", "session-id": sid, "thread-id": sid, "x-codex-window-id": sid + ":0"}
if key:
hdr["Authorization"] = "Bearer " + key
tiny = {
"model": a.model,
"input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Say ok."}]}],
"stream": True,
"temperature": 0.0,
"max_output_tokens": 1,
}
plan = [("tiny", tiny)] * 2 + [("cold", body)] + [("cached", body)] * a.reps + [("tiny", tiny)] * a.reps
out = open(a.out, "a", encoding="utf-8")
seen = {}
for label, b in plan:
seen[label] = seen.get(label, 0) + 1
rec = {"probe": label, "i": seen[label], "seq": a.seq}
rec.update(send(a.url, hdr, b, a.timeout))
out.write(json.dumps(rec) + "\n")
out.flush()
print(json.dumps(rec), flush=True)
time.sleep(0.5)
return 0
if __name__ == "__main__":
sys.exit(main())
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Prefill fixed-latency program: put a job back in the queue behind a SPARSE lab holder. Started DETACHED by pf_ab_job.sh (guard: the inherited sealed memfd is not
# sparse), after the job has touched jobs/STOP and closed the holder's descriptor and exited. Waits for the holder to end, starts the sparse one (pf_holder_window.sh),
# then removes JOB.done so the new holder's queue picks the job again (its name stays in jobs/PRIORITY). pf_sparse_requeue.sh JOBNAME. Test tooling, never in serving.
set -u
JOB=${1:?job name}
PL=/data/leleka-e2e/prefill-latency
J=$HOME/work/gpu-runs/holder2/jobs
NOTES=/data/leleka-e2e/decode/notes.md
echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $JOB found a non-sparse memfd: sparse holder restart, then $JOB runs again" >> "$NOTES"
bash "$PL/tools/pf_holder_window.sh" "requeue-$JOB" sparse
for _ in $(seq 1 60); do [ -f "$J/READY" ] && break; sleep 5; done
rm -f "$J/$JOB.done"
echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $JOB queued again behind the sparse holder" >> "$NOTES"
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Prefill fixed-latency program (step ledger A1-A3): vanilla Strata 0.2.6 answering the empty-request probe (pf_probe.py) instead of the replay; a copy of spd-gap/tools/spd_van_job2.sh without
# the engine-side profile. Holder-free window payload (started by spd_window.sh). Test tooling, never in serving.
set -uo pipefail
SPD=/data/leleka-e2e/spd-gap
PL=/data/leleka-e2e/prefill-latency
CMP=/data/leleka-e2e/codex-compare
A=/home/para/work/leleka/models/leleka-gates/assets
G=$HOME/work/gpu-runs
LOCK=/data/leleka-e2e/gpu.lock
LOSSY=${SPD_LOSSY:-0}
RUN=${SPD_RUN:-$PL/runs/probe/VANL}
CELLS=${SPD_CELLS:-"$CMP/runs/main/VANL/nestng-crm-r2"}
MAXR=${SPD_MAX:-30}
mkdir -p "$RUN"
exec > >(tee -a "$RUN/job.log") 2>&1
log() { echo "[spd-van $(date -u +%T)] $*"; }
mkdir "$G/MODEL.lock" 2>/dev/null || { echo "MODEL.lock is held (holder still up?)"; exit 3; }
got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "spd-gap vanilla $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; rmdir "$G/MODEL.lock"; exit 3; }
S=$HOME/work/vanilla-strata/control/bin/strata
cleanup() { ( cd "$HOME/work/vanilla-strata/control" && "$S" launch --stop >/dev/null 2>&1 ); sleep 5; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; rmdir "$G/MODEL.lock" 2>/dev/null; }
trap cleanup EXIT
[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; }
export XDG_CONFIG_HOME=$RUN/xdg-config XDG_STATE_HOME=$RUN/xdg-state
mkdir -p "$XDG_CONFIG_HOME/strata" "$XDG_STATE_HOME"; cp ~/.config/strata/settings.json "$XDG_CONFIG_HOME/strata/"
if [ "$LOSSY" = 1 ]; then unset STRATA_ROUTE_TAIL_SKIP STRATA_PREFILL_CPU_SHARE; else export STRATA_ROUTE_TAIL_SKIP=0 STRATA_PREFILL_CPU_SHARE=0; fi
export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
cd "$HOME/work/vanilla-strata/control"
t0=$(date +%s)
timeout 2400 "$S" launch --model iq3_s --family qwen --model-path "$A/model" --context 256k --kv int8 --vision off --parallel 1 --tune skip --access local --port 8090 --no-api-key --no-tui --yes >"$RUN/launch.out" 2>&1
log "launch rc=$? ready after $(( $(date +%s) - t0 )) s"
curl -fs http://127.0.0.1:8090/v1/models >"$RUN/models.json" || { log "vanilla did not become ready"; exit 4; }
MODEL=$(python3 -c "import json;print(json.load(open('$RUN/models.json'))['data'][0]['id'])")
args=(); for c in $CELLS; do args+=(--cell "$c"); done
python3 -I "$PL/tools/pf_probe.py" "${args[@]}" --url http://127.0.0.1:8090 --model "$MODEL" --out "$RUN/replay.jsonl" --max-requests "$MAXR" >"$RUN/replay.out" 2>&1
log "replay rc=$? $(wc -l <"$RUN/replay.jsonl") requests"
cp "$XDG_STATE_HOME/strata/launch/iq3_s-256k.engine.log" "$RUN/engine.log" 2>/dev/null
log "done"
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Prefill fixed-latency program: a copy of codex-compare/tools/cmp_window.sh for the vanilla arm (variant VANL) that records the host memory counters of the session
# (pf_memstat.sh: memstat.csv / memstat.mem.csv next to the stack directory) and writes its results under the prefill-latency task directory. pf_van_window.sh LABEL
# A holder-free window started DETACHED by a queue stub that has touched jobs/STOP and closed the holder's descriptor. Test tooling, never in serving.
# 1. waits until the lab holder has ended and its memfd is gone; 2. runs codex-compare/tools/cmp_codex_job.sh (unchanged, CMP_* from the stub); 3. ALWAYS restarts the lab holder.
set -u
LABEL=${1:-window}
C=/data/leleka-e2e/codex-compare
PL=/data/leleka-e2e/prefill-latency
H=$HOME/work/gpu-runs/holder2
NOTES=/data/leleka-e2e/decode/notes.md
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >> "$NOTES"; }
SAMPLER=
restart_holder() {
[ -n "$SAMPLER" ] && kill "$SAMPLER" 2>/dev/null
if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then echo "a holder is already running"; return; fi
rmdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null
rm -f "$H/jobs/STOP" "$H/jobs/READY"
( cd "$H" && unset CMP_ARM CMP_TASKS CMP_OPTIONAL CMP_REPS CMP_VANILLA_LOSSY CMP_WALL CMP_ROUNDS CMP_RUN CMP_TARBALL && setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & )
note "window $LABEL over: holder restarted with single-copy-holder.sh (holder3.out); queue open again"
}
trap restart_holder EXIT
note "window $LABEL: waiting for the holder to end (jobs/STOP is set), then cmp_codex_job.sh: arm=${CMP_ARM:-?} reps=[${CMP_REPS:-}] tasks=[${CMP_TASKS:-}] run=${CMP_RUN:-}"
for _ in $(seq 1 1440); do
if ! pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi
sleep 5
done
if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then note "window $LABEL: the holder did not end in 2 h, giving up (holder left as it is)"; trap - EXIT; exit 3; fi
sleep 5
note "window $LABEL: holder gone, MemAvailable $(awk '/^MemAvailable:/{printf "%d GiB", $2/1048576}' /proc/meminfo); starting"
OUTD=${CMP_RUN:-$PL/runs/van}/VANL; mkdir -p "$OUTD"
bash "$PL/tools/pf_memstat.sh" "$OUTD/memstat-r$(echo "${CMP_REPS:-1}" | tr ' ' '+')" & SAMPLER=$!
bash "$C/tools/cmp_codex_job.sh" > "$PL/window-$LABEL.out" 2>&1
note "window $LABEL: cmp_codex_job.sh ended rc=$?; log $PL/window-$LABEL.out"
+5 -1
View File
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
# Start the lab holder with the fast, page-cache-free seal (see single-copy-holder.py). Same MODEL.lock contract as run_holder2.sh.
# single-copy-holder.sh [BIN_DIR] BIN_DIR holds `leleka` (default /data/leleka-e2e/decode/dt/bin-singlecopy)
# The memfd is SPARSE by default (`--sparse-ple`: only the 14.9 GiB the serve path reads; holes elsewhere), the form of profile rtx5090-32g. A full 55.3 GB memfd is a second
# copy of model bytes next to the resident expert bank (36.6 GiB nobody reads; the 2026-11-09 server measurement, docs/design/single-copy-ram-2026-11-09.md), and `leleka run`
# now refuses it for a ple_only profile. HOLDER_MEMFD=full restores the full copy (jobs whose profile is memfd_extents=full, with LELEKA_ALLOW_FULL_MEMFD=1 where needed).
# Run it detached: cd ~/work/gpu-runs/holder2 && rm -f jobs/STOP && setsid nohup bash /data/leleka-e2e/single-copy/tools/single-copy-holder.sh > holder3.out 2>&1 &
set -u
BIN=${1:-/data/leleka-e2e/decode/dt/bin-singlecopy}
@@ -12,5 +15,6 @@ trap 'rmdir "$HOME/work/gpu-runs/MODEL.lock"' EXIT
cd "$HOME/work/gpu-runs/holder2" || exit 1
rm -f "$JOBS/READY"
exec_start=$(date +%s)
LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} "$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS"
SPARSE=--sparse-ple; [ "${HOLDER_MEMFD:-sparse}" = full ] && SPARSE=
LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} "$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 $SPARSE -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS"
echo "holder3 ended rc=$? after $(( $(date +%s) - exec_start )) s"
+48
View File
@@ -955,6 +955,54 @@
"group": "draft-round",
"optional": false
},
{
"cu": "crates/cuda-driver/src/mtp_original_check_batch.cu",
"ptx": "crates/cuda-driver/src/mtp_original_check_batch.ptx",
"flags": [
"-ptx",
"-O3",
"-arch=sm_120",
"-std=c++17",
"--fmad=true",
"--ftz=false"
],
"policy": "precise (the recipe of scripts/build-original-verify-ptx.sh, which built the single-check kernels this one batches; the predicate is the same abs + setp.ne inf)",
"entries": [
"mtp_original_check_batch"
],
"encoding": "include_bytes",
"group": "draft-check-batch",
"optional": false
},
{
"cu": "crates/cuda-driver/src/gdn_prefill_tc.cu",
"ptx": "crates/cuda-driver/src/gdn_prefill_tc.ptx",
"flags": [
"-ptx",
"-O3",
"-arch=sm_120",
"-std=c++17",
"--ftz=false",
"--prec-div=true",
"--prec-sqrt=true",
"--fmad=true"
],
"policy": "precise (the recipe of prefill_stage; EXPERIMENTAL and LOSSY by design, LELEKA_PREFILL_GDN_TC: the prompt GDN recurrence as a chunked scan on f16x3 tensor-core products, a port of Strata upstream gdn_tc.cuh, not bitwise equal to leleka_prefill_gdn_rec_kh; the lossy gate of docs/quality-gate.md decides)",
"entries": [
"leleka_gdn_tc_prep",
"leleka_gdn_tc_scan_t1",
"leleka_gdn_tc_scan_t2"
],
"encoding": "concat_include_str",
"rust_fields_to_fill": {
"gdn_prefill_tc.rs": [
"PIN.source_sha256",
"PIN.ptx_sha256"
]
},
"group": "gdn-prefill-tc",
"optional": false
},
{
"cu": "crates/cuda-driver/src/original_verify_window_qsa_kv_rows.cu",
"ptx": "crates/cuda-driver/src/original_verify_window_qsa_kv_rows.ptx",