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

+37 -2
View File
@@ -9,8 +9,8 @@ from it alone.
| phase | state |
|---|---|
| 0 environment check | done |
| 1 codebase study, `SYCL_PORTING.md` | in progress |
| 2 design | not started |
| 1 codebase study, `SYCL_PORTING.md` | done (`docs/SYCL_PORTING.md` §1-§3, Appendix A) |
| 2 design | written (`docs/SYCL_PORTING.md` §4); implementation next |
| 3 correctness-first kernels | not started |
| 4 performance | not started |
| 5 broaden and finish | not started |
@@ -171,6 +171,33 @@ Planned use: Milestone A = `minicpm5-2b-bf16.rad` (blocked, item 1); Milestone B
- D1 (Phase 0): FP8 and FP4 weights are widened to bf16 in-register for XMX; int8 uses native s8 DPAS.
Evidence above.
- D2 (Phase 1): no new device-runtime abstraction. `DeviceBackend` (`core/device/device.h:178`)
already is one and HIP/AQL sit behind it; the Intel backend is a fourth vtable,
`core/device/sycl.cpp`. The HIP path is not touched. (`SYCL_PORTING.md` §4.1)
- D3: plugins get the queue through `abi/rad_sycl.h`'s `RadSyclStream` (magic + own version +
`sycl::queue*`), not a `RAD_ABI_VERSION` bump: no existing shape changes. (§4.2)
- D4: kernel library `libxe2/`, AOT for `intel_gpu_bmg_g31`; `code_runs` under SYCL compares a
plugin's `build_target` with the device arch so libr4d rows are never selected on the B65. (§4.3)
- D5: on the SYCL backend the "host-only ops ... Not a hole" placement is fatal unless
`--debug-accept-host-ops`. (§4.4)
- D6: `RAD_SYCL=ON` builds everything with `icpx`, host code at `-ffp-model=precise` (icpx's default
is fast math); `-fsycl` only on SYCL sources. Fallback: ExternalProject for the SYCL pieces if
host results differ from GCC's. HIP + SYCL refused together at configure until a ROCm machine can
test it. (§4.5)
- D7: `advance` and `wtab` get SYCL launchers; `xprefetch` stays off. (§4.6)
- D8: `--tp > 1` refused at startup on the SYCL backend. (§4.7)
## Next steps (Phase 2 implementation, in commit order)
1. CMake: `RAD_SYCL`, the `icpx` check, `-ffp-model=precise`, `build.sh --sycl`, preset, `sycl`
label. Verify: default GCC build unchanged; SYCL build's host tier matches the baseline.
2. `abi/rad_sycl.h`; `__host__ __device__` macros' SYCL case.
3. `core/device/sycl.cpp` backend + selection + `RADIANCE_DEVICE_BACKEND`; a `sycl`-labelled
device test (the contract tests of `tests/device_test.cpp` run against it).
4. `advance` / `wtab` SYCL launchers; `--tp` refusal; fatal host-only placement.
5. `libxe2/` skeleton with one op (`add`) and its libref-checked test; `oot` rebuild.
6. Phase 3: the 13 + 13 ops of `SYCL_PORTING.md` §3.1, each with a libref test, then the tiny
llama end to end against the host backend.
## HIP-side edits awaiting a ROCm compile check
@@ -181,6 +208,14 @@ None yet.
```sh
. /opt/intel/oneapi/setvars.sh
scripts/sycl/probe.sh # Phase 0 device tables
scripts/sycl/op_inventory.sh # SYCL_PORTING.md Appendix A
# the tiny llama containers and their graphs (Phase 1, SYCL_PORTING.md §3.1):
mkdir -p "$T/tmp" && env RADIANCE_HOME=$PWD/build/radiance_home RAD_TEST_TMPDIR=$T/tmp \
ROCR_VISIBLE_DEVICES=99 RAD_E2E_KEEP=1 build/tests/engine_e2e_test -perf_
# -> $T/tmp/radiance_e2e.*/{llama,llama_int4}/ checkpoints and llama*.rad containers
build/bin/rad-convert $D/llama -o $D/llama_bf16.rad # the bf16 analogue (no recipe)
build/bin/radiance --model $D/llama_bf16.rad --debug-graph
build/bin/radiance --model $D/llama.rad --kv-cache-dtype fp8 --debug-graph
./build.sh --no-hip # host backend + fast tests
ctest --test-dir build -LE 'gpu|oot' # host baseline
```