Archived
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
966 lines
68 KiB
Markdown
966 lines
68 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 -> 53.2 tok/s decode on BetterBench with the DFlash2 drafter (`2a5e815`), prefill 356 tok/s at 2000 tokens (vLLM-SYCL's reference ~90 / ~1200), 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 | `35708cd` | qwen38-27b-m2xfp4 | sycl, + verify GEMM epilogue fused, givens/attention/head on register DPAS, typed gdn, exact chunk-parallel kkt and 1024-wide chunk scan, oneMKL prefill GEMMs | `--max-model-len 8192 --max-num-seqs 1 --embedding-placement vram` | 341.0 / 340.2 @2000 | 37.0 / - | decode +28.2%, prefill +159.8% | `~/radiance-bench/runs/20261024-175851-qwen38-27b-m2xfp4-35708cd/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-25 | `ef6c6e1` | qwen38-27b-m2xfp4 | sycl, verify GEMM in ESIMD, gdn load order | `--max-model-len 8192 --max-num-seqs 1 --embedding-placement vram` | 356.4 / 355.6 @2000 | 44.4 / - | decode +19.8%, prefill +4.5% | `~/radiance-bench/runs/20261025-111356-qwen38-27b-m2xfp4-ef6c6e1/results.html`, posted with `report.jpg` |
|
|
| 2026-10-25 | `340231d` | qwen38-27b-m2xfp4 | sycl, + e_max in the prepass, range-copy staging, w2a8 head staging, 16-byte exponent gathers | same | 356.3 / 355.4 @2000 | 48.2 / - | decode +8.7% | `~/radiance-bench/runs/20261025-142422-qwen38-27b-m2xfp4-340231d/results.html`, posted with `report.jpg` |
|
|
| 2026-10-26 | `68d510b` | qwen38-27b-m2xfp4 | sycl, + m2xfp4 codes tiled at load | same | 356.0 / 354.8 @2000 | 52.0 / - | decode +7.9% | `~/radiance-bench/runs/20261026-014745-qwen38-27b-m2xfp4-68d510b/results.html`, posted with `report.jpg` |
|
|
| 2026-10-26 | `2a5e815` | qwen38-27b-m2xfp4 | sycl, + meta/exponents tiled with stored e_max, quant_act_fp8 per group, the w2a8 head on u2 DPAS | same | 355.3 / 354.6 @2000 | 53.2 / - | decode +2.2% | `~/radiance-bench/runs/20261026-034439-qwen38-27b-m2xfp4-2a5e815/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 | 1.66 | oneMKL's fp16 GEMM (f32 accumulate) in place of the hand-tiled XMX kernel; the weight decode to fp16 a (column, 32-group) a work-item |
|
|
| gemm_nt bf16 (N = 96) | 0.49 | ~0 | oneMKL's bf16 GEMM: N = 96 had fallen to the exact kernel |
|
|
| givens_dense_quant | 0.74 | 0.52 | the register-DPAS form at every row count (one pass instead of copy, batch GEMM, quantiser) |
|
|
| rmsnorm_quant_fp8 | 0.30 | 0.16 | a row's values kept in registers, only the squares in local memory (more rows a Xe core). Exact |
|
|
|
|
KL against the exact-kernel reference (the 250-position corpus in 64-token chunks, as above): the
|
|
set as of `ea38ec6` **KLD mean 0.0040, top-1 94.0%, PPL ratio 0.997**; with `XE2_NO_MKL=1` 0.0037,
|
|
96.8% (the earlier 0.0035-0.0037). oneMKL's GEMM itself is f32-accurate (rel_l2 1.5e-7 against a
|
|
double reference on random fp16 data, probe `mklp.cpp`); both forms carry the same fp16 rounding of
|
|
the activation, so this is a different set of near-ties tipping (7 of 250 top-1 positions), not a
|
|
less accurate GEMM. Kept for the 2.4x faster prefill GEMMs; noted for the user's judgement.
|
|
|
|
**Prefill, 1882 tokens: 131 -> 324 tok/s** (device time ~14.3 -> ~5.8 s). Left: the GEMMs 1.66 s
|
|
(oneMKL ~1.2 of it), attention 0.99 (the SIMT flash kernel, ~1.6 TFLOPS), the chunk scan 0.92,
|
|
givens 0.52, conv_prep 0.47, kkt 0.33, gated_quant 0.27 (half of it libref's double exp: 15 G/s on
|
|
this card, a third of float's).
|
|
|
|
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`.
|
|
|
|
Tried and not kept: prefill attention on register DPAS (a work-group a (kv head, 8 query rows), a
|
|
sub-group a query head, K and V^T staged in local memory a 16-key step, bf16 DPAS for Q K^T and
|
|
P V, online softmax in f32; correct, 120/120 on the 27B at rel_l2 2.3e-3). It ran no faster than
|
|
the SIMT kernel (~26-31 ms a 1882-row call): switching off its reductions, either DPAS or the global
|
|
staging loads changed nothing, skipping its compute did -- the cost is its local-memory operand
|
|
loads (~200 a step a sub-group, every query head re-reading the step's keys). A layout that shares
|
|
the K operand across query heads (or oneDNN's SDPA) is the next attempt.
|
|
|
|
## Qwen3.8-27B: the verify GEMM in ESIMD (2026-10-25)
|
|
|
|
Per round (5 tokens, `profile_decode.sh` at 256 tokens, `--embedding-placement vram`): device time
|
|
~110 ms, of it the m2xfp4 GEMMs ~69 (gate_up N=34816: 444 us a call for 100 MB, 226 GB/s), the
|
|
DeltaNet update ~11, givens ~6.8, rmsnorm_quant ~6.4, the logits head 3.5, attention 3.2. Wall
|
|
time is ~27 ms a token against ~22 of device time (the profile's own synchronisations included),
|
|
so ~25 ms a round is the card waiting on the host.
|
|
|
|
**What the register-DPAS kernel spends its time on** (probe `m2v.cpp`, gate_up's shape, M = 8,
|
|
synthetic codes, GPU warmed up first -- the first runs after idle are 2x slow on clocks alone):
|
|
|
|
| variant | us | GB/s |
|
|
|---|---|---|
|
|
| as in libxe2 | 333 | 301 |
|
|
| no weight decode (raw words as B) | 193 | 520 |
|
|
| no scale multiply (kh = 1) | 195 | 515 |
|
|
| no activation loads | 266 | 377 |
|
|
| no code loads | 250 | 401 |
|
|
| no DPAS | 302 | 332 |
|
|
|
|
The weight stream is not the limit: the ALU work is. IGC's ISA for the SYCL kernel shows why: a
|
|
lane's `vec<half, 2>` multiply by the (1 + k/4) 2^d factor becomes two SIMD16 fp16 multiplies and
|
|
four moves splitting and repacking the pair -- ~10 instructions a weight pair, 499 moves in the
|
|
loop. ESIMD (what Intel's own int4 kernels in IPEX use) states the register layout directly: a
|
|
thread owns 16 columns, its codes arrive by LSC d32x4 gathers as [dword][lane] registers, so a
|
|
word of 8 nibbles is one register across the 16 columns and a decoded pair is one SIMD32 fp16
|
|
multiply. `xe2_gemv_m2_esimd.cpp`, probe `m2e.cpp`:
|
|
|
|
| variant | us | GB/s |
|
|
|---|---|---|
|
|
| ESIMD, loops left rolled by the VC compiler (indirect register access) | 400 | 250 |
|
|
| ESIMD, unrolled | **240** | **417** |
|
|
| ESIMD, raw words (its floor) | 185 | 543 |
|
|
| ESIMD, decode without the multiply | 217 | 463 |
|
|
|
|
Bit-identical to the SIMT kernel's output (0 of 278528 differ); 64/128/256-register modes and work-
|
|
group sizes 4-16 change nothing; a double-buffered line load spilled and ran at 383; LSC prefetch
|
|
of the next step's codes 1/2/4 steps ahead ran at 295/328/435 (worse); scanning e_max 16 bytes a
|
|
lane at a time 279 (worse). Weights rotated over 4 copies (cold, as the engine streams them): 265.
|
|
|
|
**In libxe2 the same kernel first ran at 379 us** (rad-kbench `--bench`, cold; SIMT 403): not
|
|
clocks, data, flags or memory placement -- compiled into a harness on the probe's data it was
|
|
still 380. The ISA showed why: the activation's 256-byte block load sat right before its DPAS, one
|
|
per DPAS, each waiting its own latency, where the probe's compiler had hoisted them. Loading the
|
|
step's eight A blocks together with the code lines (`As`) fixes it: 256 us. rad-kbench, cold,
|
|
libxe2 against libref 50/50 passed (worst rel_l2 1.4e-3):
|
|
|
|
| shape (M = 8) | SIMT | ESIMD | ESIMD, A loaded with the codes |
|
|
|---|---|---|---|
|
|
| gate_up N=34816 K=5120 | 403 | 379 | **256** |
|
|
| down N=5120 K=17408 | 208 | 192 | **156** |
|
|
| N=12288 K=5120 | 208 | 174 | **133** |
|
|
|
|
The verify GEMM now costs what the M = 1 GEMV does (gate_up 248-262 us), ~400 GB/s. (The "839
|
|
GB/s" of rad-kbench's copy probe is not the card's read rate on real weights: see the next section,
|
|
~560 GB/s on incompressible data.) Greedy output identical to before (8
|
|
prompts x 64 tokens); a story prompt (3.3 tokens a round) decodes at 30.3 tok/s, was 24.6.
|
|
|
|
**The DeltaNet update** (`gdn_conv_recurrent_update`) issued each of its 128 state loads after a
|
|
local-memory store through a generic pointer, which IGC must order behind the store: every load a
|
|
full round trip. Loading the rows into registers first, then storing: 234 -> 166 us a call
|
|
(`profile_decode.sh`). The same values reach the same local slots, so the arithmetic is unchanged;
|
|
rad-kbench has no shape recipe for the op, so it was checked end to end only (greedy output above).
|
|
|
|
**Other repositories.** vLLM's XPU int4 (GPTQ) path is oneDNN's `int4_gemm_w4a8`
|
|
(vllm-xpu-kernels lists only FP8/MXFP4 GEMMs of its own); vLLM captures decode graphs on XPU
|
|
(`cudagraph_mode FULL_DECODE_ONLY` in the user's own launch line). llama.cpp's SYCL backend
|
|
reorders Q4_0/Q4_K weights at load (quants and scales separated for coalesced reads) and has SYCL
|
|
graph support, off by default ("not yet faster", host waits unsupported while recording). Intel's
|
|
weight-only-quantization write-up describes IPEX's int4 GEMMs as ESIMD kernels with templated
|
|
work-group/sub-group levels.
|
|
|
|
## Qwen3.8-27B: the round on unitrace, and stall sampling (2026-10-25, continued)
|
|
|
|
**Measuring.** `--profile-ops` synchronises every op and the profiling queues cost ~20 us a
|
|
submission, so a multi-kernel op's number is bounded by host submission, not device time (gdn's
|
|
"90 us of other kernels" was that). Intel's unitrace (pti-gpu, built from source without root:
|
|
`cmake -S pti-gpu/tools/unitrace -DBUILD_WITH_MPI=0 -DBUILD_WITH_ITT=0 -DBUILD_WITH_XPTI=0`) gives
|
|
per-kernel device time at no visible cost to tok/s (`unitrace -d`), and on this card **EU stall
|
|
sampling** works without root (`/proc/sys/dev/xe/observation_paranoid` is 0): `unitrace
|
|
--stall-sampling` reports, per ISA instruction, active cycles and stalls by cause (send, scoreboard,
|
|
pipe, ...). It works for probes and rad-kbench; the server's SIGINT teardown loses the samples.
|
|
|
|
**The card's read rate.** An ESIMD streaming kernel reads 938 GB/s of a constant fill and **~560
|
|
GB/s of hashed data** (probe bw2.cpp; flat-CCS compression). Real 4-bit codes do not compress, so
|
|
~560 GB/s is the ceiling to judge GEMVs by: a round's ~13.2 GB of weights cost >= ~24 ms. The card
|
|
has 160 EUs x 8 threads = 1280 resident threads (20 Xe cores).
|
|
|
|
**Where a round goes** (story prompt, 2.8 tokens a round, 400 tokens, unitrace -d; before the
|
|
fixes below): 86.7 ms of device time a round against ~96 of wall time; the host is blocked in waits
|
|
80% of the time (instrumented rad_stream_sync / rad_event_sync) and xpu-smi shows the compute engine
|
|
100% busy, so decode is device-bound -- a graph/tape would recover at most the ~10 ms of gaps.
|
|
|
|
| kernel | ms a round | calls | us a call |
|
|
|---|---|---|---|
|
|
| m2xfp4 verify GEMM (ESIMD) | 38.6 | 329 | 117 |
|
|
| rmsnorm_quant_fp8 | 6.2 | 129 | 48 |
|
|
| givens_dense_quant | 6.0 | 290 | 21 |
|
|
| gdn recurrent (two phases) | 4.8 | 96 | 50 |
|
|
| GEMM prepass + split reduce | 4.9 | 329 + 260 | 11 / 5 |
|
|
| logits head (head_dpas) | 3.5 | 1 | 3475 |
|
|
| attention | 3.2 | 21 | 150 |
|
|
| w2a8 draft head (zp_dpas) | 2.8 | 1 | 2807 |
|
|
| step-upload range copy | 1.95 | 3 | 648 |
|
|
|
|
**Fixed** (each checked: rad-kbench against libref where it has a recipe, greedy output identical):
|
|
- *e_max in the prepass launch*: the split-K shapes' per-column exponent max was a launch of its
|
|
own (7.8 us x 260 a round); extra work-groups of the activation prepass form it now. Down
|
|
156 -> 142 us.
|
|
- *Range copies*: the step upload's copy kernel read its range list and sources from pinned host
|
|
memory -- over PCIe x1 a round trip a load, 648 us a call. Staged into a per-stream device buffer
|
|
first (core/device/sycl.cpp): gone from the profile.
|
|
- *w2a8 head staging*: its activation staging loaded through a generic pointer after each local
|
|
store (the gdn pattern again): 2.81 -> 2.55 ms.
|
|
- *Exponents and metadata four steps a gather*: stall sampling put 43% of the verify GEMM's samples
|
|
on **send stalls** (the memory request queue full), 3.7% on scoreboard waits: the kernel is bound
|
|
by memory *messages*. 4-byte gathers of the exponents and metadata were a third of its cache-line
|
|
requests for an eighth of its bytes; 16-byte gathers covering four steps: gate_up 253 -> 244,
|
|
down 142 -> 131 us (probe: 276 -> 246).
|
|
|
|
**Tried, no gain** (kept out): 2D block loads of the codes (transposed d32, 258 vs 240 us); a
|
|
double-buffered code line (274 vs 275); K splits 2/4 (worse); rotating each thread's K start to
|
|
break load/compute convoys (300 vs 275); LSC prefetch 1-4 steps ahead (worse); givens' T rows loaded
|
|
before staging (20.7 -> 20.5 us); the gdn phase-1 chains rescheduled for latency (norms a token a
|
|
lane, output and next sk2 fused; 49.9 -> 49.6 us -- the chains are not its limit); a ring of four
|
|
groups of codes and scales ahead in the w2a8 head (4.7 ms, worse); unrolling the prepass loads
|
|
(10.8 -> 14.6 us, worse); the split-K reduction done by each tile's last split (an atomic counter a
|
|
tile, partials past L1) instead of its own kernel: correct, but slower at every split shape (down
|
|
131 -> 140 us, N = 1024 28 -> 50) -- the last thread's serial tail costs more than the launch. The ordered sum of squares in rmsnorm_quant runs at ~13 cycles an element
|
|
however it is staged (31 us for 5120: probe chain2.cpp), and a tree sum failed the op's tolerance
|
|
before (MiniCPM5), so ~30 us of its 44 stay.
|
|
|
|
**The small kernels under stall sampling** (rad-kbench): attention 42% scoreboard + 20% distance
|
|
stalls (its dot products are dependent add chains, no send pressure); rmsnorm 45% at a barrier
|
|
(the group waits for sub-group 0's ordered sum); gated_quant_fp8 in f64 multiply-adds (pipe and
|
|
distance stalls); quant_act_fp8 and the bf16 gemm_nt (launch_dpas8) on distance / scoreboard /
|
|
instruction-fetch stalls. None is byte-bound: launches that each do little, and ~2000 of them a
|
|
round -- fusion, or more work a launch, rather than faster loads.
|
|
|
|
**Layout headroom measured**: a tiled code layout (a 16-column tile's step 1 KiB contiguous, read
|
|
by block loads) on top of the 16-byte exponent gathers gives 246 -> 229 us at gate_up's shape
|
|
(probe m2d.cpp) -- taken in the next section.
|
|
|
|
## Qwen3.8-27B: the m2xfp4 planes tiled at load, and the launch floor (2026-10-26)
|
|
|
|
**Tiled planes** (`68d510b`, `dad30c6`). libxe2's m2xfp4 layout hook no longer asks for libref's
|
|
"m2.codes.meta" where N % 16 == 0 and K % 512 == 0 (every linear of the 27B): the codes are stored
|
|
as the verify GEMM's registers ("xe2.m2.tiled16": a 16-column tile's 128-column step is 1 KiB,
|
|
dword w of the 16 columns side by side, four block loads a step), the meta bytes and the E8M0
|
|
exponents in chunks of a tile's 16 groups (256 bytes, [dword][lane]; the exponents as `b_scale`'s
|
|
own stored form, "xe2.m2.e8m0.t16"), and each column's largest exponent is computed once at load
|
|
and stored after the exponents, so no call scans the plane for it any more. Every m2 reader in
|
|
libxe2 (exact, SIMT GEMV, both DPAS forms, ESIMD, the prefill decode) reads the tiled forms;
|
|
unrelayout inverts them exactly (the column maxima are derived and dropped), so the oracle still
|
|
checks the op. M = 1 now takes the ESIMD kernel too. rad-kbench against libref: 70 checked, 70
|
|
passed (worst rel_l2 1.2e-3) after each step; greedy output identical.
|
|
|
|
| shape (us) | before | codes tiled | + meta, exponents, stored e_max |
|
|
|---|---|---|---|
|
|
| gate_up N=34816 K=5120, M = 8 | 240 | 222 | **205** |
|
|
| gate_up, M = 1 | 248 | 214 | **201** |
|
|
| down N=5120 K=17408, M = 8 | 140 | 119 | **113** |
|
|
| N=5120 K=25600, M = 8 | 213 | 178 | **160** |
|
|
| N=1024 K=5120, M = 8 | 50 | 25 | **24** |
|
|
|
|
The round (story prompt, unitrace -d): 84.4 -> 77.3 ms of device time; the verify GEMM 38.6 ->
|
|
31.9 ms (329 calls, 97 us a call), now ~75% of the 560 GB/s ceiling on average. BetterBench at
|
|
`68d510b` (codes only): decode 48.2 -> 52.0 tok/s.
|
|
|
|
**quant_act_fp8** (`ed8e26c`): a row's work-group walked its 128-column groups sixteen at a time,
|
|
~5 us a group of dependent loads, reduction and stores (49.6 us at n = 17408 whatever M). A
|
|
sub-group a (row, group) instead, as gated_quant_fp8 already did: 8.0 us, rel_l2 0 against libref.
|
|
|
|
**The w2a8 draft head on 2-bit DPAS** (`34ae231`, `2a5e815`). This card's int8 DPAS takes u2 B
|
|
operands against s8 A, 16 codes a dword from the low end (probe dpas_u2.cpp; the 8-bit layout's
|
|
"4 codes in a byte" packing gives wrong sums). So the DFlash2 drafter's head (248320 x 5120 u2,
|
|
group 128, f16 scale, u8 zero) needs no decode: gemm_zp_layout stores its codes tiled
|
|
("xe2.zp.u2.t16", a 16-column tile's 32-column step 128 bytes [dword][lane], each dword the
|
|
column's codes at quant_act_i8's stored positions, so the activation's step order is folded into
|
|
the layout), and an ESIMD kernel (xe2_gemm_zp_esimd.cpp) feeds them to DPAS as they lie, the
|
|
activation staged once a work-group in local memory as the A operand. Each group's integer sum is
|
|
exact and the group terms are added in order, as zp_dpas and libref do. Checked on 20 calls of the
|
|
engine's own inputs against the SIMT GEMV on the same bytes, 0 of 1738240 outputs differ each
|
|
(rad-kbench has no w2a8 recipe on this container), greedy output identical.
|
|
|
|
| form | ms a call |
|
|
|---|---|
|
|
| zp_dpas (SIMT, per-lane 8-byte code loads, B decoded) | 2.56 |
|
|
| ESIMD, 16 threads a work-group | 1.66 |
|
|
| 32 threads (the 40 KB staging shared by more columns) | 0.96 |
|
|
| 32, a group's codes one 512-byte load | 0.77 |
|
|
| **64, a group's codes one 512-byte load** | **0.74** |
|
|
|
|
BetterBench at `2a5e815` (exponent tiling, quant_act_fp8, the draft head on top of `68d510b`):
|
|
decode 52.0 -> 53.2 tok/s.
|
|
|
|
**Probes, kept out:**
|
|
- *512-byte block loads* of the activation (four in place of eight 256-byte ones a step): no
|
|
change (246 vs 246 us). The activation loads are not what the send stalls are made of.
|
|
- *The ordered sum of squares in ESIMD*: one thread, the squares in registers, the chain as scalar
|
|
adds on register regions (bitwise libref's serial loop): 44 us for 5120 against the SIMT form's
|
|
31 -- the SIMT broadcast-and-add chain stays (probe chain3.cpp).
|
|
- *A replayed SYCL graph* (what the engine's tape would be on this backend, probe launch2.cpp):
|
|
an in-order queue costs the host ~4.4 us a submission and a replayed graph 0.72-0.82 us a kernel;
|
|
but a chain of 2000 kernels of 12.5 us each runs 12.6 us a kernel either way (48.2 vs 47.8 at
|
|
48 us). The card's own per-kernel cost is under a microsecond; a tape would win back only the
|
|
stretches where kernels are shorter than the host's submission, and after each host wait.
|
|
The small kernels' 5-50 us are their own latency, so they are the work, not the launches.
|
|
- *The GEMM prepass's loads issued before its row-scale reduction* (bit-identical): 9.1 -> 10.1 us
|
|
a call, worse.
|
|
- *A deeper draft window*: BetterBench quick decode at `--num-speculative-tokens` 7 (the drafter's
|
|
own operating point): 51.0 tok/s; 15 (16 verify rows): 29.5; 11: refused by the architecture at
|
|
declare. Depth 7 stays.
|
|
- *givens_dense_quant's decode form* (probe gv.cpp, the libxe2 kernel copied, codes compared
|
|
bytewise): cold tables (rotated over 32 copies), M = 8: 11.0 us at n = 5120 one part, 14.2 two,
|
|
18.5 at n = 17408 (190-240 GB/s on T), against ~21 us a call in the round. Stall sampling: 40%
|
|
scoreboard waits, most on the local-memory load of each k-step's A slice ahead of its DPAS.
|
|
T's loads issued first (+3%), x loaded by type before the stores (+10%), fp8 stored by type
|
|
(+10%), T repacked so a sub-group's step is 512 contiguous bytes (-5%), every step's A and T
|
|
loaded before the DPAS chain (+40%, register pressure): none worth a layout hook. At ~80-136
|
|
work-groups the kernel is its own short chain; fewer launches (fusing it with its producer or the
|
|
GEMM's prepass) is what would move it.
|
|
- Stall sampling of the server stays empty on SIGTERM too (the metrics file is written but empty);
|
|
rad-kbench has no recipe on this container for givens_dense_quant or the gdn ops, so those need
|
|
probes of their own.
|
|
|
|
## Next steps
|
|
|
|
Deployment note: on this card (PCIe x1 2.5 GT/s, 10 GiB of VRAM unclaimed) run with
|
|
`--embedding-placement vram`; the default pins the 2.4 GiB embedding in host memory and reads it over
|
|
the link (4 ms a round).
|
|
|
|
1. Decode (~77 ms of device time a round of ~4.3 tokens; 90 tok/s needs ~48): the verify GEMMs
|
|
~32 ms at ~75% of the 560 GB/s ceiling (planes tiled at load, above). The small kernels,
|
|
~45 ms together, most of them latency- or message-bound rather than byte-bound: run each through
|
|
`unitrace --stall-sampling` (rad-kbench or a probe) before changing it -- this session's guesses
|
|
without it mostly measured nothing. givens (21 us for ~3 MB, 290 calls), the gdn phases (39 / 63
|
|
us against ~11 / ~6 us of state traffic), attention, the fp8 logits head (3.5 ms, floor ~2.3: an
|
|
ESIMD form like the m2 kernel's, ~0.7 ms at best; no fp8 DPAS on this card). givens and the gdn ops have no rad-kbench
|
|
recipe on this container and the server's stall samples come back empty, so each needs a
|
|
standalone probe first.
|
|
2. Prefill (349 tok/s at ~1900 tokens; ~5.6 s): the GEMMs 1.67 s (oneMKL ~1.2 of it; the m2xfp4
|
|
decode to fp16 and the scale epilogue the rest), attention 0.99 (a DPAS kernel needs the K operand
|
|
shared across query heads, see above), the chunk scan 0.92 (exact; a DPAS chunked form would be
|
|
tolerance-held), givens 0.52, kkt 0.33, gated_quant 0.27, conv_prep 0.26.
|
|
|
|
## 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
|
|
```
|