LELEKA_TRACE_RESIDUAL=<dir> dumps the final R of each verifier window, LELEKA_TRACE_LADDER adds a per-hc_read R ladder (2 frames per layer), LELEKA_TRACE_PLE prints the PLE row ids per window row. scripts/numerics holds the patch scripts for a private copy of the Original (not applied to engine/strata) and the comparison tools. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
import os
|
|
p = os.path.expanduser("~/work/numerics-orig/source/src/core/verify.cpp")
|
|
s = open(p).read()
|
|
old = r''' VDBG("window done\n");
|
|
++windows;'''
|
|
assert s.count(old) == 1
|
|
new = r''' if (const char* dir = std::getenv("STRATA_NUM_RESID_DIR")) { // numerics bring-up: final R of every window row
|
|
static int seq = 0;
|
|
const size_t rn = (size_t) T * (size_t) g.hc * (size_t) g.n_embd;
|
|
std::vector<float> h(rn);
|
|
cudaStreamSynchronize(cs_);
|
|
if (cudaMemcpy(h.data(), R_, rn * 4, cudaMemcpyDeviceToHost) == cudaSuccess) {
|
|
char path[512];
|
|
std::snprintf(path, sizeof path, "%s/r_win%05d_pos%lld.f32", dir, seq, (long long) pos0);
|
|
if (std::FILE* f = std::fopen(path, "wb")) { std::fwrite(h.data(), 4, h.size(), f); std::fclose(f); }
|
|
std::fprintf(stderr, "NUMRESID seq=%d pos0=%lld T=%d tokens=", seq, (long long) pos0, T);
|
|
for (int t = 0; t < T; ++t) std::fprintf(stderr, "%d%s", tokens[t], t + 1 < T ? "," : "\n");
|
|
}
|
|
++seq;
|
|
}
|
|
'''
|
|
s = s.replace(old, new + old)
|
|
open(p, "w").write(s)
|
|
print("patched")
|