This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/scripts/sycl/profile_decode.sh
T
claudeandClaude Opus 5.5 a71783806a libxe2: the norm and the fp8 quantisers 3-4x faster at decode, still bit-identical to libref
At one row a work-group, rmsnorm_quant_fp8 took 108 us and gated_quant_fp8 84 us a call (26% and 10%
of a decode step at a 1.8k context). The ordered sum of squares now reads its squares eight at a
time and adds them in the same order; quant_group computes a group's values once into registers and
writes out_bf16 itself; gated_quant_fp8 spreads a row's independent groups over ceil(groups/16)
work-groups. rad-kbench: 208/208 and 206/206 at rel_l2 0.

scripts/sycl/profile_decode.sh isolates decode steps' per-op device time (two profiled runs of the
same request, 1 and 1 + STEPS tokens, differenced). Decode at 1.8k context: 34.8 -> 26.6 ms of
device time a step; the two ops 9.1 -> 3.7 and 3.5 -> 0.9 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 20:47:13 +02:00

56 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
# profile_decode.sh -- per-op device time of decode steps alone, on the SYCL backend.
#
# --profile-ops reports every op over a whole run, so a prompt's prefill and the decode steps after
# it are mixed. This runs the same request twice in two fresh servers -- one generating 1 token, one
# generating 1 + STEPS -- and prints the difference per op type, divided by STEPS: the device time a
# decode step spends in each op at the prompt's context length. The numbers carry --profile-ops'
# synchronisations, so compare them with each other, not with unprofiled tok/s.
#
# Usage: scripts/sycl/profile_decode.sh MODEL PROMPT_FILE [STEPS] [extra radiance flags...]
# PROMPT_FILE plain text, sent as one /v1/completions prompt
# STEPS decode steps measured (default 128)
# Needs the oneAPI environment (it sources setvars.sh if icpx is not on PATH) and build-sycl/.
set -eu
model=${1:?usage: profile_decode.sh MODEL PROMPT_FILE [STEPS] [flags...]}
prompt=${2:?usage: profile_decode.sh MODEL PROMPT_FILE [STEPS] [flags...]}
steps=${3:-128}
[ $# -ge 3 ] && shift 3 || shift $#
root=$(cd "$(dirname "$0")/../.." && pwd)
if ! command -v icpx >/dev/null; then set +u; . /opt/intel/oneapi/setvars.sh >/dev/null; set -u; fi
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
port=${PORT:-8139}
run() { # run TOKENS FLAGS... -> $work/TOKENS.tsv: op, total ms
tok=$1; shift
RADIANCE_SYCL_TIMING=1 RADIANCE_HOME="$root/build-sycl/radiance_home" \
"$root/build-sycl/bin/radiance" --model "$model" --profile-ops --max-num-seqs 1 \
--host 127.0.0.1 --port "$port" "$@" > "$work/$tok.log" 2>&1 &
pid=$!
i=0
until grep -q 'server: listening' "$work/$tok.log"; do
i=$((i + 1)); [ $i -lt 600 ] || { echo "the server did not start" >&2; kill $pid; exit 1; }
kill -0 $pid 2>/dev/null || { tail -5 "$work/$tok.log" >&2; exit 1; }
sleep 1
done
python3 -I -c 'import json,sys; print(json.dumps({"prompt": open(sys.argv[1]).read(),
"max_tokens": int(sys.argv[2]), "temperature": 0}))' "$prompt" "$tok" > "$work/req.json"
curl -sf -m 3600 "http://127.0.0.1:$port/v1/completions" -H 'Content-Type: application/json' \
-d @"$work/req.json" > /dev/null
kill -INT $pid
wait $pid 2>/dev/null || true
n=$(grep -n -E 'calls +total ms' "$work/$tok.log" | tail -1 | cut -d: -f1)
awk -v from="$n" 'NR > from && $4 == "dev" { t[$7] += $2 } END { for (o in t) print o, t[o] }' \
"$work/$tok.log" | sort > "$work/$tok.tsv"
}
run 1 "$@"
run $((steps + 1)) "$@"
join "$work/1.tsv" "$work/$((steps + 1)).tsv" | awk -v n="$steps" '
{ d = $3 - $2; T += d; a[$1] = d }
END {
for (o in a) printf "%8.3f ms/step %5.1f%% %s\n", a[o] / n, 100 * a[o] / T, o
printf "%8.3f ms/step of device time over %d decode steps\n", T / n, n
}' | sort -rn