okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-own-2a (7c09c4a75) into f-own-int: the Strata quant layer and the x86 CPU rows9c143c403

main
1.8 KiB38 linesraw
1// src/quant/x86/dot_avx.cpp - the Avx contract: ggml-cpu's dot products as its AVX-only flavour compiles them (the older-CPU build, STRATA_ISA_FLOOR=avx).
2// Compiled with -mavx and AVX2, FMA and F16C explicitly off (/arch:AVX), so no wider instruction can leak in.  Types ggml has no AVX branch for run its
3// generic C code under this contract (the ported code's own #else).
4#include "tier_common.hpp"
5
6#include "../generic.hpp"
7#include "../registry.hpp"
8#include "strata/quant/dot.hpp"
9
10#if defined(__AVX2__) || defined(__FMA__) || defined(__F16C__)
11#error "dot_avx.cpp is the AVX-only tier: compile it without AVX2, FMA and F16C"
12#endif
13
14namespace strata::quant {
15namespace avx {
16
17#include "x86_helpers.inc"
18#include "x86_dots.inc"
19
20}  // namespace avx
21
22namespace {
23#define ENTRY(T, ACT, NAME) {avx::dot_##NAME, Type::T, Type::ACT, Arith::Avx, Isa::Avx1, "avx_" #NAME}
24const DotKernel kTable[] = {
25    ENTRY(Q4_0, Q8_0, q4_0_q8_0),   ENTRY(Q4_1, Q8_1, q4_1_q8_1),   ENTRY(Q5_0, Q8_0, q5_0_q8_0),   ENTRY(Q5_1, Q8_1, q5_1_q8_1),
26    ENTRY(Q8_0, Q8_0, q8_0_q8_0),   ENTRY(IQ4_NL, Q8_0, iq4_nl_q8_0), ENTRY(MXFP4, Q8_0, mxfp4_q8_0), ENTRY(NVFP4, Q8_0, nvfp4_q8_0),
27    ENTRY(Q2_K, Q8_K, q2_K_q8_K),   ENTRY(Q3_K, Q8_K, q3_K_q8_K),   ENTRY(Q4_K, Q8_K, q4_K_q8_K),   ENTRY(Q5_K, Q8_K, q5_K_q8_K),
28    ENTRY(Q6_K, Q8_K, q6_K_q8_K),   ENTRY(IQ1_S, Q8_K, iq1_s_q8_K),  ENTRY(IQ1_M, Q8_K, iq1_m_q8_K),  ENTRY(IQ2_XXS, Q8_K, iq2_xxs_q8_K),
29    ENTRY(IQ2_XS, Q8_K, iq2_xs_q8_K), ENTRY(IQ2_S, Q8_K, iq2_s_q8_K), ENTRY(IQ3_XXS, Q8_K, iq3_xxs_q8_K), ENTRY(IQ3_S, Q8_K, iq3_s_q8_K),
30    ENTRY(IQ4_XS, Q8_K, iq4_xs_q8_K),
31    {generic::dot_q2_0_q8_0_generic, Type::Q2_0, Type::Q8_0, Arith::Avx, Isa::Scalar, "avx_q2_0_generic"},
32};
33#undef ENTRY
34}  // namespace
35
36DotTable avx_dot_table() noexcept { return {kTable, (int) (sizeof kTable / sizeof kTable[0])}; }
37
38}  // namespace strata::quant