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.
This commit is contained in:
Niko1221 committed 2026-10-09 16:01:57 +02:00
1 parent 00b14af827
commit 72a67c8e90
4 files changed
+42 -1

No files matched your search

+3
View File
@@ -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
+6
View File
@@ -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<sycl::half, 1> 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
+10
View File
@@ -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 <sycl/sycl.hpp>
#include <dpct/dpct.hpp>
#include <dpct/blas_utils.hpp>
@@ -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);
+23 -1
View File
@@ -7,6 +7,7 @@
#include <sycl/ext/oneapi/matrix/matrix.hpp>
#include <sycl/ext/intel/experimental/grf_size_properties.hpp>
#include <cstdlib>
#include <cstdio>
#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<half, 1> 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; }