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: software-pipelined loads in the column-split GDN recurrence (bit-identical; STRATA_GDN_PIPELINE=0 = old kernel)
Andy18106b1c3166
diff --git a/src/prefill/kernels.cu b/src/prefill/kernels.cuindex fb7418a63..e03343dcf 100644--- a/src/prefill/kernels.cu+++ b/src/prefill/kernels.cu@@ -340,6 +340,66 @@ __global__ void __launch_bounds__(CB * RG) gdn_rec_cols_kernel(float* __restrict#pragma unrollfor (int r = 0; r < RPG; ++r) base[r * rs] = s[r];}+// dual-3090: gdn_rec_cols_kernel with the next token's inputs (q/k rows, v, gate, beta) loaded into registers while+// this token computes (software pipelining). The same arithmetic in the same order: the same bits. CBT = columns+// per block (32: upstream's split; 16: twice the blocks, STRATA_GDN_CB=16). STRATA_GDN_PIPELINE=0: upstream's kernel.+template <int CBT>+__global__ void __launch_bounds__(CBT * RG) gdn_rec_cols_pipe_kernel(float* __restrict__ state, const float* __restrict__ h,+ const float* __restrict__ gate,+ const float* __restrict__ beta,+ float* __restrict__ oc_out, int64_t T) {+ constexpr int NT = CBT * RG, LPT = S / NT, NCBT = S / CBT; // threads, q/k rows loaded per thread+ __shared__ float sk[S], sq[S], red[RG][CBT];+ const int head = blockIdx.x / NCBT, cb = blockIdx.x % NCBT;+ const int c = threadIdx.x, rg = threadIdx.y, tid = rg * CBT + c, col = cb * CBT + c;+ const int qh = head % HK;+ float s[RPG];+ float* base = state + ((size_t) (rg * RPG) * HV + head) * S + col;+ const size_t rs = (size_t) HV * S;+#pragma unroll+ for (int r = 0; r < RPG; ++r) s[r] = base[r * rs];+ float nq[LPT], nk[LPT], nv = 0.0f, ng = 0.0f, nb = 0.0f;+ auto fetch = [&](int64_t t) {+ const float* ht = h + t * C;+#pragma unroll+ for (int u = 0; u < LPT; ++u) { nq[u] = ht[qh * S + tid + u * NT]; nk[u] = ht[HK * S + qh * S + tid + u * NT]; }+ nv = ht[2 * HK * S + head * S + col];+ ng = gate[t * HV + head];+ nb = beta[t * HV + head];+ };+ if (T > 0) fetch(0);+ for (int64_t t = 0; t < T; ++t) {+ float cq[LPT], ck[LPT];+#pragma unroll+ for (int u = 0; u < LPT; ++u) { cq[u] = nq[u]; ck[u] = nk[u]; }+ const float cv = nv, cg = ng, cbt = nb;+ __syncthreads();+#pragma unroll+ for (int u = 0; u < LPT; ++u) { sq[tid + u * NT] = cq[u]; sk[tid + u * NT] = ck[u]; }+ __syncthreads();+ if (t + 1 < T) fetch(t + 1);+ const float g = __expf(cg);+ float kv = 0.0f;+#pragma unroll+ for (int r = 0; r < RPG; ++r) kv = fmaf(s[r], sk[rg * RPG + r], kv);+ red[rg][c] = kv;+ __syncthreads();+ const float kv_col = red[0][c] + red[1][c] + red[2][c] + red[3][c];+ const float delta = (cv - g * kv_col) * cbt;+ float o = 0.0f;+#pragma unroll+ for (int r = 0; r < RPG; ++r) {+ s[r] = fmaf(g, s[r], sk[rg * RPG + r] * delta);+ o = fmaf(s[r], sq[rg * RPG + r], o);+ }+ __syncthreads();+ red[rg][c] = o;+ __syncthreads();+ if (rg == 0) oc_out[t * HV * S + head * S + col] = (red[0][c] + red[1][c] + red[2][c] + red[3][c]) * rsqrtf((float) S);+ }+#pragma unroll+ for (int r = 0; r < RPG; ++r) base[r * rs] = s[r];+}__global__ void __launch_bounds__(S) gdn_out_norm_kernel(const float* __restrict__ z, const float* __restrict__ gamma,float eps, float* __restrict__ y, uint16_t* __restrict__ y16) {__shared__ float wsum[4];@@ -636,7 +696,14 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const floatif (serial || T <= 0) {gdn_rec_kernel<<<HV, dim3(S, RG), 0, (cudaStream_t) stream>>>(state, h, gate, beta, z, gamma, eps, y, y16, T);} else {- gdn_rec_cols_kernel<<<HV * NCB, dim3(CB, RG), 0, (cudaStream_t) stream>>>(state, h, gate, beta, y, T);+ static const bool pipe = [] { const char* v = std::getenv("STRATA_GDN_PIPELINE"); return v == nullptr || std::atoi(v) != 0; }();+ static const int cbt = [] { const char* v = std::getenv("STRATA_GDN_CB"); return v != nullptr && std::atoi(v) == 16 ? 16 : 32; }();+ if (pipe && cbt == 16) // dual-3090: the software-pipelined loads, 16 columns per block+ gdn_rec_cols_pipe_kernel<16><<<HV * (S / 16), dim3(16, RG), 0, (cudaStream_t) stream>>>(state, h, gate, beta, y, T);+ else if (pipe)+ gdn_rec_cols_pipe_kernel<32><<<HV * NCB, dim3(CB, RG), 0, (cudaStream_t) stream>>>(state, h, gate, beta, y, T);+ else+ gdn_rec_cols_kernel<<<HV * NCB, dim3(CB, RG), 0, (cudaStream_t) stream>>>(state, h, gate, beta, y, T);gdn_out_norm_kernel<<<dim3((unsigned) T, HV), S, 0, (cudaStream_t) stream>>>(z, gamma, eps, y, y16);}check("gdn_recurrence");