This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/docs/SYCL_PROGRESS.md
T
pascallinxweilerandClaude Opus 5.5 c25f610fda sycl: Phase 0 of the Intel backend -- the B65's limits and XMX types, the host baseline
scripts/sycl/probe.sh builds and runs two probes on the Arc Pro B65 (Level Zero, xe driver): the
device's limits and joint_matrix combinations, and an ESIMD DPAS check of E4M3 / E5M2 against bf16
and s8 controls in the same harness. bf16, fp16, s8 and tf32 XMX are exact; fp8 DPAS compiles for
bmg-g31 but returns garbage, so fp8 weights are widened to bf16 in-register (exact for E4M3).

docs/SYCL_PROGRESS.md is the resume log: device tables, the host baseline (82/88 of -LE 'gpu|oot';
the six failures are FFmpeg-less builds and CPU-time budgets on this VM), BetterBench setup, the
model library survey and the open blockers (no MiniCPM5 container in the library, no ROCm here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 15:38:42 +02:00

187 lines
10 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` | in progress |
| 2 design | not started |
| 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.
## 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
./build.sh --no-hip # host backend + fast tests
ctest --test-dir build -LE 'gpu|oot' # host baseline
```