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++
Merge f-halo-int (7440806) into the stream A branch
Niko12219d9338dd1b2b
diff --cc src/prefill/moe_fused_iq.cuindex 88ef0391f,61b5be500..d07b9d1a0--- a/src/prefill/moe_fused_iq.cu+++ b/src/prefill/moe_fused_iq.cu@@@ -227,10 -258,38 +277,38 @@@ template <int T, int NW> __device__ __f}// The sub-block as 32 int8 (q[0..7], natural order) and its scales (s0: values 0-15, s1: 16-31).- template <int T>- __device__ __forceinline__ void convert(const uint32_t (&w)[5], const uint8_t* grid, const uint32_t (&kv)[4],+ template <int T, int NW>+ __device__ __forceinline__ void convert(const uint32_t (&w)[NW], const uint8_t* grid, const uint32_t (&kv)[4],- uint32_t (&q)[8], float& s0, float& s1) {+ uint32_t (&q)[8], float& s0, float& s1, const uint4* sgn = nullptr) {- if constexpr (T == T_IQ2_XXS) {+ if constexpr (T == T_Q4_K || T == T_Q5_K) {+ const int ib = (int) (w[9] >> 24), sh = 4 * (ib & 1);+ uint32_t sc, mn;+ if (ib < 4) { sc = w[9] & 63; mn = (w[9] >> 8) & 63; }+ else {+ sc = ((w[9] & 0xF) | (((w[9] >> 8) & 0xC0) >> 2)); // sc[ib + 4] & 15 | (sc[ib - 4] >> 6) << 4+ mn = (((w[9]) >> 4) & 0xF) | (((w[9] >> 16) & 0xC0) >> 2); // sc[ib + 4] >> 4 | (sc[ib] >> 6) << 4+ }+ #pragma unroll+ for (int k = 0; k < 8; ++k) {+ q[k] = (w[k] >> sh) & 0x0F0F0F0Fu;+ if constexpr (T == T_Q5_K) q[k] |= ((w[10 + k] >> ib) & 0x01010101u) << 4;+ }+ s0 = half_at(w[8]) * (float) sc;+ s1 = -(half_at(w[8] >> 16) * (float) mn);+ } else if constexpr (T == T_Q5_1) {+ #pragma unroll+ for (int k = 0; k < 4; ++k) {+ const uint32_t lo = ((w[4] >> (4 * k)) & 0xF) * 0x00204081u, hi = ((w[4] >> (16 + 4 * k)) & 0xF) * 0x00204081u;+ q[k] = (w[k] & 0x0F0F0F0Fu) | ((lo & 0x01010101u) << 4);+ q[4 + k] = ((w[k] >> 4) & 0x0F0F0F0Fu) | ((hi & 0x01010101u) << 4);+ }+ s0 = half_at(w[5]);+ s1 = half_at(w[5] >> 16);+ } else if constexpr (T == T_Q8_0) {+ #pragma unroll+ for (int k = 0; k < 8; ++k) q[k] = w[k];+ s0 = s1 = half_at(w[8]);+ } else if constexpr (T == T_IQ2_XXS) {const uint2* g = (const uint2*) grid;#pragma unrollfor (int l = 0; l < 4; ++l) {@@@ -628,13 -659,13 +706,13 @@@ native_w11_kernel(const Batch b, const: blob + geo.down_off + (size_t) (rbase + ur) * geo.d_row;auto unit = [&](int s) -> const uint8_t* {if (GU) return wrow + (s >> 2) * BS;- return WT == T_IQ4_NL ? wrow + (2 * s + uj) * BS : wrow + s * BS;+ return (WT == T_IQ4_NL || WT == T_Q5_1 || WT == T_Q8_0) ? wrow + (2 * s + uj) * BS : wrow + s * BS;};auto sub = [&](int s) { return GU ? 2 * (s & 3) + uj : uj; };- auto put = [&](const uint32_t (&raw)[5], int buf) {+ auto put = [&](const uint32_t (&raw)[raw_words(WT)], int buf) {uint32_t q[8];float s0, s1;- convert<WT>(raw, sgrid, kv, q, s0, s1);+ convert<WT>(raw, sgrid, kv, q, s0, s1, ssign);uint4* d = (uint4*) &wt[buf][ur][32 * uj];d[0] = make_uint4(q[0], q[1], q[2], q[3]);d[1] = make_uint4(q[4], q[5], q[6], q[7]);diff --cc tests/cuda/prefill_fused_iq_test.cppindex bac1e9794,7178cdad3..30242cff7--- a/tests/cuda/prefill_fused_iq_test.cpp+++ b/tests/cuda/prefill_fused_iq_test.cpp@@@ -467,16 -513,11 +513,17 @@@ void timing_part(const Pair& p, int T,std::sort(tf2.begin(), tf2.end());std::printf(" (fused back to back: median %.3f ms, min %.3f; alternating min %.3f; MMQ min %.3f)\n", tf2[4],tf2[0], tf[0], tm[0]);- const std::vector<float> y_mmq = download(mb.dm, (size_t) rows * N), y_f = download(fb.dm, (size_t) rows * N);+ const std::vector<float> y_mmq = mq ? download(mb.dm, (size_t) rows * N) : std::vector<float>((size_t) rows * N, 0.0f),+ y_f = download(fb.dm, (size_t) rows * N);const std::vector<int32_t> slot = download_i(fb.slot, (size_t) rows);+ { // (Aurora S23) a hash of the fused output's bits, to compare two builds bit for bit+ uint64_t hsh = 1469598103934665603ull;+ for (size_t i = 0; i < (size_t) rows; ++i) // in pair order: the rows of an expert are placed in any order+ for (size_t c = 0; c < (size_t) N; ++c) { uint32_t u; std::memcpy(&u, &y_f[(size_t) slot[i] * N + c], 4); hsh = (hsh ^ u) * 1099511628211ull; }+ std::printf(" fused output bits hash %016llx\n", (unsigned long long) hsh);+ }- const Err efm = compare(y_f, [&](size_t i) { return (int64_t) slot[i]; }, y_mmq,- [&](size_t i) { return (int64_t) r.row_of[i]; }, (size_t) rows);+ const Err efm = mq ? compare(y_f, [&](size_t i) { return (int64_t) slot[i]; }, y_mmq,+ [&](size_t i) { return (int64_t) r.row_of[i]; }, (size_t) rows) : Err{};std::printf("%s - timing part: %d tokens x top %d over %d experts, one layer: MMQ path %.3f ms, fused %.3f ms ""(%.2fx); fused vs MMQ rel RMS %.3e worst row %.3e\n",p.name, T, K, E, t_mmq, t_f, t_mmq / t_f, efm.rms, efm.worst);