Archived
oneMKL's SYCL GEMM (part of oneAPI; libxe2 links it when CMake finds it, RAD_XE2_MKL=OFF or XE2_NO_MKL=1 keep the hand-written kernels) runs the fp16 prefill GEMMs at 85-91 TFLOPS on random data at the 27B's shapes, deterministic run to run, against ~23-30 for the hand-tiled XMX kernel: xmx_f16_scaled (the m2xfp4 prefill) and xmx_f16_batched (the rotation's) go to its gemm and gemm_batch, and bf16 gemm_nt at M >= 17 to its bf16 GEMM (N = 96 had fallen to the exact kernel, 5 ms a call). The m2xfp4 weight decode to fp16 now takes a (column, 32-group) a work-item. fp16 or bf16 products with f32 accumulation, as before: the 27B's cases 133/133 (rel_l2 <= 1.42e-3), the fixture 1410/1410. Prefill GEMMs over a 1882-token prompt 4.06 -> 1.66 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
700 lines
48 KiB
Markdown
700 lines
48 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 | done: device backend, build integration, core kernels (`device_test_sycl` on the B65) |
|
|
| 3 correctness-first kernels | **Milestone A reached 2026-10-23** (`874f8d2`): MiniCPM5-2B bf16 serves on the B65, greedy-identical to the libref host backend; Milestone B next |
|
|
| 4 performance | MiniCPM5-2B bf16: decode 4.2 -> 51.8 tok/s, prefill 17 -> 1576 tok/s (`b07da2a`); Qwen3.8-27B-PARO-M2XFP4 (the model from 2026-10-23): 0.1 -> 30.6 tok/s decode with the DFlash2 drafter, prefill 124 tok/s (`b0e34c6`), in progress |
|
|
| 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`.**~~ Resolved for bf16
|
|
(2026-10-23): `StillDeadcode/minicpm5-2b-bf16/minicpm5-2b-bf16.rad` (5,501,632,512 bytes) appeared;
|
|
copied to `/models/minicpm5-2b-bf16/` and verified with `cmp`. **Still missing: `minicpm5-2b-fp8.rad`**
|
|
(Milestone B). Original note:
|
|
`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**~~ Resolved: `sudo` needs a password, so the HIP compile check runs
|
|
in docker (see "HIP compile check"); it passes.
|
|
|
|
## 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: 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`.
|
|
|
|
All runs are `--quick` (1 warmup, 5 passes): progress tracking, not publishable numbers.
|
|
`scripts/sycl/bench_report.sh TAG` runs the brief's command against a live server, summarises with
|
|
BetterBench's own report functions, screenshots the HTML report (JPEG, at the user's request) and
|
|
posts both to the webhook; `--report RUN_DIR TAG` reports an existing run. The screenshot needs
|
|
headless Chromium (Playwright in the BetterBench venv), nine system libraries it lacks here and
|
|
fonts (this host has none; the first post had no text) -- all unpacked without root under
|
|
`~/tools/chromium-libs` (`apt-get download` + `dpkg -x`, a private `fonts.conf`).
|
|
|
|
| date | commit | model | backend | flags | prefill tok/s (median / 1% low) | decode tok/s (median / 1% low) | vs previous | report |
|
|
|---|---|---|---|---|---|---|---|---|
|
|
| 2026-10-23 | `874f8d2` | minicpm5-2b-bf16 | sycl, correctness-first kernels | `--num-speculative-tokens 0 --max-model-len 8192 --max-num-seqs 4` | 17.3 / 17.3 @2000 (8000+ skipped: over the 8192 context) | 4.2 / 3.5 | first run | `~/radiance-bench/runs/20261023-165102-minicpm5-2b-bf16-874f8d2/results.html`, posted with `report.jpg` |
|
|
| 2026-10-23 | `a869226` | minicpm5-2b-bf16 | sycl, Phase 4 step 1 (GEMV) | same | 17.5 / 17.4 @2000 | 25.3 / 16.2 | decode +504.5% | `~/radiance-bench/runs/20261023-194856-minicpm5-2b-bf16-a869226/results.html`, posted with `report.jpg` |
|
|
| 2026-10-24 | `5720a95` | qwen38-27b-m2xfp4 (Qwen3.8-27B-DFLASH2-PARO-M2XFP4) | sycl, fast m2xfp4 GEMV / DPAS verify / tiled XMX prefill, DFlash2 drafter on | `--max-model-len 8192 --max-num-seqs 4` | 113.4 / 113.3 @2000 | 19.1 / - | first run | `~/radiance-bench/runs/20261024-060226-qwen38-27b-m2xfp4-5720a95/results.html`, posted with `report.jpg` |
|
|
| 2026-10-24 | `b0e34c6` | qwen38-27b-m2xfp4 | sycl, the speculative round's kernels (draft head and logits on DPAS, exact selection ops, typed gdn, vector norm, register-DPAS verify GEMM) | `--max-model-len 8192 --max-num-seqs 1` | 131.3 / 130.6 @2000 | 28.9 / - | decode +51.5%, prefill +15.8% | `~/radiance-bench/runs/20261024-135808-qwen38-27b-m2xfp4-b0e34c6/results.html`, posted with `report.jpg` |
|
|
| 2026-10-23 | `b07da2a` | minicpm5-2b-bf16 | sycl, Phase 4 steps 2-6 (XMX prefill, split-KV attention, norms, GEMV split) | same | 1575.6 / 1547.1 @2000 | 51.8 / 41.4 | decode +104.7%, prefill 90x | `~/radiance-bench/runs/20261023-221354-minicpm5-2b-bf16-b07da2a/results.html`, posted with `report.jpg` |
|
|
|
|
## 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 (revised 2026-10-23): ~~`RAD_SYCL=ON` builds everything with `icpx`~~. Tried: `cmake -B build-icpx
|
|
-DCMAKE_CXX_COMPILER=icpx -DCMAKE_CXX_FLAGS=-ffp-model=precise -DRAD_WITH_HIP=OFF` fails 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 by `icpx`, 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: `advance` and `wtab` get SYCL launchers; `xprefetch` stays off. (§4.6)
|
|
- D8: `--tp > 1` refused at startup on the SYCL backend, before the device-count check. (§4.7)
|
|
- D9 (2026-10-23): queues are made **without** `enable_profiling` unless `RADIANCE_SYCL_TIMING=1`.
|
|
Measured on the idle B65 (`scratchpad` probe `subcost.cpp`, 4000 trivial kernels): in-order +
|
|
profiling 24.4 us host time per `single_task`, 22.8 us per `parallel_for`; in-order without
|
|
profiling 4.5 / 4.4 us; `ext::oneapi::experimental::nd_launch` 4.0 us either way. At ~550 launches
|
|
per MiniCPM5 decode step that is 13 ms vs 2.5 ms. Without timing, `rad_event_elapsed_ms` refuses
|
|
and names the variable (`--profile-ops` and `rad-kbench` need it set). libxe2 launches with
|
|
`nd_launch`. (An earlier 50 us figure was measured while a -j8 build loaded the host.)
|
|
- D10 (2026-10-23): `RAD_MEM_HOST_PINNED` / `_MAPPED` are `posix_memalign` + `prepare_for_device_copy`,
|
|
not SYCL `malloc_host`: O_DIRECT into `malloc_host` fails with EFAULT (driver-mapped pages), and
|
|
the mover reads the file tier straight into pinned buffers. Measured, 256 MiB: `malloc_host` 28.4 /
|
|
28.5 GB/s H2D / D2H, O_DIRECT fails; registered `posix_memalign` 28.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.
|
|
- D13 (2026-10-23): fast kernels may change libref's reduction order. They are held to rad-kbench's
|
|
per-op tolerances (libr4d's standard) and, end to end, to the KL bound measured above against the
|
|
libref host build -- no worse than libavx's distance from libref. Every fast row keeps its exact
|
|
twin, selectable with `XE2_EXACT=1`.
|
|
- D12 (2026-10-23): every libxe2 op is checked twice: rad-kbench (dense operands, fixture and the
|
|
real container) and the engine's op oracle on the operands the engine hands it
|
|
(`RADIANCE_OP_ORACLE`), at tolerance ~0 where the kernel reproduces libref's order. Transcendentals
|
|
are libref's: double `exp`/`log`/`cos`/`sin` on the device, rounded once to f32 (verified
|
|
bit-identical to glibc over MiniCPM5's rope angles and exp's [-104, -20] range).
|
|
- D11: the SYCL engine needs the oneAPI environment at run time: the runtime `dlopen`s its Level
|
|
Zero adapter, which needs `libumf.so.1` from oneAPI's `umf/` 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` (commit `f00e9b7`). 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` (default `intel_gpu_bmg_g31`),
|
|
`build.sh --sycl` (in `build-sycl/`), presets `sycl` (configure, build, test). The icpx sub-build is
|
|
`sycl/CMakeLists.txt`, run through ExternalProject; `rad_core` links `librad_sycl.so` with
|
|
`RAD_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 in
|
|
`dispatch.cpp` ahead of the host fallback; `core/sched/advance_sycl.cpp`,
|
|
`core/runtime/wtab_sycl.cpp`; startup refusals for `--tp > 1` and 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` (label `sycl`, `RAD_TEST_BACKEND=sycl` so 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 SYCL `advance` kernel (`an_advance_reads_the_token_a_copy_issued_before_it_delivers`).
|
|
Fixed on the way: memset of pageable memory returns `RAD_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.
|
|
|
|
## libxe2 (started 2026-10-23)
|
|
|
|
`libxe2/` is built by the sycl sub-build with `rad_add_plugin` into `radiance_home/kernels`
|
|
(`xe2_common.h`: queue, row views, refusals; `xe2_rows.cpp`: rows with designated initialisers).
|
|
Ops so far: `add`.
|
|
|
|
**The correctness check for every op is `rad-kbench`**: it replays each kernel against libref's
|
|
recorded answers on seeded inputs inside guarded allocations (`data/kernels.rkb`, recorded from
|
|
qwen3.8-27b; `kernels_moe.rkb`), at the project's per-op tolerances, and with `-m` against a real
|
|
container at its geometry. In a SYCL build the `kbench` and `kbench_moe` tests are labelled
|
|
`kbench;sycl` (card tier), as they are `kbench;gpu` in a HIP build. Per op:
|
|
|
|
```sh
|
|
. /opt/intel/oneapi/setvars.sh
|
|
RADIANCE_SYCL_TIMING=1 RADIANCE_HOME=$PWD/build-sycl/radiance_home build-sycl/bin/rad-kbench --op <op>
|
|
RADIANCE_SYCL_TIMING=1 RADIANCE_HOME=$PWD/build-sycl/radiance_home build-sycl/bin/rad-kbench \
|
|
-m /models/minicpm5-2b-bf16/minicpm5-2b-bf16.rad --num-speculative-tokens 0 --op <op>
|
|
```
|
|
|
|
`add`: fixture 30/30 and MiniCPM5 20/20, worst rel_l2 0, no writes outside guarded allocations.
|
|
`ctest -L '^sycl$'` (device_test_sycl, kbench, kbench_moe): 3/3 on the B65.
|
|
|
|
In a SYCL build the host tier is `ctest -LE 'gpu|oot|sycl'` (kbench moved to the card tier).
|
|
|
|
### MiniCPM5-2B bf16, the real container (`--debug-graph`, host backend)
|
|
|
|
42 layers, n_embd 2048, 16 q / 2 kv heads, head_dim 128 (gqa 8), ffn 6144, vocab 130560, rope theta
|
|
5e6 neox, eps 1e-6. With `--num-speculative-tokens 0`: 523 ops, exactly the 13 + 13 of
|
|
`SYCL_PORTING.md` §3.1 (gemm_nt at N,K = 2560x2048 qkv, 2048x2048 o, 12288x2048 gate_up,
|
|
2048x6144 down; logits 130560x2048). With its DSpark drafter (default, depth 7): 619 ops, adding
|
|
`gemm_nt_q` fp8a8 (128x128 blocks) and `w2a8` (the 2-bit head), `gemm_nt_q_gated`, `silu_mul`,
|
|
`quant_act_i8`, `row_topk` (N 130560, R 16), `dflash_select`, a non-causal `attn_paged`, and
|
|
`rmsnorm` n=128. Milestone A runs with speculation off first; the drafter's ops are Milestone B.
|
|
|
|
## Milestone A (2026-10-23, commit `874f8d2`)
|
|
|
|
`minicpm5-2b-bf16.rad` with `--num-speculative-tokens 0` serves on the Arc Pro B65: 26 libxe2 ops
|
|
(13 model, 13 sampler), every one resolved to a device row, none placed on the host.
|
|
|
|
- **Greedy, token for token, against the host backend restricted to libref** (`--kernels libref
|
|
--debug-accept-reference-kernels`): `scripts/sycl/greedy_compare.py`, 8 prompts x 64 tokens,
|
|
**8/8 identical**; top-5 logprobs over 96 decode steps differ by **exactly 0**.
|
|
- Against the default host backend (libavx): 5/8 identical; the three others diverge late (tokens
|
|
27, 55, 61) at near-ties (top-2 gaps 0.01-0.07 nats). libavx's reductions are not libref's, and
|
|
libxe2 reproduces libref, so this is libavx vs libref, not the card. Measured, not bounded further.
|
|
- `/v1/chat/completions` answers coherently, the reasoning split out ("In one sentence, why is the
|
|
sky blue?" -> "The sky appears blue because shorter blue wavelengths of sunlight are scattered
|
|
more by the atmosphere's molecules than longer red wavelengths.").
|
|
- Reproduce:
|
|
```sh
|
|
. /opt/intel/oneapi/setvars.sh
|
|
RADIANCE_HOME=$PWD/build-sycl/radiance_home build-sycl/bin/radiance \
|
|
--model /models/minicpm5-2b-bf16/minicpm5-2b-bf16.rad --num-speculative-tokens 0 \
|
|
--max-model-len 8192 --max-num-seqs 4 --port 8100 &
|
|
RADIANCE_HOME=$PWD/build/radiance_home ROCR_VISIBLE_DEVICES=99 build/bin/radiance \
|
|
--model /models/minicpm5-2b-bf16/minicpm5-2b-bf16.rad --kernels libref \
|
|
--debug-accept-reference-kernels --num-speculative-tokens 0 --max-model-len 8192 --port 8102 &
|
|
python3 -I scripts/sycl/greedy_compare.py http://127.0.0.1:8100 http://127.0.0.1:8102
|
|
```
|
|
|
|
**Two checks, not one.** rad-kbench passed every op, and the engine still found two bugs, because its
|
|
operands are not kbench's: `cast` was handed a strided slice of the fused qkv row (refused, loudly),
|
|
and `gated_quant_fp8`'s f32 `exp` was inside kbench's tolerance but not libref's double `exp`, which
|
|
moved one E4M3 code in some layers and flipped a greedy near-tie later. The engine's op oracle finds
|
|
the second kind: it runs libref on the very operands each device kernel was handed. **Every new op
|
|
gets both checks** (D12):
|
|
|
|
```sh
|
|
RADIANCE_OP_ORACLE='*' RADIANCE_OP_ORACLE_MAX=600 RADIANCE_OP_ORACLE_TOL=1e-9 \
|
|
RADIANCE_HOME=$PWD/build-sycl/radiance_home build-sycl/bin/radiance --model ... --port 8120
|
|
# one short request, then: grep -c 'oracle #.* agrees' / grep 'MISMATCH' in the log
|
|
```
|
|
After the fix: 600/600 issues of a 26-token prefill bit-identical.
|
|
|
|
Speed (correctness-first kernels: serial-dot GEMM, one work-group a (row, head) attention):
|
|
24 tokens in 5.6 s including prefill; BetterBench quick numbers in "Benchmarks".
|
|
|
|
## Milestone B, part 1: the DSpark drafter (2026-10-23)
|
|
|
|
libxe2 now serves every op of `minicpm5-2b-bf16.rad` with its drafter: `gemm_nt_q` over fp8a8
|
|
(128x128 blocks; libref's `quant_dot` per output), `gemm_nt_q_gated` (fp8a8, gated epilogue; n <= 28672
|
|
in local memory, declared as N <= 57344), the `w2a8` vocabulary head (libref's `gemm_zp`; `b_scale`
|
|
in libref's joined planes form through the same layout hook, the planes found on the device),
|
|
`quant_act_i8`, `silu_mul`, `row_topk`, `dflash_select`. Non-causal attention and head-only rope were
|
|
already served.
|
|
|
|
- rad-kbench: MiniCPM5-2B 191/191 at rel_l2 0 (the head's row is not reached by kbench's cases);
|
|
fixture: the gated GEMM at a 27B geometry (N 34816) was refused at first -- its first version held
|
|
the whole N-wide row in local memory -- and passes since.
|
|
- Engine oracle with speculation on: **1500/1500 issues bit-identical**, the w2a8 head included.
|
|
- Greedy, speculation on (DSpark, depth 7) against libref's greedy with it off:
|
|
**8/8 prompts identical** (`greedy_compare.py`, 64 tokens each).
|
|
- Speed: 2.5-5.4 tok/s with speculation against 4.2 without: verifying 7 drafts costs about as much as
|
|
7 tokens in a serial-dot GEMM. Speculation pays once the GEMMs are bandwidth-bound (Phase 4).
|
|
|
|
## Install and the out-of-tree rebuild (2026-10-23)
|
|
|
|
A SYCL build installs `librad_sycl.so` to `lib/` and `libxe2.so` to `share/radiance/kernels`, and
|
|
its executables carry `INSTALL_RPATH $ORIGIN/../lib` (checked: an installed `radiance` resolves the
|
|
backend from the prefix with no environment). `tests/oot_plugins.sh` rebuilds libxe2 out of tree
|
|
with icpx when `RAD_OOT_ICPX` is set (the SYCL build's registration sets it) and hides Level Zero
|
|
GPUs from its listing and replay. `ctest -R oot_plugins` in build-sycl: **passed** (370 s).
|
|
|
|
## Phase 4, step 1 (2026-10-23)
|
|
|
|
Profile (`RADIANCE_SYCL_TIMING=1 --profile-ops`, MiniCPM5 bf16 decode, correctness-first kernels):
|
|
232.8 ms/step; `gemm_nt` 79.2% (gate_up, 50 MB of bf16, 810 us a call = 62 GB/s on a ~600 GB/s
|
|
card), `rmsnorm_quant_fp8` 13.0% (the serial sum of squares, 360 us a call), `logits_gemm` 3.4%,
|
|
the rest under 1.5% each.
|
|
|
|
- `rmsnorm*`: the squares are formed in parallel into local memory, work-item 0 adds them in index
|
|
order -- the same additions, still bit-identical to libref (kbench rel_l2 0).
|
|
- `xe2_gemm_nt_gemv`, `xe2_logits_gemm_gemv` (priority 10, `M <= 16`, bf16): a sub-group an output
|
|
column, 16-byte coalesced weight loads, a tree reduction. Not libref's order. kbench: fixture
|
|
361/361, MiniCPM5 180/180 (worst rel_l2 1.6e-4, tol 8e-3). `XE2_EXACT=1` sends them to the exact
|
|
kernels.
|
|
- **Decode: 4.2 -> 35.5 tok/s** (128-token greedy completions, speculation off).
|
|
- **KL bound (D13)**, `--kld-record` with the libref host build over 12 passages of the repo's docs
|
|
(1914 positions), scored with `--max-num-batched-tokens 16` so the GEMV computes every position:
|
|
|
|
| path | KL mean | median | p99 | p99.9 | max | top-1 | PPL ratio |
|
|
|---|---|---|---|---|---|---|---|
|
|
| B65, `XE2_EXACT=1` | 0 | 0 | 0 | 0 | 0 | 100% | 1.0000 |
|
|
| B65, fast GEMV | 5.9e-4 | 4.1e-4 | 3.5e-3 | 9.4e-3 | 0.045 | 98.54% | 0.9989 |
|
|
| host, libavx (reference point) | 5.7e-4 | 4.2e-4 | 3.0e-3 | 6.4e-3 | 0.016 | 98.59% | 1.0004 |
|
|
|
|
The B65's fast path is as far from libref as the production CPU library is. Greedy against libref:
|
|
7/8 prompts identical, the eighth diverging at token 18 on a 0.008-nat near-tie.
|
|
|
|
## Phase 4, step 2 (2026-10-23): XMX GEMM and one-pass attention
|
|
|
|
- `xe2_gemm_nt_xmx` / `xe2_logits_gemm_xmx` (priority 5, `M >= 17`, bf16): joint_matrix M8 N16 K16,
|
|
use::b loaded column-major straight from the [N, K] weight (probed exact on the card), eight
|
|
sub-groups a work-group sharing one 64-column slice; tail rows by the GEMV, odd shapes to the exact
|
|
kernel.
|
|
- `xe2_attn_paged` (priority 10): one pass, online softmax, keys over eight sub-groups, head_dim over
|
|
lanes; the exact kernel underneath.
|
|
- rad-kbench: fixture 499/499, MiniCPM5 482/482 (worst rel_l2 1.7e-4); every new row reached.
|
|
- KL against the libref reference (same corpus as D13): normal batching (XMX + fast attention)
|
|
mean 5.8e-4, p99 3.2e-3, top-1 98.69%, PPL x1.0001; 16-token chunks (GEMV + fast attention)
|
|
5.8e-4 / 2.9e-3 / 98.59%. Inside the bound.
|
|
- **Prefill 1795 tokens: TTFT 4.57 s = 393 tok/s (was ~17).** Decode 33.2 tok/s over 512 tokens, but
|
|
16.2 tok/s right after a 1.8k-token prompt: single-row decode attention runs 16 work-groups (one a
|
|
head) on a 160-engine card, and each kv head is read by 8 query heads. Next: split the keys across
|
|
work-groups and share a kv head's reads across its query heads.
|
|
|
|
## Phase 4, step 3 (2026-10-23): split-KV attention
|
|
|
|
Long-context decode profile (1.8k-token prompt, 64 steps): attn_paged 69.9%, gemm_nt 11.1%,
|
|
rmsnorm_quant_fp8 9.3%, gated_quant_fp8 4.1%. `xe2_attn_paged` is now flash-decoding: a work-group a
|
|
(row, kv head, key partition) whose sub-groups are the kv head's query heads (each key read once for
|
|
all 8), partitions of 32+ keys merged from 64 MiB of scratch; P = 1 for prefill-sized row counts.
|
|
A first try at 256-key partitions halved short-context decode (all keys in one partition, each
|
|
sub-group walking every key for its head): 32 keys fixed it.
|
|
|
|
- rad-kbench 138/138 and 132/132 (worst rel_l2 2.9e-4); KL mean 5.8e-4, p99 3.2e-3, top-1 98.5%.
|
|
- **Decode after a 1797-token prompt: 16.2 -> 29.8 tok/s**; short-context decode 32.0 tok/s;
|
|
1797-token prefill 4.61 s.
|
|
|
|
## Phase 4, step 4 (2026-10-23): the norm and the quantisers, still exact
|
|
|
|
`scripts/sycl/profile_decode.sh MODEL PROMPT [STEPS] [flags]` isolates decode: the same request at
|
|
1 and 1 + STEPS tokens in two profiled servers, the difference per op divided by STEPS. At a
|
|
1.8k-token context, before: 34.8 ms/step of device time -- gemm_nt 9.65, attn_paged 9.51,
|
|
rmsnorm_quant_fp8 9.12 (108 us a call for one row), gated_quant_fp8 3.52 (84 us, one work-group a row
|
|
and every value computed twice, a double exp each).
|
|
|
|
- The ordered sum reads its squares eight at a time, adding them in the same order.
|
|
- `quant_group` computes a group's values once into registers (up to 128 a group) and writes
|
|
out_bf16 itself; `gated_quant_fp8` spreads a row's groups over ceil(groups/16) work-groups.
|
|
- Still bit-identical: rad-kbench 208/208 and 206/206 at rel_l2 0.
|
|
- After: **26.6 ms/step** -- gemm_nt 9.62, attn_paged 9.50, rmsnorm_quant_fp8 3.75, logits_gemm 1.02,
|
|
gated_quant_fp8 0.87.
|
|
|
|
## Phase 4, step 5 (2026-10-23): attention, lane-per-key with vector loads
|
|
|
|
- 16 keys a step, one a lane: a lane scores its key in full against q in local memory; one max and
|
|
one sum a step; value rows accumulated with each key's weight taken from its lane. Alone: 9.5 ->
|
|
8.8 ms/step.
|
|
- Partitions split each row's *own* visible span on the device (P = 32), not the context limit.
|
|
Alone it was slower (11.5 ms: fewer active work-groups), which showed the real cost.
|
|
- bf16 cache rows read 16 bytes at a time (keys for the lane's dot, values for the lane's 8 dims):
|
|
**4.67 ms/step**. P = 64: 4.81, P = 128: 7.46 -- kept 32.
|
|
- rad-kbench 138/138, 132/132; KL mean 5.7e-4, p99 3.1e-3, top-1 98.6%.
|
|
- **Decode 55 tok/s short context, 49.2 tok/s after a 1797-token prompt (was 29.8); that prefill
|
|
1.62 s = 1109 tok/s (was 4.61 s).** Device time a 1.8k-context step 23.4 ms (profiled):
|
|
gemm_nt 9.7, attn 4.7, rmsnorm_quant_fp8 3.8.
|
|
|
|
## Phase 4, step 6 (2026-10-23): the decode GEMV, and what GRIMOIRE suggested
|
|
|
|
Per-shape times from `rad-kbench -m ... --timing-only --op gemm_nt --report FILE` (cold weights),
|
|
M = 1, MiniCPM5-2B: gate_up N=12288 K=2048 93.3 us (540 GB/s), down N=2048 K=6144 59.7 (420),
|
|
qkv N=2560 K=2048 21.0, o N=2048 K=2048 18.1. A plain read kernel reaches ~600 GB/s with
|
|
incompressible data (1042 GB/s on a memset buffer: the card compresses).
|
|
|
|
- Two columns a sub-group (commit 7a58b31): gemm_nt 9.1 -> 8.5 ms a step at 1.8k.
|
|
- **down_proj splits K two ways inside the work-group** (partials added in chunk order through
|
|
local memory, deterministic): 59.7 -> 52.2 us. 4/8/16 ways no better; splitting the K=2048 shapes
|
|
made them slower (18.1 -> 21.6 us), so only K >= 4096 splits.
|
|
- Tried and dropped: four columns a sub-group (10.9 ms a step, fewer sub-groups), K unrolled 2/4/8
|
|
loads ahead (9.2 / 9.4 / 12.3 against 8.8 ms).
|
|
- rad-kbench 361/361, 350/350; KL (chunk 16) mean 6.0e-4; greedy against libref 7/8, the eighth a
|
|
near-tie at token 14 (" and" vs " Neptune", 0.025 nats apart here, 0.048 in libref).
|
|
- **Decode 57.3 tok/s short, 51.4 tok/s after a 1797-token prompt.**
|
|
|
|
`rad_memcpy_ranges_async` read its range list on the host (commit 10455f2); device.h has the kernel
|
|
read it, and rad-kbench's timer keeps it on the card, so `--bench` / `--timing-only` crashed. Fixed:
|
|
the list is read by a kernel. rad-kbench's timer is slow on this backend (a 4-op `-m` run 7 min:
|
|
each unit restores its inputs with a small host copy).
|
|
|
|
**GRIMOIRE** (github.com/doopeworld/GRIMOIRE, a SYCL engine for the Arc Pro B70) was read on the
|
|
user's suggestion. It is GPL-3.0 and radiance is Apache-2.0, so no code comes from it; only measured
|
|
ideas were tried:
|
|
- wide loads with several in flight, sub-group-contiguous ("vec16x4", 626 GB/s there): our GEMV
|
|
already reads 16 B a lane contiguously; more loads in flight lost (above).
|
|
- decode split-K scaled with context (their attention went 3650 -> 1197 us a layer): ours already
|
|
splits each row's visible keys 32 ways (step 5).
|
|
- low-N decode GEMVs underfilling the card: the down_proj split above.
|
|
- the decode step as a replayed SYCL command graph: not taken yet. Profiled device time (21.3 ms a
|
|
step at short context, inflated by the timing events) already exceeds wall time (17.5 ms), so the
|
|
card is not waiting on the host; a graph would only trim launch gaps. Radiance's tape hooks
|
|
(`tape_begin` / `tape_play` in device.h) are where it would go.
|
|
|
|
## Qwen3.8-27B-DFLASH2-PARO-M2XFP4: the model from now on (2026-10-23)
|
|
|
|
The user put `hugypufy/Qwen3.8-27B-DFLASH2-PARO-M2XFP4/Qwen3.8-27B-DFLASH2-PARO-M2XFP4.rad` in the
|
|
library for testing and optimisation from now on (it is also the 19-22 GiB class Milestone B
|
|
asked for). Copied to `/models/qwen3.8-27b-dflash2-paro-m2xfp4/`, `cmp` identical (19.64 GiB).
|
|
|
|
- qwen35 hybrid: 64 layers, n_embd 5120, gated DeltaNet in three layers of four, full attention
|
|
every fourth (24 q / 4 kv heads, head_dim 256, imrope, rotary 64 of 256, attention output gate),
|
|
n_ff 17408, vocab 248320; a 27-block bf16 vision tower; DFlash2 drafter (depth 7, block 8).
|
|
- Weights: m2xfp4 (e2m1 codes, e8m0 per-32 scales, a u8 per-subgroup multiplier plane, learned
|
|
Givens rotations applied to the activation by `givens_dense_quant`); `output.weight` fp8 128x128
|
|
blocks; the drafter head u2 with zero points.
|
|
- M2XFP4 is not in upstream radiance: merged `hugypufy/radiance` branch `m2xfp` (upstream PR #203,
|
|
Apache-2.0, 8 commits on our base 9eaf10d) at the user's go-ahead, commit 6fbe59b, no conflicts.
|
|
Its `kbench_m2xfp4` test loads libr4d, so it is now registered only in a HIP build (6174d5e).
|
|
`ctest -LE 'gpu|oot'`: 84/89, the five known failures.
|
|
- On the SYCL build the engine refuses to start, as it must: no device kernel for
|
|
- linears: `gemm_nt_q` (m2xfp4; u2 for the drafter head), `givens_dense_quant`, `logits_gemm`
|
|
(fp8 blocks), `gemm_nt_bias`
|
|
- gated DeltaNet: `gdn_conv_prep`, `gdn_conv_update`, `gdn_kkt_solve`, `gdn_chunk_scan`,
|
|
`gdn_recurrent_update`, `gdn_conv_recurrent_update`, `gdn_gated_rmsnorm`
|
|
- attention and elementwise: `rope` mode imrope, `rope_table`, `sigmoid`, `mul`, `scatter_rows`
|
|
- drafter: `dflash_conv`, `logit_rerank`; vision: `attn_dense`, `layernorm`, `grid_embed`
|
|
|
|
Plan: correctness-first libxe2 kernels for every op above, each held to libref by rad-kbench on
|
|
this container (`-m`), until the model serves and is greedy-identical to the libref host backend
|
|
(Milestone B); then the fast kernels (m2xfp4 GEMV/XMX, DeltaNet scan) under the KL bound, with
|
|
BetterBench after each.
|
|
|
|
## Qwen3.8-27B on the B65: bring-up and the first fast kernels (2026-10-24)
|
|
|
|
Goal set by the user: beat vLLM-SYCL on Qwen3.8-27B int4 (~90 tok/s decode, ~1200 tok/s prefill).
|
|
|
|
**Bring-up (4921641).** Every op the container needs got a correctness-first libxe2 kernel in
|
|
libref's arithmetic and order: m2xfp4 gemm_nt_q with libref's m2 layout hooks, givens_dense_quant
|
|
(double, as libref), the gated delta net (seven ops), rope's mrope/imrope/axial and rope_table,
|
|
the fp8 joined logits head, gemm_nt_bias, mul, sigmoid, scatter_rows, layernorm, grid_embed,
|
|
attn_dense, dflash_conv, logit_rerank. libref's gemm_m2 gained the parts (pb1/pb2) every other
|
|
ParoQuant grid and libr4d already define (the oracle refused this model's fused projections), and
|
|
both m2 arms take the engine's u8 [N, K] view of the codes-then-meta blob. rad-kbench: every new
|
|
row at rel_l2 0 on the fixture; the exact m2 kernel rel_l2 0 against libref on the 27B (parts
|
|
included). First greedy answer: "The capital of France is" -> " Paris.\nThe capital of Germany is
|
|
Berlin...", 0.1 tok/s.
|
|
|
|
**Fast kernels (07cdc54, 55a350f, and the gdn commits).**
|
|
|
|
| op | form | 27B decode, before -> after |
|
|
|---|---|---|
|
|
| m2xfp4 GEMV, M = 1 | e2m1 to fp16 by bits ((mag << 9) \| sign << 15 = e2m1 * 2^-14, fp16 subnormals kept), K permuted (u, u+4), fp16 activation and group sums | 157.6 -> 40.5 ms a token (scalar f32 form: ALU-bound, ~10 ops a weight) |
|
|
| m2xfp4, 2 <= M <= 16 (verify) | lane-per-column decode into a VNNI slice of local memory, DPAS | gate_up at M = 8: 1159 -> ~490 us |
|
|
| m2xfp4, M >= 17 (prefill) | weight decoded to bf16 (exact), bf16 XMX | -- |
|
|
| givens_dense_quant | sub-group an output, coalesced rotation rows, the double sum as a float pair | 146 -> 5.4 ms |
|
|
| fp8 joined head | E4M3 to fp16 by bits ((b & 0x7F) << 7 = E4M3 * 2^-8) | 43 -> 3.9 ms |
|
|
| w2a8 draft head | sub-group a column, exact integer groups, libref's group terms in order: **bit-identical** (0 bytes differ, live) | 252 ms -> < 1 ms a call |
|
|
| logit_rerank | sub-group a candidate, float-pair sum, libref's selection | 136 ms -> negligible a call |
|
|
| gdn recurrence | 16-column blocks (384 work-groups), state in registers (grf 256), gates once a (token, head): **bit-identical** | 431 -> 173 us a call |
|
|
| rmsnorm_quant_fp8 | row in local memory, loads before stores, ordered sum by broadcasts: **bit-identical**; the chain alone has a ~32 us floor for 5120 (probe) | 103 -> 96 us a call |
|
|
|
|
rad-kbench: 1410/1410 on the fixture; on the 27B the M <= 32 bands 77/77 and the verify band
|
|
50/50 (m2 rel_l2 ~1e-3, tolerance 4e-2). Measured: **12.1 tok/s plain greedy, 13.2 tok/s with the
|
|
DFlash2 drafter** (device time a token 78 / 71 ms). With the fast kernels the drafter's greedy text
|
|
departs from plain decoding at a near-tie (byte 246 of 256 tokens): the M = 8 verify and the M = 1
|
|
GEMV round differently; with the exact kernels the two were identical.
|
|
|
|
**Accuracy (KL).** libref cannot run a 27B forward on this host in reasonable time, so the
|
|
reference is the SYCL engine with `XE2_EXACT=1` (every kernel in its exact form; each exact form
|
|
matched libref bit for bit wherever checked), recorded over a 3-document, 250-position mini corpus
|
|
in 64-token chunks (the model's DeltaNet chunk). The fast set against it: **KLD mean 0.0035-0.0037,
|
|
median ~0.0025, p99 ~0.021, top-1 95.6-97.2%, PPL ratio 0.995-0.998** (the model's own quantisation
|
|
error against bf16 is 0.0211 per its README). The fast set's KL is dominated by the fp8 activation
|
|
quantiser in front of every linear re-rounding small upstream differences; moving the prefill GEMM
|
|
from bf16 to fp16 activations took it 0.0041 -> 0.0035.
|
|
|
|
**Prefill (1792 tokens).** 26.3 s (68 tok/s) -> **17.0 s (105 tok/s)**:
|
|
- gdn_chunk_scan chain-parallel (a work-group of 256 a (head, 32 value columns), every phase's
|
|
independent chains spread, still bit-identical): 11.2 -> 4.6 s
|
|
- m2xfp4 GEMM fp16 (weight exact in fp16 after its column's e_max, activation fp16(a / R)) on a new
|
|
local-memory-tiled XMX kernel (128 x 128 tiles, 32 x 64 a sub-group, ~30 TFLOPS against the
|
|
card's ~98 fp16 DPAS peak, measured): 6.4 -> 3.7 s
|
|
- givens_dense_quant as batched XMX GEMMs for rows >= 17: 2.07 -> 0.70 s
|
|
- attn_paged at head_dim 256: the value rows read 16 bytes at a time (they were scalar): 2.72 ->
|
|
0.88 s (rad-kbench 138/138 fixture, 33/33 on the 27B)
|
|
- tried and dropped: a chunk-parallel kkt_solve (exact but slower, 1.44 -> 2.14 s).
|
|
|
|
Remaining prefill (profiled): chunk scan 4.6 s, GEMMs 3.7, attention 2.7 (head_dim 256, the
|
|
lane-per-key kernel), kkt 1.4, the rest ~2.4. A 27B prefill at 1200 tok/s needs ~65 TFLOPS of
|
|
GEMM alone, two thirds of this card's DPAS peak.
|
|
|
|
Probes in the scratch directory, not in the tree: `gemm.cpp` (XMX GEMM tilings), `peak.cpp`
|
|
(DPAS peak), `scan.cpp` (the chunk scan's phases), `m2bench.cpp` (decode GEMV variants on synthetic
|
|
m2xfp4 data), `chain.cpp` (the ordered-sum floor), `jmap.cpp` (joint_matrix_apply coordinates on a
|
|
packed B -- lost the device; not used).
|
|
|
|
## Qwen3.8-27B: the speculative round (2026-10-24)
|
|
|
|
**What the target means.** The user's vLLM numbers (~90 tok/s decode, ~1200 tok/s prefill) are for
|
|
`Swift-1.5-Qwen3.8-27b-GPTQ-Int4-baked-v1-embed-int8` with MTP6 speculation: its model card's own
|
|
records (`benchmarks/swift-baked-coding-c1.jsonl`) show ~5.3 tokens a round at ~68 ms a round. One
|
|
token at a time is bandwidth-bound near 40 tok/s on this card, so the lever is the cost of a round,
|
|
not acceptance: radiance's DFlash2 drafter already lands 4.2-4.3 tokens a round (45-47% of drafts
|
|
accepted, `/metrics` `radiance:draft_*`), but a round cost ~235 ms.
|
|
|
|
**Per round, device time** (`scripts/sycl/profile_decode.sh`, 256 tokens, grouped by geometry):
|
|
|
|
| op | before | after | how |
|
|
|---|---|---|---|
|
|
| w2a8 draft head (N=248320) | 24.0 ms | 4.2 | int8 DPAS on the group sums, u2 codes unpacked into the packed B tile; lane-per-column group terms in order: bit-identical (63/63 live calls against the libref-checked form) |
|
|
| dflash_select | 11.4 | 0.5 | a sub-group a sequence, a lane a candidate in libref's order: exact |
|
|
| row_topk (R=32 of 248320) | 3.2 | 0.95 | 128 chunks' top R, then the top R of the winners: exact |
|
|
| logits head, M = 8 | 9.5 | 3.5 | E4M3 by bits into a packed fp16 tile, fp16 DPAS, a scale block's sum scaled in f32 (also M = 1: 3.9 -> 3.4) |
|
|
| gemm_nt bf16, N=96 x 48 | 7.7 | 1.4 | M <= 8 on bf16 DPAS, 8 activation rows in local memory, K split |
|
|
| rmsnorm_quant_fp8 x 128 | 17.2 | 6.5 | 16-byte loads and stores for bf16 rows (gain bf16 or f32): 112 -> 44 us a call, bit-identical (408/408 live) |
|
|
| gdn_conv_recurrent_update x 48 | 32.7 | ~13 | typed q/k/v and an f32 state moved 16 rows at a time through local memory: the 8-token pass 408 -> 101 us, the replay 222 -> 110 us; bit-identical (400/400 live) |
|
|
| m2xfp4 verify GEMMs | ~86 | ~75 | DPAS on registers (`dpas_f16`, SPV_INTEL_subgroup_matrix_multiply_accumulate): a lane decodes its column straight into B, no local memory; 15-20% a call |
|
|
|
|
**End to end** (greedy, 512-token answers, drafter on): **30.4-30.9 tok/s** (was 14.0); prefill 124
|
|
tok/s at 2584 tokens (unchanged).
|
|
|
|
**Learned on the way.**
|
|
- libxe2's generic element accessors (`rad_load_f32` / `DT::ld`, a dtype switch an element) inside
|
|
a kernel's hot loop cost far more than their instruction count: the gdn register kernel ran 8x a
|
|
probe of the same loop until its accessors were typed. Kernels that stream with them are suspects.
|
|
- The m2 verify GEMM's weight stream is not the limit by layout: the lane-a-row 64-byte pattern
|
|
reads 89 MB of codes at 526 GB/s alone (a contiguous 1 KiB-a-sub-group layout: 281 GB/s, probe
|
|
`pat.cpp`); the kernel loses its time on the activation loads and the decode not overlapping it.
|
|
Tried and slower: two column tiles a lane (463 -> 639 us), the step's activation loads batched
|
|
ahead (-> 586 us), longer per-lane runs (KS 8/16), more K splits, a software-pipelined line load.
|
|
- VTune's GPU analyses do not run here (it does not recognise the host CPU); the per-kernel split
|
|
above came from temporary waits around each sub-kernel.
|
|
|
|
## Qwen3.8-27B: prefill (2026-10-24, continued)
|
|
|
|
1882-token prompt, device time by op (`--profile-ops`), before -> after:
|
|
|
|
| op | before | after | how |
|
|
|---|---|---|---|
|
|
| gdn_chunk_scan | 4.80 s | 0.92 | typed loads for the engine's bf16/f32 operands (4.8 -> 2.7), then 1024 work-items a work-group: its ~124 KB of local memory leaves one a Xe core, and 256 left three quarters of the core idle (2.7 -> 0.92). Exact |
|
|
| gdn_kkt_solve | 1.51 | 0.33 | a work-group a (head, chunk) -- chunks are independent -- the row terms over 512 work-items, then the solve from local memory. Exact |
|
|
| gdn_conv_prep | 0.54 | 0.45 | the conv a work-item a (token, channel), the gate cumsum a work-item a (head, chunk). Exact |
|
|
| gdn_gated_rmsnorm | 0.38 | 0.20 | the row staged in local memory before the ordered sum. Exact |
|
|
| m2xfp4 GEMMs (M >= 17) | 4.06 | see below | oneMKL's fp16 GEMM (f32 accumulate) in place of the hand-tiled XMX kernel |
|
|
|
|
oneMKL (part of oneAPI, linked by libxe2 when found; `RAD_XE2_MKL=OFF` or `XE2_NO_MKL=1` keeps the
|
|
hand-tiled kernel): 85-91 TFLOPS on random fp16 data at the 27B's shapes (probe `mklg.cpp`:
|
|
M=941 N=34816 K=5120 3.8 ms, M=1882 N=5120 K=17408 3.7 ms), deterministic run to run, against
|
|
~23-30 for the hand-tiled kernel. The prefill rotation's batched GEMMs use its `gemm_batch`.
|
|
|
|
## Next steps
|
|
|
|
1. The verify round, ~137 ms now against vLLM's ~68: the m2xfp4 verify GEMMs (~75 ms, ~2.5x their
|
|
bandwidth floor), givens_dense_quant at M = 8 (~19 ms), the DeltaNet conv (~70 us x 48) and its
|
|
norm kernel, embed_lookup over the x1 link (4 ms: the table is host-pinned), attention.
|
|
2. Prefill (124 tok/s): the chunk scan (4.6 s of 1792 tokens; its probe runs 3x faster than the
|
|
engine's kernel), the prefill GEMM (~30% of the DPAS peak), kkt.
|
|
|
|
## Next steps (Milestone era)
|
|
|
|
1. ~~Milestone B, part 2: `minicpm5-2b-fp8.rad`~~ **Dropped by the user (2026-10-23): "instead of the
|
|
fp8 use the one you are already using so the bf16".** Milestone B's MiniCPM5 half is the bf16
|
|
container with its DSpark drafter, done above.
|
|
2. A 19-22 GiB container: none is in the library as `.rad` (the two Swift-1.5 Qwen3.8-27B int4
|
|
checkpoints there are safetensors, not containers). Asking the user which to use / for a container.
|
|
3. Phase 4 can start now that Milestone A is correct: XMX GEMMs and a split-KV attention, each checked
|
|
against the correctness-first kernels and libref with both checks (D12).
|
|
|
|
## Next steps (previous list, kept for reference)
|
|
|
|
1. Milestone B: `minicpm5-2b-fp8.rad` (**not in the library; asked**), the DSpark drafter's ops
|
|
(fp8a8 GEMMs, `gemm_nt_q_gated`, `w2a8` head, `quant_act_i8`, `row_topk`, `dflash_select`,
|
|
`silu_mul`, non-causal attention), then a 19-22 GiB container. The 27B models at correctness-
|
|
first speed will be very slow (a serial-dot GEMM over 27B weights), so their end-to-end check may
|
|
come after the first XMX GEMM (Phase 4 order adjusted only for the big model, not for
|
|
correctness: the fast GEMM is checked against the slow one and libref first).
|
|
2. `code_runs` under SYCL from `build_target` (D4); install rules and the `oot` rebuild for
|
|
`librad_sycl.so` and libxe2.
|
|
|
|
## Notifications
|
|
|
|
`scripts/sycl/notify.sh "msg"` posts to the Discord webhook (user's request, 2026-10-23): used for
|
|
blockers, questions and milestones. Tested: posted.
|
|
|
|
## HIP compile check
|
|
|
|
2026-10-23, commit `370a906` (the SYCL backend, every core-side change): built in docker,
|
|
`rocm/dev-ubuntu-24.04:10.1.0-full` (HIP 7.16, AMD clang 24.0.0git, the Dockerfile's base with its
|
|
stock compiler rather than the Dockerfile's patched LLVM), `cmake -DRAD_WITH_HIP=ON
|
|
-DRAD_GPU_TARGETS=gfx1201`, g++-14: **785/785 targets, 0 errors**, libr4d included. Later commits add
|
|
only libxe2 and sycl/, which a HIP build does not compile. Re-run after any core change:
|
|
|
|
```sh
|
|
git worktree add --detach /tmp/hipsrc HEAD
|
|
docker run --rm -v /tmp/hipsrc:/src:ro rocm/dev-ubuntu-24.04:10.1.0-full bash -c '
|
|
apt-get update -qq && apt-get install -y -qq --no-install-recommends cmake ninja-build pkg-config g++-14 gawk
|
|
export CC=gcc-14 CXX=g++-14 ROCM_PATH=/opt/rocm HIP_PATH=/opt/rocm
|
|
cmake -S /src -B /build -G Ninja -DRAD_WITH_HIP=ON -DRAD_GPU_TARGETS=gfx1201 && cmake --build /build -j6'
|
|
git worktree remove --force /tmp/hipsrc
|
|
```
|
|
|
|
## Reproduce the current state
|
|
|
|
```sh
|
|
. /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
|
|
```
|