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
222 lines
13 KiB
Markdown
222 lines
13 KiB
Markdown
# 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); implementation next |
|
|
| 3 correctness-first kernels | not started |
|
|
| 4 performance | not started |
|
|
| 5 broaden and finish | not started |
|
|
|
|
## Open blockers / questions for the user
|
|
|
|
1. **No `.rad` container for any milestone model is in `/mnt/model-library`.**
|
|
`StillDeadcode/minicpm5-2b-bf16/` holds only `README.md` and `minicpm5-2b-bf16-dspark.recipe`; there
|
|
is no `minicpm5-2b-bf16.rad`, no `minicpm5-2b-fp8.rad`, and no raw `openbmb/MiniCPM5-2B` /
|
|
`MiniCPM5-2B-DSpark` checkpoint to convert from. A `find -iname '*.rad'` over the library and
|
|
`/models` returns nothing. Milestones A and B cannot be run until the user provides the containers
|
|
(or the checkpoints plus permission to run `rad-convert`). Per the brief, nothing is downloaded or
|
|
converted without asking.
|
|
2. **Bring-up without a real model.** The test suite writes synthetic llama checkpoints and converts
|
|
them to `.rad` itself (`tests/tiny_model.h`, `tests/engine_e2e_test.cpp`; `RAD_E2E_KEEP=1` keeps
|
|
them): bf16, block-fp8 trunk, fp8 / int8 heads, int4, MXFP4, all on the `llama_dense_fp8` graph
|
|
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.
|
|
3. **No ROCm on this machine** (`hipcc` absent, no `/opt/rocm`). "The HIP build must still compile"
|
|
cannot be checked here; it needs a ROCm host or a ROCm container (the repo's `Dockerfile` may
|
|
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 driver `xe`. Linux 7.0.0-38-generic.
|
|
- User is in `render` and `video`; `/dev/dri/renderD128` is `root: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) and
|
|
`convert_test` pass.
|
|
|
|
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`.
|
|
|
|
```sh
|
|
~/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: **`~/.config/radiance-bench.env` does not exist, so `DISCORD_WEBHOOK_URL` is unset**
|
|
(checked 2026-10-23). Runs are recorded here without posting until the user creates that file.
|
|
`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`'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
|
|
|
|
None yet.
|
|
|
|
## Reproduce the current state
|
|
|
|
```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
|
|
```
|