mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 23:38:47 +00:00
sycl(inkling2): optimize B70 GGUF MoE prefill and decode for IQ3_S and UD-Q4_K_XL
This commit is contained in:
1 parent
c10238703b
commit
37098d39db
4 files changed
+1352
-379
No files matched your search
+11
-4
@@ -224,11 +224,18 @@ Running on Windows:
|
||||
- Always set `ONEAPI_DEVICE_SELECTOR=level_zero:gpu` so SYCL selects the discrete Arc GPU over Level Zero.
|
||||
- In zero-oneMKL builds on Battlemage, `UR_LOADER_USE_LEVEL_ZERO_V2=1` (immediate command lists) and SYCL `command_graph` decode replay are enabled automatically unless overridden.
|
||||
- For DFlash 2 speculative decoding, set `STRATA_INK_DRAFTER=dflash2` and pass `--draft dflash2` (or `--draft on`).
|
||||
- Default mode is 100% lossless/exact (`chunk=4096` for single-slot `<=128K`, register-direct `BK=64` XMX FlashAttention-2, `BN=128` contiguous-`h_act` XMX MoE, 2-term BF16 XMX dense/controller GEMMs, 2,048-entry SWA ring, and 0-ULP speculative tree + linear verify parity); pass `--turbo` (`STRATA_INK_INTELARC=1` + `STRATA_INK_TAIL_SKIP=turbo`) to opt into `Q8_ROW` trunk compaction, load-time `MX8 -> SF4` Coda transcoding, Hybrid KV (`40` lossless FP16 SWA visits + `8` `FP8_E4M3` global visits), Quest Block-TopK (`128` prefill / `96` decode blocks), VNNI `joint_matrix` INT8/FP16 XMX prefill & decode, and router tail-skip.
|
||||
- Default mode is 100% lossless/exact (`chunk=4096` for single-slot `<=128K`, register-direct `BK=64` XMX FlashAttention-2, `BN=128` contiguous-`h_act` XMX MoE including 2-term `BK=16` exact GGUF MoE, 2-term BF16 XMX dense/controller GEMMs, 16B-aligned `SG32` GGUF MoE decode/verify, 2,048-entry SWA ring, and 0-ULP speculative tree + linear verify parity); pass `--turbo` (`STRATA_INK_INTELARC=1` + `STRATA_INK_TAIL_SKIP=turbo`) to opt into `Q8_ROW` trunk/unembed compaction, load-time `MX8 -> SF4` and GGUF `Q8_0 -> SF4` Coda transcoding, Hybrid KV (`40` lossless FP16 SWA visits + `8` `FP8_E4M3` global visits), Quest Block-TopK (`128` prefill / `96` decode blocks), VNNI `joint_matrix` INT8/FP16 XMX prefill & decode, and router tail-skip.
|
||||
- Every prefill and long-context attention launch is sub-chunked well below the ~2 s Windows GPU TDR limit so long contexts run without device resets or host spill.
|
||||
- **Measured on one Arc Pro B70 32 GB (Windows 11, `Inkling-2-Mini SQ-20 v2`, `--max-context 131072`, `--draft dflash2`, all 3,072 experts in VRAM, zero spill):**
|
||||
- **Lossless Default (`dflash2`):** `1,812.5 tok/s` prompt / `178.9 tok/s` gen (`96.7` non-repeating prose) at 4K; `1,582.0` / `97.1 tok/s` (`151.8` prose) at 32K; `1,382.2` / `121.5 tok/s` at 64K; `1,097.1` / `97.1 tok/s` (`123.9` prose) at 128K (`0-ULP` `--spec-check 64`, `100%` Top-1 at `pos >= 1024` in `--ring-check 128`, `25.91 GiB` peak VRAM, `0.06 GiB` shared).
|
||||
- **Opt-in `--turbo` (`dflash2`):** `2,549.6 tok/s` prompt / `211.7 tok/s` gen (`92.7` non-repeating prose) at 4K; `2,333.0` / `199.1 tok/s` (`136.8` synthetic) at 32K; `2,313.7` / `163.8 tok/s` at 64K; `2,293.6` (`2,254.6` prose) / `165.7 tok/s` at 128K (`21.24 GiB` peak VRAM, `9.96 GiB` free headroom, `0.07 GiB` shared).
|
||||
- **Measured on one Arc Pro B70 32 GB (Windows 11, `--max-context 131072`, `--draft dflash2`, all 3,072 experts in VRAM, zero spill across 4K–128K):**
|
||||
- **`Inkling-2-Mini SQ-20 v2` (`.strata`):**
|
||||
- **Lossless Default (`dflash2`):** `1,812.5 tok/s` prompt / `178.9 tok/s` gen (`96.7` non-repeating prose) at 4K; `1,582.0` / `97.1 tok/s` (`151.8` prose) at 32K; `1,382.2` / `121.5 tok/s` at 64K; `1,097.1` / `97.1 tok/s` (`123.9` prose) at 128K (`0-ULP` `--spec-check 64`, `--ring-check 128` `ok`, `25.91 GiB` peak VRAM, `0.06 GiB` shared).
|
||||
- **Opt-in `--turbo` (`dflash2`):** `2,549.6 tok/s` prompt / `211.7 tok/s` gen (`92.7` prose) at 4K; `2,333.0` / `199.1 tok/s` (`136.8` synthetic) at 32K; `2,313.7` / `163.8 tok/s` at 64K; `2,293.6` (`2,254.6` prose) / `165.7 tok/s` at 128K (`21.24 GiB` peak VRAM, `9.96 GiB` free headroom, `0.07 GiB` shared).
|
||||
- **`Inkling-2-Mini GSQ-RCO IQ3_S` (`.gguf`, `10.64 GiB`):**
|
||||
- **Lossless Default (`dflash2`):** `1,382.9 tok/s` prompt (`1,682.9` 1-term) / `157.6–158.8 tok/s` gen at 4K; `1,243.0` (`1,483.5` 1-term) / `134.3 tok/s` prose (`83.7–87.3` synthetic) at 32K; `1,114.6` (`1,303.6` 1-term) / `138.8 tok/s` at 64K; `837.5` (`957.0` 1-term) / `110.6 tok/s` prose (`84.6–85.9` synthetic) at 128K (`0-ULP` `--spec-check 64`, `--ring-check 128` `ok`, `6/7` prompts bit-identical to scalar FP32 including `long4k`, `19.84 GiB` peak VRAM, `0.07 GiB` shared).
|
||||
- **Opt-in `--turbo` (`dflash2`):** `2,273.5 tok/s` prompt / `175.1 tok/s` gen at 4K; `2,105.5–2,109.1` / `159.8 tok/s` prose (`103.5` synthetic) at 32K; `2,090.3` / `178.9 tok/s` at 64K; `1,823.9` (`1,804.7` prose) / `158.2 tok/s` prose (`133.3` synthetic) at 128K (`16.88 GiB` peak VRAM, `14.3 GiB` free headroom, `0.07 GiB` shared).
|
||||
- **`Inkling-2-Mini UD-Q4_K_XL` (`.gguf`, `16.42 GiB`):**
|
||||
- **Lossless Default (`dflash2`):** `1,780.9–1,817.6 tok/s` prompt / `174.4–175.8 tok/s` gen at 4K; `1,546.4–1,588.9` / `151.0 tok/s` prose (`96.1` synthetic) at 32K; `1,383.9` / `149.1 tok/s` at 64K; `994.4–1,006.4` / `122.9 tok/s` prose (`86.2–86.4` synthetic) at 128K (`0-ULP` `--spec-check 64`, `--ring-check 128` `ok`, `25.68 GiB` peak VRAM, `0.07 GiB` shared).
|
||||
- **Opt-in `--turbo` (`dflash2`):** `2,536.7 tok/s` prompt / `198.9 tok/s` gen at 4K; `2,335.4` (`2,306.0` prose) / `188.1 tok/s` prose (`118.1` synthetic) at 32K; `2,315.9` / `202.2 tok/s` at 64K; `2,035.7` (`1,977.6` prose) / `186.2 tok/s` prose (`92.5` synthetic) at 128K (`20.86 GiB` peak VRAM, `10.3 GiB` free headroom, `0.08 GiB` shared).
|
||||
|
||||
Note: `setup --backend sycl` and the older `engine/sycl` (`strata`) target still only support Linux. WSL2 with an Arc was used by one tester (the B580 row above), though `setup` cannot detect `/sys/class/drm` inside WSL2.
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -719,6 +719,94 @@ inline void transcode_mx8_expert_to_sf4(const uint8_t* raw_mx8, uint32_t orig_dn
|
||||
std::memcpy(out_sf4, hdr, 16u);
|
||||
}
|
||||
|
||||
// Host-side fast GGUF Q8_0 (type 8) -> SF4 Coda expert transcoder for --turbo mode (UD-Q4_K_XL L20..L23: -1.90 GiB VRAM, 2.0x MoE BW!):
|
||||
inline float encode_q8_0_mat_to_sf4(
|
||||
const uint8_t* q8_base, int rows, int cols, bool split_gu_to_ilv,
|
||||
float scale_even, float scale_odd, uint8_t* sf4_pb, uint8_t* sf4_sb) {
|
||||
const int n_blk32 = cols >> 5;
|
||||
const int n_blk16 = cols >> 4;
|
||||
const size_t rb = (size_t)n_blk32 * 34u;
|
||||
const int half_rows = rows >> 1;
|
||||
float gmax = 0.0f;
|
||||
for (int r = 0; r < rows; ++r) {
|
||||
const int src_r = split_gu_to_ilv ? (((r & 1) ? half_rows : 0) + (r >> 1)) : r;
|
||||
const float ext_sc = (r & 1) ? scale_odd : scale_even;
|
||||
const uint8_t* wr = q8_base + (size_t)src_r * rb;
|
||||
for (int b32 = 0; b32 < n_blk32; ++b32) {
|
||||
const uint8_t* blk = wr + (size_t)b32 * 34u;
|
||||
const float d = std::fabs(h2f_bits(ld16(blk)) * ext_sc);
|
||||
if (d == 0.0f) continue;
|
||||
int m_q = 0;
|
||||
for (int j = 0; j < 32; ++j) {
|
||||
const int aq = std::abs((int)(int8_t)blk[2 + j]);
|
||||
if (aq > m_q) m_q = aq;
|
||||
}
|
||||
const float bmax = d * (float)m_q;
|
||||
if (bmax > gmax) gmax = bmax;
|
||||
}
|
||||
}
|
||||
const float outer = (gmax > 0.0f) ? (gmax * (1.0f / (6.0f * 448.0f))) : 1.0f;
|
||||
const float inv_6outer = (gmax > 0.0f) ? (1.0f / (6.0f * outer)) : 0.0f;
|
||||
|
||||
for (int r = 0; r < rows; ++r) {
|
||||
const int src_r = split_gu_to_ilv ? (((r & 1) ? half_rows : 0) + (r >> 1)) : r;
|
||||
const float ext_sc = (r & 1) ? scale_odd : scale_even;
|
||||
const uint8_t* wr = q8_base + (size_t)src_r * rb;
|
||||
uint8_t* p_dst = sf4_pb + (size_t)r * (cols >> 1);
|
||||
uint8_t* s_dst = sf4_sb + (size_t)r * n_blk16;
|
||||
for (int b16 = 0; b16 < n_blk16; ++b16) {
|
||||
const uint8_t* blk = wr + (size_t)(b16 >> 1) * 34u;
|
||||
const float d = h2f_bits(ld16(blk)) * ext_sc;
|
||||
const int8_t* qp = reinterpret_cast<const int8_t*>(blk + 2 + (b16 & 1) * 16);
|
||||
float wf[16];
|
||||
float bmax = 0.0f;
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
const float v = (float)qp[j] * d;
|
||||
wf[j] = v;
|
||||
const float av = std::fabs(v);
|
||||
if (av > bmax) bmax = av;
|
||||
}
|
||||
const uint8_t sc_u8 = (bmax > 0.0f) ? f32_to_e4m3(bmax * inv_6outer) : 0u;
|
||||
s_dst[b16] = sc_u8;
|
||||
const float sc_eff = e4m3_to_f32(sc_u8) * outer;
|
||||
const float inv_sc = (sc_eff > 0.0f) ? (1.0f / sc_eff) : 0.0f;
|
||||
uint8_t* pb = p_dst + b16 * 8;
|
||||
for (int j2 = 0; j2 < 8; ++j2) {
|
||||
const float v0 = wf[2 * j2 + 0] * inv_sc;
|
||||
const float v1 = wf[2 * j2 + 1] * inv_sc;
|
||||
const float a0 = std::fabs(v0), a1 = std::fabs(v1);
|
||||
const uint32_t m0 = (a0 < 0.25f) ? 0u : (a0 < 0.75f) ? 1u : (a0 < 1.25f) ? 2u : (a0 < 1.75f) ? 3u
|
||||
: (a0 < 2.50f) ? 4u : (a0 < 3.50f) ? 5u : (a0 < 5.00f) ? 6u : 7u;
|
||||
const uint32_t m1 = (a1 < 0.25f) ? 0u : (a1 < 0.75f) ? 1u : (a1 < 1.25f) ? 2u : (a1 < 1.75f) ? 3u
|
||||
: (a1 < 2.50f) ? 4u : (a1 < 3.50f) ? 5u : (a1 < 5.00f) ? 6u : 7u;
|
||||
const uint32_t n0 = ((v0 < 0.0f) ? 8u : 0u) | m0;
|
||||
const uint32_t n1 = ((v1 < 0.0f) ? 8u : 0u) | m1;
|
||||
pb[j2] = (uint8_t)(n0 | (n1 << 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
return outer;
|
||||
}
|
||||
|
||||
inline void transcode_gguf_q8_0_expert_to_sf4(const uint8_t* raw_gguf, uint32_t orig_dn_off, uint8_t* out_sf4) {
|
||||
constexpr uint32_t kSf4DnOff = 2986000u;
|
||||
uint32_t flags = 0;
|
||||
float gate_sc = 1.0f, up_sc = 1.0f, dn_sc = 1.0f;
|
||||
std::memcpy(&flags, raw_gguf + 12, 4);
|
||||
std::memcpy(&gate_sc, raw_gguf + 16, 4);
|
||||
std::memcpy(&up_sc, raw_gguf + 20, 4);
|
||||
std::memcpy(&dn_sc, raw_gguf + 24, 4);
|
||||
const bool ilv = (flags & 1u) != 0;
|
||||
const float gu_outer = encode_q8_0_mat_to_sf4(
|
||||
raw_gguf + 32u, 2304, 2304, !ilv, gate_sc, up_sc,
|
||||
out_sf4 + 16u, out_sf4 + 16u + 2654208u);
|
||||
const float dn_outer = encode_q8_0_mat_to_sf4(
|
||||
raw_gguf + orig_dn_off, 2304, 1152, false, dn_sc, dn_sc,
|
||||
out_sf4 + kSf4DnOff, out_sf4 + kSf4DnOff + 1327104u);
|
||||
const float hdr[4] = {gu_outer, 1.0f, dn_outer, 1.0f};
|
||||
std::memcpy(out_sf4, hdr, 16u);
|
||||
}
|
||||
|
||||
// ---- Format IDs & Manifest ----
|
||||
enum InkFmt : int32_t {
|
||||
FMT_S2 = 2, FMT_S3 = 3, FMT_S4 = 4, FMT_S5 = 5, FMT_S6 = 6, FMT_S8 = 8,
|
||||
@@ -1726,17 +1814,35 @@ struct InkSyclModel {
|
||||
const bool force_sk_tc = (std::getenv("INK_SYCL_FORCE_SK_TRANSCODE") && std::atoi(std::getenv("INK_SYCL_FORCE_SK_TRANSCODE")) != 0);
|
||||
std::vector<strata::artifact::StrataExpertEntry> adj_dir = mf.expert_directory();
|
||||
std::vector<uint8_t> native_gguf(adj_dir.size(), 0);
|
||||
std::vector<uint8_t> gguf_q8_to_sf4(adj_dir.size(), 0);
|
||||
std::vector<uint32_t> orig_dn_off_di(adj_dir.size(), 0);
|
||||
size_t n_native_gguf = 0;
|
||||
size_t n_coda_q8_sf4 = 0;
|
||||
size_t coda_q8_saved_bytes = 0;
|
||||
if (mf.kind == ink2::ModelSourceKind::Gguf && mf.gguf_adapter) {
|
||||
const size_t h_sz = (size_t)man.c.hidden;
|
||||
const size_t i_sz = (size_t)man.c.inter;
|
||||
const bool allow_coda_q8_sf4 = acfg.fast && h_sz == 2304 && i_sz == 1152 &&
|
||||
!env_truthy_arc("STRATA_INK_NO_TURBO_CODA_SF4");
|
||||
constexpr uint32_t kSf4ExpertBytes = 4478992u;
|
||||
constexpr uint32_t kSf4DnOff = 2986000u;
|
||||
for (size_t i = 0; i < adj_dir.size(); ++i) {
|
||||
auto& e = adj_dir[i];
|
||||
if (e.gu_code_id != FMT_GGUF_RAW && e.dn_code_id != FMT_GGUF_RAW) continue;
|
||||
const int il = (int)(i / (size_t)man.c.n_experts);
|
||||
if (il < 0 || il >= (int)mf.gguf_adapter->layers.size()) continue;
|
||||
const auto& lm = mf.gguf_adapter->layers[il];
|
||||
if (!force_sk_tc && gguf_type_has_sycl_kernel(lm.gu_type) && gguf_type_has_sycl_kernel(lm.dn_type)) {
|
||||
if (allow_coda_q8_sf4 && il >= man.c.core_end && lm.gu_type == 8u && lm.dn_type == 8u &&
|
||||
e.body_bytes > kSf4ExpertBytes) {
|
||||
gguf_q8_to_sf4[i] = 1;
|
||||
orig_dn_off_di[i] = e.dn_offset;
|
||||
coda_q8_saved_bytes += (e.body_bytes - kSf4ExpertBytes);
|
||||
e.gu_code_id = FMT_SF4;
|
||||
e.dn_code_id = FMT_SF4;
|
||||
e.dn_offset = kSf4DnOff;
|
||||
e.body_bytes = kSf4ExpertBytes;
|
||||
++n_coda_q8_sf4;
|
||||
} else if (!force_sk_tc && gguf_type_has_sycl_kernel(lm.gu_type) && gguf_type_has_sycl_kernel(lm.dn_type)) {
|
||||
native_gguf[i] = 1;
|
||||
++n_native_gguf;
|
||||
} else {
|
||||
@@ -1750,6 +1856,10 @@ struct InkSyclModel {
|
||||
e.body_bytes = body_b;
|
||||
}
|
||||
}
|
||||
if (n_coda_q8_sf4 > 0) {
|
||||
fprintf(stderr, "[ink_sycl_intelarc] transcoding %zu GGUF Q8_0 Coda experts -> SF4 in --turbo (saves %.1f MiB VRAM)\n",
|
||||
n_coda_q8_sf4, (double)coda_q8_saved_bytes / 1048576.0);
|
||||
}
|
||||
if (n_native_gguf > 0) {
|
||||
fprintf(stderr, "[ink_sycl] native lossless GGUF_RAW SG16+XMX kernels active for %zu/%zu experts (zero S_K transcode)\n",
|
||||
n_native_gguf, adj_dir.size());
|
||||
@@ -1757,6 +1867,16 @@ struct InkSyclModel {
|
||||
}
|
||||
auto read_expert_sy = [&](size_t di, std::vector<uint8_t>& out_b,
|
||||
uint32_t& out_dn, uint8_t& out_gu, uint8_t& out_dnc, std::string& lerr) -> bool {
|
||||
if (di < gguf_q8_to_sf4.size() && gguf_q8_to_sf4[di]) {
|
||||
std::vector<uint8_t> raw_tmp;
|
||||
if (!mf.read_expert_body(di, raw_tmp, lerr)) return false;
|
||||
out_b.resize(adj_dir[di].body_bytes);
|
||||
transcode_gguf_q8_0_expert_to_sf4(raw_tmp.data(), orig_dn_off_di[di], out_b.data());
|
||||
out_dn = adj_dir[di].dn_offset;
|
||||
out_gu = adj_dir[di].gu_code_id;
|
||||
out_dnc = adj_dir[di].dn_code_id;
|
||||
return true;
|
||||
}
|
||||
if (di < native_gguf.size() && native_gguf[di]) {
|
||||
if (!mf.read_expert_body(di, out_b, lerr)) return false;
|
||||
out_dn = adj_dir[di].dn_offset;
|
||||
|
||||
@@ -1755,13 +1755,18 @@ struct InkSyRunner {
|
||||
|
||||
const uint8_t gu_f_l = (ip < (int)layer_gu_fmt.size()) ? layer_gu_fmt[ip] : 0;
|
||||
const uint8_t dn_f_l = (ip < (int)layer_dn_fmt.size()) ? layer_dn_fmt[ip] : 0;
|
||||
const uint32_t g_gt_l = (ip < (int)layer_gguf_gu_type.size()) ? layer_gguf_gu_type[ip] : 0;
|
||||
const uint32_t g_dt_l = (ip < (int)layer_gguf_dn_type.size()) ? layer_gguf_dn_type[ip] : 0;
|
||||
const bool any_gguf_l = (gu_f_l == FMT_GGUF_RAW || dn_f_l == FMT_GGUF_RAW);
|
||||
#if INK_SY_HAS_JOINT_MATRIX
|
||||
const bool exact_xmx_moe = !acfg.fast && is_bmg_gpu() && b70_k && M >= 64 && !any_gguf_l &&
|
||||
const bool gguf_bm128_ok = !any_gguf_l ||
|
||||
((gu_f_l != FMT_GGUF_RAW || b70_gguf_gu_xmx_supported(g_gt_l)) &&
|
||||
(dn_f_l != FMT_GGUF_RAW || b70_gguf_dn_xmx_supported(g_dt_l)));
|
||||
const bool exact_xmx_moe = !acfg.fast && is_bmg_gpu() && b70_k && M >= 64 && gguf_bm128_ok &&
|
||||
!use_bf16_sc && !env_truthy_arc("STRATA_INK_NO_EXACT_XMX");
|
||||
const bool exact_bm128 = exact_xmx_moe && M >= 128;
|
||||
const bool fast_bm128_f16 = acfg.fast && acfg.use_joint_matrix_xmx && is_bmg_gpu() && b70_k && M >= 128 &&
|
||||
!any_gguf_l && !use_bf16_sc;
|
||||
const bool exact_bm128 = exact_xmx_moe && (M >= 128 || any_gguf_l);
|
||||
const bool fast_bm128_f16 = acfg.fast && acfg.use_joint_matrix_xmx && is_bmg_gpu() && b70_k &&
|
||||
(M >= 128 || (M >= 64 && any_gguf_l)) && gguf_bm128_ok && !use_bf16_sc;
|
||||
#else
|
||||
const bool exact_xmx_moe = false;
|
||||
const bool exact_bm128 = false;
|
||||
@@ -1887,23 +1892,44 @@ struct InkSyRunner {
|
||||
const InkSyExpertDev* ex_layer = mod->expert_dev + (size_t)ip * c.n_experts;
|
||||
const uint8_t gu_f = gu_f_l;
|
||||
const uint8_t dn_f = dn_f_l;
|
||||
const uint32_t g_gt = (ip < (int)layer_gguf_gu_type.size()) ? layer_gguf_gu_type[ip] : 0;
|
||||
const uint32_t g_dt = (ip < (int)layer_gguf_dn_type.size()) ? layer_gguf_dn_type[ip] : 0;
|
||||
const bool gguf_gu_xm_ok = (g_gt == 21u || g_gt == 22u || g_gt == 17u || g_gt == 16u || g_gt == 19u ||
|
||||
g_gt == 42u || g_gt == 18u || g_gt == 12u || g_gt == 13u || g_gt == 14u ||
|
||||
g_gt == 23u || g_gt == 20u || g_gt == 8u || g_gt == 2u || g_gt == 39u);
|
||||
const bool gguf_dn_xm_ok = (g_dt == 42u || g_dt == 20u || g_dt == 8u || g_dt == 2u || g_dt == 39u);
|
||||
const uint32_t g_gt = g_gt_l;
|
||||
const uint32_t g_dt = g_dt_l;
|
||||
const bool gguf_gu_xm_ok = b70_gguf_gu_xmx_supported(g_gt);
|
||||
const bool gguf_dn_xm_ok = b70_gguf_dn_xmx_supported(g_dt);
|
||||
const bool allow_gguf_xm = b70_k && (gu_f == FMT_GGUF_RAW && dn_f == FMT_GGUF_RAW && gguf_gu_xm_ok && gguf_dn_xm_ok);
|
||||
if (fast_bm128_f16) {
|
||||
half* x_in_f16 = reinterpret_cast<half*>(b_wo);
|
||||
k_b70_f32_to_f16_sg16(Q(), b_mlp_in, x_in_f16, (size_t)M * D);
|
||||
k_moe_plan_active_sg16(Q(), b_topk_idx, P, 1, b_moe_bk, b_moe_pairs, ex_layer, false);
|
||||
k_b70_jm_moe_gu_bm128_sg16<false, true, true>(Q(), ex_layer, x_in_f16, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h);
|
||||
k_b70_jm_moe_dn_bm128_sg16<false, true>(Q(), ex_layer, b_topk_w, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, b_moe_yp);
|
||||
k_moe_plan_active_sg16(Q(), b_topk_idx, P, 1, b_moe_bk, b_moe_pairs, ex_layer, any_gguf_l);
|
||||
if (gu_f == FMT_GGUF_RAW) {
|
||||
b70_dispatch_jm_moe_gu_gguf_bm128<true, true>(
|
||||
Q(), g_gt, ex_layer, x_in_f16, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, iq_grid_table_dev());
|
||||
} else {
|
||||
k_b70_jm_moe_gu_bm128_sg16<false, true, true>(Q(), ex_layer, x_in_f16, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h);
|
||||
}
|
||||
if (dn_f == FMT_GGUF_RAW) {
|
||||
b70_dispatch_jm_moe_dn_gguf_bm128<true, true>(
|
||||
Q(), g_dt, ex_layer, b_topk_w, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, b_moe_yp, iq_grid_table_dev());
|
||||
} else {
|
||||
k_b70_jm_moe_dn_bm128_sg16<false, true>(Q(), ex_layer, b_topk_w, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, b_moe_yp);
|
||||
}
|
||||
} else if (exact_bm128) {
|
||||
static const bool moe_2term = env_truthy_arc("STRATA_INK_MOE_2TERM");
|
||||
k_moe_plan_active_sg16(Q(), b_topk_idx, P, 1, b_moe_bk, b_moe_pairs, ex_layer, false);
|
||||
if (moe_2term) {
|
||||
k_moe_plan_active_sg16(Q(), b_topk_idx, P, 1, b_moe_bk, b_moe_pairs, ex_layer, any_gguf_l);
|
||||
if (any_gguf_l) {
|
||||
if (gu_f == FMT_GGUF_RAW) {
|
||||
b70_dispatch_jm_moe_gu_gguf_bm128<false, false>(
|
||||
Q(), g_gt, ex_layer, b_mlp_in, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, iq_grid_table_dev());
|
||||
} else {
|
||||
k_b70_jm_moe_gu_bm128_sg16<false, false>(Q(), ex_layer, b_mlp_in, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h);
|
||||
}
|
||||
if (dn_f == FMT_GGUF_RAW) {
|
||||
b70_dispatch_jm_moe_dn_gguf_bm128<false, false>(
|
||||
Q(), g_dt, ex_layer, b_topk_w, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, b_moe_yp, iq_grid_table_dev());
|
||||
} else {
|
||||
k_b70_jm_moe_dn_bm128_sg16<false, false>(Q(), ex_layer, b_topk_w, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, b_moe_yp);
|
||||
}
|
||||
} else if (moe_2term) {
|
||||
k_b70_jm_moe_gu_bm128_sg16<true, false>(Q(), ex_layer, b_mlp_in, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h);
|
||||
k_b70_jm_moe_dn_bm128_sg16<true, false>(Q(), ex_layer, b_topk_w, b_moe_bk, b_moe_pairs, max_xm_tiles, b_moe_h, b_moe_yp);
|
||||
} else {
|
||||
@@ -1997,7 +2023,11 @@ struct InkSyRunner {
|
||||
const uint32_t g_gt = (ip < (int)layer_gguf_gu_type.size()) ? layer_gguf_gu_type[ip] : 0;
|
||||
const uint32_t g_dt = (ip < (int)layer_gguf_dn_type.size()) ? layer_gguf_dn_type[ip] : 0;
|
||||
bool gu_done = false;
|
||||
const bool use_gguf_dp4a = acfg.fast && M <= 16 && env_truthy_arc("STRATA_INK_GGUF_DP4A");
|
||||
// On Xe2 (bmg_g31), Exact-SG32 FP32 FMA beats Q8_1 dp4a by 11%-32% on IQ* & Q4_K while avoiding
|
||||
// 2 extra quant_q8_1 launches per layer; Q6_K (type 14) is 1.17x faster on dp4a at M<=16.
|
||||
const bool use_gguf_dp4a = acfg.fast && M <= 16 &&
|
||||
(env_truthy_arc("STRATA_INK_GGUF_DP4A") ||
|
||||
(!env_truthy_arc("STRATA_INK_NO_GGUF_DP4A") && g_gt == 14u));
|
||||
if (gu_f == FMT_GGUF_RAW && g_gt != 0) {
|
||||
if (use_gguf_dp4a) {
|
||||
gu_done = b70_dispatch_moe_gu_gguf_dp4a(g_gt, ex_layer, b_mlp_in, b_gguf_xq,
|
||||
|
||||
Reference in new issue
Block a user