gr_parity: compare the split read (STRATA_GR_V3=1) within float rounding
With STRATA_GR_V3=1 "fused GR multi max-T=8 LDS launch and changing graph replay" failed: the test compares the multi-token read with the single-token kernel bit for bit, and v3 sums `down` in another order (row group x stream blocks). It also compared `lo`, the default kernels' workspace between down and up, which v3 keeps in shared memory and never writes. Under v3 the test now checks R_out, rs, inject and mixed within 2e-6 of the largest reference value and leaves `lo` out; without it, bit for bit as before. Passes both ways.
This commit is contained in:
1 parent
e878547256
commit
17ebb94433
1 file changed
+17
-1
@@ -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 ui
|
||||
check(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 &&
|
||||
|
||||
Reference in new issue
Block a user