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.6 KiB35 linesraw
1// src/quant/x86/dot_avx512.cpp - the Avx2 contract on CPUs with AVX-512 VL + VNNI: the same ported ggml code as dot_avx2.cpp, built so that its
2// mul_sum_us8_pairs_float helper takes the VPDPBUSD branch ggml has for `__AVX512VNNI__ && __AVX512VL__` (one instruction for maddubs + madd).  The integer sums are
3// exact either way and the float order is the AVX2 one, so the bits are the AVX2 tier's (quant_parity runs these kernels against ggml's AVX2 dots).
4// Compiled with the AVX-512 flags of cmake/backends/quant.cmake; only ever called when caps() says AVX-512 F/DQ/BW/VL + VNNI (Isa::Avx512).
5// Only the formats whose dot goes through that helper are registered; the others gain nothing here.
6#include "tier_common.hpp"
7
8#include "../generic.hpp"
9#include "../registry.hpp"
10#include "strata/quant/dot.hpp"
11
12#if !defined(_MSC_VER) && (!defined(__AVX512VNNI__) || !defined(__AVX512VL__))
13#error "dot_avx512.cpp needs AVX-512 VL and VNNI"
14#endif
15
16namespace strata::quant {
17namespace avx512 {
18
19#include "x86_helpers.inc"
20#include "x86_dots.inc"
21
22}  // namespace avx512
23
24namespace {
25#define ENTRY(T, ACT, NAME) {avx512::dot_##NAME, Type::T, Type::ACT, Arith::Avx2, Isa::Avx512, "avx512_" #NAME}
26const DotKernel kTable[] = {
27    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),
28    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),
29};
30#undef ENTRY
31}  // namespace
32
33DotTable avx512_dot_table() noexcept { return {kTable, (int) (sizeof kTable / sizeof kTable[0])}; }
34
35}  // namespace strata::quant