[PR #1711] [CLOSED] sycl: opt-in grouped XMX expert GEMM for the prompt path (STRATA_PF_XMX), with a parity test #3625

Closed
opened 2026-11-07 15:29:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1711
Author: @aslater3
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: a770/pr-xmx-group


📝 Commits (3)

  • a67eaa5 sycl/A770 prefill: grouped XMX expert GEMM (opt-in STRATA_PF_XMX=1/2)
  • aedec6c sycl: grouped XMX passes the decoder thread that writes [o, o+8) for the run-of-8 IQ decoders
  • 8f4ddb1 sycl: grouped XMX GEMMs build and run on Xe2 (16x16x16, sub-group 16), 8x8x16 kept for DG2

📊 Changes

8 files changed (+694 additions, -14 deletions)

View changed files

📝 include/strata/kernels/iq_kernels.hpp (+8 -0)
➕ include/strata/prefill/xmx_moe.hpp (+20 -0)
📝 sycl/CMakeLists.txt (+10 -1)
➕ sycl/include/strata/xmx_tile.hpp (+39 -0)
📝 sycl/src/kernels/cuda/iq_kernels.dp.cpp (+171 -0)
➕ sycl/src/kernels/xmx_group_parity.cpp (+112 -0)
📝 sycl/src/prefill/prefill.cpp (+150 -13)
➕ sycl/src/prefill/xmx_moe.dp.cpp (+184 -0)

📄 Description

Adds an opt-in grouped XMX GEMM for the prompt path's routed experts on Intel Arc. With STRATA_PF_XMX unset, the default path does not change.

What it changes

  • STRATA_PF_XMX=1: dequantizes a group of up to 16 routed experts to FP16, then runs one joint_matrix launch per product. A standalone measurement against oneMKL on uneven routing: down 1.75–6x faster, gate/up 0.8–3x. Above STRATA_PF_XMX_GU_MAX=250 tokens per expert, gate/up stays on oneMKL.
  • STRATA_PF_XMX=2: the same GEMM, but the kernel decodes the IQ3_XXS / IQ3_S / IQ2_S / IQ4_XS gate/up rows and the IQ4_NL / Q2_0 down rows itself, so there is no FP16 staging pass.
  • New xmx_group_parity test (built with STRATA_SYCL_PARITY=ON): checks every supported type against dequant+oneMKL.

The third commit (8f4ddb1) makes both kernels build and run on Xe2 (Battlemage). There they use 16×16×16 tiles with sub-group 16, following @maxious's retile; DG2 keeps 8×8×16 with sub-group 8. A JIT build picks per device, and an AOT build carries only the 16×16 kernel (sycl/include/strata/xmx_tile.hpp).

The second commit fixes the in-kernel decode after rebasing onto current main. main now has the IQ2/IQ3/IQ4_NL/IQ1_M decoders write values [8·tid, 8·tid+8) in coalesced runs. The grouped kernel was still passing the old sub*8 + o32/32 thread index, so four of the six types decoded garbage (relative error ≈10). It now passes tid = o >> 3 for every type except IQ4_XS, which keeps its own layout.

Measured

On an Arc A770 16 GB (xe driver, oneAPI 2025.3, Linux 7.0), xmx_group_parity on this branch:

type 18 gate/up rows 1365: dequant+oneMKL 2.593 ms | fused xmx 1.800 ms (1.44x) relerr 9.9e-07 OK
type 21 gate/up rows 1365: dequant+oneMKL 1.507 ms | fused xmx 1.765 ms (0.85x) relerr 1.1e-06 OK
type 22 gate/up rows 1365: dequant+oneMKL 1.238 ms | fused xmx 1.330 ms (0.93x) relerr 1.5e-06 OK
type 23 gate/up rows 1365: dequant+oneMKL 2.498 ms | fused xmx 1.516 ms (1.65x) relerr 1.8e-06 OK
type 20 down    rows 1365: dequant+oneMKL 0.825 ms | fused xmx 0.773 ms (1.07x) relerr 4.6e-07 OK
type 42 down    rows 1365: dequant+oneMKL 0.700 ms | fused xmx 0.603 ms (1.16x) relerr 1.5e-07 OK
all OK

Without the second commit, types 18, 21, 22 and 20 fail with relative error ≈10.

End to end, on the Coder IQ1_M model with an 8K prompt:

  • Earlier local measurements, before the rebase: 0.5–3K-token prompts were 14–29% faster with STRATA_PF_XMX=2, and 8K/32K prompts 2–5% faster. These were not repeated on this branch.
  • This branch, main + #1602 on the A770: a same-day 8K run did not show a gain.

So it stays opt-in.

On the same A770 with this branch: 2,058-token code prompt, greedy decoding, 128 new tokens. STRATA_PF_XMX=0 gave 847.8 and 832.6 tok/s prompt, =2 gave 847.3 and 825.3, =1 gave 835.7, all with identical output. On an Arc Pro B60, @maxious measured the fused path at about 2.9x slower than the default (505.5 vs 177.3 tok/s prompt). It stays opt-in and off by default.

Not tested

  • Running on B-series here: AOT bmg-g21 links on this branch, but I have no Battlemage card. @maxious ran the 16×16 kernels on a B60.
  • Other Alchemist cards.
  • The CUDA and HIP builds: these files are SYCL only (sycl/), plus one declaration in include/strata/kernels/iq_kernels.hpp and a new include/strata/prefill/xmx_moe.hpp, neither of which the CUDA/HIP sources include.
  • A full logit comparison end to end with STRATA_PF_XMX=2. The parity test covers the kernel only.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1711 **Author:** [@aslater3](https://github.com/aslater3) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `a770/pr-xmx-group` --- ### 📝 Commits (3) - [`a67eaa5`](https://github.com/Niko1221/Strata/commit/a67eaa5e4193474f2d605e2c10929412074655eb) sycl/A770 prefill: grouped XMX expert GEMM (opt-in STRATA_PF_XMX=1/2) - [`aedec6c`](https://github.com/Niko1221/Strata/commit/aedec6c28502b0a03c6d0b28f6a280a2b49a27d7) sycl: grouped XMX passes the decoder thread that writes [o, o+8) for the run-of-8 IQ decoders - [`8f4ddb1`](https://github.com/Niko1221/Strata/commit/8f4ddb16f2fed2f792a345251c85484a8b3c824a) sycl: grouped XMX GEMMs build and run on Xe2 (16x16x16, sub-group 16), 8x8x16 kept for DG2 ### 📊 Changes **8 files changed** (+694 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/kernels/iq_kernels.hpp` (+8 -0) ➕ `include/strata/prefill/xmx_moe.hpp` (+20 -0) 📝 `sycl/CMakeLists.txt` (+10 -1) ➕ `sycl/include/strata/xmx_tile.hpp` (+39 -0) 📝 `sycl/src/kernels/cuda/iq_kernels.dp.cpp` (+171 -0) ➕ `sycl/src/kernels/xmx_group_parity.cpp` (+112 -0) 📝 `sycl/src/prefill/prefill.cpp` (+150 -13) ➕ `sycl/src/prefill/xmx_moe.dp.cpp` (+184 -0) </details> ### 📄 Description Adds an opt-in grouped XMX GEMM for the prompt path's routed experts on Intel Arc. With `STRATA_PF_XMX` unset, the default path does not change. ## What it changes - `STRATA_PF_XMX=1`: dequantizes a group of up to 16 routed experts to FP16, then runs one `joint_matrix` launch per product. A standalone measurement against oneMKL on uneven routing: down 1.75–6x faster, gate/up 0.8–3x. Above `STRATA_PF_XMX_GU_MAX=250` tokens per expert, gate/up stays on oneMKL. - `STRATA_PF_XMX=2`: the same GEMM, but the kernel decodes the IQ3_XXS / IQ3_S / IQ2_S / IQ4_XS gate/up rows and the IQ4_NL / Q2_0 down rows itself, so there is no FP16 staging pass. - New `xmx_group_parity` test (built with `STRATA_SYCL_PARITY=ON`): checks every supported type against dequant+oneMKL. The third commit (8f4ddb1) makes both kernels build and run on Xe2 (Battlemage). There they use 16×16×16 tiles with sub-group 16, following @maxious's retile; DG2 keeps 8×8×16 with sub-group 8. A JIT build picks per device, and an AOT build carries only the 16×16 kernel (`sycl/include/strata/xmx_tile.hpp`). The second commit fixes the in-kernel decode after rebasing onto current `main`. `main` now has the IQ2/IQ3/IQ4_NL/IQ1_M decoders write values `[8·tid, 8·tid+8)` in coalesced runs. The grouped kernel was still passing the old `sub*8 + o32/32` thread index, so four of the six types decoded garbage (relative error ≈10). It now passes `tid = o >> 3` for every type except IQ4_XS, which keeps its own layout. ## Measured On an Arc A770 16 GB (xe driver, oneAPI 2025.3, Linux 7.0), `xmx_group_parity` on this branch: ``` type 18 gate/up rows 1365: dequant+oneMKL 2.593 ms | fused xmx 1.800 ms (1.44x) relerr 9.9e-07 OK type 21 gate/up rows 1365: dequant+oneMKL 1.507 ms | fused xmx 1.765 ms (0.85x) relerr 1.1e-06 OK type 22 gate/up rows 1365: dequant+oneMKL 1.238 ms | fused xmx 1.330 ms (0.93x) relerr 1.5e-06 OK type 23 gate/up rows 1365: dequant+oneMKL 2.498 ms | fused xmx 1.516 ms (1.65x) relerr 1.8e-06 OK type 20 down rows 1365: dequant+oneMKL 0.825 ms | fused xmx 0.773 ms (1.07x) relerr 4.6e-07 OK type 42 down rows 1365: dequant+oneMKL 0.700 ms | fused xmx 0.603 ms (1.16x) relerr 1.5e-07 OK all OK ``` Without the second commit, types 18, 21, 22 and 20 fail with relative error ≈10. End to end, on the Coder IQ1_M model with an 8K prompt: - Earlier local measurements, before the rebase: 0.5–3K-token prompts were 14–29% faster with `STRATA_PF_XMX=2`, and 8K/32K prompts 2–5% faster. These were not repeated on this branch. - This branch, `main` + #1602 on the A770: a same-day 8K run did not show a gain. So it stays opt-in. On the same A770 with this branch: 2,058-token code prompt, greedy decoding, 128 new tokens. `STRATA_PF_XMX=0` gave 847.8 and 832.6 tok/s prompt, `=2` gave 847.3 and 825.3, `=1` gave 835.7, all with identical output. On an Arc Pro B60, @maxious measured the fused path at about 2.9x slower than the default (505.5 vs 177.3 tok/s prompt). It stays opt-in and off by default. ## Not tested - Running on B-series here: AOT `bmg-g21` links on this branch, but I have no Battlemage card. @maxious ran the 16×16 kernels on a B60. - Other Alchemist cards. - The CUDA and HIP builds: these files are SYCL only (`sycl/`), plus one declaration in `include/strata/kernels/iq_kernels.hpp` and a new `include/strata/prefill/xmx_moe.hpp`, neither of which the CUDA/HIP sources include. - A full logit comparison end to end with `STRATA_PF_XMX=2`. The parity test covers the kernel only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3625
No description provided.