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_prompt_attn: tensor-core kernel for Volta (sm_70, mma.m8n8k4)
Klaus Friedel649fc7fcad7c
diff --git a/src/kernels/cuda/qsa_prompt_attn.cu b/src/kernels/cuda/qsa_prompt_attn.cuindex 614856630..914690afa 100644--- a/src/kernels/cuda/qsa_prompt_attn.cu+++ b/src/kernels/cuda/qsa_prompt_attn.cu@@ -736,6 +736,389 @@ bool launch(const float* q, const QsaAttnPools& pools, const int32_t* ids, constreturn true;}++#if !defined(__HIPCC__)+// ---- sm_70 (Volta): v1's structure on mma.m8n8k4 ------------------------------------------------------------------+// Volta's tensor cores only have m8n8k4 (FP16 in, FP32 accumulate): per warp FOUR independent 8x8x4 products, one per+// quad-pair (QP q = lanes 4q..4q+3 and 4q+16..4q+19; thread j = (lane & 3) + 4 * (lane >> 4) within it). Layout, measured on+// a V100 (tools-free microtest, and equal to turbomind's SM70_MMA_884): the thread holds row j of A (k 0..3 as two+// registers) and column j of B (k 0..3); C register i is row (lane & 1) + 4 * (lane >> 4) + 2 * ((i >> 1) & 1),+// column (lane & 2) + 4 * (i >> 2) + (i & 1) of its QP's 8x8 tile.+// q.k: warp w owns dims [64w, 64w+64) = int8 scale group w; QP q takes cells 8q..8q+7 of the 32-cell chunk; 16 k-steps+// of 4 dims, two 8-row blocks (12 heads + 4 zero rows), q as hi + lo halves. The warp's partial (times the+// cells' K scale) goes to S.part[w]; the softmax adds the four groups in a fixed order (deterministic).+// p.v: warp w owns dims [64w, 64w+64) again; QP q takes the 16 dims 64w+16q.. (two n-tiles of 8); k = the 32 cells in+// steps of 4; p carries the V scale (as v1) and is split into hi + lo halves.+#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 && __CUDA_ARCH__ < 750+#define STRATA_PA_VOLTA 1+#else+#define STRATA_PA_VOLTA 0+#endif++__device__ __forceinline__ void mma884(float* c, uint32_t a0, uint32_t a1, uint32_t b0, uint32_t b1) {+#if STRATA_PA_VOLTA+ asm volatile("mma.sync.aligned.m8n8k4.row.col.f32.f16.f16.f32 {%0,%1,%2,%3,%4,%5,%6,%7}, {%8,%9}, {%10,%11}, "+ "{%0,%1,%2,%3,%4,%5,%6,%7};\n"+ : "+f"(c[0]), "+f"(c[1]), "+f"(c[2]), "+f"(c[3]), "+f"(c[4]), "+f"(c[5]), "+f"(c[6]), "+f"(c[7])+ : "r"(a0), "r"(a1), "r"(b0), "r"(b1));+#else+ __trap(); // m8n8k4 is a Volta instruction; the host only launches this kernel on sm_70+#endif+}++template <int KV_MODE>+struct Smem70 {+ using KElem = typename std::conditional<KV_MODE == 0, __half, int8_t>::type;+ using VElem = typename std::conditional<KV_MODE == 1, int8_t, __half>::type;+ static constexpr int KROW = KV_MODE == 0 ? HD + 8 : HD + 16;+ static constexpr int VROW = KV_MODE == 1 ? HD + 16 : HD + 8;+ __half qh[16][QS];+ __half ql[16][QS];+ KElem k[CH][KROW];+ VElem v[CH][VROW];+ float ks[CH][4];+ float vs[CH][4];+ float part[4][16][CH + 4]; // q.k per dim group (scaled by the cell's K scale)+ float s[16][CH + 4]; // the chunk's probabilities+ float qmax[THREADS / 32];+ float alpha[16];+ float lsum[16];+ float mrow[16];+ long long row[CH];+};++template <int KV_MODE>+__global__ void __launch_bounds__(THREADS) prompt_attn_v70_kernel(const float* __restrict__ q, QsaAttnPools p,+ const int32_t* __restrict__ ids,+ const int32_t* __restrict__ steps, int n_kv_heads,+ int page_size, float scale_log2,+ float* __restrict__ attn, int cap) {+ extern __shared__ __align__(16) unsigned char smem_raw[];+ Smem70<KV_MODE>& S = *reinterpret_cast<Smem70<KV_MODE>*>(smem_raw);+ const int qi = blockIdx.x, kvh = blockIdx.y;+ const int n_head = n_kv_heads * G;+ q += (size_t) qi * n_head * HD + (size_t) kvh * G * HD;+ attn += (size_t) qi * n_head * HD + (size_t) kvh * G * HD;+ ids += (size_t) qi * cap;+ const int n = __ldg(steps + (size_t) qi * kStepCount + kStepWidth);+ const int t = threadIdx.x, lane = t & 31, warp = t >> 5;+ const int qp = (lane >> 2) & 3, jj = (lane & 3) + 4 * (lane >> 4); // quad-pair, thread within it+ const int crow = (lane & 1) + 4 * (lane >> 4); // C row of register 0 (+2 per register pair)+ const int ccol = lane & 2; // C column of register 0 (+4 per half, +1 per reg)++ // q: 12 heads + 4 zero rows, scaled by a power of two that puts its largest value near 2^14 (exact, and the+ // lo halves stay out of FP16's subnormal range), then split into hi + lo halves+ float qm = 0.0f;+ for (int i = t; i < G * HD; i += THREADS) qm = fmaxf(qm, fabsf(q[i]));+#pragma unroll+ for (int o = 16; o > 0; o >>= 1) qm = fmaxf(qm, __shfl_xor_sync(0xffffffffu, qm, o));+ if (lane == 0) S.qmax[warp] = qm;+ __syncthreads();+ qm = fmaxf(fmaxf(S.qmax[0], S.qmax[1]), fmaxf(S.qmax[2], S.qmax[3]));+ int qe = 0;+ if (qm > 0.0f) frexpf(qm, &qe); // qm < 2^qe+ const float qup = ldexpf(1.0f, 14 - qe), qdown = ldexpf(scale_log2, qe - 14);+ for (int i = t; i < 16 * HD; i += THREADS) {+ const int h = i / HD, d = i % HD;+ const float x = h < G ? q[(size_t) h * HD + d] * qup : 0.0f;+ const __half hi = __float2half_rn(x);+ S.qh[h][d] = hi;+ S.ql[h][d] = __float2half_rn(x - __half2float(hi));+ }+ if (t < 16) { S.mrow[t] = -INFINITY; S.lsum[t] = 0.0f; }++ float acc[2][2][8];+#pragma unroll+ for (int rb = 0; rb < 2; ++rb)+#pragma unroll+ for (int nt = 0; nt < 2; ++nt)+#pragma unroll+ for (int i = 0; i < 8; ++i) acc[rb][nt][i] = 0.0f;++ for (int c0 = 0; c0 < n; c0 += CH) {+ const int nh = min(CH, n - c0);+ if (t < CH) {+ long long r = -1;+ if (t < nh) {+ const int cell = ids[c0 + t];+ const long long page = (long long) p.page_table[cell / page_size];+ r = (page * n_kv_heads + kvh) * page_size + (cell % page_size);+ }+ S.row[t] = r;+ }+ __syncthreads(); // rows ready; the previous chunk's p.v is done with k, v, s+ // gather the chunk's K and V rows (16-byte pieces; K8V4's V as q4_0 blocks dequantized to fp16)+ // and their scales+ {+ constexpr int KPIECES = HD * (int) sizeof(typename Smem<KV_MODE>::KElem) / 16; // per K row+ for (int i = t; i < CH * KPIECES; i += THREADS) {+ const int c = i / KPIECES, pc = i % KPIECES;+ const long long r = S.row[c];+ uint4 kx = make_uint4(0, 0, 0, 0);+ if (r >= 0) {+ if constexpr (KV_MODE == 0)+ kx = __ldg(reinterpret_cast<const uint4*>(p.k_pool + r * HD) + pc);+ else // modes 1 and 3: the K side is INT8+ kx = __ldg(reinterpret_cast<const uint4*>(p.k_q + r * HD) + pc);+ }+ *reinterpret_cast<uint4*>(reinterpret_cast<unsigned char*>(&S.k[c][0]) + pc * 16) = kx;+ }+ if constexpr (KV_MODE == 3) { // V: dequantize the row's q4_0 blocks straight into the fp16 V row+ constexpr int BLKS = HD / QK4_0;+ constexpr int BYTES = BLKS * (int) sizeof(block_q4_0);+ for (int i = t; i < CH * BLKS; i += THREADS) {+ const int c = i / BLKS, b = i % BLKS;+ const long long r = S.row[c];+#pragma unroll+ for (int j = 0; j < QK4_0; ++j) S.v[c][b * QK4_0 + j] = __half(0);+ if (r >= 0) {+ const block_q4_0* blk = reinterpret_cast<const block_q4_0*>(p.v_q4 + r * BYTES) + b;+ const float d = __half2float(__ushort_as_half(blk->d));+#pragma unroll+ for (int j = 0; j < QK4_0 / 2; ++j) {+ S.v[c][b * QK4_0 + j] = __float2half_rn((float) ((int)(blk->qs[j] & 0x0F) - 8) * d);+ S.v[c][b * QK4_0 + j + QK4_0 / 2] =+ __float2half_rn((float) ((int)(blk->qs[j] >> 4) - 8) * d);+ }+ }+ }+ } else {+ constexpr int VPIECES = HD * (int) sizeof(typename Smem<KV_MODE>::VElem) / 16; // per V row+ for (int i = t; i < CH * VPIECES; i += THREADS) {+ const int c = i / VPIECES, pc = i % VPIECES;+ const long long r = S.row[c];+ uint4 vx = make_uint4(0, 0, 0, 0);+ if (r >= 0) {+ if constexpr (KV_MODE == 1)+ vx = __ldg(reinterpret_cast<const uint4*>(p.v_q + r * HD) + pc);+ else+ vx = __ldg(reinterpret_cast<const uint4*>(p.v_pool + r * HD) + pc);+ }+ *reinterpret_cast<uint4*>(reinterpret_cast<unsigned char*>(&S.v[c][0]) + pc * 16) = vx;+ }+ }+ for (int i = t; i < CH * 4; i += THREADS) {+ const int c = i / 4, g = i % 4;+ const long long r = S.row[c];+ float a = 0.0f, b = 0.0f;+ if (r >= 0) {+ if constexpr (KV_MODE == 1) {+ a = __half2float(__ushort_as_half(p.k_scale[r * (HD / KV_Q8_GROUP) + g]));+ b = __half2float(__ushort_as_half(p.v_scale[r * (HD / KV_Q8_GROUP) + g]));+ } else if constexpr (KV_MODE == 3) { // K as int8, V dequantized to fp16 (scale 1)+ a = __half2float(__ushort_as_half(p.k_scale[r * (HD / KV_Q8_GROUP) + g]));+ b = 1.0f;+ } else {+ a = b = 1.0f;+ }+ }+ S.ks[c][g] = a;+ S.vs[c][g] = b;+ }+ }+ __syncthreads();+ // scores: warp w = dim group w (64 dims), QP q = cells 8q..8q+7+ {+ float tg[2][8];+#pragma unroll+ for (int rb = 0; rb < 2; ++rb)+#pragma unroll+ for (int i = 0; i < 8; ++i) tg[rb][i] = 0.0f;+ const int cell_b = qp * 8 + jj;+#pragma unroll+ for (int ks = 0; ks < 16; ++ks) {+ const int d0 = warp * 64 + ks * 4;+ uint32_t b0, b1;+ if constexpr (KV_MODE != 0) { // modes 1 and 3: the K side is INT8 codes, exact in FP16+ const uint32_t raw = *reinterpret_cast<const uint32_t*>(&S.k[cell_b][d0]);+ b0 = i8x2_to_h2(raw & 0xffffu);+ b1 = i8x2_to_h2(raw >> 16);+ } else {+ const uint2 raw = *reinterpret_cast<const uint2*>(&S.k[cell_b][d0]);+ b0 = raw.x;+ b1 = raw.y;+ }+#pragma unroll+ for (int rb = 0; rb < 2; ++rb) {+ const uint2 ah = *reinterpret_cast<const uint2*>(&S.qh[rb * 8 + jj][d0]);+ const uint2 al = *reinterpret_cast<const uint2*>(&S.ql[rb * 8 + jj][d0]);+ mma884(tg[rb], ah.x, ah.y, b0, b1);+ mma884(tg[rb], al.x, al.y, b0, b1);+ }+ }+#pragma unroll+ for (int rb = 0; rb < 2; ++rb)+#pragma unroll+ for (int i = 0; i < 8; ++i) {+ const int row = rb * 8 + crow + 2 * ((i >> 1) & 1);+ const int cell = qp * 8 + ccol + 4 * (i >> 2) + (i & 1);+ S.part[warp][row][cell] = tg[rb][i] * S.ks[cell][warp];+ }+ }+ __syncthreads();+ // online softmax: row t/8, 4 cells per thread, 8 threads per row (lanes 8r..8r+7 of a warp)+ {+ constexpr int PER = CH / 8;+ const int r = t >> 3, sub = t & 7;+ float x[PER], mx = -INFINITY;+#pragma unroll+ for (int j = 0; j < PER; ++j) {+ const int c = sub * PER + j;+ const float sum4 = ((S.part[0][r][c] + S.part[1][r][c]) + S.part[2][r][c]) + S.part[3][r][c];+ x[j] = c < nh ? sum4 * qdown : -INFINITY;+ mx = fmaxf(mx, x[j]);+ }+#pragma unroll+ for (int o = 1; o < 8; o <<= 1) mx = fmaxf(mx, __shfl_xor_sync(0xffffffffu, mx, o));+ const float m_old = S.mrow[r];+ const float m_new = fmaxf(m_old, mx);+ float sum = 0.0f;+#pragma unroll+ for (int j = 0; j < PER; ++j) {+ const float e = x[j] == -INFINITY ? 0.0f : exp2f(x[j] - m_new);+ S.s[r][sub * PER + j] = e;+ sum += e;+ }+#pragma unroll+ for (int o = 1; o < 8; o <<= 1) sum += __shfl_xor_sync(0xffffffffu, sum, o);+ __syncwarp();+ if (sub == 0) {+ const float a = m_old == -INFINITY ? 0.0f : exp2f(m_old - m_new);+ S.alpha[r] = a;+ S.lsum[r] = fmaf(S.lsum[r], a, sum);+ S.mrow[r] = m_new;+ }+ }+ __syncthreads();+ __syncthreads();+ // p.v: warp w owns dims [64w, 64w+64) (int8 scale group w), QP q its 16 dims 64w+16q..; the V scale is folded+ // into p relative to the chunk's largest, times 2^14 (as v1)+ {+ float vmax = 0.0f;+#pragma unroll+ for (int c = lane; c < CH; c += 32) vmax = fmaxf(vmax, S.vs[c][warp]);+#pragma unroll+ for (int o = 16; o > 0; o >>= 1) vmax = fmaxf(vmax, __shfl_xor_sync(0xffffffffu, vmax, o));+ const float vup = vmax > 0.0f ? 16384.0f / vmax : 0.0f, vdown = vmax * (1.0f / 16384.0f);+ float tmp[2][2][8];+#pragma unroll+ for (int rb = 0; rb < 2; ++rb)+#pragma unroll+ for (int nt = 0; nt < 2; ++nt)+#pragma unroll+ for (int i = 0; i < 8; ++i) tmp[rb][nt][i] = 0.0f;+#pragma unroll+ for (int ks = 0; ks < CH / 4; ++ks) {+ const int c0 = ks * 4;+ float w[4];+#pragma unroll+ for (int e = 0; e < 4; ++e) w[e] = S.vs[c0 + e][warp] * vup;+ uint2 ah[2], al[2];+#pragma unroll+ for (int rb = 0; rb < 2; ++rb) {+ const float4 pv = *reinterpret_cast<const float4*>(&S.s[rb * 8 + jj][c0]);+ const float p0 = pv.x * w[0], p1 = pv.y * w[1], p2 = pv.z * w[2], p3 = pv.w * w[3];+ ah[rb].x = pack_h2(p0, p1);+ ah[rb].y = pack_h2(p2, p3);+ const float2 f01 = __half22float2(*reinterpret_cast<const __half2*>(&ah[rb].x));+ const float2 f23 = __half22float2(*reinterpret_cast<const __half2*>(&ah[rb].y));+ al[rb].x = pack_h2(p0 - f01.x, p1 - f01.y);+ al[rb].y = pack_h2(p2 - f23.x, p3 - f23.y);+ }+#pragma unroll+ for (int nt = 0; nt < 2; ++nt) {+ const int d = warp * 64 + qp * 16 + nt * 8 + jj;+ uint32_t b0, b1;+ if constexpr (KV_MODE == 1) {+ const uint32_t x0 = (uint8_t) S.v[c0][d] | ((uint32_t) (uint8_t) S.v[c0 + 1][d] << 8);+ const uint32_t x1 = (uint8_t) S.v[c0 + 2][d] | ((uint32_t) (uint8_t) S.v[c0 + 3][d] << 8);+ b0 = i8x2_to_h2(x0);+ b1 = i8x2_to_h2(x1);+ } else {+ const __half2 h0 = __halves2half2(S.v[c0][d], S.v[c0 + 1][d]);+ const __half2 h1 = __halves2half2(S.v[c0 + 2][d], S.v[c0 + 3][d]);+ b0 = *reinterpret_cast<const uint32_t*>(&h0);+ b1 = *reinterpret_cast<const uint32_t*>(&h1);+ }+#pragma unroll+ for (int rb = 0; rb < 2; ++rb) {+ mma884(tmp[rb][nt], ah[rb].x, ah[rb].y, b0, b1);+ mma884(tmp[rb][nt], al[rb].x, al[rb].y, b0, b1);+ }+ }+ }+#pragma unroll+ for (int rb = 0; rb < 2; ++rb) {+ float a_[2];+ a_[0] = S.alpha[rb * 8 + crow];+ a_[1] = S.alpha[rb * 8 + crow + 2];+#pragma unroll+ for (int nt = 0; nt < 2; ++nt)+#pragma unroll+ for (int i = 0; i < 8; ++i)+ acc[rb][nt][i] = fmaf(acc[rb][nt][i], a_[(i >> 1) & 1], tmp[rb][nt][i] * vdown);+ }+ }+ }+ __syncthreads();+#pragma unroll+ for (int rb = 0; rb < 2; ++rb)+#pragma unroll+ for (int h = 0; h < 2; ++h) {+ const int row = rb * 8 + crow + 2 * h;+ if (row >= G) continue;+ const float l = S.lsum[row];+ const float inv = l > 0.0f ? 1.0f / l : 0.0f;+#pragma unroll+ for (int nt = 0; nt < 2; ++nt)+#pragma unroll+ for (int hh = 0; hh < 2; ++hh) {+ const int i = hh * 4 + h * 2; // registers i, i+1: row h, columns ccol + 4 * hh + {0, 1}+ const int d = warp * 64 + qp * 16 + nt * 8 + ccol + 4 * hh;+ *reinterpret_cast<float2*>(attn + (size_t) row * HD + d) =+ make_float2(acc[rb][nt][i] * inv, acc[rb][nt][i + 1] * inv);+ }+ }+}++template <int KV_MODE>+bool launch70(const float* q, const QsaAttnPools& pools, const int32_t* ids, const int32_t* steps, int64_t cap,+ const QsaShapes& s, float* attn, int64_t n_q, cudaStream_t st) {+ static bool attr[64] = {};+ int dev = 0;+ cudaGetDevice(&dev);+ const int bytes = (int) sizeof(Smem70<KV_MODE>);+ if (dev < 0 || dev >= 64) return false;+ if (!attr[dev]) {+ if (cudaFuncSetAttribute(prompt_attn_v70_kernel<KV_MODE>, cudaFuncAttributeMaxDynamicSharedMemorySize, bytes) !=+ cudaSuccess) {+ cudaGetLastError();+ return false;+ }+ attr[dev] = true;+ }+ 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_v70_kernel<KV_MODE><<<dim3((unsigned) nb, (unsigned) s.n_head_kv), THREADS, bytes, 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) {+ std::fprintf(stderr, "qsa_prompt_attn_batch (sm_70): %s\n", cudaGetErrorString(e));+ std::exit(1);+ }+ return true;+}+#else // AMD: no m8n8k4 kernel; the dispatcher never selects it there+template <int KV_MODE>+bool launch70(const float*, const QsaAttnPools&, const int32_t*, const int32_t*, int64_t, const QsaShapes&, float*,+ int64_t, cudaStream_t) {+ return false;+}+#endif // !__HIPCC__+#if defined(__HIPCC__)// ---- S6: the int8-KV prompt attention on RDNA4 matrix cores (opt-in: STRATA_HIP_WMMA=1, gfx12 only). The design of// the v2 kernel above with gfx12's v_wmma_f32_16x16x16_f16 (wave32) in place of m16n8k16: wave w owns dims@@ -1022,7 +1405,7 @@ bool launch_wmma(const float* q, const QsaAttnPools& pools, const int32_t* ids,bool qsa_prompt_attn_batch(const float* q, const QsaAttnPools& pools, const int32_t* ids, const int32_t* steps,int64_t cap, const QsaShapes& s, float* attn, int64_t n_q, void* stream) {if (n_q <= 0) return true;- bool turing = false; // per call, from the CURRENT device (a layer split can mix Turing with newer cards)+ bool volta = false, turing = false; // per call, from the CURRENT device (a layer split can mix Turing with newer cards){ // sm_75 or newer: the MMA above compiles for both. sm_80+ runs the cp.async kernel (launch_i8); Turing has// no cp.async, so it runs the v1 kernel (launch<1>, same accuracy, another summation order). An older card// keeps the old kernel.@@ -1042,13 +1425,14 @@ bool qsa_prompt_attn_batch(const float* q, const QsaAttnPools& pools, const int3cc[dev] = w && (!std::strcmp(w, "1") || !std::strcmp(w, "attn")) ? 75: 10 * strata::cc_major_of(major) + strata::cc_minor_of(minor);}- if (cc[dev] < 75) return false;+ if (cc[dev] < 70) return false;+ volta = cc[dev] < 75; // sm_70: the m8n8k4 kernel (STRATA_PA_VOLTA); STRATA_QSA_WARP=1 still forces the old oneturing = cc[dev] < 80;}#if defined(__HIPCC__)// the tensor-core kernels are compiled out on AMD (its major version is not a CUDA sm); RDNA4 has its own int8-KV// matrix-core kernel, opt-in (STRATA_HIP_WMMA=1); everything else keeps the old kernel- (void) turing;+ (void) turing; (void) volta;if (pools.k_q != nullptr && pools.v_q != nullptr && pools.k_scale != nullptr && pools.v_scale != nullptr &&pools.k_q4 == nullptr && pools.v_q4 == nullptr && s.head_dim == HD && s.n_head == (int64_t) G * s.n_head_kv &&cap > 0 && ids && steps && pools.page_table && hip_wmma_usable())@@ -1069,6 +1453,7 @@ bool qsa_prompt_attn_batch(const float* q, const QsaAttnPools& pools, const int3}if (pools.k_q != nullptr && pools.v_q4 != nullptr) { // hybrid K8V4: int8 K + dequantized-q4 Vif (!pools.k_scale) return false;+ if (volta) return launch70<3>(q, pools, ids, steps, cap, s, attn, n_q, st);return launch<3>(q, pools, ids, steps, cap, s, attn, n_q, st);}if (pools.k_q != nullptr) {@@ -1077,10 +1462,12 @@ bool qsa_prompt_attn_batch(const float* q, const QsaAttnPools& pools, const int3// for how far the model amplifies an FP32-level change. Turing always takes it: v2's cp.async does not// exist before sm_80.static const bool v1 = std::getenv("STRATA_PROMPT_ATTN_V1") != nullptr;+ if (volta) return launch70<1>(q, pools, ids, steps, cap, s, attn, n_q, st);if (v1 || turing) return launch<1>(q, pools, ids, steps, cap, s, attn, n_q, st);return launch_i8(q, pools, ids, steps, cap, s, attn, n_q, st);}if (!pools.k_pool || !pools.v_pool) return false;+ if (volta) return launch70<0>(q, pools, ids, steps, cap, s, attn, n_q, st);return launch<0>(q, pools, ids, steps, cap, s, attn, n_q, st);}diff --git a/src/kernels/qsa_prompt_attn_parity.cpp b/src/kernels/qsa_prompt_attn_parity.cppindex d7dfda270..4a0921db6 100644--- a/src/kernels/qsa_prompt_attn_parity.cpp+++ b/src/kernels/qsa_prompt_attn_parity.cpp@@ -41,6 +41,18 @@ float h2f(uint16_t b) { __half h; *reinterpret_cast<uint16_t*>(&h) = b; return _uint16_t f2h(float f) { __half h = __float2half(f); return *reinterpret_cast<uint16_t*>(&h); }int run(int fmt, int64_t ctx, int64_t nq, int reps) { // fmt 1 int8, 0 fp16, 2 q4_0+#if !defined(__HIPCC__) && !defined(STRATA_USE_HIP)+ if (fmt == 2) { // mode 4 (Q4_0 KV) runs on sm_80 and newer only: below that the dispatcher keeps the old kernel+ int dev = 0, major = 0;+ ck(cudaGetDevice(&dev), "device");+ ck(cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev), "cc");+ if (major < 8) {+ std::printf("SKIP q4_0 ctx %lld: the tensor-core kernel takes Q4_0 KV on sm_80+ only (this device: sm_%d)\n",+ (long long) ctx, major);+ return 0;+ }+ }+#endifconst k::QsaShapes s = k::qsa_real_shapes();const int64_t HD = s.head_dim, NKV = s.n_head_kv, NH = s.n_head, PS = s.page_size;const int64_t pages = (ctx + PS - 1) / PS, rows = pages * NKV * PS;