serve: STRATA_DUMP_FIRST_LOGITS also writes each request's first-window logits (<path>.<n>), to compare prompt paths by KL

This commit is contained in:
Niko1221 committed 2026-10-07 22:55:42 +02:00
1 parent 2c7c02ab72
commit 421e163a30
1 file changed
+14
+14
View File
@@ -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=<path> writes the logits of each request's first
// window to <path>.<n>, 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<float> 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; }