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++
SYCL prompt path: an expert's gate/up and down dequantized in one launch (iq_dequant_expert_f16, the same values; STRATA_PF_DQ_FUSED=0: two launches), -2% on a B70 4K prompt
Niko1221751095962cac
diff --git a/sycl/include/strata/kernels/iq_dequant_expert.hpp b/sycl/include/strata/kernels/iq_dequant_expert.hppnew file mode 100644index 000000000..56deefd8e--- /dev/null+++ b/sycl/include/strata/kernels/iq_dequant_expert.hpp@@ -0,0 +1,11 @@+// SYCL port, 0.1.43: one expert's gate/up and down matrices dequantized to FP16 in ONE launch (the prompt path's FP16 expert+// path used two: iq_dequant_gu_f16 then iq_dequant_f16). The values are the two launches' values, byte for byte; only the+// launch count changes (one kernel boundary less per expert, ~24,500 per 4K prompt).+#pragma once+#include <cstdint>+namespace strata::kernels {+/// gate/up -> dst_gu (interleaved rows 2r = gate r, 2r+1 = up r, as iq_dequant_gu_f16), down (n_embd x n_ff values, n a multiple+/// of 256) -> dst_d (as iq_dequant_f16). Same argument rules as the two functions.+void iq_dequant_expert_f16(int gu_type, int d_type, const void* gate, const void* up, const void* down, int64_t n_ff,+ int64_t n_embd, uint16_t* dst_gu, uint16_t* dst_d, void* stream);+} // namespace strata::kernelsdiff --git a/sycl/src/kernels/cuda/iq_kernels.dp.cpp b/sycl/src/kernels/cuda/iq_kernels.dp.cppindex d7b17d167..f67de0d7a 100644--- a/sycl/src/kernels/cuda/iq_kernels.dp.cpp+++ b/sycl/src/kernels/cuda/iq_kernels.dp.cpp@@ -10,6 +10,7 @@#include "strata/sycl_math.hpp"#include "strata/sycl_queue.hpp"#include "strata/kernels/iq_kernels.hpp"+#include "strata/kernels/iq_dequant_expert.hpp"#include "strata/kernels/dp4a.hpp"#include "strata/kernels/q8_1_finite.hpp"#include "s26_tsum.dp.hpp"@@ -4418,6 +4419,51 @@ void iq_dequant_gu_f16(int t, const void* gate, const void* up, int64_t n_ff, incheck("iq_dequant_gu_f16");}+// 0.1.43: gate/up and down of one expert in one launch. Work-group g of the first 2 * n_ff * per_row is the gu kernel's+// (row-superblock g / 2, parity g % 2); the rest are the flat kernel's superblocks of the down matrix.+namespace {+__dpct_inline__ void dequant_expert_kernel(int gt, int dt, const void *__restrict__ gate, const void *__restrict__ up,+ const void *__restrict__ down, int64_t per_row, int64_t gu_wgs,+ sycl::half *__restrict__ ygu, sycl::half *__restrict__ yd) {+ auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();+ const int64_t g = item_ct1.get_group(2);+ if (g < gu_wgs) {+ const int64_t i = g >> 1;+ const int parity = (int) (g & 1);+ const int64_t r = i / per_row, c = i % per_row;+ dq_dispatch<sycl::half>(gt, parity ? up : gate, i, ygu + ((2 * r + parity) * per_row + c) * QK_K,+ item_ct1.get_local_id(2));+ } else {+ const int64_t j = g - gu_wgs;+ dq_dispatch<sycl::half>(dt, down, j, yd + j * QK_K, item_ct1.get_local_id(2));+ }+}+} // namespace++void iq_dequant_expert_f16(int gt, int dt, const void* gate, const void* up, const void* down, int64_t n_ff,+ int64_t n_embd, uint16_t* dst_gu, uint16_t* dst_d, void* stream) {+ if (n_embd % 256 != 0 || (n_ff * n_embd) % 256 != 0 || !is_iq(gt) || !is_iq(dt)) {+ std::fprintf(stderr, "iq_dequant_expert_f16: types %d/%d, %lld x %lld\n", gt, dt, (long long) n_ff, (long long) n_embd);+ std::exit(1);+ }+ const int64_t per_row = n_embd / 256, gu_wgs = 2 * n_ff * per_row, d_wgs = n_ff * n_embd / 256;+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};+ dpct::has_capability_or_fail(strata::q_of(stream)->get_device(), {sycl::aspect::fp16});+ strata::q_of(stream)->submit([&](sycl::handler &cgh) {+ cgh.parallel_for<dpct_kernel_name<class dequant_expert_kernel_7d2c41>>(+ sycl::nd_range<3>(sycl::range(1, 1, (unsigned) (gu_wgs + d_wgs)) * sycl::range(1, 1, 32),+ sycl::range(1, 1, 32)),+ exp_props, [=](sycl::nd_item<3> item_ct1) {+ dequant_expert_kernel(gt, dt, gate, up, down, per_row, gu_wgs, (sycl::half *) dst_gu,+ (sycl::half *) dst_d);+ });+ });+ }+ check("iq_dequant_expert_f16");+}+bool native_expert_supported(int gu_type, int d_type, int64_t n_embd, int64_t n_ff) noexcept {const int qg = gu_qk(gu_type), qd = d_qk(d_type);return qg > 0 && qd > 0 && is_iq(gu_type) && is_iq(d_type) && n_embd % qg == 0 && n_ff % qd == 0 &&diff --git a/sycl/src/prefill/prefill.cpp b/sycl/src/prefill/prefill.cppindex 87e9e0258..a34f8b931 100644--- a/sycl/src/prefill/prefill.cpp+++ b/sycl/src/prefill/prefill.cpp@@ -21,6 +21,7 @@#include "strata/kernels/ple.hpp"#include "strata/kernels/native_ple_postops.hpp"#include "strata/kernels/iq_kernels.hpp"+#include "strata/kernels/iq_dequant_expert.hpp"#include "strata/kernels/cpu/expert_layout.hpp"#include "strata/kernels/qsa.hpp"#include "strata/kernels/kv_stream.hpp"@@ -4074,9 +4075,17 @@ bool Prefill::run_impl(const int64_t *tokens, int64_t n, int64_t pos0,if (lay.native) {// plan v0.3 P6: a native pack's layer, dequantized by llama.cpp's own formulasconst auto& f = lay.fmt[(size_t) l];- strata::kernels::iq_dequant_gu_f16(f.gu_type, blob_dev, blob_dev + f.up_off, f.n_ff, f.n_embd,- m.dq_gu[q], m.cs);- strata::kernels::iq_dequant_f16(f.d_type, blob_dev + f.down_off, f.n_embd * f.n_ff, m.dq_d[q], m.cs);+ // 0.1.43: both matrices in one launch (the same values; STRATA_PF_DQ_FUSED=0: two launches)+ static const bool dq_one = [] { const char* v = std::getenv("STRATA_PF_DQ_FUSED"); return !(v && v[0] == '0'); }();+ if (dq_one) {+ strata::kernels::iq_dequant_expert_f16(f.gu_type, f.d_type, blob_dev, blob_dev + f.up_off,+ blob_dev + f.down_off, f.n_ff, f.n_embd, m.dq_gu[q],+ m.dq_d[q], m.cs);+ } else {+ strata::kernels::iq_dequant_gu_f16(f.gu_type, blob_dev, blob_dev + f.up_off, f.n_ff, f.n_embd,+ m.dq_gu[q], m.cs);+ strata::kernels::iq_dequant_f16(f.d_type, blob_dev + f.down_off, f.n_embd * f.n_ff, m.dq_d[q], m.cs);+ }} else {blob_dequant_f16(blob_dev, m.dq_gu[q], m.dq_d[q], m.cs);}