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++

prefill: Volta runs the prompt experts on FP16 tensor-core tiles, a group per launch (STRATA_PF_WMMA)

Niko1221cb2740a8c26e
diff --git a/include/strata/kernels/iq_kernels.hpp b/include/strata/kernels/iq_kernels.hpp
index 0a39f6460..4c18f7177 100644
--- a/include/strata/kernels/iq_kernels.hpp
+++ b/include/strata/kernels/iq_kernels.hpp
@@ -86,6 +86,11 @@ void native_expert_set_mode(int mode, int phase);
/// `iq_mmvq` and `native_expert_grouped` decode each weight part once and apply it to every column / entry;
/// true selects the older kernels that decode it again per column (STRATA_OLD_IQ_MMVQ=1 at startup). Both give
/// bitwise the same results. Set before graph capture; captured graphs keep the kernels they captured.
+/// Volta prompt experts (STRATA_PF_WMMA): Y[rows of expert e] = X[rows] . W_e^T for a group of experts, W_e at
+/// W + e * expert_bytes (n_out rows of K values of type ty, GGUF blocks), X FP16 (ldx), rows bounds[e]..bounds[e+1],
+/// Y FP32 (ldy). FP16 tensor cores, FP32 sums. false: not launched (shape or type not covered). CUDA only.
+bool gemm_iq_f16_grouped(int ty, const void* W, size_t expert_bytes, int n_out, int K, const void* X, int ldx,
+ const int32_t* bounds, int n_experts, int max_rows, float* Y, int ldy, void* stream);
void iq_set_old_kernels(bool old);
bool iq_old_kernels();
diff --git a/include/strata/prefill/kernels.hpp b/include/strata/prefill/kernels.hpp
index f12f34b94..6033e0e02 100644
--- a/include/strata/prefill/kernels.hpp
+++ b/include/strata/prefill/kernels.hpp
@@ -77,6 +77,8 @@ void route(const float* logits, int32_t* ids, float* weights, int64_t T, int64_t
void blob_dequant(const uint8_t* blob, uint16_t* gu16, uint16_t* down16, void* stream);
/// h16[n, r] = fp16(silu(gu[n, 2r]) * gu[n, 2r + 1]) (the interleaved expert gate/up)
void swiglu_interleaved(const float* gu, uint16_t* h16, int64_t n, void* stream);
+/// the Volta prompt experts: SwiGLU of gate/up rows (gate first, or interleaved) to FP16, saturated like swiglu_interleaved
+void swiglu_split_f16(const float* gu, uint16_t* h16, int64_t rows, int n_ff, bool interleaved, void* stream);
/// h16[n, r] = fp16(silu(g[n, r]) * u[n, r]) (the shared expert, gate and up separate, width 640)
void swiglu_pair(const float* g, const float* u, uint16_t* h16, int64_t n, void* stream);
/// dst[i] = src[i] for n int32s, as a kernel: either side may be mapped host memory, and the copy never waits
diff --git a/src/kernels/cuda/iq_kernels.cu b/src/kernels/cuda/iq_kernels.cu
index 947952a04..cc1ba0f9c 100644
--- a/src/kernels/cuda/iq_kernels.cu
+++ b/src/kernels/cuda/iq_kernels.cu
@@ -3822,3 +3822,163 @@ void native_expert_grouped(const NativeExpertLayout& L, const unsigned long long
}
} // namespace strata::kernels
+
+// ---- Volta prompt experts (STRATA_PF_WMMA): a group's experts as one launch of FP16 tensor-core tiles, the weights
+// dequantized into shared memory by dq_dispatch (the FP16 path's own formulas), the activations FP16, FP32 sums.
+// Replaces MMQ's dp4a products on sm_70, and the FP16 path's dequantize-to-global + one cuBLAS call per expert.
+#if !defined(__HIPCC__)
+#include <mma.h>
+namespace strata::kernels {
+namespace {
+constexpr int WG_BM = 64, WG_BN = 128, WG_THREADS = 256, WG_XK = 128, WG_MT = 4;
+// A block: BN = 128 weight rows of one expert x up to WG_MT * BM = 256 of its token rows (blockIdx.y walks an expert's
+// rows in such chunks), so every weight superblock is dequantized ONCE per chunk into shared memory (WK 256: an IQ
+// superblock through dq_dispatch; WK 128: two Q2_0 blocks); the activations stream through a BM x 128 tile. 8 warps
+// of 32 x 32 per m-tile (2 x 2 fragments), FP32 accumulators for the chunk's m-tiles in registers.
+template<int WK, bool Q20>
+__global__ void __launch_bounds__(WG_THREADS) gemm_iq_f16_grouped_kernel(int ty, const uint8_t* __restrict__ W,
+ size_t expert_bytes, size_t row_bytes, int K,
+ const __half* __restrict__ X, int ldx,
+ const int32_t* __restrict__ bounds, int ch_per_e,
+ float* __restrict__ Y, int ldy) {
+ using namespace nvcuda;
+ constexpr int LDW = WK + 8, LDX = WG_XK + 8;
+ extern __shared__ __align__(16) unsigned char wg_smem[];
+ __half* sw = reinterpret_cast<__half*>(wg_smem); // [BN][LDW]
+ __half* sx = sw + WG_BN * LDW; // [BM][LDX]
+ const int e = blockIdx.y / ch_per_e, ch = blockIdx.y % ch_per_e;
+ const int c0 = bounds[e] + ch * WG_MT * WG_BM, r1 = bounds[e + 1];
+ if (c0 >= r1) return;
+ const int crow = min(WG_MT * WG_BM, r1 - c0);
+ const int nmt = (crow + WG_BM - 1) / WG_BM;
+ const int n0 = blockIdx.x * WG_BN;
+ const uint8_t* we = W + (size_t) e * expert_bytes;
+ const int tid = threadIdx.x, warp = tid >> 5, lane = tid & 31;
+ const int wm = warp >> 2, wn = warp & 3; // rows wm*32, cols wn*32 of an m-tile
+ wmma::fragment<wmma::accumulator, 16, 16, 16, float> acc[WG_MT][2][2];
+#pragma unroll
+ for (int t = 0; t < WG_MT; ++t)
+#pragma unroll
+ for (int a = 0; a < 2; ++a)
+#pragma unroll
+ for (int b = 0; b < 2; ++b) wmma::fill_fragment(acc[t][a][b], 0.0f);
+ // the activation tiles in order (k0, m-tile, half): the next one's 4 uint4 per thread are loaded into registers
+ // while the current one is multiplied (the first before the weights' dequantization)
+ constexpr int XQ = WG_BM * (WG_XK / 8) / WG_THREADS; // 4
+ const int nx = WK / WG_XK, per_k = nmt * nx, total = (K / WK) * per_k;
+ uint4 xr[XQ];
+ auto load_x = [&](int it) {
+ const int kb = it / per_k, rem = it % per_k, t = rem / nx, xh = rem % nx;
+ const int rows = min(WG_BM, crow - t * WG_BM);
+#pragma unroll
+ for (int q = 0; q < XQ; ++q) {
+ const int i = tid + q * WG_THREADS, r = i / (WG_XK / 8), c = (i % (WG_XK / 8)) * 8;
+ xr[q] = r < rows ? *reinterpret_cast<const uint4*>(X + (size_t) (c0 + t * WG_BM + r) * ldx + kb * WK + xh * WG_XK + c)
+ : make_uint4(0, 0, 0, 0);
+ }
+ };
+ load_x(0);
+ int it = 0;
+ for (int k0 = 0; k0 < K; k0 += WK) {
+ if constexpr (!Q20) {
+ for (int r = warp; r < WG_BN; r += WG_THREADS / 32)
+ dq_dispatch<__half>(ty, we + (size_t) (n0 + r) * row_bytes, k0 / 256, sw + r * LDW, lane);
+ } else {
+ const int r = tid >> 1, blk = tid & 1; // one thread per (row, 64-value block)
+ const block_q2_0* b = reinterpret_cast<const block_q2_0*>(we + (size_t) (n0 + r) * row_bytes) + k0 / 64 + blk;
+ const float d = (float) b->d;
+ uint4 q4;
+ memcpy(&q4, b->qs, 16);
+ const uint8_t* qb = reinterpret_cast<const uint8_t*>(&q4);
+ __half* o = sw + r * LDW + blk * 64;
+#pragma unroll
+ for (int c = 0; c < 16; ++c) {
+ const int v = qb[c];
+ *reinterpret_cast<__half2*>(o + 4 * c) = __floats2half2_rn(d * (float) ((v & 3) - 1), d * (float) (((v >> 2) & 3) - 1));
+ *reinterpret_cast<__half2*>(o + 4 * c + 2) = __floats2half2_rn(d * (float) (((v >> 4) & 3) - 1), d * (float) (((v >> 6) & 3) - 1));
+ }
+ }
+#pragma unroll
+ for (int t = 0; t < WG_MT; ++t) {
+ if (t >= nmt) break;
+#pragma unroll 1
+ for (int xh = 0; xh < WK / WG_XK; ++xh, ++it) {
+ __syncthreads(); // the previous X tile is consumed (and W is written)
+#pragma unroll
+ for (int q = 0; q < XQ; ++q) {
+ const int i = tid + q * WG_THREADS, r = i / (WG_XK / 8), c = (i % (WG_XK / 8)) * 8;
+ *reinterpret_cast<uint4*>(sx + r * LDX + c) = xr[q];
+ }
+ __syncthreads();
+ if (it + 1 < total) load_x(it + 1);
+#pragma unroll
+ for (int kk = 0; kk < WG_XK; kk += 16) {
+ wmma::fragment<wmma::matrix_a, 16, 16, 16, __half, wmma::row_major> a[2];
+ wmma::fragment<wmma::matrix_b, 16, 16, 16, __half, wmma::col_major> b[2];
+#pragma unroll
+ for (int f = 0; f < 2; ++f) {
+ wmma::load_matrix_sync(a[f], sx + (wm * 32 + f * 16) * LDX + kk, LDX);
+ wmma::load_matrix_sync(b[f], sw + (wn * 32 + f * 16) * LDW + xh * WG_XK + kk, LDW);
+ }
+#pragma unroll
+ for (int fa = 0; fa < 2; ++fa)
+#pragma unroll
+ for (int fb = 0; fb < 2; ++fb) wmma::mma_sync(acc[t][fa][fb], a[fa], b[fb], acc[t][fa][fb]);
+ }
+ }
+ }
+ __syncthreads(); // W is consumed before the next superblock
+ }
+ float* so = reinterpret_cast<float*>(wg_smem); // [BM][BN + 4] per m-tile
+ constexpr int LDO = WG_BN + 4;
+#pragma unroll
+ for (int t = 0; t < WG_MT; ++t) {
+ if (t >= nmt) break;
+ const int rows = min(WG_BM, crow - t * WG_BM);
+#pragma unroll
+ for (int fa = 0; fa < 2; ++fa)
+#pragma unroll
+ for (int fb = 0; fb < 2; ++fb)
+ wmma::store_matrix_sync(so + (wm * 32 + fa * 16) * LDO + wn * 32 + fb * 16, acc[t][fa][fb], LDO, wmma::mem_row_major);
+ __syncthreads();
+ for (int i = tid; i < rows * (WG_BN / 4); i += WG_THREADS) {
+ const int r = i / (WG_BN / 4), c = (i % (WG_BN / 4)) * 4;
+ *reinterpret_cast<float4*>(Y + (size_t) (c0 + t * WG_BM + r) * ldy + n0 + c) = *reinterpret_cast<const float4*>(so + r * LDO + c);
+ }
+ __syncthreads();
+ }
+}
+} // namespace
+
+bool gemm_iq_f16_grouped(int ty, const void* W, size_t expert_bytes, int n_out, int K, const void* X, int ldx,
+ const int32_t* bounds, int n_experts, int max_rows, float* Y, int ldy, void* stream) {
+ if (n_out % WG_BN != 0 || n_experts <= 0 || max_rows <= 0 || ldy % 4 != 0) return false;
+ const bool q20 = ty == 42;
+ if (q20 ? K % 128 != 0 : (K % 256 != 0 || !is_iq(ty))) return false;
+ const size_t row_bytes = iq_row_bytes(ty, K);
+ const int mt = (max_rows + WG_MT * WG_BM - 1) / (WG_MT * WG_BM); // row chunks per expert
+ const dim3 grid((unsigned) (n_out / WG_BN), (unsigned) (n_experts * mt));
+ cudaStream_t s = (cudaStream_t) stream;
+ auto smem = [](int wk) { return (size_t) WG_BN * (wk + 8) * 2 + (size_t) WG_BM * (WG_XK + 8) * 2; };
+ static bool attr = false;
+ if (!attr) {
+ cudaFuncSetAttribute(gemm_iq_f16_grouped_kernel<256, false>, cudaFuncAttributeMaxDynamicSharedMemorySize, (int) smem(256));
+ cudaFuncSetAttribute(gemm_iq_f16_grouped_kernel<128, true>, cudaFuncAttributeMaxDynamicSharedMemorySize, (int) smem(128));
+ attr = true;
+ }
+ if (q20)
+ gemm_iq_f16_grouped_kernel<128, true><<<grid, WG_THREADS, smem(128), s>>>(ty, (const uint8_t*) W, expert_bytes, row_bytes, K,
+ (const __half*) X, ldx, bounds, mt, Y, ldy);
+ else
+ gemm_iq_f16_grouped_kernel<256, false><<<grid, WG_THREADS, smem(256), s>>>(ty, (const uint8_t*) W, expert_bytes, row_bytes, K,
+ (const __half*) X, ldx, bounds, mt, Y, ldy);
+ return cudaGetLastError() == cudaSuccess;
+}
+} // namespace strata::kernels
+#else
+namespace strata::kernels {
+bool gemm_iq_f16_grouped(int, const void*, size_t, int, int, const void*, int, const int32_t*, int, int, float*, int, void*) {
+ return false;
+}
+} // namespace strata::kernels
+#endif
diff --git a/src/prefill/kernels.cu b/src/prefill/kernels.cu
index c031ee086..435cac684 100644
--- a/src/prefill/kernels.cu
+++ b/src/prefill/kernels.cu
@@ -1681,6 +1681,17 @@ __global__ void swiglu_il_kernel(const float* __restrict__ gu, uint16_t* __restr
const float g = gu[r * 1280 + 2 * k], u = gu[r * 1280 + 2 * k + 1];
h16[i] = hf_sat(g / (1.0f + __expf(-g)) * u);
}
+// The Volta prompt experts (gemm_iq_f16_grouped): SwiGLU of the gate/up product's rows (gate 0..n_ff, up n_ff..2 n_ff,
+// or interleaved) to the FP16 input of the down product, saturated as swiglu_il_kernel
+__global__ void swiglu_split_f16_kernel(const float* __restrict__ gu, uint16_t* __restrict__ h16, int64_t rows, int n_ff,
+ bool interleaved) {
+ const int64_t i = (int64_t) blockIdx.x * blockDim.x + threadIdx.x;
+ if (i >= rows * n_ff) return;
+ const int64_t r = i / n_ff, k = i % n_ff;
+ const float* row = gu + r * 2 * n_ff;
+ const float g = interleaved ? row[2 * k] : row[k], u = interleaved ? row[2 * k + 1] : row[n_ff + k];
+ h16[i] = hf_sat(g / (1.0f + __expf(-g)) * u);
+}
__global__ void swiglu_pair_kernel(const float* __restrict__ g, const float* __restrict__ u, uint16_t* __restrict__ h16,
int64_t n) {
const int64_t i = (int64_t) blockIdx.x * blockDim.x + threadIdx.x;
@@ -2194,6 +2205,11 @@ void swiglu_interleaved(const float* gu, uint16_t* h16, int64_t n, void* stream)
swiglu_il_kernel<<<blocks_for(n * 640), 256, 0, (cudaStream_t) stream>>>(gu, h16, n);
check("swiglu_interleaved");
}
+void swiglu_split_f16(const float* gu, uint16_t* h16, int64_t rows, int n_ff, bool interleaved, void* stream) {
+ if (rows <= 0) return;
+ swiglu_split_f16_kernel<<<blocks_for(rows * n_ff), 256, 0, (cudaStream_t) stream>>>(gu, h16, rows, n_ff, interleaved);
+ check("swiglu_split_f16");
+}
void swiglu_pair(const float* g, const float* u, uint16_t* h16, int64_t n, void* stream) {
swiglu_pair_kernel<<<blocks_for(n * 640), 256, 0, (cudaStream_t) stream>>>(g, u, h16, n);
check("swiglu_pair");
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp
index 2fa71c7ce..749f1c592 100644
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -1005,10 +1005,30 @@ constexpr size_t MMQ_TAIL = 4096;
struct MmqPlan {
bool any = false, fallback = true;
std::vector<char> layer; // per layer: MMQ
+ std::vector<char> wmma_only; // per layer: in the MMQ grouping for the WMMA tiles only (pf_wmma: IQ1_M)
std::vector<char> fo; // per layer: no MMQ here but the native fused kernels cover its formats
// (gfx11: UD-Q4_K_XL's Q4_K / Q5_K and Q5_1 / Q8_0 experts, STRATA_PF_FUSED=1)
size_t gu_max = 0, d_max = 0;
};
+// Volta (sm_70): MMQ runs on dp4a there (no int8 tensor cores). pf_wmma(): the layers MMQ would take, and the IQ1_M
+// ones the FP16 path would, run as one launch per expert group on FP16 tensor-core tiles instead
+// (strata::kernels::gemm_iq_f16_grouped: each weight superblock dequantized once into shared memory by the FP16 path's
+// own formulas, FP16 activations, FP32 sums). STRATA_PF_WMMA=0 / 1: off / on on any CUDA card.
+bool pf_wmma() {
+#if defined(__HIPCC__)
+ return false;
+#else
+ static const bool on = [] {
+ if (const char* e = std::getenv("STRATA_PF_WMMA")) return e[0] == '1';
+ int dev = 0, major = 0, minor = 0;
+ if (cudaGetDevice(&dev) != cudaSuccess) return false;
+ cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev);
+ cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev);
+ return major == 7 && minor == 0;
+ }();
+ return on;
+#endif
+}
const MmqPlan& mmq_plan() {
static const MmqPlan plan = [] {
MmqPlan p;
@@ -1018,11 +1038,21 @@ const MmqPlan& mmq_plan() {
const int64_t layers = lay.native ? (int64_t) lay.fmt.size() : lay.n_layers;
p.layer.assign((size_t) std::max<int64_t>(layers, 0), 0);
p.fo.assign(p.layer.size(), 0);
+ p.wmma_only.assign(p.layer.size(), 0);
p.fallback = !on || layers <= 0;
for (int64_t l = 0; on && l < layers; ++l) {
const int gt = lay.native ? lay.fmt[(size_t) l].gu_type : 42, dt = lay.native ? lay.fmt[(size_t) l].d_type : 42;
// #420: a tile on every GPU for these shapes (gate+up: 1280 rows, down: N rows), else the FP16 path
if (!mmq::fits(gt, 1280) || !mmq::fits(dt, N)) {
+ // pf_wmma: a format dq_dispatch takes (IQ1_M) rides the MMQ grouping, computed by the WMMA tiles only
+ if (pf_wmma() && lay.native && dt == 42 && strata::kernels::iq_row_bytes(gt, N) > 0) {
+ p.layer[(size_t) l] = 1;
+ p.wmma_only[(size_t) l] = 1;
+ p.any = true;
+ p.gu_max = std::max(p.gu_max, mmq::matrix_bytes(gt, 1280, N));
+ p.d_max = std::max(p.d_max, mmq::matrix_bytes(dt, N, 640));
+ continue;
+ }
p.fallback = true;
// the fused path's buffers (Xq, H) exist for it; a chunk it does not take (a small one) keeps the FP16 path
if (on && lay.native && fused::native_supported(gt, dt)) { p.fo[(size_t) l] = 1; p.any = true; }
@@ -1037,6 +1067,8 @@ const MmqPlan& mmq_plan() {
}();
return plan;
}
+// the FP16 buffers (Xs, Hh): the FP16 path's, or pf_wmma's activations and down input
+bool fp16_bufs(const MmqPlan& mp) { return mp.fallback || pf_wmma(); }
// #136 P3: a layout whose chunks run the fused experts (STRATA_PF_FUSED=1, the Q2_0 pack, a streamed chunk of
// stream_all_min() tokens or more). Its GU, H and Xq hold only the fused path's grouping tables, int8 H and per-token
// int8 activations, and Hq nothing: ~100 KB a token less than MMQ's FP32 GU / H and per-slot q8_1 rows, which is what
@@ -1063,9 +1095,9 @@ uint64_t moe_set_bytes(size_t T, int64_t n_expert, bool fused) {
Alloc a; a.count_only = true; bool ok = true;
a.take<float>(T * n_expert, ok); a.take<float>(T * K, ok); a.take<int32_t>(T * K, ok); a.take<int32_t>(T * K, ok);
a.take<int32_t>(T * K, ok);
- if (mp.fallback) a.take<uint16_t>(T * K * N, ok);
+ if (fp16_bufs(mp)) a.take<uint16_t>(T * K * N, ok);
a.take<float>(mb.gu, ok);
- if (mp.fallback) a.take<uint16_t>(T * K * 640, ok);
+ if (fp16_bufs(mp)) a.take<uint16_t>(T * K * 640, ok);
a.take<float>(T * K * N, ok); a.take<float>(T * 640, ok);
a.take<float>(T * 640, ok); a.take<uint16_t>(T * 640, ok); a.take<float>(T * N, ok); a.take<float>(T, ok);
if (mp.any) {
@@ -1288,9 +1320,9 @@ bool Prefill::carve(size_t T, void* alloc) {
m.logits = c.take<float>(T * m.g->n_expert, ok); m.w = c.take<float>(T * K, ok); m.ids = c.take<int32_t>(T * K, ok);
m.slot_dev = c.take<int32_t>(T * K, ok); m.src_dev = c.take<int32_t>(T * K, ok);
const MmqPlan& mp = mmq_plan();
- m.Xs = mp.fallback ? c.take<uint16_t>(T * K * N, ok) : nullptr;
+ m.Xs = fp16_bufs(mp) ? c.take<uint16_t>(T * K * N, ok) : nullptr;
m.GU = c.take<float>(mb.gu, ok);
- m.Hh = mp.fallback ? c.take<uint16_t>(T * K * 640, ok) : nullptr;
+ m.Hh = fp16_bufs(mp) ? c.take<uint16_t>(T * K * 640, ok) : nullptr;
m.Dm = c.take<float>(T * K * N, ok);
m.sgate = c.take<float>(T * 640, ok); m.sup = c.take<float>(T * 640, ok); m.sh_h = c.take<uint16_t>(T * 640, ok);
m.shared = c.take<float>(T * N, ok); m.sg = c.take<float>(T, ok);
@@ -3449,12 +3481,20 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
return true;
});
}
+ // pf_wmma: this layer's groups on the FP16 tensor-core tiles (single GPU, native pack, Q2_0 down)
+ const bool wmma_l = use_mmq && pf_wmma() && !fused_l && on_peer.empty() && lay.native &&
+ mmq_dt == 42 && strata::kernels::iq_row_bytes(mmq_gt, N) > 0;
+ if (use_mmq && mmq_plan().wmma_only[(size_t) l] && !wmma_l) {
+ err = "prefill: an IQ1_M layer in the MMQ grouping needs the WMMA tiles, which this chunk cannot take";
+ return false;
+ }
const size_t mmq_gub = use_mmq ? mmq::matrix_bytes(mmq_gt, 1280, N) : 0;
const size_t mmq_db = use_mmq ? mmq::matrix_bytes(mmq_dt, N, 640) : 0;
pt.mark(kPfGather, cs);
if (use_mmq) {
// step 2b: the layer's activations as q8_1 rows in expert order, straight from `mixed`
- mmq::quantize(m.mixed, m.src_dev, m.Xq, mmq_gt, N, N, T * K, m.cs, m.Xscale);
+ if (wmma_l) gather_rows16(m.mixed_h, m.src_dev, m.Xs, T * K, N, m.cs); // FP16 rows
+ else mmq::quantize(m.mixed, m.src_dev, m.Xq, mmq_gt, N, N, T * K, m.cs, m.Xscale);
// each group's rows: absolute bounds (gate/up reads the layer's rows), relative ones (down
// reads the group's own quantized H)
const size_t n = order.size(), ng = (n + MMQ_GROUP - 1) / MMQ_GROUP;
@@ -3905,6 +3945,19 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
int64_t maxr = 0;
for (size_t i = j0; i <= j; ++i) maxr = std::max<int64_t>(maxr, m.cnt[(size_t) order[i]]);
pt.mark(kPfGemmGU, cs);
+ if (wmma_l) { // pf_wmma: gate/up, SwiGLU to FP16, down - the group in 2 tile launches
+ const int32_t* dnb = m.bounds_dev + n + 1 + g * (MMQ_GROUP + 1);
+ const bool ok1 = strata::kernels::gemm_iq_f16_grouped(
+ mmq_gt, m.grp_gu, mmq_gub, 1280, (int) N, m.Xs, (int) N, m.bounds_dev + j0, ngx,
+ (int) maxr, m.GU, 1280, m.cs);
+ swiglu_split_f16(m.GU + r0 * 1280, m.Hh + r0 * 640, nr, 640, !lay.native, m.cs);
+ pt.mark(kPfGemmD, cs);
+ const bool ok2 = strata::kernels::gemm_iq_f16_grouped(
+ mmq_dt, m.grp_d, mmq_db, (int) N, 640, m.Hh + r0 * 640, 640, dnb, ngx, (int) maxr,
+ m.Dm + r0 * N, (int) N, m.cs);
+ if (!ok1 || !ok2) { err = "prefill: the WMMA expert tiles could not launch"; return false; }
+ return true;
+ }
mmq::Product gu;
gu.w = m.grp_gu; gu.type = mmq_gt; gu.w_rows = 1280; gu.w_cols = N; gu.expert_bytes = mmq_gub;
gu.n = ngx; gu.xq = m.Xq; gu.bounds = m.bounds_dev + j0; gu.ids = m.ids_identity;