libxe2: Phase 4 step 1 -- a bandwidth-bound decode GEMV and an ordered sum from local memory

The profile of a MiniCPM5-2B decode step on the B65 (232.8 ms) was 79% gemm_nt, reading its
weights at 62 GB/s, and 13% the norms' serial sum of squares.

- 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: rad-kbench passes
  them at the gemm tolerance (fixture 361/361, MiniCPM5 180/180, worst rel_l2 1.6e-4), and
  XE2_EXACT=1 sends every launch to the exact kernel for bisecting.
- The norms form their squares in parallel into local memory and add them in index order: still
  bit-identical to libref.

Decode 4.2 -> 35.5 tok/s. Against a libref-only host build, over 1914 positions of the repo's docs
with every position through the GEMV: KL mean 5.9e-4, p99 3.5e-3, top-1 98.5% -- libavx's own
distance from libref is 5.7e-4 / 3.0e-3 / 98.6%. The exact path scores KL 0, top-1 100%.

docs/SYCL_PROGRESS.md: the profile, the KL bound (D13), and the user's decision to use the bf16
container for Milestone B instead of the fp8 one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-10-23 19:48:40 +02:00
1 parent 5da5c1ba05
commit a65ab54213
5 files changed
+196 -9

No files matched your search

+33 -2
View File
@@ -217,6 +217,10 @@ 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.
- 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
@@ -352,10 +356,37 @@ backend from the prefix with no environment). `tests/oot_plugins.sh` rebuilds li
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.
## Next steps
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.
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