Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

sycl: prompt GDN recurrence with one barrier per token on Alchemist (bit-identical; A770 prompt 8K +3-5%, 32K +7%; STRATA_GDN_XE=0 for the column kernels)

Andy Slater65cf54355fb3
diff --git a/docs/INTEL.md b/docs/INTEL.md
index 53435e432..2f5444475 100644
--- a/docs/INTEL.md
+++ b/docs/INTEL.md
@@ -728,6 +728,18 @@ Measured on an Arc A750 (8 GB, `i915`, PCIe 4.0) with the Flash-Next IQ3_XXS in
1.3 s; the A750's PCIe link probes at 10.6 GB/s.
- **A750 and the xe error counters.** The engine segfaults in a worker thread of the CPU pool when it exits (dmesg only, the server
has already printed "stopped"); it is not a GPU event.
+- **The prompt's GDN recurrence runs a sub-group kernel on Alchemist** (`sycl/include/strata/prefill/gdn_xe.hpp`,
+ variant 6 of `gdn_recurrence_variant`). It keeps the column kernel's four row groups and their FMA chains in the same
+ order, but a 16-lane sub-group holds four columns x four row groups, so the two cross-row-group sums are sub-group
+ shuffles instead of SLM round trips and a token needs one work-group barrier instead of five (256 GRFs a thread).
+ Measured on an Arc A770 (16 GB, `xe`, oneAPI 2026.1 JIT), 2026-10-13: `gdn_parity --prefill-tokens 8192` 51.0 ->
+ 24.5 ms, 32,768 tokens 204-236 -> 110-113 ms (48 heads), 0 mismatches; end to end, Coder IQ1_M, `--max-context
+ 131072 --kv int8 --kv-resident 20480 --vram-reserve-mib 1200 --resident-experts`, prompt 386 -> 396-407 tok/s at
+ 8K and 478-480 -> 511-518 tok/s at 32K, the same output tokens. On by default on Alchemist only, the column kernels everywhere else (not measured there). `STRATA_GDN_XE=0`
+ turns it off, `STRATA_GDN_XE=1` turns it on for any Intel GPU with 16-lane sub-groups. To check another Intel card:
+ `STRATA_GDN_XE=1 ./gdn_parity --selftest --prefill-only` (or `ctest -R prefill_gdn_parity`), and `--prefill-tokens
+ 8192 --prefill-repeat 5` for the time of both kernels. Not taken: the same kernel with its state in SLM (no register
+ spills, the same bits, ~4x slower: 13.7 vs 3.1-3.3 ms at T=1000).
## Not done
diff --git a/include/strata/prefill/kernels.hpp b/include/strata/prefill/kernels.hpp
index c98bea9e1..f12f34b94 100644
--- a/include/strata/prefill/kernels.hpp
+++ b/include/strata/prefill/kernels.hpp
@@ -64,6 +64,8 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const float
/// The kernels behind gdn_recurrence, for the parity test: 0 = the column-split kernels + the norm kernel (or the
/// one-block-per-head kernel under STRATA_GDN_REC_HEADS), 1 = four lanes per column (no barrier per token) + the grid-stride norm, 2 = the
/// one-block-per-head kernel (its fused norm rounds differently). 0 and 1 give the same bits.
+/// SYCL only: 6 = the Xe sub-group recurrence (16-lane sub-groups, one barrier per token) + the norm kernel, the same
+/// bits as 0 on an Arc A770; gdn_recurrence takes it by default on Alchemist (STRATA_GDN_XE=0 off, =1 any Intel GPU).
void gdn_recurrence_variant(int variant, float* state, const float* h, const float* gate, const float* beta,
const float* z, const float* gamma, float eps, float* y, uint16_t* y16, int64_t T,
void* stream, int64_t ld16 = 0);
diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt
index 04406a133..fd42efbff 100644
--- a/sycl/CMakeLists.txt
+++ b/sycl/CMakeLists.txt
@@ -262,6 +262,8 @@ if(STRATA_SYCL_PARITY)
target_link_libraries(${p}_parity PRIVATE strata_kernels)
add_test(NAME ${p}_parity COMMAND ${p}_parity --selftest)
endforeach()
+ target_link_libraries(gdn_parity PRIVATE strata_prefill) # prefill recurrence variant tests
+ add_test(NAME prefill_gdn_parity COMMAND gdn_parity --selftest --prefill-only)
# #1795: iq_parity and ple_parity are registered as the top-level CMakeLists.txt does, not by the loop above
# (iq_parity takes a fixture directory, not --selftest; ple_parity reads real artifacts from the engine root).
foreach(p IN ITEMS iq ple)
diff --git a/sycl/include/strata/prefill/gdn_xe.hpp b/sycl/include/strata/prefill/gdn_xe.hpp
new file mode 100644
index 000000000..167b34c45
--- /dev/null
+++ b/sycl/include/strata/prefill/gdn_xe.hpp
@@ -0,0 +1,104 @@
+// sycl/include/strata/prefill/gdn_xe.hpp - the prompt GDN recurrence for Intel GPUs (variant 6 of
+// gdn_recurrence_variant, src/prefill/kernels.dp.cpp). The column kernel's four row groups and their 32-long FMA
+// chains, in the same order, but a 16-lane sub-group holds four columns x four row groups (lane % 4 = column,
+// lane / 4 = row group), so the two cross-row-group sums are sub-group shuffles instead of SLM round trips, and a
+// token needs one work-group barrier instead of five. Bit-identical to variant 0 on an Arc A770.
+#pragma once
+#include <sycl/sycl.hpp>
+#include <sycl/ext/intel/experimental/grf_size_properties.hpp>
+#include <cstdint>
+
+namespace strata::prefill::detail {
+constexpr int GDN_XE_S = 128, GDN_XE_HK = 16, GDN_XE_HV = 48, GDN_XE_C = 10240;
+constexpr int GDN_XE_CB = 16, GDN_XE_NCB = GDN_XE_S / GDN_XE_CB;
+constexpr int GDN_XE_NT = GDN_XE_CB * 4;
+
+// Do not replace with reduce_over_group: keep ((p0+p1)+p2)+p3,
+// exactly the old red[0][c]+red[1][c]+red[2][c]+red[3][c] expression.
+inline float gdn_xe_sum4(sycl::sub_group sg, float x, unsigned c) {
+ const float p0 = sycl::select_from_group(sg, x, c);
+ const float p1 = sycl::select_from_group(sg, x, c + 4);
+ const float p2 = sycl::select_from_group(sg, x, c + 8);
+ const float p3 = sycl::select_from_group(sg, x, c + 12);
+ return p0 + p1 + p2 + p3;
+}
+
+inline void gdn_xe_body(sycl::nd_item<1> it, float* __restrict__ state,
+ const float* __restrict__ h, const float* __restrict__ gate,
+ const float* __restrict__ beta, float* __restrict__ out,
+ int64_t T, sycl::local_accessor<float, 1> inputs) {
+ const auto sg = it.get_sub_group();
+ const unsigned lane = sg.get_local_linear_id();
+ const unsigned rg = lane / 4, c = lane % 4;
+ const unsigned tid = it.get_local_linear_id();
+ const unsigned head = it.get_group_linear_id() / GDN_XE_NCB;
+ const unsigned cb = it.get_group_linear_id() % GDN_XE_NCB;
+ const unsigned col = cb * GDN_XE_CB + sg.get_group_linear_id() * 4 + c;
+ const unsigned qh = head % GDN_XE_HK;
+ constexpr unsigned RPG = GDN_XE_S / 4;
+ constexpr size_t rs = GDN_XE_HV * GDN_XE_S;
+ float* base = state + (rg * RPG * GDN_XE_HV + head) * GDN_XE_S + col;
+ float s[RPG];
+#pragma unroll
+ for (unsigned r = 0; r < RPG; ++r) s[r] = base[r * rs];
+ float nq[2], nk[2], nv = 0, ng = 0, nb = 0;
+ auto fetch = [&](int64_t t) {
+ const float* ht = h + t * GDN_XE_C;
+#pragma unroll
+ for (unsigned u = 0; u < 2; ++u) {
+ nq[u] = ht[qh * GDN_XE_S + tid + u * GDN_XE_NT];
+ nk[u] = ht[GDN_XE_HK * GDN_XE_S + qh * GDN_XE_S + tid + u * GDN_XE_NT];
+ }
+ nv = ht[2 * GDN_XE_HK * GDN_XE_S + head * GDN_XE_S + col];
+ ng = gate[t * GDN_XE_HV + head];
+ nb = beta[t * GDN_XE_HV + head];
+ };
+ if (T > 0) fetch(0);
+ for (int64_t t = 0; t < T; ++t) {
+ // Alternate q/k banks. The barrier at t-1 guarantees every read of
+ // bank t-2 has finished before we overwrite it at t. No end barrier.
+ const unsigned bank = (t & 1) * 2 * GDN_XE_S;
+#pragma unroll
+ for (unsigned u = 0; u < 2; ++u) {
+ inputs[bank + tid + u * GDN_XE_NT] = nq[u];
+ inputs[bank + GDN_XE_S + tid + u * GDN_XE_NT] = nk[u];
+ }
+ const float cv = nv, cg = ng, cbt = nb;
+ it.barrier(sycl::access::fence_space::local_space);
+ if (t + 1 < T) fetch(t + 1);
+ const float g = sycl::native::exp(cg);
+ float kv = 0.0f;
+#pragma unroll
+ for (unsigned r = 0; r < RPG; ++r)
+ kv = sycl::fma(s[r], inputs[bank + GDN_XE_S + rg * RPG + r], kv);
+ const float kv_col = gdn_xe_sum4(sg, kv, c);
+ const float delta = (cv - g * kv_col) * cbt;
+ float o = 0.0f;
+#pragma unroll
+ for (unsigned r = 0; r < RPG; ++r) {
+ s[r] = sycl::fma(g, s[r], inputs[bank + GDN_XE_S + rg * RPG + r] * delta);
+ o = sycl::fma(s[r], inputs[bank + rg * RPG + r], o);
+ }
+ const float oc = gdn_xe_sum4(sg, o, c) * sycl::rsqrt(float(GDN_XE_S));
+ if (rg == 0) out[t * GDN_XE_HV * GDN_XE_S + head * GDN_XE_S + col] = oc;
+ }
+#pragma unroll
+ for (unsigned r = 0; r < RPG; ++r) base[r * rs] = s[r];
+}
+
+// Intel GPUs only (the caller checks gdn_xe_device). 256 GRFs a thread: an offline DG2 (acm-g10) compile of this kernel
+// spilled 4000 bytes a thread at the default 128. Keeping the state in SLM instead of registers removed the spill
+// but ran ~4x slower on an A770 (13.7 vs 3.1-3.3 ms at T=1000, same bits), so the state stays in registers.
+inline sycl::event gdn_xe_launch(sycl::queue& q, float* state, const float* h,
+ const float* gate, const float* beta, float* out, int64_t T) {
+ const auto range = sycl::nd_range<1>(GDN_XE_HV * GDN_XE_NCB * GDN_XE_NT, GDN_XE_NT);
+ return q.submit([&](sycl::handler& cgh) {
+ sycl::local_accessor<float, 1> inputs(4 * GDN_XE_S, cgh); // two q/k banks, 2048 bytes a work-group
+ cgh.parallel_for<class GdnXeLargeGrf>(range,
+ sycl::ext::oneapi::experimental::properties{sycl::ext::intel::experimental::grf_size<256>},
+ [=](sycl::nd_item<1> it) [[sycl::reqd_sub_group_size(16)]] {
+ gdn_xe_body(it, state, h, gate, beta, out, T, inputs);
+ });
+ });
+}
+} // namespace strata::prefill::detail
diff --git a/sycl/src/kernels/gdn_parity.cpp b/sycl/src/kernels/gdn_parity.cpp
index afe0ae20c..895feaabc 100644
--- a/sycl/src/kernels/gdn_parity.cpp
+++ b/sycl/src/kernels/gdn_parity.cpp
@@ -25,6 +25,10 @@
#include "strata/kernels/fused_gdn.hpp"
#include "strata/kernels/verify_kernels.hpp"
+#include "strata/prefill/kernels.hpp"
+
+#include <algorithm>
+#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
@@ -91,19 +95,155 @@ double rel_l1(const std::vector<float>& a, const std::vector<float>& b) {
return d / (m > 1e-30 ? m : 1e-30);
}
+// Compare every state element and every token/head output, including FP16 bits.
+// Fixtures have nonzero initial state, modulo-paired heads, signed q/k/v, and
+// both shallow and deep decay. A tolerance is diagnostic only, never a pass.
+int prefill_case(int T, int seed, int repeats) {
+ constexpr int S = 128, HK = 16, HV = 48, C = 10240;
+ sycl::queue q(dpct::get_in_order_queue().get_device(),
+ sycl::property_list{sycl::property::queue::in_order{}});
+ // Variant 6 runs on Intel GPUs only (the engine throws elsewhere): skip, not fail, on any other device.
+ const auto dev = q.get_device();
+ const auto sizes = dev.get_info<sycl::info::device::sub_group_sizes>();
+ if (!dev.is_gpu() || dev.get_info<sycl::info::device::vendor_id>() != 0x8086 ||
+ std::find(sizes.begin(), sizes.end(), size_t(32)) == sizes.end() ||
+ std::find(sizes.begin(), sizes.end(), size_t(16)) == sizes.end()) {
+ static bool said = false;
+ if (!said) std::printf("prefill gdn: skipped (needs an Intel GPU with sub-groups 16 and 32)\n");
+ said = true;
+ return 0;
+ }
+ std::mt19937 rng(seed);
+ std::normal_distribution<float> gauss(0.0f, 1.0f);
+ std::vector<float> st(size_t(S) * HV * S), h(size_t(T) * C),
+ gate(size_t(T) * HV), beta(gate.size()), z(size_t(T) * HV * S), gamma(S);
+ for (auto& x : st) x = gauss(rng) * 0.03f;
+ for (int t = 0; t < T; ++t) {
+ for (int j = 0; j < C; ++j) h[size_t(t) * C + j] = gauss(rng) * (j < 2 * HK * S ? 0.08f : 0.7f);
+ }
+ for (auto& x : gate) x = -(seed % 2 ? 0.02f : 2.0f) * (1.0f + std::fabs(gauss(rng)));
+ for (auto& x : beta) x = 0.1f + float(rng() % 800) / 1000.0f;
+ for (auto& x : z) x = gauss(rng);
+ for (auto& x : gamma) x = 1.0f + 0.2f * gauss(rng);
+ auto copy = [&](const std::vector<float>& src) {
+ auto* ptr = sycl::malloc_device<float>(src.size(), q);
+ if (!ptr) throw std::bad_alloc();
+ q.memcpy(ptr, src.data(), src.size() * sizeof(float)).wait_and_throw();
+ return ptr;
+ };
+ float *dst = copy(st), *dh = copy(h), *dg = copy(gate), *db = copy(beta), *dz = copy(z), *dgm = copy(gamma);
+ float* dy = sycl::malloc_device<float>(z.size(), q);
+ uint16_t* dy16 = sycl::malloc_device<uint16_t>(z.size(), q);
+ if (!dy || !dy16) throw std::bad_alloc();
+ std::vector<float> refst(st.size()), refy(z.size()), gotst(st.size()), goty(z.size());
+ std::vector<uint16_t> ref16(z.size()), got16(z.size());
+ auto run = [&](int variant, std::vector<float>& ost, std::vector<float>& oy, std::vector<uint16_t>& o16) {
+ // Warm up the compiled kernel before measuring; every run resets state.
+ q.memcpy(dst, st.data(), st.size() * sizeof(float)).wait_and_throw();
+ if (variant == -1)
+ strata::prefill::gdn_recurrence(dst, dh, dg, db, dz, dgm, 1e-6f, dy, dy16, T, &q);
+ else
+ strata::prefill::gdn_recurrence_variant(variant, dst, dh, dg, db, dz, dgm,
+ 1e-6f, dy, dy16, T, &q);
+ q.wait_and_throw();
+ double elapsed = 0;
+ for (int i = 0; i < repeats; ++i) {
+ q.memcpy(dst, st.data(), st.size() * sizeof(float)).wait_and_throw();
+ const auto start = std::chrono::steady_clock::now();
+ if (variant == -1)
+ strata::prefill::gdn_recurrence(dst, dh, dg, db, dz, dgm, 1e-6f, dy, dy16, T, &q);
+ else
+ strata::prefill::gdn_recurrence_variant(variant, dst, dh, dg, db, dz, dgm,
+ 1e-6f, dy, dy16, T, &q);
+ q.wait_and_throw();
+ elapsed += std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count();
+ }
+ q.memcpy(ost.data(), dst, ost.size() * sizeof(float)).wait_and_throw();
+ q.memcpy(oy.data(), dy, oy.size() * sizeof(float)).wait_and_throw();
+ q.memcpy(o16.data(), dy16, o16.size() * sizeof(uint16_t)).wait_and_throw();
+ return elapsed / repeats;
+ };
+ const double base_ms = run(0, refst, refy, ref16);
+ const double xe_ms = run(6, gotst, goty, got16);
+ size_t state_bad = 0, y_bad = 0, half_bad = 0;
+ double max_abs = 0, max_rel = 0;
+ auto compare = [&](const std::vector<float>& a, const std::vector<float>& b, size_t& mismatches) {
+ for (size_t i = 0; i < a.size(); ++i) {
+ if (!std::isfinite(a[i]) || !std::isfinite(b[i]) ||
+ std::memcmp(&a[i], &b[i], sizeof(float)) != 0) ++mismatches;
+ const double diff = std::fabs(double(a[i]) - b[i]);
+ max_abs = std::max(max_abs, diff);
+ max_rel = std::max(max_rel, diff / std::max(std::fabs(double(a[i])), 1e-20));
+ }
+ };
+ compare(refst, gotst, state_bad);
+ compare(refy, goty, y_bad);
+ for (size_t i = 0; i < ref16.size(); ++i) half_bad += ref16[i] != got16[i];
+ std::printf("prefill T=%d seed=%d heads=%d: state=%zu y=%zu fp16=%zu mismatches; max_abs=%.9g max_rel=%.9g; baseline=%.3f ms xe=%.3f ms\n",
+ T, seed, HV, state_bad, y_bad, half_bad, max_abs, max_rel, base_ms, xe_ms);
+ // T=7 additionally checks the production entry point (variant 6 on Alchemist or under STRATA_GDN_XE=1,
+ // else variant 0) and T=0's no-op contract.
+ int extra_bad = 0;
+ if (T == 7) {
+ run(-1, gotst, goty, got16);
+ // Both variants must match anyway; compare production to baseline.
+ extra_bad += std::memcmp(refst.data(), gotst.data(), refst.size() * sizeof(float)) != 0;
+ extra_bad += std::memcmp(refy.data(), goty.data(), refy.size() * sizeof(float)) != 0;
+ extra_bad += ref16 != got16;
+ q.memcpy(dst, st.data(), st.size() * sizeof(float)).wait_and_throw();
+ strata::prefill::gdn_recurrence_variant(6, dst, dh, dg, db, dz, dgm,
+ 1e-6f, dy, dy16, 0, &q);
+ q.memcpy(gotst.data(), dst, st.size() * sizeof(float)).wait_and_throw();
+ extra_bad += gotst != st;
+ const auto saved_y = goty;
+ const auto saved16 = got16;
+ q.memcpy(goty.data(), dy, goty.size() * sizeof(float)).wait_and_throw();
+ q.memcpy(got16.data(), dy16, got16.size() * sizeof(uint16_t)).wait_and_throw();
+ extra_bad += goty != saved_y || got16 != saved16;
+ std::printf("prefill production + T=0: %s\n", extra_bad ? "FAIL" : "OK");
+ }
+ for (auto ptr : {dst, dh, dg, db, dz, dgm, dy}) sycl::free(ptr, q);
+ sycl::free(dy16, q);
+ return state_bad || y_bad || half_bad || extra_bad ? 1 : 0;
+}
+
} // namespace
int main(int argc, char** argv) {
- bool selftest = false;
+ bool selftest = false, prefill_only = false;
+ int prefill_tokens = 0, prefill_repeat = 1;
for (int i = 1; i < argc; ++i) {
- if (std::string(argv[i]) == "--selftest") selftest = true;
- else { std::fprintf(stderr, "usage: gdn_parity [--selftest]\n"); return 2; }
+ const std::string arg(argv[i]);
+ if (arg == "--selftest") selftest = true;
+ else if (arg == "--prefill-only") prefill_only = true;
+ else if ((arg == "--prefill-tokens" || arg == "--prefill-repeat") && i + 1 < argc) {
+ char* end = nullptr;
+ const long n = std::strtol(argv[++i], &end, 10);
+ if (!end || *end || n < 1 || n > (arg == "--prefill-tokens" ? 32768 : 1000)) return 2;
+ (arg == "--prefill-tokens" ? prefill_tokens : prefill_repeat) = int(n);
+ } else {
+ std::fprintf(stderr, "usage: gdn_parity [--selftest] [--prefill-only] [--prefill-tokens N] [--prefill-repeat N]\n");
+ return 2;
+ }
+ }
+ const auto device = dpct::get_in_order_queue().get_device();
+ std::printf("device: %s (%s), sub-groups:", device.get_info<sycl::info::device::name>().c_str(),
+ device.is_cpu() ? "CPU" : device.is_gpu() ? "GPU" : "other");
+ for (auto n : device.get_info<sycl::info::device::sub_group_sizes>()) std::printf(" %zu", n);
+ std::printf("\n");
+ int prefill_bad = 0;
+ for (int t : prefill_tokens ? std::vector<int>{prefill_tokens} : std::vector<int>{1, 7, 256, 1000})
+ for (int seed : {2025, 2026}) prefill_bad += prefill_case(t, seed, prefill_repeat);
+ std::printf("prefill gdn: %d failures\n", prefill_bad);
+ if (prefill_only) {
+ if (selftest && !prefill_bad) std::printf("gdn_parity OK\n");
+ return prefill_bad ? 1 : 0;
}
const int S = 128, h_k = 16, h_v = 48; // the artifact's real geometry
std::mt19937 rng(2024);
std::normal_distribution<float> gauss(0.0f, 1.0f);
- int bad = 0;
+ int bad = prefill_bad;
// ================= 1. the recurrence =================
{
diff --git a/sycl/src/prefill/kernels.dp.cpp b/sycl/src/prefill/kernels.dp.cpp
index 01600bd58..7f1879574 100644
--- a/sycl/src/prefill/kernels.dp.cpp
+++ b/sycl/src/prefill/kernels.dp.cpp
@@ -4,6 +4,7 @@
#include <dpct/dpct.hpp>
#include "strata/sycl_queue.hpp"
#include "strata/prefill/kernels.hpp"
+#include "strata/prefill/gdn_xe.hpp"
#include "strata/kernels/mrope.hpp"
#include "strata/kernels/gfx_arch.hpp"
#include "strata/kernels/router_top10.hpp"
@@ -16,6 +17,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <stdexcept>
namespace strata::prefill {
namespace {
@@ -2600,6 +2602,25 @@ void gdn_conv(float* history, const float* qkv, const float* conv_w, float* h, i
}
check("gdn_conv");
}
+// Variant 6, the Xe sub-group recurrence (gdn_xe.hpp): one barrier per token instead of five, the same bits. Arc A770
+// (Coder IQ1_M, 128K context, int8 KV): recurrence 1.83 -> 0.92 s on an 8K prompt (+5% prompt tok/s), 7.3 -> 3.65 s on
+// 32K (+8%), the same output tokens. On by default on Alchemist only (not measured on other cards).
+// STRATA_GDN_XE=0: the column kernels everywhere; STRATA_GDN_XE=1: variant 6 on any Intel GPU with 16-lane sub-groups.
+static bool gdn_xe_device(void* stream) {
+ const auto device = strata::q_of(stream)->get_device();
+ const auto subgroups = device.get_info<sycl::info::device::sub_group_sizes>();
+ const bool sg16 = std::find(subgroups.begin(), subgroups.end(), size_t(16)) != subgroups.end();
+ return sg16 && device.is_gpu() && device.get_info<sycl::info::device::vendor_id>() == 0x8086;
+}
+static bool gdn_xe_on(void* stream) {
+ static const bool on = [stream] {
+ const char* v = std::getenv("STRATA_GDN_XE");
+ if (v && *v) return std::atoi(v) != 0 && gdn_xe_device(stream);
+ return strata::intel_gpu_gen(strata::q_of(stream)->get_device()) == strata::IntelGpuGen::Alchemist &&
+ gdn_xe_device(stream);
+ }();
+ return on;
+}
void gdn_recurrence_variant(int variant, float* state, const float* h, const float* gate, const float* beta,
const float* z, const float* gamma, float eps, float* y, uint16_t* y16, int64_t T,
void* stream, int64_t ld16) {
@@ -2648,7 +2669,10 @@ void gdn_recurrence_variant(int variant, float* state, const float* h, const flo
(void) variant; // the quad recurrence kernels are AMD-only
#endif
static const bool serial = std::getenv("STRATA_GDN_REC_HEADS") != nullptr; // the one-block-per-head kernel (A/B)
- if (serial || T <= 0 || variant == 2) {
+ // variant 6 = the Xe sub-group recurrence + the unchanged norm kernel (gdn_recurrence: gdn_xe_on)
+ const bool xe = T > 0 && !serial && variant == 6;
+ if (xe && !gdn_xe_device(stream)) throw std::runtime_error("GDN Xe variant requires an Intel GPU with 16-lane sub-groups");
+ if (!xe && (serial || T <= 0 || variant == 2)) {
/*
DPCT1049: The work-group size passed to the SYCL kernel may exceed
the limit. To get the device limit, query
@@ -2669,6 +2693,9 @@ void gdn_recurrence_variant(int variant, float* state, const float* h, const flo
});
} else {
static const bool pipe = [] { const char* v = std::getenv("STRATA_GDN_PIPELINE"); return v == nullptr || std::atoi(v) != 0; }();
+ if (xe) {
+ detail::gdn_xe_launch(*strata::q_of(stream), state, h, gate, beta, y, T);
+ } else
#if !defined(__HIPCC__)
if (pipe && gdn_keyhead_ok()) // the value heads of a key head in one thread (same bits)
{
@@ -2740,7 +2767,8 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const float
// (AMD builds only; the arch defaults set STRATA_GDN_HEAD=1 on gfx1151 and leave other cards on the earlier kernels)
static const bool head = [] { const char* v = std::getenv("STRATA_GDN_HEAD"); return v != nullptr && std::atoi(v) != 0; }();
static const bool serial = std::getenv("STRATA_GDN_REC_HEADS") != nullptr;
- gdn_recurrence_variant(head && !serial ? 1 : 0, state, h, gate, beta, z, gamma, eps, y, y16, T, stream, ld16);
+ const int v = head && !serial ? 1 : (!serial && gdn_xe_on(stream)) ? 6 : 0;
+ gdn_recurrence_variant(v, state, h, gate, beta, z, gamma, eps, y, y16, T, stream, ld16);
}
void route(const float* logits, int32_t* ids, float* weights, int64_t T, int64_t n_expert, void* stream) {
if (n_expert == 512)