File size: 1,892 Bytes
b324599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
# Profile the resident Fast-WAM runtime on the IQ-9075 — from the host, one command.
#
# Copies the LATEST runtime/*.py from this repo to an EPHEMERAL workspace under the
# device's /tmp, symlinks the heavy assets (ctx/ golden/ qnn_libs/ dsp_libs/) from the
# persistent /root/fastwam_workspace (no multi-GB copy), runs resident_run.py, prints the
# latency table + per-step pure [infer-ms], then deletes the temp dir. Nothing persistent
# is modified.
#
# Usage (fp16 default; A/B a quantized action bin via env):
#   runtime/profile_device.sh
#   runtime/profile_device.sh ACTION_CTX_SUFFIX=_w4a16
#
# Device creds are read from IQ9_info.txt (override path with IQ9_INFO=...).
set -euo pipefail

HERE="$(cd "$(dirname "$0")" && pwd)"
INFO="${IQ9_INFO:-$HERE/../../IQ9_info.txt}"
[ -f "$INFO" ] || { echo "device info not found: $INFO (set IQ9_INFO=...)" >&2; exit 1; }
IP=$(awk -F'[: ]+' '/^IP/{print $2}' "$INFO")
PW=$(awk -F'[: ]+' '/passwd/{print $2}' "$INFO")
PERSIST=/root/fastwam_workspace
ENVS="$*"

SSH="sshpass -p $PW ssh -o StrictHostKeyChecking=no -o ConnectTimeout=15 root@$IP"
SCP="sshpass -p $PW scp -o StrictHostKeyChecking=no"

echo "[profile] device $IP  envs: ${ENVS:-<fp16>}"

TMP=$($SSH "mktemp -d /tmp/fastwam_run.XXXXXX")
cleanup() { $SSH "rm -rf $TMP" >/dev/null 2>&1 || true; echo "[profile] cleaned $TMP"; }
trap cleanup EXIT
$SSH "mkdir -p $TMP/runtime $TMP/tmp && for d in ctx golden qnn_libs dsp_libs; do ln -sfn $PERSIST/\$d $TMP/\$d; done"

$SCP "$HERE"/resident_run.py "$HERE"/resident_worker.py root@"$IP":"$TMP"/runtime/ >/dev/null

$SSH "cd $TMP && FASTWAM_WS=$TMP $ENVS python3 -u runtime/resident_run.py"

echo "[profile] pure ctx.Inference times ([infer-ms], excl. TCP):"
$SSH "grep -h infer-ms $TMP/tmp/w_*.log 2>/dev/null | awk '{a[\$2]+=\$3;n[\$2]++} END{for(k in a) printf \"  %-12s %.1f ms\n\", k, a[k]/n[k]}' | sort" || true