mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 00:08:52 +00:00
New files (replacements, same interfaces):
engine/src/quant/x86/dot_avx2_clean.cpp table + six _opt kernels + three x4 kernels, bit-identical to the plain kernels of the TU
engine/src/quant/x86/act_avx512_clean.cpp AVX-512 Q8_0 / Q8_1 / Q8_K quantisers, byte-identical to the Avx2 contract
engine/src/kernels/cpu/kq_dots_avx2.{hpp,cpp} Q4_K / Q5_1 / Q8_0 multi-token dots, bit-identical per token to the single-token Avx2 dots
Float orders were found by black-box probing of the current kernels (tests/clean_p2/probe_*.cpp, model_*.cpp), then
confirmed on random rows. Tests: dot_avx2_verify, act_avx512_verify (needs AVX-512), kq_dots_avx2_test, plus the probes,
a manual build script for the quant layer and Windows (MSVC) drivers.
28 lines
1.1 KiB
C++
28 lines
1.1 KiB
C++
// probe_one: single-element rows (one non-zero product): does the kernel give fl(D * p)? Prints a few raw cases when not.
|
|
#include "probe_core.hpp"
|
|
|
|
int main(int argc, char** argv) {
|
|
const std::string name = argc > 1 ? argv[1] : "q6_K";
|
|
ProbeType* t = find_probe_type(name);
|
|
const DotKernel* k = dot_kernel(t->type, Arith::Avx2, Isa::Avx2);
|
|
std::mt19937_64 rng(1);
|
|
int bad = 0, shown = 0;
|
|
const int N = 2000;
|
|
for (int tr = 0; tr < N; ++tr) {
|
|
const int i = (int)(rng() % t->elems);
|
|
ProbeRow r(*t, 1);
|
|
r.zero_bsums = true;
|
|
r.randomize_scales(rng);
|
|
const int p = r.set_product(0, i, rng);
|
|
float o = 0;
|
|
k->fn(t->elems, &o, r.w.data(), r.a.data());
|
|
const float e = r.D(0) * (float)p;
|
|
if (std::memcmp(&o, &e, 4)) {
|
|
++bad;
|
|
if (shown++ < 5) printf("elem %d p=%d D=%.9g oracle=%.9g expected=%.9g ratio=%.6g\n", i, p, r.D(0), o, e, e != 0 ? o / e : 0);
|
|
}
|
|
}
|
|
printf("%s: %d of %d single-element rows differ from fl(D*p)\n", name.c_str(), bad, N);
|
|
return 0;
|
|
}
|