Archived
The core's HIP use is already behind the DeviceBackend vtable except three core kernels (advance, wtab, xprefetch), the engine's interposed hipLaunchKernel that plugins launch through, and build switches; each site is listed with file and line. The minimal set for MiniCPM5-2B is measured with --debug-graph on the test suite's synthetic llama containers (13 model ops, 13 sampler ops; fp8 adds gemm_nt_q / gemm_nt_q_gated), since no MiniCPM5 container is in the model library. The design: a fourth DeviceBackend over SYCL, a RadSyclStream hand-off for plugins with its own version instead of an ABI bump, libxe2 AOT for bmg-g31, and on that backend a fatal error where the planner would otherwise put a weighted op on the CPU. scripts/sycl/op_inventory.sh generates the 238-op appendix: libref's schemas through rad-schemas, libr4d's 407 rows parsed from source by r4d_rows.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
38 lines
1.9 KiB
Bash
Executable File
38 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# op_inventory.sh -- the op vocabulary as a markdown table, for docs/SYCL_PORTING.md.
|
|
#
|
|
# One row per op that libref or libr4d declares: whether libref has it (the oracle), the libr4d
|
|
# kernels that implement it (from the kKernels rows in libr4d/r4d_rows.cpp, read as source because a
|
|
# build without HIP has no libr4d.so), the dtypes those rows state, and the architecture plugins
|
|
# whose source names the op. "Architectures naming it" is a grep, so it over-counts an op a plugin
|
|
# names only conditionally; --debug-graph on a real container is the exact answer for one model.
|
|
#
|
|
# Usage: scripts/sycl/op_inventory.sh [BUILD_DIR] (default build/)
|
|
set -e
|
|
root=$(cd "$(dirname "$0")/../.." && pwd)
|
|
build=${1:-$root/build}
|
|
tmp=$(mktemp -d)
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
RADIANCE_HOME=$build/radiance_home "$build/bin/rad-schemas" "$build/radiance_home/kernels/libref.so" |
|
|
awk '/^ [a-z0-9_]+$/ {print $1}' | sort -u > "$tmp/libref"
|
|
|
|
python3 -I "$root/scripts/sycl/r4d_rows.py" "$root/libr4d/r4d_rows.cpp" | sort > "$tmp/r4d"
|
|
|
|
cut -f1 "$tmp/r4d" | sort -u > "$tmp/r4d_ops"
|
|
sort -u "$tmp/libref" "$tmp/r4d_ops" > "$tmp/all"
|
|
|
|
echo "| op | libref | libr4d kernels | libr4d dtypes (first three rows' prose) | architectures naming it |"
|
|
echo "|---|---|---|---|---|"
|
|
while read -r op; do
|
|
ref=no; grep -qx "$op" "$tmp/libref" && ref=yes
|
|
kern=$(awk -F'\t' -v o="$op" '$1 == o {print $2}' "$tmp/r4d" | tr '\n' ' ' | sed 's/ $//; s/ /, /g')
|
|
dts=$(awk -F'\t' -v o="$op" '$1 == o && $3 != "" {print $3}' "$tmp/r4d" | sort -u | head -3 |
|
|
tr '\n' ';' | sed 's/;$//; s/;/; /g; s/|/\\|/g')
|
|
archs=$(grep -rlw --include=*.cpp --include=*.h -e "\"$op\"" "$root/arch" 2>/dev/null |
|
|
sed "s#$root/arch/##; s#/.*##" | sort -u | tr '\n' ' ' | sed 's/ $//; s/ /, /g')
|
|
[ -z "$kern" ] && kern="--"
|
|
[ -z "$archs" ] && archs="--"
|
|
echo "| \`$op\` | $ref | $kern | $dts | $archs |"
|
|
done < "$tmp/all"
|