A fourth DeviceBackend, in librad_sycl.so: in-order sycl::queues on one context, events as barriers, copies and fills on the queue, gates as a spin kernel on a pinned flag, and the core's advance and weight-table kernels as SYCL twins of their .hip files. RadStreams are RadSyclStreams (abi/rad_sycl.h). Pinned host memory is page-aligned memory registered for device copies, since O_DIRECT cannot read into SYCL's malloc_host pages; event timing is opt-in (RADIANCE_SYCL_TIMING=1) because profiling queues cost ~20 us of host time a submission. The SYCL code is its own CMake project, sycl/, configured with icpx through ExternalProject, so the engine and every host plugin stay on the main compiler: a SYCL build's host code is the default build's. RAD_SYCL (default OFF), build.sh --sycl, the sycl presets; HIP and SYCL in one build are refused at configure. On the SYCL backend --tp > 1 and ops resolved only to host kernels stop the start, since the Intel backend runs on one card and never puts an op on the CPU. A SYCL build that sees no GPU warns that it runs on the CPU and names the missing oneAPI environment. device_test runs on the Arc Pro B65 as device_test_sycl (label sycl): 36 cases pass, 12 skip (elastic memory, not provided; host-backend-only cases). Host tests hide Level Zero GPUs with ONEAPI_DEVICE_SELECTOR. The host tier is the baseline's in both the default and the SYCL build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
17 KiB
Intel GPU (SYCL / Level Zero) backend: progress log
Task brief: radiance-sycl.md (repo root, not committed). Porting analysis: docs/SYCL_PORTING.md
(Phase 1, not written yet). This file is the resume point: a fresh session should be able to continue
from it alone.
Status
| phase | state |
|---|---|
| 0 environment check | done |
1 codebase study, SYCL_PORTING.md |
done (docs/SYCL_PORTING.md §1-§3, Appendix A) |
| 2 design | written (docs/SYCL_PORTING.md §4); device backend, build integration and core kernels done and passing device_test on the B65; libxe2 skeleton next |
| 3 correctness-first kernels | not started |
| 4 performance | not started |
| 5 broaden and finish | not started |
Open blockers / questions for the user
- No
.radcontainer for any milestone model is in/mnt/model-library.StillDeadcode/minicpm5-2b-bf16/holds onlyREADME.mdandminicpm5-2b-bf16-dspark.recipe; there is nominicpm5-2b-bf16.rad, nominicpm5-2b-fp8.rad, and no rawopenbmb/MiniCPM5-2B/MiniCPM5-2B-DSparkcheckpoint to convert from. Afind -iname '*.rad'over the library and/modelsreturns nothing. Milestones A and B cannot be run until the user provides the containers (or the checkpoints plus permission to runrad-convert). Per the brief, nothing is downloaded or converted without asking. - Bring-up without a real model. The test suite writes synthetic llama checkpoints and converts
them to
.raditself (tests/tiny_model.h,tests/engine_e2e_test.cpp;RAD_E2E_KEEP=1keeps them): bf16, block-fp8 trunk, fp8 / int8 heads, int4, MXFP4, all on thellama_dense_fp8graph MiniCPM5 uses. Those are test fixtures, not library models, and are what the Intel backend is brought up and compared against the host backend on until the real containers exist. Optionally,HuggingFaceTB/SmolLM2-135M(real bf16 llama weights, head_dim 64, tied embeddings) could be converted as a real-weights check; that needs the user's OK, since it is a conversion. - No ROCm on this machine (
hipccabsent, no/opt/rocm). "The HIP build must still compile" cannot be checked here; it needs a ROCm host or a ROCm container (the repo'sDockerfilemay serve). Until then, HIP-side edits are kept to a minimum and listed below for review.
Phase 0 results (2026-10-23)
Toolchain and device
- Compiler:
Intel(R) oneAPI DPC++/C++ Compiler 2026.2.0 (2026.2.0.20261001), at/opt/intel/oneapi(not on PATH by default:. /opt/intel/oneapi/setvars.sh). sycl-ls:[level_zero:gpu][level_zero:0] Intel(R) oneAPI Unified Runtime over Level-Zero V2, Intel(R) Arc(TM) Pro B65 Graphics 20.2.0 [1.17.39395+16](also an OpenCL GPU entry for the same card, NEO 26.31.39395.16, and the OpenCL CPU device).clinfo -l: Intel OpenCL (EPYC 7282 CPU), Intel OpenCL Graphics (Arc Pro B65).lspci -k:01:00.0 Intel Corporation Battlemage G31, kernel driverxe. Linux 7.0.0-38-generic.- User is in
renderandvideo;/dev/dri/renderD128isroot:render 0660. - Host: AMD EPYC 7282, 8 visible cores, 30 GiB RAM (a VM; the bochs VGA is the emulated console).
Device limits (scripts/sycl/devprobe.cpp)
| query | value |
|---|---|
| architecture | intel_gpu_bmg_g31 (alias intel_gpu_20_2_0); AOT target -device bmg-g31 |
| compute units | 160 (20 Xe cores x 8 vector engines) |
| max work-group size | 1024 |
| sub-group sizes | 16, 32 |
| local memory (SLM) per work-group | 131072 B (128 KiB) |
| global memory | 34242297856 B (31.89 GiB) |
| max single allocation | 32530182144 B (30.30 GiB) |
| L2 (global_mem_cache_size) | 18 MiB |
| max clock | 2400 MHz |
| fp16 / fp64 / atomic64 | yes / yes / yes |
| USM device / host / shared / system | yes / yes / yes / yes |
ext_intel_matrix aspect |
yes |
XMX (joint_matrix and ESIMD DPAS)
matrix_combinations reports, for sub-group 16: A/B in {u8,s8} -> s32 at M<=8 N16 K32; fp16 and bf16
-> fp32 or 16-bit at M<=8 N16 K16, plus the larger fixed shapes M16N16K16, M1/M32 x N64 x K16/K32;
tf32 -> fp32 at M<=8 N16 K8. No FP8 combination is listed (the query enum has no fp8 member).
Executed on the device, each checked exactly against a host loop:
| op | result |
|---|---|
| joint_matrix bf16 x bf16 -> f32, M8 N16 K16 | exact |
| joint_matrix fp16 x fp16 -> f32, M8 N16 K16 | exact |
| joint_matrix s8 x s8 -> s32, M8 N16 K32 | exact |
ESIMD xmx::dpas bf16 -> f32, M8 N16 K16 (control) |
exact |
ESIMD xmx::dpas s8 -> s32, M8 N16 K32 (control) |
exact |
ESIMD xmx::dpas hf8 (E4M3) -> f32, M8 N16 K32 |
wrong (values ~1e15..1e24 and inf; expected 31.75) |
ESIMD xmx::dpas bf8 (E5M2) -> f32, M8 N16 K32 |
wrong |
The ESIMD headers declare hf8/bf8/e2m1 DPAS argument types, and IGC compiles them for
bmg-g31 (AOT and JIT) without a diagnostic, but the results are garbage while the bf16 and s8
controls through the identical harness and VNNI packing are exact. Conclusion: FP8 is not a native
XMX input on this Battlemage part (the brief's belief holds). The 8-bit float DPAS precisions are
for a later generation; the compiler does not reject them for BMG.
Consequence for the design: fp8 (E4M3) weights are widened in-register before DPAS. E4M3 -> bf16 is exact for every finite E4M3 value (3 mantissa bits fit in bf16's 7; max 448 and the smallest subnormal 2^-9 are inside bf16's range), and it keeps the activations bf16, so bf16 XMX is the default path for fp8 weights. (E4M3 -> fp16 is also exact, but the bf16 activations would then have to be narrowed to fp16, which can overflow.) MXFP4 (e2m1) is the same: widen to bf16 in-register. int8 (w4a8, int8 trunks) has native s8 DPAS.
Reproduce: scripts/sycl/probe.sh (prints both tables' raw output).
Host baseline (tree at 9eaf10d, before any change)
./build.sh --no-hip builds cleanly (625 targets, GCC, Ninja). Then:
ctest -L '^fast$' -j8: 75/80 pass.ctest --test-dir build -LE 'gpu|oot' -j8: 82/88 pass, 540 s.engine_e2e_test(33 s) andconvert_testpass.
The six failures are pre-existing and environmental; none touches code this task changes. This set is the baseline that "passes exactly as before" is measured against:
| test | cause | evidence |
|---|---|---|
images_test |
no FFmpeg dev libraries, so RAD_WITH_FFMPEG resolves off and pictures cannot be encoded |
500 ... this build has no media decoder: it was configured without libavformat / libavcodec / libswscale; pkg-config libavcodec fails |
videos_test |
same | 400 ... input_reference: the picture could not be read: this build has no media decoder |
glm5next_test |
over its CPU-time budget on this slow VM host | the binary spent 11.17 s of CPU, over its budget of 10 s (RAD_TEST_CPU_BUDGET) |
gbnf_test_shard2 |
same | 10.52 s of CPU, over its budget of 10 s |
quant_ggml_test |
same | 25.38 s of CPU, over its budget of 25 s |
trigger_test |
timing ratio under -j8 load; passes 3/3 run alone |
trigger_test.cpp:429: CHECK((double)last < (double)first * 1.25) in lazy_grammar_waiting_work_does_not_grow_with_the_reply |
Installing libavformat-dev libavcodec-dev libswscale-dev would clear the first two (the user's
call; not needed for this task). After each phase, the same command must show these six and no
others; the CPU-budget and timing tests are compared by cause (re-run alone if they flip).
Benchmarks
Tool: BetterBench 0.6.1 (GGZ14/BetterBench at f72bb90), cloned to ~/tools/BetterBench and
installed editable into its own venv ~/tools/betterbench-venv (Python 3.14.4). Every flag of the
brief's command (--quick --decode --prefill --no-update-check --name --out --note --api-key) is
present in betterbench run --help.
~/tools/betterbench-venv/bin/betterbench run --endpoint http://127.0.0.1:8000/v1 --model <served name> \
--quick --decode --prefill --no-update-check \
--name sycl-<model>-<short commit> --out <run dir>/results.json \
--note backend=sycl --note gpu=arc-pro-b65 --note commit=<short commit>
Discord posting: the user added ~/.config/radiance-bench.env (mode 0600) on 2026-10-23;
DISCORD_WEBHOOK_URL loads from it (never printed or logged). The user also asked for
screenshots of BetterBench's HTML report to be sent to the webhook with each result. No headless
browser is installed (no chromium/firefox/wkhtmltoimage, no playwright); at the first benchmark,
install one outside the repo (e.g. playwright + chromium in ~/tools/betterbench-venv) and have
scripts/bench_report.sh render the report to PNG and post it as a multipart attachment beside the
summary. scripts/bench_report.sh (quick run, parse results.json with jq, post, check the HTTP
status) is to be written at the first benchmarkable milestone, against a real results.json.
Runs: none yet. Nothing is benchmarked before Milestone A passes its correctness checks. All runs
are --quick (1 warmup, 5 passes): progress tracking, not publishable numbers.
| date | commit | model | backend | flags | prefill tok/s (median / 1% low) | decode tok/s (median / 1% low) | vs previous | report |
|---|
Models
Library (/mnt/model-library, read-only), as of 2026-10-23:
| path | what | useful for |
|---|---|---|
StillDeadcode/minicpm5-2b-bf16/ |
README + recipe only, no weights | nothing until the .rad is supplied |
HuggingFaceTB/SmolLM2-135M/ |
bf16 safetensors, llama | possible bring-up stand-in (blocker 2) |
Launch80/Swift-1.5-Qwen3.8-27B-Uncensored-Int4-baked/ |
16 GiB int4 safetensors (qwen35, "baked") | possibly a 19-22 GiB-class Milestone B model, if rad-convert reads it; unverified |
Wrapzii/Swift-1.5-Qwen3.8-27b-GPTQ-Int4-baked-v1-embed-int8/ |
17 GiB GPTQ int4 + int8 embed | same |
unsloth/Qwen3.8-27B-GGUF, other *-GGUF dirs |
GGUF quantisations | the engine converts some GGUF (libquant/lq_ggml.cpp); unverified for these |
Qwen/Qwen3-0.6B-GGUF, unsloth/Qwen3-8B-GGUF, SmolLM3-3B-GGUF, ... |
GGUF | not on the README's model table |
/models (196 GiB, 137 GiB free) already holds copies made before this task: Qwen3.8-27B-Q4_0.gguf,
mtp-Qwen3.8-27B-Q4_0.gguf, and the two Swift 27B directories. They are left as found.
Planned use: Milestone A = minicpm5-2b-bf16.rad (blocked, item 1); Milestone B = minicpm5-2b-fp8.rad
(blocked) and one of the 27B int4 / MXFP4 containers (to be decided once Phase 1 shows what
rad-convert accepts, and with the user's OK for any conversion).
Decisions
- 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'sRadSyclStream(magic + own version +sycl::queue*), not aRAD_ABI_VERSIONbump: no existing shape changes. (§4.2) - D4: kernel library
libxe2/, AOT forintel_gpu_bmg_g31;code_runsunder SYCL compares a plugin'sbuild_targetwith 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 (revised 2026-10-23):
. Tried:RAD_SYCL=ONbuilds everything withicpxcmake -B build-icpx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_CXX_FLAGS=-ffp-model=precise -DRAD_WITH_HIP=OFFfails in libavx:avx_gemm_tile.cpp:289: always_inline function '_pdep_u64' requires target feature 'bmi2', but would be inlined into function 'qb_codes_zp' that is compiled without support(GCC accepts it, clang does not), and fixing that means changing libavx. So the main build stays GCC in every configuration and only the SYCL code is built and linked byicpx, as shared libraries in a sub-build (librad_sycl.so: the device backend and the core's SYCL kernels, a C entry point and a callback table for logging and errors;libxe2.so: the kernel plugin). Host code in a SYCL build is then the default build's, byte for byte. HIP + SYCL refused together at configure until a ROCm machine can test it. (§4.5) - D7:
advanceandwtabget SYCL launchers;xprefetchstays off. (§4.6) - D8:
--tp > 1refused at startup on the SYCL backend, before the device-count check. (§4.7) - D9 (2026-10-23): queues are made without
enable_profilingunlessRADIANCE_SYCL_TIMING=1. Measured on the idle B65 (scratchpadprobesubcost.cpp, 4000 trivial kernels): in-order + profiling 24.4 us host time persingle_task, 22.8 us perparallel_for; in-order without profiling 4.5 / 4.4 us;ext::oneapi::experimental::nd_launch4.0 us either way. At ~550 launches per MiniCPM5 decode step that is 13 ms vs 2.5 ms. Without timing,rad_event_elapsed_msrefuses and names the variable (--profile-opsandrad-kbenchneed it set). libxe2 launches withnd_launch. (An earlier 50 us figure was measured while a -j8 build loaded the host.) - D10 (2026-10-23):
RAD_MEM_HOST_PINNED/_MAPPEDareposix_memalign+prepare_for_device_copy, not SYCLmalloc_host: O_DIRECT intomalloc_hostfails with EFAULT (driver-mapped pages), and the mover reads the file tier straight into pinned buffers. Measured, 256 MiB:malloc_host28.4 / 28.5 GB/s H2D / D2H, O_DIRECT fails; registeredposix_memalign28.4 / 28.4 GB/s, O_DIRECT ok, kernel read/write ok (system USM); unregistered 21.0 / 18.2 GB/s. The backend keeps a registry of those ranges, since the runtime does not know them. - D11: the SYCL engine needs the oneAPI environment at run time: the runtime
dlopens its Level Zero adapter, which needslibumf.so.1from oneAPI'sumf/tree (no RUNPATH can reach it). A SYCL build that sees no GPU now warns (not Info) that it is running on the CPU and names the fix.
Done in Phase 2 (2026-10-23)
abi/rad_sycl.h(commitf00e9b7). The__host__ __device__macros needed no SYCL case: their#else(empty) is what SYCL device code wants.- Build:
RAD_SYCL=OFF|ON|AUTO(default OFF),RAD_SYCL_TARGETS(defaultintel_gpu_bmg_g31),build.sh --sycl(inbuild-sycl/), presetssycl(configure, build, test). The icpx sub-build issycl/CMakeLists.txt, run through ExternalProject;rad_corelinkslibrad_sycl.sowithRAD_HAVE_SYCL=1. HIP + SYCL refused at configure. The default build's generated test definitions are byte-identical apart from CMake's backtrace line numbers. core/device/sycl.cpp(+sycl_host.h/.cpp: the logger/error-slot callback table), selection indispatch.cppahead of the host fallback;core/sched/advance_sycl.cpp,core/runtime/wtab_sycl.cpp; startup refusals for--tp > 1and host-only ops on SYCL.- Tests: host-tier tests hide Level Zero GPUs with
ONEAPI_DEVICE_SELECTOR=!level_zero:*(RAD_TEST_HIDE_ENV).device_test_sycl(labelsycl,RAD_TEST_BACKEND=syclso a fallback to the host backend fails,RADIANCE_SYCL_TIMING=1): 36 cases pass on the B65, 16579 checks, 12 skipped (8 elastic memory, not provided; 4 host-backend-only, skipped on AMD cards too). It runs the SYCLadvancekernel (an_advance_reads_the_token_a_copy_issued_before_it_delivers). Fixed on the way: memset of pageable memory returnsRAD_E_UNSUPPORTED; ranged copies refuse what the other backends refuse; a room check refuses an allocation past the driver's free count; gates (a spin kernel on a pinned flag). - SYCL build,
ctest -LE 'gpu|oot'with the oneAPI environment loaded (card present, hidden): 83/88, the baseline's failures (FFmpeg, CPU budgets);trigger_test's load flake did not occur.
Next steps
libxe2/skeleton built by the icpx sub-build, installed underradiance_home/kernels, with one op (add) and a libref-checked test on the card (sycllabel); itsootrebuild.code_runsunder SYCL frombuild_target(D4), so a host-only build target never claims the card.- 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
None yet.
Reproduce the current state
. /opt/intel/oneapi/setvars.sh
./build.sh --sycl # build-sycl/: configure, build, fast tests
ctest --test-dir build-sycl -L '^sycl$' --output-on-failure # the card tests (B65)
ctest --test-dir build-sycl -LE 'gpu|oot' -j8 # host tier in the SYCL build
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