Fix #3465: after non-finite logits in a prompt window the retry reads the whole prompt batched

The reporter's prompts ended in non-finite logits in the window that reads the prompt's last few tokens (after the last turn boundary), every time and on every retry, and passed with --short-read 0. The cause on their machine (a Windows VM, sm_89, a Broadwell AVX2 CPU, IQ3_S) was not reproduced on a P100 with a Broadwell Xeon, an RTX 3060 or a Core Ultra.
The engine now reads the request that follows such a window with --short-read 0 for that one request, so the server's transparent retry succeeds instead of failing the same way. Nothing changes until a prompt window reports non-finite logits. STRATA_NAN_INJECT=1 exercises it.
This commit is contained in:
Niko1221 committed 2026-10-21 00:52:29 +02:00
1 parent f05725c332
commit 894f133b7d
2 files changed
+19 -1

No files matched your search

+15
View File
@@ -9199,6 +9199,10 @@ int main(int argc, char** argv) {
bool live_ok = false;
// #879: a window met non-finite logits: the next request drops every cached state first and reads from token 0
bool nan_flush = false;
// #3465: the non-finite logits came in a window that reads the PROMPT's tail (the last few tokens, read through
// the verify windows after the batched part). The retry reads that tail batched (--short-read 0 for one request):
// a reporter's prompts failed there every time and passed with --short-read 0.
bool nf_prompt_windows = false, short_read_off_once = false;
std::vector<ConvCheckpoint> checks;
// STRATA_CKPT_POOL: the dropped checkpoints' storage, reused. STRATA_SLOT_CKPT_MOVE turns it on too: a moved
// checkpoint frees nothing at the next prune, so every save would fault in fresh pages (17 -> 40-60 ms)
@@ -9485,6 +9489,7 @@ int main(int argc, char** argv) {
std::fflush(stderr);
nf_hit = true;
nan_flush = true;
if (std::strcmp(what, "prompt") == 0) nf_prompt_windows = true;
return true;
};
auto imgs_below = [&](const std::vector<ImgKey>& all, int64_t L) {
@@ -12363,6 +12368,10 @@ int main(int argc, char** argv) {
// conversation and every idle batch slot go, and this prompt is read from token 0 (resume == 0 below)
if (nan_flush) {
nan_flush = false;
if (nf_prompt_windows) {
nf_prompt_windows = false;
short_read_off_once = o.short_read > 0;
}
const size_t n_checks = checks.size();
live_ok = false;
checks.clear();
@@ -12871,6 +12880,12 @@ int main(int argc, char** argv) {
// STRATA_CKPT_REREAD compares a restored checkpoint with a batched re-read, so it keeps every read batched.
static const bool no_short = std::getenv("STRATA_CKPT_REREAD") != nullptr;
int64_t req_short_read = o.short_read; // STRATA_PIPELINE_SWITCH may set it per request (short_read=)
if (short_read_off_once) { // #3465: the request after non-finite logits in a prompt window
short_read_off_once = false;
req_short_read = 0;
std::fprintf(stderr, "strata serve: after non-finite logits in a prompt window (#3465): this request reads its "
"whole prompt through the batched path, none of it through the verify windows\n");
}
auto windows_ok = [&](int64_t a, int64_t b) -> bool {
if (no_short || b - a > req_short_read) return false;
if (sp.embd_rows != nullptr)