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++
qsa: opt-in STRATA_PA_FAST=1 - the gfx11 prompt attention with single FP16 q and p
Niko12217aaf466d188f
diff --git a/src/kernels/cuda/qsa_prompt_attn.cu b/src/kernels/cuda/qsa_prompt_attn.cuindex 30de4b340..6cfd8e434 100644--- a/src/kernels/cuda/qsa_prompt_attn.cu+++ b/src/kernels/cuda/qsa_prompt_attn.cu@@ -754,6 +754,10 @@ __device__ __forceinline__ wh8 i8_to_h(const uint32_t* x) { // PA_KL codes, exreturn h;}+// SPLIT = true (default): q and p carried as FP16 hi + lo pairs (two WMMAs each: FP32-level). S23 (opt-in+// STRATA_PA_FAST=1): SPLIT = false, one FP16 image each - half the matrix work, rounding-level (FP16 attention as the+// usual flash-attention kernels), quality-gated+template <bool SPLIT>__global__ void __launch_bounds__(THREADS) prompt_attn_wmma_kernel(const float* __restrict__ q, QsaAttnPools p,const int32_t* __restrict__ ids,const int32_t* __restrict__ steps, int n_kv_heads,@@ -859,7 +863,7 @@ __global__ void __launch_bounds__(THREADS) prompt_attn_wmma_kernel(const float*}const wh8 b = i8_to_h(kx);s = wmma_f16(qh[kk], b, s);- s = wmma_f16(ql[kk], b, s);+ if constexpr (SPLIT) s = wmma_f16(ql[kk], b, s);}#pragma unrollfor (int i = 0; i < 8; ++i) S.part[warp][PA_ROW(i, half)][nt * 16 + col] = s[i] * ksc;@@ -925,7 +929,7 @@ __global__ void __launch_bounds__(THREADS) prompt_attn_wmma_kernel(const float*#pragma unrollfor (int i = 0; i < PA_KL; ++i) b[i] = (_Float16) (int) (int8_t) S.v[warp][cb + i][d];tmp[j] = wmma_f16(ah, b, tmp[j]);- tmp[j] = wmma_f16(al, b, tmp[j]);+ if constexpr (SPLIT) tmp[j] = wmma_f16(al, b, tmp[j]);}}float a[8];@@ -988,9 +992,15 @@ bool launch_wmma(const float* q, const QsaAttnPools& pools, const int32_t* ids,const float scale_log2 = 1.4426950408889634f / sqrtf((float) HD);for (int64_t q0 = 0; q0 < n_q; q0 += 65535) {const int64_t nb = n_q - q0 < 65535 ? n_q - q0 : 65535;- prompt_attn_wmma_kernel<<<dim3((unsigned) nb, (unsigned) s.n_head_kv), THREADS, 0, st>>>(- q + q0 * s.n_head * HD, pools, ids + q0 * cap, steps + q0 * kStepCount, (int) s.n_head_kv,- (int) s.page_size, scale_log2, attn + q0 * s.n_head * HD, (int) cap);+ static const bool fast = [] { const char* e = std::getenv("STRATA_PA_FAST"); return e != nullptr && e[0] == '1'; }();+ if (fast)+ prompt_attn_wmma_kernel<false><<<dim3((unsigned) nb, (unsigned) s.n_head_kv), THREADS, 0, st>>>(+ q + q0 * s.n_head * HD, pools, ids + q0 * cap, steps + q0 * kStepCount, (int) s.n_head_kv,+ (int) s.page_size, scale_log2, attn + q0 * s.n_head * HD, (int) cap);+ else+ prompt_attn_wmma_kernel<true><<<dim3((unsigned) nb, (unsigned) s.n_head_kv), THREADS, 0, st>>>(+ q + q0 * s.n_head * HD, pools, ids + q0 * cap, steps + q0 * kStepCount, (int) s.n_head_kv,+ (int) s.page_size, scale_log2, attn + q0 * s.n_head * HD, (int) cap);}const cudaError_t e = cudaGetLastError();if (e != cudaSuccess) {