Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
gr_parity: compare the split read (STRATA_GR_V3=1) within float rounding
sergiywith17ebb94433bf
diff --git a/src/kernels/gr_parity.cpp b/src/kernels/gr_parity.cppindex d1f79fa38..b5ceb76c5 100644--- a/src/kernels/gr_parity.cpp+++ b/src/kernels/gr_parity.cpp@@ -26,6 +26,7 @@#include <cmath>#include <cstdio>+#include <algorithm>#include <cstdlib>#include <cstring>#include <random>@@ -331,7 +332,22 @@ int fused_multi_lds_parity(const float* d_norm, const uint16_t* d_down, const uicheck(cudaMemcpy(s.mixed.data(), d_mixed, s.mixed.size() * sizeof(float), cudaMemcpyDeviceToHost), "multi read mixed");return s;};- auto same = [](const Snapshot& a, const Snapshot& b) {+ // the split read (STRATA_GR_V3=1) sums in another order than the single-token kernel: equal within float+ // rounding, not to the bit, so it is compared with a relative tolerance; the default kernels bit for bit+ static const bool v3 = [] { const char* v = std::getenv("STRATA_GR_V3"); return v != nullptr && std::atoi(v) != 0; }();+ auto close = [](const std::vector<float>& x, const std::vector<float>& y) {+ double worst = 0.0, mag = 1e-30;+ for (size_t i = 0; i < x.size(); ++i) {+ worst = std::max(worst, (double) std::fabs(x[i] - y[i]));+ mag = std::max(mag, (double) std::fabs(y[i]));+ }+ if (worst > 2e-6 * mag)+ std::printf(" tolerance: worst %.3e of max |ref| %.3e (rel %.3e), n %zu\n", worst, mag, worst / mag, x.size());+ return worst <= 2e-6 * mag;+ };+ auto same = [&](const Snapshot& a, const Snapshot& b) {+ if (v3) // `lo` is the default kernels' workspace between down and up; the split read keeps it in shared memory+ return close(a.r_out, b.r_out) && close(a.rs, b.rs) && close(a.inject, b.inject) && close(a.mixed, b.mixed);return std::memcmp(a.r_out.data(), b.r_out.data(), a.r_out.size() * sizeof(float)) == 0 &&std::memcmp(a.lo.data(), b.lo.data(), a.lo.size() * sizeof(float)) == 0 &&std::memcmp(a.rs.data(), b.rs.data(), a.rs.size() * sizeof(float)) == 0 &&