dsv41: BMI2-off ggml-cpu applies only to the DeepSeek engine build (STRATA_BUILD_DSV41); ds4_gg_bench --dump FILE to compare two ggml builds bit for bit (IQ1_S/IQ1_M with and without BMI2: identical at 1,2,4,8,16 tokens)

This commit is contained in:
Niko1221 committed 2026-10-24 09:14:06 +02:00
1 parent 6953d896d0
commit 46bddbbb74
2 files changed
+16 -4

No files matched your search

+8 -4
View File
@@ -1664,12 +1664,16 @@ if(STRATA_NATIVE_EXPERTS)
set(GGML_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
if(STRATA_PORTABLE)
set(GGML_NATIVE OFF CACHE BOOL "" FORCE)
foreach(_f GGML_AVX GGML_AVX2 GGML_FMA GGML_F16C)
foreach(_f GGML_AVX GGML_AVX2 GGML_FMA GGML_F16C GGML_BMI2)
set(${_f} ON CACHE BOOL "" FORCE)
endforeach()
# BMI2 off: ggml's IQ1_S / IQ1_M dots use _pdep_u64 with it, and AMD Zen 1/2 run PDEP in microcode (EPYC 7452, IQ1_M one-token
# dot 1.8 GB/s against 32 GB/s without it; IQ1_S 2.3 against 37). Intel loses nothing measurable: no other ggml-cpu quant uses it.
set(GGML_BMI2 OFF CACHE BOOL "" FORCE)
# The DeepSeek engine (STRATA_BUILD_DSV41) builds ggml-cpu with BMI2 OFF: ggml's IQ1_S / IQ1_M dots use _pdep_u64 with it, and AMD
# Zen 1/2 run PDEP in microcode (EPYC 7452, IQ1_M one-token dot 1.8 GB/s against 32 GB/s without it; IQ1_S 2.3 against 37). The
# results are bit-identical either way (ds4_gg_bench --dump, types 19 and 29, 1-16 tokens). Other engines keep BMI2 until their
# next rebuild is looked at: no Qwen package changes with this commit.
if(STRATA_BUILD_DSV41)
set(GGML_BMI2 OFF CACHE BOOL "" FORCE)
endif()
elseif(STRATA_ISA_FLOOR)
# the experimental older-CPU build (STRATA_ISA_FLOOR above): one ggml-cpu for the floor, ggml's "sandybridge"
# feature set (SSE4.2 + AVX) or SSE4.2 alone - not the build host's, which may be newer than the PC it runs on.
+8
View File
@@ -124,6 +124,7 @@ int main(int argc, char** argv) {
long mb = 3072;
bool exact = false, expert = false;
int dtype = -1;
std::string dump; // --dump FILE: ggml-cpu's results (nt x rows floats) written raw - compare two builds with cmp
for (int i = 1; i < argc; ++i) {
std::string a = argv[i];
auto val = [&] { return i + 1 < argc ? std::atol(argv[++i]) : 0L; };
@@ -135,6 +136,7 @@ int main(int argc, char** argv) {
else if (a == "--exact") exact = true;
else if (a == "--expert") expert = true;
else if (a == "--dtype") dtype = (int) val();
else if (a == "--dump" && i + 1 < argc) dump = argv[++i];
}
if (expert) return run_expert(type, dtype < 0 ? type : dtype, threads, mb, nt, reps);
ggml_cpu_init();
@@ -204,6 +206,12 @@ int main(int argc, char** argv) {
const double t_gg = pass(0, p0.data());
const double t_own = pass(1, p1.data());
if (!dump.empty()) {
if (std::FILE* df = std::fopen(dump.c_str(), "wb")) {
for (int t = 0; t < nt; ++t) std::fwrite(o0[(size_t) t].data(), 4, (size_t) rows, df);
std::fclose(df);
}
}
long bad = 0, differ = 0;
double worst = 0, worst_ref = 0, absmax = 0, absdiff = 0;
for (int t = 0; t < nt; ++t)