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++
OPUS-MTP-MMVQ multi-colonna con attivazioni riusate fra le righe del blocco (STRATA_B6_MMVQ_ROWS) e micro-bench
imanu8e68aa587981
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 5e94c773b..714c60e2c 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -915,6 +915,12 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)add_executable(router_chain_bench src/kernels/router_chain_bench.cpp)target_include_directories(router_chain_bench PRIVATE ${_strata_gpu_include_directories})target_link_libraries(router_chain_bench PRIVATE strata_kernels ${_strata_gpu_runtime_target})+ # B6: the dense projections' time per verify row at the model's shapes, default vs STRATA_B6_MMVQ_ROWS, bitwise+ if(STRATA_ENABLE_CUDA)+ add_executable(b6_mmvq_bench src/kernels/b6_mmvq_bench.cpp)+ target_include_directories(b6_mmvq_bench PRIVATE ${_strata_gpu_include_directories})+ target_link_libraries(b6_mmvq_bench PRIVATE strata_kernels ${_strata_gpu_runtime_target})+ endif()add_executable(gr_parity src/kernels/gr_parity.cpp)target_include_directories(gr_parity PRIVATE ${_strata_gpu_include_directories})target_link_libraries(gr_parity PRIVATE strata_kernels ${_strata_gpu_runtime_target})diff --git a/include/strata/kernels/native_mmvq.hpp b/include/strata/kernels/native_mmvq.hppindex fef71027d..3c4185f88 100644--- a/include/strata/kernels/native_mmvq.hpp+++ b/include/strata/kernels/native_mmvq.hpp@@ -31,6 +31,12 @@ std::size_t native_q8_1_bytes(int n_in, int ncols = 1);// graph capture; captured graphs keep the kernels they captured.void native_mmvq_set_multi_exact(bool exact);bool native_mmvq_multi_exact();+// B6 (lab, opt-in STRATA_B6_MMVQ_ROWS=1): the exact multi-column layout with the activation blocks of every column+// loaded once per weight block and reused across the block's rows (bitwise the same sums as the default exact+// layout). 0 = off (default), 1 = 2 rows per block, 2 / 4 / 8 = that many rows. Q4_K, Q5_K, Q6_K and IQ4_XS only.+// Set before graph capture.+void native_mmvq_set_b6_rows(int mode);+int native_mmvq_b6_rows();// One quantization may serve multiple weight matrices sharing the same input.// Q8_1 stores FP16 scale and FP16 warp sum of the ORIGINAL float inputs; it doesdiff --git a/src/kernels/b6_mmvq_bench.cpp b/src/kernels/b6_mmvq_bench.cppnew file mode 100644index 000000000..75e136d98--- /dev/null+++ b/src/kernels/b6_mmvq_bench.cpp@@ -0,0 +1,218 @@+// src/kernels/b6_mmvq_bench.cpp - B6: what a verify row costs in the dense projections, per kernel, per card.+//+// build/b6_mmvq_bench [reps] [device, -1 = all] [B rows mode: 1 = 2 rows, or 2 / 4 / 8]+//+// The decode's dense projections at the model's own shapes and formats (qwen3.8-flash-next GSQ-RCO IQ3_XXS:+// GDN qkv / gate / out, QSA q / out, shared expert, the head; the BF16 router), called with ncols = 1..5 and 8 as a+// verify window of that many rows calls them. Per call: CUDA events around each launch, every launch queued back to+// back (no host gap inside a measurement), the median of `reps` (default 500) after a warm-up. The weights rotate+// over enough copies to exceed the L2, as the decode reads each layer's weights cold. Synthetic bytes with sane+// block scales (as mmvq_multi_parity): the time does not depend on the values.+//+// Two layouts side by side: the default exact layout (A) and STRATA_B6_MMVQ_ROWS (B, native_mmvq_set_b6_rows). For+// every case and ncols: B's output against A's, bit for bit (memcmp), and both against ncols single-column calls.+// Exit code 1 if any comparison differs. GPU time only: immune to the host and to any generated text.+#include "strata/kernels/bf16_gemv.hpp"+#include "strata/kernels/iq_kernels.hpp"+#include "strata/kernels/native_mmvq.hpp"++#include <cuda_runtime.h>++#include <algorithm>+#include <cmath>+#include <cstdint>+#include <cstdio>+#include <cstdlib>+#include <cstring>+#include <random>+#include <vector>++namespace K = strata::kernels;++namespace {++struct Case {+ const char* name;+ int type; // GGML type id; 30 = BF16 (bf16_gemv_fp32_mmvf_multi)+ int n_in, n_out;+ int block_elems, block_bytes;+ int scale_at[2]; // byte offsets of the fp16 scales in a block; -1 = none+};++const Case CASES[] = {+ {"gdn qkv Q6_K", 14, 2560, 10240, 256, 210, {208, -1}},+ {"gdn qkv Q4_K", 12, 2560, 10240, 256, 144, {0, 2}},+ {"gdn qkv Q5_K", 13, 2560, 10240, 256, 176, {0, 2}},+ {"gdn qkv IQ4_XS", 23, 2560, 10240, 256, 136, {0, -1}},+ {"gdn gate Q6_K", 14, 2560, 6144, 256, 210, {208, -1}},+ {"gdn out Q6_K", 14, 6144, 2560, 256, 210, {208, -1}},+ {"gdn out IQ4_XS", 23, 6144, 2560, 256, 136, {0, -1}},+ {"gdn out Q4_K", 12, 6144, 2560, 256, 144, {0, 2}},+ {"qsa q IQ4_XS", 23, 2560, 12288, 256, 136, {0, -1}},+ {"qsa q Q6_K", 14, 2560, 12288, 256, 210, {208, -1}},+ {"shexp up IQ3_S", 21, 2560, 640, 256, 110, {0, -1}},+ {"shexp gate Q4_K", 12, 2560, 640, 256, 144, {0, 2}},+ {"shexp down IQ4_NL", 20, 640, 2560, 32, 18, {0, -1}},+ {"router BF16", 30, 2560, 512, 1, 2, {-1, -1}},+ {"head Q5_K", 13, 2560, 248320, 256, 176, {0, 2}},+};+const int WIDTHS[] = {1, 2, 3, 4, 5, 8};++bool ck(cudaError_t e, const char* what) {+ if (e == cudaSuccess) return true;+ std::printf("CUDA: %s: %s\n", what, cudaGetErrorString(e));+ return false;+}++uint16_t sane_half(std::mt19937& rng) {+ const uint32_t r = rng();+ return (uint16_t) (((r >> 31) << 15) | ((5u + (r >> 10) % 5u) << 10) | (r & 0x3ffu));+}+uint16_t bf16(float x) {+ uint32_t u;+ std::memcpy(&u, &x, 4);+ return (uint16_t) ((u + 0x7fff + ((u >> 16) & 1)) >> 16);+}++struct Buf {+ std::vector<void*> w; // weight copies+ std::size_t wbytes = 0;+ void* xq = nullptr; // Q8_1 of 8 columns+ float* xf = nullptr; // the float activations (BF16 path)+ float* y = nullptr; // 8 columns of output+};++// one call of the case at `ncols` on weight copy `k` into y+void call(const Case& c, const Buf& b, int k, int ncols, float* y, cudaStream_t s) {+ if (c.type == 30)+ K::bf16_gemv_fp32_mmvf_multi(b.xf, c.n_in, (const uint16_t*) b.w[(size_t) k], y, c.n_out, c.n_in, c.n_out, ncols, s);+ else+ K::native_mmvq(c.type, b.w[(size_t) k], b.xq, y, c.n_in, c.n_out, ncols, s);+}+// column j alone (ncols = 1), into y + j * n_out+void call_col(const Case& c, const Buf& b, int j, float* y, cudaStream_t s) {+ if (c.type == 30)+ K::bf16_gemv_fp32_mmvf_multi(b.xf + (size_t) j * c.n_in, c.n_in, (const uint16_t*) b.w[0],+ y + (size_t) j * c.n_out, c.n_out, c.n_in, c.n_out, 1, s);+ else+ K::native_mmvq(c.type, b.w[0], (const uint8_t*) b.xq + K::native_q8_1_bytes(c.n_in, 1) * (size_t) j,+ y + (size_t) j * c.n_out, c.n_in, c.n_out, 1, s);+}++double median_ms(const Case& c, const Buf& b, int ncols, int reps, cudaStream_t s, std::vector<cudaEvent_t>& ev) {+ const int nk = (int) b.w.size();+ for (int r = 0; r < 30; ++r) call(c, b, r % nk, ncols, b.y, s); // warm-up+ for (int r = 0; r < reps; ++r) {+ cudaEventRecord(ev[(size_t) 2 * r], s);+ call(c, b, r % nk, ncols, b.y, s);+ cudaEventRecord(ev[(size_t) 2 * r + 1], s);+ }+ cudaStreamSynchronize(s);+ std::vector<float> t((size_t) reps);+ for (int r = 0; r < reps; ++r) cudaEventElapsedTime(&t[(size_t) r], ev[(size_t) 2 * r], ev[(size_t) 2 * r + 1]);+ std::nth_element(t.begin(), t.begin() + reps / 2, t.end());+ return t[(size_t) reps / 2];+}++} // namespace++int main(int argc, char** argv) {+ setvbuf(stdout, nullptr, _IONBF, 0);+ const int reps = argc > 1 ? std::max(50, std::atoi(argv[1])) : 500;+ int n_dev = 0;+ if (!ck(cudaGetDeviceCount(&n_dev), "device count")) return 1;+ const int only = argc > 2 ? std::atoi(argv[2]) : -1;+ const int bmode = argc > 3 ? std::atoi(argv[3]) : 1;+ long long bad = 0;+ for (int dev = 0; dev < n_dev; ++dev) {+ if (only >= 0 && dev != only) continue;+ cudaSetDevice(dev);+ cudaDeviceProp pr{};+ cudaGetDeviceProperties(&pr, dev);+ std::printf("\n=== device %d: %s (sm_%d%d, L2 %d KB), %d reps, median ms per call, B = rows mode %d ===\n", dev, pr.name,+ pr.major, pr.minor, pr.l2CacheSize / 1024, reps, bmode);+ std::printf("%-18s %4s %9s %9s %8s %8s %s\n", "case", "cols", "A ms", "B ms", "A +col", "B +col",+ "bitwise B=A, A=1col, B=1col");+ cudaStream_t s;+ if (!ck(cudaStreamCreate(&s), "stream")) return 1;+ std::vector<cudaEvent_t> ev((size_t) 2 * reps);+ for (auto& e : ev) cudaEventCreate(&e);+ for (const Case& c : CASES) {+ if (c.type != 30 && !K::native_mmvq_supported(c.type)) {+ std::printf("%-18s unsupported type %d\n", c.name, c.type);+ continue;+ }+ std::mt19937 rng(77u + (unsigned) c.type * 131u + (unsigned) c.n_out);+ Buf b;+ b.wbytes = c.type == 30 ? (size_t) c.n_in * c.n_out * 2 : K::native_mmvq_weight_bytes(c.type, c.n_in, c.n_out);+ std::vector<uint8_t> w(b.wbytes);+ if (c.type == 30) {+ std::normal_distribution<float> nd(0.f, 0.05f);+ auto* p = (uint16_t*) w.data();+ for (size_t i = 0; i < b.wbytes / 2; ++i) p[i] = bf16(nd(rng));+ } else {+ for (auto& x : w) x = (uint8_t) (rng() & 0xff);+ const size_t nb = (size_t) c.n_out * (size_t) (c.n_in / c.block_elems);+ for (size_t k = 0; k < nb; ++k)+ for (int at : c.scale_at)+ if (at >= 0) {+ const uint16_t h = sane_half(rng);+ std::memcpy(&w[k * (size_t) c.block_bytes + (size_t) at], &h, 2);+ }+ }+ const size_t copies = std::max<size_t>(1, std::min<size_t>(8, (96u << 20) / b.wbytes + 1));+ bool ok = true;+ for (size_t k = 0; k < copies && ok; ++k) {+ void* d = nullptr;+ ok = ck(cudaMalloc(&d, b.wbytes), "malloc w") && ck(cudaMemcpy(d, w.data(), b.wbytes, cudaMemcpyHostToDevice), "copy w");+ b.w.push_back(d);+ }+ std::vector<float> x((size_t) 8 * c.n_in);+ std::normal_distribution<float> nx(0.f, 1.f);+ for (auto& v : x) v = nx(rng);+ const size_t ybytes = (size_t) 8 * c.n_out * 4;+ ok = ok && ck(cudaMalloc(&b.xf, x.size() * 4), "malloc x") &&+ ck(cudaMemcpy(b.xf, x.data(), x.size() * 4, cudaMemcpyHostToDevice), "copy x") &&+ ck(cudaMalloc(&b.y, ybytes), "malloc y");+ if (ok && c.type != 30) {+ ok = ck(cudaMalloc(&b.xq, K::native_q8_1_bytes(c.n_in, 8)), "malloc xq");+ if (ok) K::quantize_q8_1_rows(b.xf, 8, c.n_in, b.xq, s);+ }+ float *ya = nullptr, *yb = nullptr, *y1 = nullptr;+ ok = ok && ck(cudaMalloc(&ya, ybytes), "ya") && ck(cudaMalloc(&yb, ybytes), "yb") && ck(cudaMalloc(&y1, ybytes), "y1");+ if (!ok) return 1;+ double a1 = 0, b1 = 0;+ for (int T : WIDTHS) {+ std::vector<uint32_t> ha((size_t) T * c.n_out), hb(ha.size()), h1(ha.size());+ K::native_mmvq_set_b6_rows(0);+ const double ta = median_ms(c, b, T, reps, s, ev);+ call(c, b, 0, T, ya, s);+ for (int j = 0; j < T; ++j) call_col(c, b, j, y1, s);+ K::native_mmvq_set_b6_rows(bmode);+ const double tb = median_ms(c, b, T, reps, s, ev);+ call(c, b, 0, T, yb, s);+ K::native_mmvq_set_b6_rows(0);+ if (!ck(cudaStreamSynchronize(s), "run")) return 1;+ cudaMemcpy(ha.data(), ya, ha.size() * 4, cudaMemcpyDeviceToHost);+ cudaMemcpy(hb.data(), yb, hb.size() * 4, cudaMemcpyDeviceToHost);+ cudaMemcpy(h1.data(), y1, h1.size() * 4, cudaMemcpyDeviceToHost);+ const bool ba = std::memcmp(ha.data(), hb.data(), ha.size() * 4) == 0;+ const bool a_1 = std::memcmp(ha.data(), h1.data(), ha.size() * 4) == 0;+ const bool b_1 = std::memcmp(hb.data(), h1.data(), hb.size() * 4) == 0;+ long long nonfinite = 0;+ for (uint32_t u : ha) { float f; std::memcpy(&f, &u, 4); if (!std::isfinite(f)) ++nonfinite; }+ if (!ba || !b_1 || nonfinite) ++bad;+ if (T == 1) { a1 = ta; b1 = tb; }+ std::printf("%-18s %4d %9.4f %9.4f %8.4f %8.4f %s %s %s%s\n", c.name, T, ta, tb,+ T > 1 ? (ta - a1) / (T - 1) : 0.0, T > 1 ? (tb - b1) / (T - 1) : 0.0, ba ? "ok" : "DIFF",+ a_1 ? "ok" : "diff", b_1 ? "ok" : "DIFF", nonfinite ? " NONFINITE" : "");+ }+ for (void* d : b.w) cudaFree(d);+ cudaFree(b.xq); cudaFree(b.xf); cudaFree(b.y); cudaFree(ya); cudaFree(yb); cudaFree(y1);+ }+ for (auto& e : ev) cudaEventDestroy(e);+ cudaStreamDestroy(s);+ }+ std::printf("\nb6_mmvq_bench: %s (%lld case/width comparisons failed)\n", bad ? "FAILED" : "ok", bad);+ return bad ? 1 : 0;+}diff --git a/src/kernels/cuda/native_mmvq.cu b/src/kernels/cuda/native_mmvq.cuindex d537fd5fe..136eeb603 100644--- a/src/kernels/cuda/native_mmvq.cu+++ b/src/kernels/cuda/native_mmvq.cu@@ -1154,6 +1154,8 @@ struct SmallTraits<IQ4NLBlock, 4> {// llama.cpp's generic multi-column table (ncols 2-4: 4 warps; 5-8: 2 warps; always 2 rows per block): faster,// equal to ncols = 1 only to float rounding (the cross-warp reduction groups partial sums differently).bool g_multi_exact = true; // until the upstream layout is timed on an idle GPU (plan rule: default only what is measured)+// B6 STRATA_B6_MMVQ_ROWS (lab, default 0 = off): see native_mmvq_set_b6_rows+int g_b6_rows = [] { const char* v = std::getenv("STRATA_B6_MMVQ_ROWS"); return v ? std::atoi(v) : 0; }();// S26 STRATA_TSUM=1 (TS): warp 0's NCOLS x ROWS sums as one transposed butterfly (s26_tsum.cuh), bitwise the samestatic bool s26_tsum_on() {@@ -1303,10 +1305,174 @@ bool q8_0_rows1(int n_in, int n_out) {}}+// ---- B6 STRATA_B6_MMVQ_ROWS (lab, opt-in): the exact multi-column layout with each column's activation fragment+// loaded ONCE per weight block and reused across ROWS rows of the block (the default kernel reloads it for every row+// it applies it to, and the K-quant scales once per column). A thread keeps the same blocks (kbx = tid / T, stride+// BPI with WARPS warps), each (row, column) sum adds the same per-block values in the same order, and the cross-warp+// and warp reductions are the default kernel's: every output is bitwise the default exact layout's, so bitwise a+// single-column call. Only the formats with a B6X below; the others keep the default kernel.+template<typename F> struct B6X { static constexpr bool ok = false; };+template<> struct B6X<Q6KTraits> {+ static constexpr bool ok = true;+ struct X { int u[2]; float d8[2]; };+ struct W { int vl, vh, sc[2]; float d; };+ __device__ static X xload(const Q81Block* x, int iqs) {+ X r;+ const int off = 4 * (iqs / 16) + (iqs % 16) / 8; // Q6KTraits::load's bq8_offset+#pragma unroll+ for (int i = 0; i < 2; ++i) {+ r.u[i] = reinterpret_cast<const int*>(x[off + 2 * i].qs)[iqs % 8];+ r.d8[i] = __low2float(x[off + 2 * i].ds);+ }+ return r;+ }+ __device__ static W wload(const Q6KBlock* __restrict__ w, int iqs) {+ const Q6KTraits::W t = Q6KTraits::load(w, iqs);+ W r;+ r.vl = t.vl;+ r.vh = t.vh;+ r.sc[0] = t.scales[0];+ r.sc[1] = t.scales[4];+ r.d = t.d;+ return r;+ }+ __device__ static float dot(const W& w, const X& x) { // q6_q8_dot_impl, the scales already in registers+ float sumf = 0.0f;+#pragma unroll+ for (int i = 0; i < 2; ++i) {+ const int vil = (w.vl >> (4 * i)) & 0x0f0f0f0f;+ const int vih = ((w.vh >> (4 * i)) << 4) & 0x30303030;+ const int vi = __vsubss4(vil | vih, 0x20202020);+ sumf += x.d8[i] * (STRATA_DP4A(vi, x.u[i], 0) * w.sc[i]);+ }+ return w.d * sumf;+ }+};+template<typename T, int KIND> struct B6XK { // Q4_K (KIND 4) and Q5_K (KIND 5): the same activation fragment+ static constexpr bool ok = true;+ struct X { int u[4]; float d8[2]; };+ using W = typename T::W;+ __device__ static X xload(const Q81Block* bq8, int iqs) {+ X r;+ const int off = 2 * ((iqs / 2) / 4); // the traits' bq8_offset+#pragma unroll+ for (int i = 0; i < 2; ++i) {+ const Q81Block* bq8i = bq8 + off + i;+ r.d8[i] = __low2float(bq8i->ds);+ const int* q8 = reinterpret_cast<const int*>(bq8i->qs) + ((iqs / 2) % 4);+ r.u[2 * i] = q8[0];+ r.u[2 * i + 1] = q8[4];+ }+ return r;+ }+ __device__ static W wload(const typename T::Block* __restrict__ w, int iqs) { return T::load(w, iqs); }+ __device__ static float dot(const W& w, const X& x) {+ const uint8_t* sc = reinterpret_cast<const uint8_t*>(w.aux);+ if constexpr (KIND == 4) return q4_q8_dot_impl(w.v, x.u, sc, sc + 2, w.dm, x.d8);+ else return q5_q8_dot_impl(w.vl, w.vh, x.u, sc, sc + 2, w.dm, x.d8);+ }+};+template<> struct B6X<Q4KTraits> : B6XK<Q4KTraits, 4> {};+template<> struct B6X<Q5KTraits> : B6XK<Q5KTraits, 5> {};+template<> struct B6X<IQ4XSTraits> {+ static constexpr bool ok = true;+ struct X { int u0[4], u1[4]; float dx; };+ using W = IQ4XSTraits::W;+ __device__ static X xload(const Q81Block* x, int iqs) {+ X r;+#pragma unroll+ for (int j = 0; j < 4; ++j) {+ r.u0[j] = reinterpret_cast<const int*>(x[iqs / 4].qs)[j];+ r.u1[j] = reinterpret_cast<const int*>(x[iqs / 4].qs)[j + 4];+ }+ r.dx = __low2float(x[iqs / 4].ds);+ return r;+ }+ __device__ static W wload(const IQ4XSBlock* __restrict__ w, int iqs) { return IQ4XSTraits::load(w, iqs); }+ __device__ static float dot(const W& w, const X& x) { // IQ4XSTraits::apply+ int sumi = 0;+#pragma unroll+ for (int j = 0; j < 4; ++j) {+ sumi = STRATA_DP4A(w.v[j].x, x.u0[j], sumi);+ sumi = STRATA_DP4A(w.v[j].y, x.u1[j], sumi);+ }+ sumi *= w.ls - 32;+ const float d = w.dw * x.dx;+ return d * sumi;+ }+};++template<typename F, int NCOLS, int ROWS>+__launch_bounds__(WARPS * WARP, 1)+__global__ void b6_mmvq_rows_kernel(const typename F::Block* __restrict__ w, const Q81Block* __restrict__ x,+ float* __restrict__ y, int n_in, int n_out) {+ using XB = B6X<F>;+ const int tid = WARP * int(threadIdx.y) + int(threadIdx.x);+ const int row0 = ROWS * int(blockIdx.x);+ const int blocks_per_row = n_in / F::DIV;+ const int x_stride = n_in / Q8K;+ const int kqs = F::kqs(tid);+ float tmp[NCOLS][ROWS] = {};+ for (int kbx = tid / F::T; kbx < blocks_per_row; kbx += F::BPI) {+ const int kby = kbx * F::KBY;+ typename XB::X xv[NCOLS];+#pragma unroll+ for (int j = 0; j < NCOLS; ++j) xv[j] = XB::xload(x + std::size_t(j) * x_stride + kby, kqs);+#pragma unroll+ for (int i = 0; i < ROWS; ++i) {+ if (row0 + i < n_out) {+ const typename XB::W wv = XB::wload(w + std::size_t(row0 + i) * blocks_per_row + kbx, kqs);+#pragma unroll+ for (int j = 0; j < NCOLS; ++j) tmp[j][i] += XB::dot(wv, xv[j]);+ }+ }+ }+ __shared__ float partial[WARPS - 1][NCOLS][ROWS][WARP];+ if (threadIdx.y > 0) {+#pragma unroll+ for (int j = 0; j < NCOLS; ++j)+#pragma unroll+ for (int i = 0; i < ROWS; ++i) partial[threadIdx.y - 1][j][i][threadIdx.x] = tmp[j][i];+ }+ __syncthreads();+ if (threadIdx.y > 0) return;+#pragma unroll+ for (int j = 0; j < NCOLS; ++j) {+#pragma unroll+ for (int i = 0; i < ROWS; ++i) {+#pragma unroll+ for (int l = 0; l < WARPS - 1; ++l) tmp[j][i] += partial[l][j][i][threadIdx.x];+ tmp[j][i] = warp_sum(tmp[j][i]);+ if (threadIdx.x == i && row0 + i < n_out) y[std::size_t(j) * n_out + row0 + i] = tmp[j][i];+ }+ }+}++// the B6 launch for a format that has a B6X: true when it ran. g_b6_rows: 1 = 2 rows per block (the fastest on both+// cards in b6_mmvq_bench), else 2 / 4 / 8 rows.+template<typename F, int NCOLS>+bool b6_launch(const typename F::Block* w, const Q81Block* x, float* y, int n_in, int n_out, cudaStream_t s) {+ if constexpr (!B6X<F>::ok) {+ return false;+ } else {+ if (g_b6_rows <= 0 || !g_multi_exact || s26_tsum_on() || n_in / F::DIV < 1) return false;+ const int rows = g_b6_rows == 1 ? 2 : g_b6_rows;+ const dim3 threads(WARP, WARPS);+ if (rows == 2)+ b6_mmvq_rows_kernel<F, NCOLS, 2><<<unsigned((n_out + 1) / 2), threads, 0, s>>>(w, x, y, n_in, n_out);+ else if (rows == 8)+ b6_mmvq_rows_kernel<F, NCOLS, 8><<<unsigned((n_out + 7) / 8), threads, 0, s>>>(w, x, y, n_in, n_out);+ else+ b6_mmvq_rows_kernel<F, NCOLS, 4><<<unsigned((n_out + 3) / 4), threads, 0, s>>>(w, x, y, n_in, n_out);+ return true;+ }+}+template<typename F, int NCOLS>void launch_multi_n(const void* weights, const void* x_q8_1, float* y, int n_in, int n_out, cudaStream_t s) {const auto* w = static_cast<const typename F::Block*>(weights);const auto* x = static_cast<const Q81Block*>(x_q8_1);+ if (b6_launch<F, NCOLS>(w, x, y, n_in, n_out, s)) return; // STRATA_B6_MMVQ_ROWSif (!g_multi_exact) {constexpr int NW = NCOLS <= 4 ? 4 : 2;const unsigned blocks = unsigned((std::size_t(n_out) + 1) / 2);@@ -2151,6 +2317,8 @@ void native_q6_k_unpack(const void* weights) {void native_mmvq_set_multi_exact(bool exact) { g_multi_exact = exact; }bool native_mmvq_multi_exact() { return g_multi_exact; }+void native_mmvq_set_b6_rows(int mode) { g_b6_rows = mode; }+int native_mmvq_b6_rows() { return g_b6_rows; }std::size_t native_q8_1_bytes(int n_in, int ncols) {validate_shape(n_in, ncols);