sycl: Phase 1 -- docs/SYCL_PORTING.md: where the core meets HIP, the op set, the design

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
This commit is contained in:
pascallinxweilerandClaude Opus 5.5 committed 2026-10-23 15:38:42 +02:00
1 parent c25f610fda
commit ec4dbb6464
5 files changed
+677 -2

No files matched your search

+10
View File
@@ -55,3 +55,13 @@ output. `mcagent.sh` and `mcdecl.sh` start their own MiniCPM5-2B server through
| `mcstream.sh` | Tool-call replies streamed, asserting on raw SSE fragments rather than the assembled message. Streamed content cannot be retracted, so a repair applied at the end is not a fix. |
| `mcagent.sh` | What speculation is worth on an agentic workload: `/v1/chat/completions` with tools, a constrained decode. Speculation on and off alternate across restarts because the speculation depth is a server-level setting. |
| `mcdecl.sh` | How often the drafter proposes, by context length. `draft_acceptance_ratio` is conditional on having drafted, so it can look healthy while tokens per step collapse; blocks per step separates the two. |
## The Intel (SYCL) backend
Tools for the port in `docs/SYCL_PORTING.md`; its log is `docs/SYCL_PROGRESS.md`. They need oneAPI
(`. /opt/intel/oneapi/setvars.sh`) only where they compile device code.
| | |
|---|---|
| `sycl/probe.sh` | The card's limits, sub-group sizes and `joint_matrix` combinations, and whether XMX executes E4M3 / E5M2 DPAS, each checked against a host loop with bf16 and s8 DPAS as controls in the same harness (on the Arc Pro B65 fp8 DPAS compiles and returns garbage). |
| `sycl/op_inventory.sh` | The op vocabulary as a markdown table: libref's schemas, libr4d's kernels and dtypes per op (its rows read from source by `sycl/r4d_rows.py`, since a build without HIP has no `libr4d.so`), and which architectures name each op. |
+37
View File
@@ -0,0 +1,37 @@
#!/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"
+44
View File
@@ -0,0 +1,44 @@
"""r4d_rows.py ROWS_CPP -- the kKernels rows of libr4d/r4d_rows.cpp as TSV: op, kernel, dtypes, domain.
Read as source because a build without HIP has no libr4d.so to ask. A row is
{ "kernel", "op", "family", "computes", "shape", "dtypes", RAD_DOMAIN_..., ... }; adjacent string
literals are joined as the C compiler joins them, so a dtypes string split over lines stays whole.
"""
import re
import sys
src = open(sys.argv[1], encoding="utf-8").read()
start = src.index("static const RadKernelInfo kKernels[] = {")
body = src[start:]
# Comments out, so prose in them cannot look like a row.
body = re.sub(r"/\*.*?\*/", " ", body, flags=re.S)
body = re.sub(r"//[^\n]*", " ", body)
body = body.replace("\\\n", "\n") # macro line continuations
lit = r'"(?:[^"\\]|\\.)*"'
# Between literals a row may splice in a macro: R4D_XSTR(X), a stringised #PARAM, or a name such as
# KVDOC. Each is kept as <NAME>, so a template row's kernel reads attn_window_h<HD>_gqa<G>_<KVN>.
mac = r"R4D_XSTR\(\s*\w+\s*\)|#\w+|\b(?!RAD_DOMAIN_)[A-Z][A-Z0-9_]*\b"
row_re = re.compile(r"\{\s*((?:(?:" + lit + "|" + mac + r")\s*,?\s*)+?)(RAD_DOMAIN_[A-Z]+)")
for m in row_re.finditer(body):
if not m.group(1).lstrip().startswith('"'):
continue
# Split the run into arguments at commas; join adjacent literals and macros within one.
args, cur = [], []
for tok in re.finditer(lit + "|" + mac + r"|,", m.group(1)):
t = tok.group(0)
if t == ",":
args.append("".join(cur))
cur = []
elif t.startswith('"'):
cur.append(re.sub(r"\\(.)", r"\1", t[1:-1]))
else:
name = re.sub(r"^R4D_XSTR\(\s*|\s*\)$|^#", "", t)
cur.append(f"<{name}>")
if cur:
args.append("".join(cur))
if len(args) < 6:
continue
kern, op, dtypes = args[0], args[1], " ".join(args[5].split())
print(f"{op}\t{kern}\t{dtypes}\t{m.group(2)[len('RAD_DOMAIN_'):].lower()}")