diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 914d37f5..f6252cc5 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -10518,6 +10518,20 @@ int main(int argc, char** argv) { std::printf("ERR %s\n", drive.d.failed && drive.d.fail ? drive.d.fail : err.c_str()); return 1; } + // Diagnostics (as in generate): STRATA_DUMP_FIRST_LOGITS= writes the logits of each request's first + // window to ., so the prompt paths (a peer card's share, a split) can be compared by KL + if (first_window) { + static const char* fl = std::getenv("STRATA_DUMP_FIRST_LOGITS"); + static int fl_n = 0; + if (fl != nullptr) { + std::vector row((size_t) ver.vocab()); + const std::string path = std::string(fl) + "." + std::to_string(fl_n++); + std::FILE* f = ver.copy_logits(0, row.data()) ? std::fopen(path.c_str(), "wb") : nullptr; + if (f == nullptr || std::fwrite(row.data(), sizeof(float), row.size(), f) != row.size()) + std::fprintf(stderr, "strata serve: STRATA_DUMP_FIRST_LOGITS: cannot write %s\n", path.c_str()); + if (f) std::fclose(f); + } + } int a = 0; while (a < T - 1 && window[(size_t) a + 1] == outv[(size_t) a]) ++a; if (from_sfx) { ++sfx_windows; sfx_drafts += T - 1; sfx_ok += a; }