Archived
libxe2: the DSpark drafter's ops -- speculative decoding on the B65, greedy-identical
Every op MiniCPM5-2B bf16's DSpark drafter issues now has a libxe2 row, each libref's arithmetic in libref's order: gemm_nt_q over fp8a8 block-scaled codes (quant_dot per output, the scale grids worked out on the host as make_scales does), gemm_nt_q_gated with the gated fp8 epilogue, the w2a8 vocabulary head (gemm_zp; b_scale in libref's joined planes form through a copy of libref's layout hook, so both libraries ask for the same stored bytes, its planes found on the device), quant_act_i8, silu_mul, row_topk and dflash_select. rad-kbench: MiniCPM5-2B 191/191 at rel_l2 0. The fixture found the gated GEMM refusing a 27B geometry its row accepted (it held the whole N-wide row in local memory); it now keeps the n gated values and declares N <= 57344. The engine oracle with speculation on: 1500/1500 issues bit-identical, the w2a8 head included. Greedy with speculation on matches libref's greedy without it on all eight prompts. Install and oot: a SYCL build installs librad_sycl.so and libxe2.so, its executables find the backend through $ORIGIN/../lib, and tests/oot_plugins.sh rebuilds libxe2 out of tree with icpx when RAD_OOT_ICPX is set; it passes in build-sycl. scripts/sycl/bench_report.sh: the report's screenshot is a JPEG, rendered with fonts (this host has none, and the first post had no text). docs/SYCL_PROGRESS.md: the first quick benchmark (4.2 tok/s decode, 17.3 tok/s prefill at 2000 tokens), Milestone B part 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
874f8d28b1
commit
43d84111c2
13 files changed
+1076
-36
No files matched your search
+100
-10
@@ -10,8 +10,8 @@ from it alone.
|
||||
|---|---|
|
||||
| 0 environment check | done |
|
||||
| 1 codebase study, `SYCL_PORTING.md` | done (`docs/SYCL_PORTING.md` §1-§3, Appendix A) |
|
||||
| 2 design | written (`docs/SYCL_PORTING.md` §4); device backend, build integration and core kernels done and passing `device_test` on the B65; `libxe2` skeleton next |
|
||||
| 3 correctness-first kernels | not started |
|
||||
| 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 | not started |
|
||||
| 5 broaden and finish | not started |
|
||||
|
||||
@@ -147,11 +147,17 @@ install one outside the repo (e.g. playwright + chromium in `~/tools/betterbench
|
||||
summary. `scripts/bench_report.sh` (quick run, parse `results.json` with `jq`, post, check the HTTP
|
||||
status) is to be written at the first benchmarkable milestone, against a real `results.json`.
|
||||
|
||||
Runs: none yet. Nothing is benchmarked before Milestone A passes its correctness checks. All runs
|
||||
are `--quick` (1 warmup, 5 passes): progress tracking, not publishable numbers.
|
||||
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` |
|
||||
|
||||
## Models
|
||||
|
||||
@@ -211,6 +217,11 @@ Planned use: Milestone A = `minicpm5-2b-bf16.rad` (blocked, item 1); Milestone B
|
||||
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.
|
||||
- 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.
|
||||
@@ -272,14 +283,93 @@ In a SYCL build the host tier is `ctest -LE 'gpu|oot|sycl'` (kbench moved to the
|
||||
`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).
|
||||
|
||||
## Next steps
|
||||
|
||||
1. Phase 3, Milestone A's 13 + 13 ops in libxe2, each passing `rad-kbench` (fixture and MiniCPM5),
|
||||
correctness-first kernels. Order: elementwise/norm/rope/cast/embed/gather, sampler, gemm_nt and
|
||||
logits_gemm, kv_store and attn_paged.
|
||||
2. Then serve MiniCPM5 on the B65 with `--num-speculative-tokens 0` and compare greedy output with
|
||||
the host backend.
|
||||
3. `code_runs` under SYCL from `build_target` (D4); install rules and the `oot` rebuild for
|
||||
1. Milestone B, part 2: `minicpm5-2b-fp8.rad` (**not in the library; asked by webhook**). Its fp8 trunk
|
||||
uses the ops part 1 added (fp8a8 GEMMs), so it should need no new kernel.
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user