From 72a67c8e9023f87defc290da24a5d8021c948df9 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 9 Oct 2026 16:01:57 +0200 Subject: [PATCH] sycl: the grouped XMX kernels (sub-group 8, joint_matrix 8x8x16) are Arc A-series only: an AOT build for Xe2 / Xe-HPC leaves them out (STRATA_NO_DG2_XMX), STRATA_PF_XMX is ignored with a message on Battlemage, and xmx_group_parity skips there PR #1711 as posted made the Arc Pro B70 AOT build (bmg-g31) fail to link: the backend compiler rejects the sub-group 8 kernel. --- sycl/CMakeLists.txt | 3 +++ sycl/src/kernels/cuda/iq_kernels.dp.cpp | 6 ++++++ sycl/src/kernels/xmx_group_parity.cpp | 10 ++++++++++ sycl/src/prefill/xmx_moe.dp.cpp | 24 +++++++++++++++++++++++- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index fa0c79dd..fd734937 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -37,6 +37,9 @@ if(STRATA_SYCL_SPIN_MAX) add_compile_definitions(STRATA_SYCL_SPIN_MAX=${STRATA_SYCL_SPIN_MAX}u) endif() set(_sycl_flags -fsycl) +if(STRATA_SYCL_AOT MATCHES "^(bmg|lnl|pvc)") + add_compile_definitions(STRATA_NO_DG2_XMX=1) # the grouped XMX kernels (sub-group 8, 8x8x16) do not compile for Xe2 / Xe-HPC +endif() if(STRATA_SYCL_AOT) list(APPEND _sycl_flags -fsycl-targets=spir64_gen) # the divide/sqrt rounding option (below) must reach ocloc here: an AOT build has no spir64 backend to take it diff --git a/sycl/src/kernels/cuda/iq_kernels.dp.cpp b/sycl/src/kernels/cuda/iq_kernels.dp.cpp index 2bcf692b..e9f4a574 100644 --- a/sycl/src/kernels/cuda/iq_kernels.dp.cpp +++ b/sycl/src/kernels/cuda/iq_kernels.dp.cpp @@ -5213,6 +5213,7 @@ void launch(sycl::queue& q, int ty, bool gu, const sycl::half* X, float* Y, cons constexpr int BM = C::BM, BN = C::BN, KS = C::KS, WG = C::WG, SG = C::SG; constexpr int LDA = KS + 8, LDB = KS + 8; const int nb = N / BN; +#ifndef STRATA_NO_DG2_XMX q.submit([&](sycl::handler& h) { sycl::local_accessor sa(BM * LDA, h), sb(BN * LDB, h); auto props = sycl::ext::oneapi::experimental::properties{sycl::ext::intel::experimental::grf_size<256>}; @@ -5298,6 +5299,11 @@ void launch(sycl::queue& q, int ty, bool gu, const sycl::half* X, float* Y, cons } }); }); +#else + (void) q; (void) X; (void) Y; (void) gp; (void) ntiles; (void) N; (void) K; + std::fprintf(stderr, "grouped XMX: the 8x8x16 / sub-group 8 kernel is not built for this device (STRATA_NO_DG2_XMX)\n"); + std::exit(1); +#endif } class k_xg_small; class k_xg_big; using Small = Cfg<2, 8, 4, 2>; // 64 x 128 diff --git a/sycl/src/kernels/xmx_group_parity.cpp b/sycl/src/kernels/xmx_group_parity.cpp index d99f8c23..7b9d3eb4 100644 --- a/sycl/src/kernels/xmx_group_parity.cpp +++ b/sycl/src/kernels/xmx_group_parity.cpp @@ -2,6 +2,7 @@ // oneMKL per expert, on random expert blobs of each format the native packs use. Also times both. // xmx_group_parity [mean_rows=160] [n=16] #include "strata/kernels/iq_kernels.hpp" +#include "strata/sycl_queue.hpp" #include #include #include @@ -16,6 +17,15 @@ int main(int argc, char** argv) { const int mean = argc > 1 ? std::atoi(argv[1]) : 160; const int n = argc > 2 ? std::atoi(argv[2]) : 16; sycl::queue* q = &dpct::get_in_order_queue(); +#ifdef STRATA_NO_DG2_XMX + std::printf("xmx_group_parity: SKIP (the sub-group 8 / 8x8x16 kernels are not built for this AOT device)"); + return 0; +#else + if (strata::intel_gpu_gen(q->get_device()) == strata::IntelGpuGen::Battlemage) { + std::printf("xmx_group_parity: SKIP (Battlemage has no sub-group 8 / 8x8x16 joint_matrix)"); + return 0; + } +#endif dpct::blas::descriptor_ptr hd = new dpct::blas::descriptor(); hd->set_queue(q); std::mt19937 rng(3); diff --git a/sycl/src/prefill/xmx_moe.dp.cpp b/sycl/src/prefill/xmx_moe.dp.cpp index f0418902..416af931 100644 --- a/sycl/src/prefill/xmx_moe.dp.cpp +++ b/sycl/src/prefill/xmx_moe.dp.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "strata/sycl_queue.hpp" #include "strata/prefill/xmx_moe.hpp" @@ -34,6 +35,7 @@ void launch(sycl::queue& q, const half* X, float* Y, const Grp& gp, int ntiles, constexpr int BM = C::BM, BN = C::BN, KS = C::KS, WG = C::WG, SG = C::SG; constexpr int LDA = KS + 8, LDB = KS + 8; const int nb = N / BN; +#ifndef STRATA_NO_DG2_XMX q.submit([&](sycl::handler& h) { sycl::local_accessor sa(BM * LDA, h), sb(BN * LDB, h); auto props = sycl::ext::oneapi::experimental::properties{sycl::ext::intel::experimental::grf_size<256>}; @@ -107,6 +109,11 @@ void launch(sycl::queue& q, const half* X, float* Y, const Grp& gp, int ntiles, } }); }); +#else + (void) q; (void) X; (void) Y; (void) gp; (void) ntiles; (void) N; (void) K; + std::fprintf(stderr, "grouped XMX: the 8x8x16 / sub-group 8 kernel is not built for this device (STRATA_NO_DG2_XMX)\n"); + std::exit(1); +#endif } class k_small; class k_big; @@ -126,7 +133,22 @@ int fill(Grp& gp, const int32_t* cnt, int n) { } // namespace int mode() { - static const int v = [] { const char* e = std::getenv("STRATA_PF_XMX"); return e ? std::atoi(e) : 0; }(); + // The kernels are joint_matrix 8x8x16 on sub-group 8: DG2 (Arc A-series) only. Battlemage has neither. + static const int v = [] { + const char* e = std::getenv("STRATA_PF_XMX"); + const int want = e ? std::atoi(e) : 0; + if (want == 0) return 0; +#ifdef STRATA_NO_DG2_XMX + std::fprintf(stderr, "STRATA_PF_XMX ignored: this build is AOT for a device without the sub-group 8 XMX kernels\n"); + return 0; +#else + if (strata::intel_gpu_gen(strata::q_of(nullptr)->get_device()) == strata::IntelGpuGen::Battlemage) { + std::fprintf(stderr, "STRATA_PF_XMX ignored: Battlemage has no sub-group 8 / 8x8x16 joint_matrix (Arc A-series only)\n"); + return 0; + } + return want; +#endif + }(); return v; } bool enabled() { return mode() != 0; }